DennisDeSwart / php-stanford-corenlp-adapter

PHP adapter for Stanford CoreNLP
26 stars 4 forks source link

`$sentence['parse']` not working #7

Closed edgard-habanbou closed 1 year ago

edgard-habanbou commented 3 years ago

Hello i'm working on coreNLP adapter and i'm facing a problem with the function getTreeWithTokens where $parse = $sentence['parse']; is giving me Unidentified index. I've made a var_dump on $sentence with the text " What fox say Hi bob how you " to see whats the problem i got these: array(7) { ["index"]=> int(0) ["basicDependencies"]=> array(7) { [0]=> array(5) { ["dep"]=> string(4) "ROOT" ["governor"]=> int(0) ["governorGloss"]=> string(4) "ROOT" ["dependent"]=> int(3) ["dependentGloss"]=> string(3) "say" } [1]=> array(5) { ["dep"]=> string(3) "det" ["governor"]=> int(2) ["governorGloss"]=> string(3) "fox" ["dependent"]=> int(1) ["dependentGloss"]=> string(4) "What" } [2]=> array(5) { ["dep"]=> string(5) "nsubj" ["governor"]=> int(3) ["governorGloss"]=> string(3) "say" ["dependent"]=> int(2) ["dependentGloss"]=> string(3) "fox" } [3]=> array(5) { ["dep"]=> string(9) "discourse" ["governor"]=> int(5) ["governorGloss"]=> string(3) "bob" ["dependent"]=> int(4) ["dependentGloss"]=> string(2) "Hi" } [4]=> array(5) { ["dep"]=> string(5) "ccomp" ["governor"]=> int(3) ["governorGloss"]=> string(3) "say" ["dependent"]=> int(5) ["dependentGloss"]=> string(3) "bob" } [5]=> array(5) { ["dep"]=> string(6) "advmod" ["governor"]=> int(7) ["governorGloss"]=> string(3) "you" ["dependent"]=> int(6) ["dependentGloss"]=> string(3) "how" } [6]=> array(5) { ["dep"]=> string(3) "dep" ["governor"]=> int(5) ["governorGloss"]=> string(3) "bob" ["dependent"]=> int(7) ["dependentGloss"]=> string(3) "you" } } ["enhancedDependencies"]=> array(7) { [0]=> array(5) { ["dep"]=> string(4) "ROOT" ["governor"]=> int(0) ["governorGloss"]=> string(4) "ROOT" ["dependent"]=> int(3) ["dependentGloss"]=> string(3) "say" } [1]=> array(5) { ["dep"]=> string(3) "det" ["governor"]=> int(2) ["governorGloss"]=> string(3) "fox" ["dependent"]=> int(1) ["dependentGloss"]=> string(4) "What" } [2]=> array(5) { ["dep"]=> string(5) "nsubj" ["governor"]=> int(3) ["governorGloss"]=> string(3) "say" ["dependent"]=> int(2) ["dependentGloss"]=> string(3) "fox" } [3]=> array(5) { ["dep"]=> string(9) "discourse" ["governor"]=> int(5) ["governorGloss"]=> string(3) "bob" ["dependent"]=> int(4) ["dependentGloss"]=> string(2) "Hi" } [4]=> array(5) { ["dep"]=> string(5) "ccomp" ["governor"]=> int(3) ["governorGloss"]=> string(3) "say" ["dependent"]=> int(5) ["dependentGloss"]=> string(3) "bob" } [5]=> array(5) { ["dep"]=> string(6) "advmod" ["governor"]=> int(7) ["governorGloss"]=> string(3) "you" ["dependent"]=> int(6) ["dependentGloss"]=> string(3) "how" } [6]=> array(5) { ["dep"]=> string(3) "dep" ["governor"]=> int(5) ["governorGloss"]=> string(3) "bob" ["dependent"]=> int(7) ["dependentGloss"]=> string(3) "you" } } ["enhancedPlusPlusDependencies"]=> array(7) { [0]=> array(5) { ["dep"]=> string(4) "ROOT" ["governor"]=> int(0) ["governorGloss"]=> string(4) "ROOT" ["dependent"]=> int(3) ["dependentGloss"]=> string(3) "say" } [1]=> array(5) { ["dep"]=> string(3) "det" ["governor"]=> int(2) ["governorGloss"]=> string(3) "fox" ["dependent"]=> int(1) ["dependentGloss"]=> string(4) "What" } [2]=> array(5) { ["dep"]=> string(5) "nsubj" ["governor"]=> int(3) ["governorGloss"]=> string(3) "say" ["dependent"]=> int(2) ["dependentGloss"]=> string(3) "fox" } [3]=> array(5) { ["dep"]=> string(9) "discourse" ["governor"]=> int(5) ["governorGloss"]=> string(3) "bob" ["dependent"]=> int(4) ["dependentGloss"]=> string(2) "Hi" } [4]=> array(5) { ["dep"]=> string(5) "ccomp" ["governor"]=> int(3) ["governorGloss"]=> string(3) "say" ["dependent"]=> int(5) ["dependentGloss"]=> string(3) "bob" } [5]=> array(5) { ["dep"]=> string(6) "advmod" ["governor"]=> int(7) ["governorGloss"]=> string(3) "you" ["dependent"]=> int(6) ["dependentGloss"]=> string(3) "how" } [6]=> array(5) { ["dep"]=> string(3) "dep" ["governor"]=> int(5) ["governorGloss"]=> string(3) "bob" ["dependent"]=> int(7) ["dependentGloss"]=> string(3) "you" } } ["kbp"]=> array(0) { } ["entitymentions"]=> array(0) { } ["tokens"]=> array(7) { [0]=> array(11) { ["index"]=> int(1) ["word"]=> string(4) "What" ["originalText"]=> string(4) "What" ["lemma"]=> string(4) "what" ["characterOffsetBegin"]=> int(0) ["characterOffsetEnd"]=> int(4) ["pos"]=> string(3) "WDT" ["ner"]=> string(1) "O" ["speaker"]=> string(4) "PER0" ["before"]=> string(0) "" ["after"]=> string(1) " " } [1]=> array(11) { ["index"]=> int(2) ["word"]=> string(3) "fox" ["originalText"]=> string(3) "fox" ["lemma"]=> string(3) "fox" ["characterOffsetBegin"]=> int(5) ["characterOffsetEnd"]=> int(8) ["pos"]=> string(2) "NN" ["ner"]=> string(1) "O" ["speaker"]=> string(4) "PER0" ["before"]=> string(1) " " ["after"]=> string(1) " " } [2]=> array(11) { ["index"]=> int(3) ["word"]=> string(3) "say" ["originalText"]=> string(3) "say" ["lemma"]=> string(3) "say" ["characterOffsetBegin"]=> int(9) ["characterOffsetEnd"]=> int(12) ["pos"]=> string(3) "VBP" ["ner"]=> string(1) "O" ["speaker"]=> string(4) "PER0" ["before"]=> string(1) " " ["after"]=> string(5) " " } [3]=> array(11) { ["index"]=> int(4) ["word"]=> string(2) "Hi" ["originalText"]=> string(2) "Hi" ["lemma"]=> string(2) "hi" ["characterOffsetBegin"]=> int(17) ["characterOffsetEnd"]=> int(19) ["pos"]=> string(2) "UH" ["ner"]=> string(1) "O" ["speaker"]=> string(4) "PER0" ["before"]=> string(5) " " ["after"]=> string(1) " " } [4]=> array(11) { ["index"]=> int(5) ["word"]=> string(3) "bob" ["originalText"]=> string(3) "bob" ["lemma"]=> string(3) "bob" ["characterOffsetBegin"]=> int(20) ["characterOffsetEnd"]=> int(23) ["pos"]=> string(2) "NN" ["ner"]=> string(1) "O" ["speaker"]=> string(4) "PER0" ["before"]=> string(1) " " ["after"]=> string(2) " " } [5]=> array(11) { ["index"]=> int(6) ["word"]=> string(3) "how" ["originalText"]=> string(3) "how" ["lemma"]=> string(3) "how" ["characterOffsetBegin"]=> int(25) ["characterOffsetEnd"]=> int(28) ["pos"]=> string(3) "WRB" ["ner"]=> string(1) "O" ["speaker"]=> string(4) "PER0" ["before"]=> string(2) " " ["after"]=> string(1) " " } [6]=> array(11) { ["index"]=> int(7) ["word"]=> string(3) "you" ["originalText"]=> string(3) "you" ["lemma"]=> string(3) "you" ["characterOffsetBegin"]=> int(29) ["characterOffsetEnd"]=> int(32) ["pos"]=> string(3) "PRP" ["ner"]=> string(1) "O" ["speaker"]=> string(4) "PER0" ["before"]=> string(1) " " ["after"]=> string(1) " " } } } the problem is that there's no ["parse"] section in the sentence in there a way to fix it?

edgard-habanbou commented 3 years ago

i forgot to mention that i'm working on version 4.1.0

DennisDeSwart commented 3 years ago

Hi Edgard,

I will look into this issue. Due to the holidays it might take a few days