Hello all.
How I can, in CIAO Prolog, read a string of characters and put it in a list?
For example:
my name is jose
and obtain
[my,name,is,jose]
I need make this for "speak" to the program in natural language, and after build a database consult, for example:
give me the books that treat of libraries and archives and users
Now, in my program, I must ask with the following format:
[give,me,the,books,that,treat,of,libraries,and,archives,and,users]
After, with a pattern, I get the tail of the list, [libraries,and,archives,and,users], and delete the non-significative words ("and" in this case). Therefore, my problem is convert the string of characters in a list of elements.
Thank you for your help, a greeting.
José Antonio Echagüe Burgos
_________________________________________________________ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com ============================================================================== Message: Address: Action: help majordomo(a)clip.dia.fi.upm.es Info. on useful commands subscribe ciao-users-request(a)clip.dia.fi.upm.es Subscribe to this list unsubscribe ciao-users-request(a)clip.dia.fi.upm.es Unsubscribe from this list <whatever> ciao-users(a)clip.dia.fi.upm.es Send message to list ----------------------------------------------------------------------------- Archived messages: http://www.clip.dia.fi.upm.es/Mail/ciao-users/ -----------------------------------------------------------------------------
hello this is a piece of code i had lying around. i found it somewhere ont he web. if you ask read_list(X) then X should be the list of words. good luck.
swithun.
% read a line of words from the user
read_list(L) :- read_line(CL), wordlist(L,CL,[]), !.
read_line(L) :- get0(C), buildlist(C,L).
buildlist(-1,[]).
buildlist(C,[C|X]) :- get0(C2), buildlist(C2,X).
wordlist([X|Y]) --> word(X), whitespace, wordlist(Y).
wordlist([X]) --> whitespace, wordlist(X).
wordlist([X]) --> word(X).
wordlist([X]) --> word(X), whitespace.
word(W) --> charlist(X), {name(W,X)}.
charlist([X|Y]) --> chr(X), charlist(Y).
charlist([X]) --> chr(X).
chr(X) --> [X], {X>=48}.
chr(X) --> [X], {X=46}.
whitespace --> whsp, whitespace.
whitespace --> whsp.
whsp --> [X], {X<48}.
============================================================================== Message: Address: Action: help majordomo(a)clip.dia.fi.upm.es Info. on useful commands subscribe ciao-users-request(a)clip.dia.fi.upm.es Subscribe to this list unsubscribe ciao-users-request(a)clip.dia.fi.upm.es Unsubscribe from this list <whatever> ciao-users(a)clip.dia.fi.upm.es Send message to list ----------------------------------------------------------------------------- Archived messages: http://www.clip.dia.fi.upm.es/Mail/ciao-users/ -----------------------------------------------------------------------------