Thread View: comp.lang.prolog
3 messages
3 total messages
Started by Weiguang Huang
Mon, 04 Jan 1993 11:33
How to parse "I say: 'I love you'" to [I, say, I love you]
Author: Weiguang Huang
Date: Mon, 04 Jan 1993 11:33
Date: Mon, 04 Jan 1993 11:33
12 lines
670 bytes
670 bytes
The program tok([String,[A|B]) :- fronttoken(String,A,String2), tok(String2,B). tok(_,[]). parse "I say ' I love you'" to [I, say, I, love, you], but how to parse to ["I", "say", "I love you"] ? Please help. huang@deakin.edu.au
Re: How to parse "I say: 'I love you'" to [I, say, I love you]
Author: Ken Johnson
Date: Tue, 05 Jan 1993 11:08
Date: Tue, 05 Jan 1993 11:08
37 lines
1647 bytes
1647 bytes
In article <1i97a9INN8h@sol.deakin.OZ.AU> huang@deakin.OZ.AU (Weiguang
Huang) writes:
# but how to parse to ["I", "say", "I love you"] ?
The following will do what you want, but I don't think what you describe
is really what you want to do. Instead of a list, you should really
generate a term expressing the structure of the original, so [I, say, I,
love, you] should really parse to a term such as
say('I',love('I',you)).
report([P,V|St]) --> pronoun(P), verb(V), quotation(St).
quotation([P1,V,P2]) --> pronoun(P1), verb(V), pronoun(P2).
pronoun('I') --> ['I'].
pronoun(you) --> [you].
verb(say) --> [say].
verb(love) --> [love].
This is how it works:
?- phrase(report(R),['I',say,'I',love,you]).
R=[I,say,I,love,you]
--
Son, all the pretty, intelligent, || Ken Johnson healthy young women are taken. || A I Applications Institute
It's a basic rule of the universe, || 80 South Bridge and if you don't like it, || Edinburgh, Scotland EH1 1HN
go somewhere else. || Phone 031-650 2756 Fax 031-650 6513
-- my dad 1906-1992 || E-mail ken@aiai.ed.ac.uk
Re: How to parse "I say 'I love you'" to ["I", "say", "'I love you'"]
Author: Weiguang Huang
Date: Tue, 05 Jan 1993 23:35
Date: Tue, 05 Jan 1993 23:35
28 lines
1381 bytes
1381 bytes
In article <8085@skye.ed.ac.uk> ken@aiai.ed.ac.uk (Ken Johnson) writes:
>
>In article <1i97a9INN8h@sol.deakin.OZ.AU> huang@deakin.OZ.AU (Weiguang
>Huang) writes:
>
># but how to parse to ["I", "say", "I love you"] ?
>
>The following will do what you want, but I don't think what you describe
>is really what you want to do. Instead of a list, you should really
>generate a term expressing the structure of the original, so [I, say, I,
>love, you] should really parse to a term such as
>
> say('I',love('I',you)).
>?- phrase(report(R),['I',say,'I',love,you]).
>
> R=[I,say,I,love,you]
All variables in my program are a string or a list of string, instead
of term nor word nor atom. I want to parse a string "I say 'I love you'" to
a list of string ["I", "say", "'I love you'"].
-? tok("I say 'I love you'", R).
R=["I", "say", "'I love you'"]
How to do so ?
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads