comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » You have been replaced by a small procedure
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
You have been replaced by a small procedure [message #43711] Sat, 23 April 2005 10:05
Ken Mankoff is currently offline  Ken Mankoff
Messages: 158
Registered: February 2000
Senior Member
; $Id: lixiaoyao.pro,v 1.2 2005/04/23 05:45:21 mankoff Exp mankoff $
;
;+
; NAME:
; LIXIAOYAO
;
; PURPOSE:
; This is a small script to generate newsgroup postings
; Inspired by http://groups-beta.google.com/groups?as_uauthors=lixiaoyao
;
; CATEGORY:
; NewsGroup
;
; CALLING SEQUENCE:
; LIXIAOYAO
;
; KEYWORD PARAMETERS:
; HELP: The _EXTRA=e keyword is used to HELP. This is where the IDL
; part of the vocabulary comes from.
;
; OUTPUTS:
; A newsgroup post (cut-and-paste to comp.lang.idl-pvwave)
;
; PROCEDURE:
; Ask a semi-formed pseudo-random question about an IDL procedure, term,
; technique, or keyword.
;
; The procedure gets part of the vocabulary from introspection of the
; IDL session via the HELP command. Therefore, the procedure has a
; larger vocabulary if you have been in an active IDL session for a
; while and modified the state.
;
; For the largest possible vocabulary, stop (or crash or breakpoint)
; inside a large procedure or function (ex: surface, indgen(16,16,16)).
; Then, use an appropriate keyword.
;
; I find using the PROCEDURE and/or FULL keywords work well.
;
; EXAMPLE:
; IDL> lixiaoyao, /PROC, /FULL
;
; I want system with MAP_SATELLITE_LIMIT that is NZ
; Show me answer
;
; I want result with E_HORIZON that is GOODESHOMOLOSINE
; Please solve for me.
;
; MODIFICATION HISTORY:
; Written by: Ken Mankoff, 2005-04-23
;
;-


pro lixiaoyao, _EXTRA=e

q = [ 'Why does X need Y for Z?', $ ; basic sentence structure
'I have a X to do Y using Z.', $
'I have a X to show Y using Z', $
'I want X with Y that is Z', $
'It does X but with Y and then result is Z?', $
'Where does X show Y. Also, Z is what?' ]
q = q[ randomu( seed ) * n_elements( q ) ] ; pick one

; build x,y,z
help, _EXTRA=e, output=v ;vocabulary
null = where( v eq '', n, complement=notnull, ncomplement=nnotnull )
if nnotnull ne 0 then v = v[ notnull ]
vv = [ 'foo' ]
for i = 0, n_elements( v )-1 do vv = [ vv, strsplit( v[ i ], /extract ) ]
vv = vv[ sort( vv ) ]
vv = vv[ uniq( vv ) ]
short = where( strlen( vv ) lt 1, nshort, complement=long, ncomplement=nlong )
if nlong ne 0 then vv = vv[ long ]

x = ['var','function','procedure','variable','system','session', 'result']
y = ( z = vv )

nx = n_elements( x ) ; again, pick one
ny = n_elements( y )
nz = n_elements( z )
rx = randomu( seed0 ) * nx
ry = randomu( seed1 ) * ny
rz = randomu( seed2 ) * nz

s = stregex( q, '(.*)X(.*)Y(.*)Z(.*)', /extract, /subexpr ) ; insert XYZ to Q
p = s[ 1 ] + x[ rx ] + s[ 2 ] + y[ ry ] + s[ 3 ] + z[ rz ] + s[ 4 ] ; phrase

print, p ; ask phrase

g = [ 'How to solve it?', $ ; grovel
'Can you help?', $
'Who will help?', $
'Explain for me.', $
'Show me answer', $
'Tell me why', $
'Please solve for me.']
print, g[ randomu( seed ) * n_elements( g ) ]

END

;
; $Log: lixiaoyao.pro,v $
; Revision 1.2 2005/04/23 05:45:21 mankoff
; First working version. Mimics well. Poorly coded
;
; Revision 1.1 2005/04/23 04:51:03 mankoff
; Initial revision
;
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: GDL - a little uppdate...
Next Topic: Re: You have been replaced by a small procedure

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Fri Oct 10 01:04:48 PDT 2025

Total time taken to generate the page: 1.11855 seconds