How can we distinguish the meaning from POS,words,form..or any other information.. f.e.
the cube is **in** the box the sign splits a rule **in** two parts
in the first case the meaning is containment in the second it is just sort of connector.
the reason I want to know this is to build structures. If i want to use in as functor :
in(cube,box) in(sign-split-rule,two-parts) <-- not convincing split(sign,rule^in(rule,two-parts)) <--- better
i.e. in the first case i can use in , in the second i have to prioritize the verb first..
Is it the case always to use verb first and only then to look for connectors like in,into,on,after,before ...
BTW I'm not looking for pure Linguistic rules, but more for a Structural/relational rules. verbs,nouns reveal L-Struct, connectors reveal R-Struct
this is my initial crack on it, for now POS-based :
import spacy class Sent2Struct(object): def root(self,doc): for word in doc : if word.dep_ == 'ROOT' : return word def lol(self,root) : if len(list(root.children)) == 0 : return root.text childs = [ self.lol(child) for child in root.children ] return [root.text] + childs In : print( ss.lol(ss.root(nlp('the box is on the table'))) ) ['is', ['box', 'the'], ['on', ['table', 'the']]]
is(box(the), on(table(the)) )