Frame2PLN

From OpenCog
Jump to: navigation, search

Obsolete Documentation. The frame elements no longer exist in RelEx. They were removed because they never worked very well. This page should probably be blanked and removed, but is kept here for a little while because maybe it contains a useful idea. Feel free to kill this page.


These are Jared Wigmore's rough notes about how to represent data from NLP for use with PLN.

Most Frames

The current RelEx2Frame output stores a Frame Element like this. Note that the WordInstanceNodes are only in the raw Relex2Frame output, and are replaced with appropriate ConceptNodes during another part of the pipeline:

; The ball is red.

([[InheritanceLink]] (stv 1 1)
   ([[PredicateNode]] "red@87cd46cc-006d-4ff4-b4de-7e579f92adf6_Color_Entity")
   ([[DefinedFrameElementNode]] "#Color:Entity")
)
([[FrameElementLink]] (stv 1 1)
   (PredicateNode "red@87cd46cc-006d-4ff4-b4de-7e579f92adf6_Color")
   (PredicateNode "red@87cd46cc-006d-4ff4-b4de-7e579f92adf6_Color_Entity")
)
([[EvaluationLink]] (stv 1 1)
   (PredicateNode "red@87cd46cc-006d-4ff4-b4de-7e579f92adf6_Color_Entity")
   (WordInstanceNode "ball@72673eaa-74db-4ff1-9ce9-f57f8805d20c")
)

