Closed raschild6 closed 3 years ago
What do you do to get this? I tried the following, and cannot reproduce it.
cd to directory containing the relex server
./opencog-server.sh
in a different terminal,
telnet localhost 4444
The book is on the table.
Note the lack of quotation marks. Writing text: The book is on the table.
also works. I get lots of output, including this snippet:
; _pobj (<<on>>, <<table>>)
(EvaluationLink (stv 1.0 1.0)
(DefinedLinguisticRelationshipNode "_pobj")
(ListLink
(WordInstanceNode "on@56b8fd20-c7bc-4fb9-8281-bf4a300f92db")
(WordInstanceNode "table.n@91ad9cfc-1057-4188-b73d-b706b5c12752")
)
)
; _predadj (<<book>>, <<on>>)
(EvaluationLink (stv 1.0 1.0)
(DefinedLinguisticRelationshipNode "_predadj")
(ListLink
(WordInstanceNode "book.n@701f73c1-0c82-4199-a3ce-388723d17056")
(WordInstanceNode "on@56b8fd20-c7bc-4fb9-8281-bf4a300f92db")
)
)
Nothing in relex ever produces a PredicateNode
, and so I am guessing that the R2L rules are the ones producing this. (and that the R2L rules are proken for this expression). How do you trigger R2L to run?
ahh ok! Now I understand which Evaluation I have to consider to get the sorted list!
I'm using the following method:
; start RelexServer and CogServer (port 17001)
./opencog-server.sh
cogserver
rlwrap telnet localhost 17001
So from telnet I parse the sentence using:
(use-modules (opencog) (opencog nlp) (opencog nlp chatbot) (opencog nlp relex2logic))
(nlp-parse "The book is on the table")
(car (sentence-get-parses (SentenceNode "sentence@a1771da7-3997-4bbf-975b-1f9aa9596a98")))
(parse-get-r2l-outputs (ParseNode "sentence@a1771da7-3997-4bbf-975b-1f9aa9596a98_parse_0" (stv 1 0.991)))
and so I get the following result: (in which the two Evaluations of Predicate "on" appear with a list of one element)
(
(InheritanceLink (stv 1 1)
(ConceptNode "table.n@7f11d0c8-e929-4ed4-aec7-760737d722b3")
(ConceptNode "table"))
; First Evaluation
(EvaluationLink (stv 1 1)
(PredicateNode "on@6ca3ffff-8374-451c-92d0-b22f2e48d83e" (stv 9.75697e-13 0.00124844))
(ListLink
(ConceptNode "table.n@7f11d0c8-e929-4ed4-aec7-760737d722b3")))
(InheritanceLink (stv 1 1)
(ConceptNode "book.n@798c2e3f-a442-43c7-846c-e889dcd0647c")
(ConceptNode "book"))
(InheritanceLink (stv 1 1)
(PredicateNode "on@6ca3ffff-8374-451c-92d0-b22f2e48d83e" (stv 9.75697e-13 0.00124844))
(DefinedLinguisticConceptNode "present" (stv 9.75697e-13 0.00124844)))
(InheritanceLink (stv 1 1)
(InterpretationNode "sentence@a1771da7-3997-4bbf-975b-1f9aa9596a98_parse_0_interpretation_$X" (stv 9.75697e-13 0.00124844))
(DefinedLinguisticConceptNode "DeclarativeSpeechAct" (stv 9.75697e-13 0.00124844)))
(EvaluationLink (stv 1 1)
(DefinedLinguisticPredicateNode "definite" (stv 9.75697e-13 0.00124844))
(ListLink
(ConceptNode "book.n@798c2e3f-a442-43c7-846c-e889dcd0647c")))
(EvaluationLink (stv 1 1)
(DefinedLinguisticPredicateNode "definite" (stv 9.75697e-13 0.00124844))
(ListLink
(ConceptNode "table.n@7f11d0c8-e929-4ed4-aec7-760737d722b3")))
; Second Evaluation
(EvaluationLink (stv 1 1)
(PredicateNode "on@6ca3ffff-8374-451c-92d0-b22f2e48d83e" (stv 9.75697e-13 0.00124844))
(ListLink
(ConceptNode "book.n@798c2e3f-a442-43c7-846c-e889dcd0647c")))
(ImplicationLink (stv 1 1)
(PredicateNode "on@6ca3ffff-8374-451c-92d0-b22f2e48d83e" (stv 9.75697e-13 0.00124844))
(PredicateNode "on" (stv 9.75697e-13 0.00124844)))
)
Anyway, thanks to your comment I solved it with a Query
(define get_on_objs
(QueryLink
(VariableList
(TypedVariableLink (VariableNode "?d1") (TypeNode "DefinedLinguisticRelationshipNode"))
(TypedVariableLink (VariableNode "?d2") (TypeNode "DefinedLinguisticRelationshipNode"))
(TypedVariableLink (VariableNode "?ob_w") (TypeNode "WordInstanceNode"))
(TypedVariableLink (VariableNode "?underob_w") (TypeNode "WordInstanceNode"))
(TypedVariableLink (VariableNode "?pred_w") (TypeNode "WordInstanceNode"))
(TypedVariableLink (VariableNode "?ob") (TypeNode "ConceptNode"))
(TypedVariableLink (VariableNode "?underob") (TypeNode "ConceptNode"))
(TypedVariableLink (VariableNode "?pred") (TypeNode "PredicateNode"))
(TypedVariableLink (VariableNode "?ob_id") (TypeNode "ConceptNode"))
(TypedVariableLink (VariableNode "?underob_id") (TypeNode "ConceptNode"))
(TypedVariableLink (VariableNode "?pred_id") (TypeNode "PredicateNode"))
)
(PresentLink
(EvaluationLink
(VariableNode "?d1")
(ListLink
(VariableNode "?pred_w")
(VariableNode "?underob_w")
)
)
(EvaluationLink
(VariableNode "?d2")
(ListLink
(VariableNode "?ob_w")
(VariableNode "?pred_w")
)
)
(InheritanceLink
(VariableNode "?ob_id")
(VariableNode "?ob")
)
(InheritanceLink
(VariableNode "?underob_id")
(VariableNode "?underob")
)
(ImplicationLink
(VariableNode "?pred_id")
(VariableNode "?pred")
)
(ReferenceLink
(VariableNode "?ob_id")
(VariableNode "?ob_w")
)
(ReferenceLink
(VariableNode "?underob_id")
(VariableNode "?underob_w")
)
(ReferenceLink
(VariableNode "?pred_id")
(VariableNode "?pred_w")
)
)
(EvaluationLink
(VariableNode "?pred")
(ListLink
(VariableNode "?ob")
(VariableNode "?underob")
)
)
)
)
For what I need, I search the ConceptNode associated to the ConceptNode with id .. So for example I'm looking for:
(EvaluationLink (stv 1 1)
(PredicateNode "on" (stv 9.75697e-13 0.00124844))
(ListLink
(ConceptNode "book")
(ConceptNode "table"))
Yes, that is a good solution. It is the one I would have recommended, had I said more.
Here's a sketch of the situation. All three (R2L, relex and link-grammar) are collections of hand-curated rules for altering natural language into a more "computationally desirable" form. Like all curated systems, they are incomplete and buggy, and will remain so, forever (as they depend on human effort). Of the three, LG is by far the most sophisticated and advanced. Relex applies a few hundred rules to transform the LG output to a more traditional dependency form. (The QueryLink was inspired by the relex rules, but we never got around to porting the relex rules to use QueryLink). R2L is a few hundred more rules to create a "logical" representation of sentences, so that a "logic" layer (PLN) could perform reasoning. The stack of all three is fragile, and almost all of the value is provided by LG, so that is a good level to work with, at the base. Neither Relex nor R2L are maintained any more.
The goal of the "learn" project is to replace the whole stack (and more) with machine-learnned systems (no more human curation; I suppose it will learn buggy things, but at least, with more cpu power, maybe it can learn to fix it's own mis-learned stuff.)
Anyway, since you have chosen to work with LG directly, there is a way of working with LG in the atomspace directly, without using the relex server. It's faster and lighter. (For you the speed won't matter, so, to keep it simple, you can continue doing as you are doing.) Let me describe this, next post.
An example of parsing directly can be found in
https://github.com/opencog/lg-atomese/blob/master/examples/parse.scm
(I'm expanding this example right now)
Documentation in https://wiki.opencog.org/w/LgParseLink
Great! For now, i have already written the code which runs telnet from python and it works, so i don't change it. But this is definitely a better solution! Thus, at least, i might stop running shells by hand! Thanks for all.
I expanded the demo slightly.
Regarding the cogserver: it can also be started from the guile prompt, which is handy, because it gives you a full guile shell, instead of that telnet thing. Do it like so:
$ guile
(use-modules (opencog))
(use-modules (opencog cogserver))
(start-cogserver) ; starts using the default port 17001
; print the docs:
,d start-cogserver
(stop-cogserver)
(start-cogserver #:port 17003 #:logfile "/tmp/foo.log")
Basically, everything runs fine without the cogserver; I use it because the telnet port provides a nice way of monitoring long-running jobs launched at the main guile prompt.
I'm closing this issue because R2L is currently unmaintained, and I don't want to maintain it, and this particular bug is just one of many that a future maintainer would have to deal with. Basically, it's "won't fix" until someone steps up to maintaining that subsystem.
Following the example of the text highlighted in this link: https://wiki.opencog.org/w/RelEx2Logic_representation#:~:text=The%20book%20is,stv%200.001%200.99000001))%0A%20%20%20)%0A)
When I execute sentences like "The book is on the table." I get 2 EvaluationLink with List each with one element:
instead of 1 EvaluationLink with List with the two elements (as in the link)