This format seems unnecessarily complex. PLN also had difficulty with it (queries required finding three separate links with typically 3-4 variables). I added a simple preprocessing layer to convert the frames to a nicer form. (Obviously that's a bit of a hack, but actually changing it would require changes throughout hundreds of lines of code.) This is shown with ConceptNodes already filled in.

      (EvaluationLink (VariableNode "$frameElement")
        (ListLink
            (VariableNode "$frameInstance")
            (VariableNode "$value")
        )
      )

e.g.

      (EvaluationLink (DefinedFrameElementNode "#Color:Entity")
        (ListLink
            (PredicateNode "red@87cd46cc-006d-4ff4-b4de-7e579f92adf6_Color")
            (ConceptNode "ball")
        )
      )

This representation removes the "frame element instance", and two of the links.

Comment on the above by Ben G

Jared, I understand why the revised representation makes some queries faster and simpler. However, I worry that the semantics is a bit messed up in the new representation. What about

      (EvaluationLink 
        (DefinedFrameElementNode "#Color:Entity")
        (ListLink
            (ConceptNode "red@87cd46cc-006d-4ff4-b4de-7e579f92adf6_Color")
            (ConceptNode "ball@72673eaa-74db-4ff1-9ce9-f57f8805d20c")
        )
      )

InheritanceLinks

Example (Mortal Socrates):

John is a man.
Men are mortal.
Is John mortal?
[It should say "Yes".]

Note that the NLP pipeline breaks with the name "Socrates". In this case it will produce two InheritanceLinks, one for each statement. And then combine them using DeductionRule.

Convert frames like Attributes into an InheritanceLink between the two things. There is a difference between being an adjective vs being a noun (i.e. having a property vs being a specific object). Probably ignore that for now, but maybe make the distinction using intensional inheritance and extensional (i.e. Subset).

Another example:

John is a man.
Men breathe air.
Does John breathe air?
[It should say "Yes".]

"John is a man" will be represented with an InheritanceLink, and "Men breathe air" will be represented with an EvaluationLink (something like (Eval breathe man air)). PLN handles this example using SimSubstRule, which uses an InheritanceLink to replace something in an EvaluationLink.

ImplicationLinks

Convert if..then sentences into ImplicationLinks. Although the Frames have a "flat" structure, the ImplicationLinks will have to link to some of the Frames as arguments.

The dog is next to the house.

; Locative_relation:Figure(to@7630b619-d6e7-44ab-a9ef-f075dd1c366f,dog@c135b2aa-fcb4-45ef-8c4a-6bf2c2f271e7)
; Locative_relation:Ground(to@7630b619-d6e7-44ab-a9ef-f075dd1c366f,house@21cfa599-ec4c-49b6-bffc-3650ca16c644)
; Locative_relation:Relation_type(to@7630b619-d6e7-44ab-a9ef-f075dd1c366f,next)

The dog eats food.

; Ingestion:Ingestibles(eats@7a7ce100-eef8-4e12-a170-9aa20abe60af,food@9f22241a-4466-4361-af91-86254f4c4d66)
; Ingestion:Ingestor(eats@7a7ce100-eef8-4e12-a170-9aa20abe60af,dog@feb3ca2a-bf53-4c13-bce9-fc36d1ae7afa)

If the dog is next to the house, the dog eats food.

; Locative_relation:Ground(to@8266dccf-da6c-4389-b371-07608434c374,house@c97b9482-2fff-4188-8a9d-2021a536c108)
; Locative_relation:Figure(to@8266dccf-da6c-4389-b371-07608434c374,dog@23516d9f-5e64-470e-a049-691022a0b3a2)
; Locative_relation:Relation_type(to@8266dccf-da6c-4389-b371-07608434c374,next)

; Ingestion:Ingestibles(eats@cc8874e1-84d0-4b6e-8cac-8b0bd0c59f26,food@9f9cce52-2470-471b-bd84-bbe7b6db0af3)
; Ingestion:Ingestor(eats@cc8874e1-84d0-4b6e-8cac-8b0bd0c59f26,dog@48c7a394-8c85-40f1-a95f-4968344cc9ea)

; Possibilities:Event(hyp,to@8266dccf-da6c-4389-b371-07608434c374)
; Contingency:Determinant(if,to@8266dccf-da6c-4389-b371-07608434c374)
; Contingency:Outcome(if,eats@cc8874e1-84d0-4b6e-8cac-8b0bd0c59f26)

[reversed...]
; Logical_Inference:Conclusion(if,to@8266dccf-da6c-4389-b371-07608434c374)
; Logical_Inference:Proposition(if,eats@cc8874e1-84d0-4b6e-8cac-8b0bd0c59f26)
ImplicationLink
        ; Locative_relation:Ground(to@8266dccf-da6c-4389-b371-07608434c374,house@c97b9482-2fff-4188-8a9d-2021a536c108)
        ; Locative_relation:Figure(to@8266dccf-da6c-4389-b371-07608434c374,dog@23516d9f-5e64-470e-a049-691022a0b3a2)
        ; Locative_relation:Relation_type(to@8266dccf-da6c-4389-b371-07608434c374,next)
THEN
        ; Ingestion:Ingestibles(eats@cc8874e1-84d0-4b6e-8cac-8b0bd0c59f26,food@9f9cce52-2470-471b-bd84-bbe7b6db0af3)
        ; Ingestion:Ingestor(eats@cc8874e1-84d0-4b6e-8cac-8b0bd0c59f26,dog@48c7a394-8c85-40f1-a95f-4968344cc9ea)


If the red ball is next to the house, the small dog eats food.

; Locative_relation:Relation_type(to@98e0678d-c5b5-4e03-9fc4-be51266d3b2e,next)
; Locative_relation:Figure(to@98e0678d-c5b5-4e03-9fc4-be51266d3b2e,ball@0396007f-6175-4d45-8e49-663cb76c54fd)
; Locative_relation:Ground(to@98e0678d-c5b5-4e03-9fc4-be51266d3b2e,house@b847f532-6985-4bc4-9ee9-e7b4ff8599e5)
; Color:Entity(red@8e2cfd15-a818-4cda-84a8-d2d9c150a3c4,ball@0396007f-6175-4d45-8e49-663cb76c54fd)
; Color:Color(red@8e2cfd15-a818-4cda-84a8-d2d9c150a3c4,red@8e2cfd15-a818-4cda-84a8-d2d9c150a3c4)

; Dimension:Object(small@04d971d8-b063-4ec7-b5fc-5e88cc2b1bff,dog@0d9bd5bf-cfbf-4606-bb2b-57c3584a5330)
; Dimension:Measurement(small@04d971d8-b063-4ec7-b5fc-5e88cc2b1bff,small@04d971d8-b063-4ec7-b5fc-5e88cc2b1bff)
; Ingestion:Ingestibles(eats@1a438200-9fbb-48f4-83f3-1ebd7b565f50,food@f625e44e-46fc-414f-ba42-f2fd46b022eb)
; Ingestion:Ingestor(eats@1a438200-9fbb-48f4-83f3-1ebd7b565f50,dog@0d9bd5bf-cfbf-4606-bb2b-57c3584a5330)

; Possibilities:Event(hyp,to@98e0678d-c5b5-4e03-9fc4-be51266d3b2e)
; Contingency:Determinant(if,to@98e0678d-c5b5-4e03-9fc4-be51266d3b2e)
; Contingency:Outcome(if,eats@1a438200-9fbb-48f4-83f3-1ebd7b565f50)

[reversed...]
; Logical_Inference:Proposition(if,eats@1a438200-9fbb-48f4-83f3-1ebd7b565f50)
; Logical_Inference:Conclusion(if,to@98e0678d-c5b5-4e03-9fc4-be51266d3b2e)

color ball red
size  dog  small

ImplicationLink
        AndLink
                next_to ball house
        AndLink
                eats    dog  food

If that red ball is next to that house, that small dog eats that food.

ImplicationLink        
        AndLink
                Inh     ball "ball"
                Inh     dog  "dog"
                Inh     house"house"
                Inh     food "food"
                color   ball red
                size    dog  small
                next_to ball house
        AndLink
                eats    dog  food

(i.e there is some specific $ball, $dog, $house and $food. If they meet all those criteria, that will be true for them. No need to specify the criteria really (as part of the antecedent).)

X If any red ball is next to any house, any small dog eats any food. If any red ball is next to any house, some specific small dog eats some specific food.

You could spend forever working out the right quantifiers. Maybe do it numerically.

Start with just claiming it about a specific bunch... (and doing whatever re the mined implications).

All up, I'd say it's OK to leave the frames outside the Implication.

(If you allow variables you need to support variables in the frames. If we make these all specific variables, then you can put the descriptive frames somewhere else. Otherwise do ____?)


If that red ball is next to that house, then that dog is small. If that red ball is next to that house, then that dog is small and eats that food.

(In this case the smallness of the dog _is_ part of what was implied. This is handled correctly by Relex2Frame)

; Contingency:Determinant(if_1,to@0b5e406f-4f0c-466e-9543-27dabe03ab24)
; Contingency:Outcome(if,eats@3c587337-5011-40c1-bdaf-ca434cc7adac)
; Contingency:Determinant(if,to@0b5e406f-4f0c-466e-9543-27dabe03ab24)
; Contingency:Outcome(if_1,small@a9f668d2-0370-4094-9136-8581b961bf52)

; Locative_relation:Ground(to@0b5e406f-4f0c-466e-9543-27dabe03ab24,house@87573e6f-a9b5-4a83-800a-a84de85b89af)
; Locative_relation:Relation_type(to@0b5e406f-4f0c-466e-9543-27dabe03ab24,next)
; Locative_relation:Figure(to@0b5e406f-4f0c-466e-9543-27dabe03ab24,ball@91f3f60e-bc63-4b3a-b634-65007eb770e7)

; Logical_Inference:Conclusion(if,to@0b5e406f-4f0c-466e-9543-27dabe03ab24)
; Logical_Inference:Proposition(if,eats@3c587337-5011-40c1-bdaf-ca434cc7adac)

; Possibilities:Event(hyp,to@0b5e406f-4f0c-466e-9543-27dabe03ab24)

; Color:Entity(red@e14b1953-4f63-4633-95a8-7febe8452717,ball@91f3f60e-bc63-4b3a-b634-65007eb770e7)
; Color:Color(red@e14b1953-4f63-4633-95a8-7febe8452717,red@e14b1953-4f63-4633-95a8-7febe8452717)
; Ingestion:Ingestibles(eats@3c587337-5011-40c1-bdaf-ca434cc7adac,food@50b0eee4-3ba4-44ef-9497-6fc488282950)
; Ingestion:Ingestor(eats@3c587337-5011-40c1-bdaf-ca434cc7adac,dog@07197f76-aaa7-4653-9e59-6064f427f925)

; Dimension:Measurement(small@a9f668d2-0370-4094-9136-8581b961bf52,small@a9f668d2-0370-4094-9136-8581b961bf52)
; Dimension:Object(small@a9f668d2-0370-4094-9136-8581b961bf52,dog@07197f76-aaa7-4653-9e59-6064f427f925)

Design for the Implementation

Currently during reference resolution, all WordInstanceNodes get converted to ConceptNodes (or SemeNodes if they refer to specific individuals. This may not be the correct use of SemeNodes, but anyway...). But if it is a frame such as Contingency, then that would just produce concepts like "to" and "eats" which are useless/garbage. It seems the best way would be for reference resolution to change those frames so their element values are the other frame instances. E.g. for the example above (this is in the old format because reference resolution uses the old format):

(InheritanceLink (stv 1 1)
   (PredicateNode "if_Contingency_Determinant")
   (DefinedFrameElementNode "#Contingency:Determinant")
)
(FrameElementLink (stv 1 1)
   (PredicateNode "if_Contingency")
   (PredicateNode "if_Contingency_Determinant")
)
(EvaluationLink (stv 1 1)
   (PredicateNode "if_Contingency_Determinant")
   (PredicateNode "to@9c46471c-b6f9-4e5d-a797-28c91dbe6352_Locative_relation")
)
(InheritanceLink (stv 1 1)
   (PredicateNode "if_Contingency_Outcome")
   (DefinedFrameElementNode "#Contingency:Outcome")
)
(FrameElementLink (stv 1 1)
   (PredicateNode "if_Contingency")
   (PredicateNode "if_Contingency_Outcome")
)
(EvaluationLink (stv 1 1)
   (PredicateNode "if_Contingency_Outcome")
   (PredicateNode "eats@c19cfa35-0d75-4762-ae96-f960745d777f_Ingestion")
)

There could then be a rule during the frames2pln processing step, which converts those two frame elements into an ImplicationLink (using their values to find the right frame instances to put into the ImplicationLink. In this case the specific instances of Locative_relation and Ingestion from this sentence).