Stanford NLP Get Component Activity Issue

activities
nlp
p_qa

#1

Hi Guys,
How to extract Location from the Stanford Core NLP sentence(Output of Text analysis activity) using Get components activity.I have tried the named entity (component type) in Get components for extracting, but it returns the raw sentence only.

Eg:
Activity: Get Component(Named Entity)
Input: “I have to go USA from London”
Output: (I, ),(have, ),(to, ),(go, ),(USA, )_(from, ),(London, )
Issue: Not recognize the Location(USA,London)

Thanks,
Tharma KS


#2

In RawResult output, I can see London and USA are recognized as sentences.

{‘after’: ‘’,
‘before’: ’ ',
‘characterOffsetBegin’: 22,
‘characterOffsetEnd’: 28,
‘index’: 7,
‘lemma’: ‘London’,
‘ner’: ‘CITY’,
‘originalText’: ‘London’,
‘pos’: ‘NNP’,
‘word’: ‘London’}

Though, I am not able to try ‘Get Components’ activity as I see following compilation error for ‘Sentences’ output in ‘text analysis’ activity. I am trying on 2018.2.3-beta.4.

image

nlpOutput variable seems to initialized correctly as well:
image


#3

You ll need to go to the Imports panel and import manually the stanford type of variable


#4

Hi,
Now I got the named entities, but how can I get the date value.

Eg:
O/P: (Today,Date)
From o/p I have to get the Today live date value in date format(yyyy-mm-dd)

Thanks,
Tharma KS


#5

seems to work fine for me. See last line, ‘tomorrow’ is identified as entity ‘DATE’

{"sentences":[{"index":0,"parse":"(ROOT\r\n (S\r\n (NP (PRP I))\r\n (VP (VBP have)\r\n (S\r\n (VP (TO to)\r\n (VP (VB go)\r\n (NP (NNP USA))\r\n (PP (IN from)\r\n (NP (NNP London)))\r\n (NP-TMP (NN tomorrow))))))))","basicDependencies":[{"dep":"ROOT","governor":0,"governorGloss":"ROOT","dependent":2,"dependentGloss":"have"},{"dep":"nsubj","governor":2,"governorGloss":"have","dependent":1,"dependentGloss":"I"},{"dep":"mark","governor":4,"governorGloss":"go","dependent":3,"dependentGloss":"to"},{"dep":"xcomp","governor":2,"governorGloss":"have","dependent":4,"dependentGloss":"go"},{"dep":"dobj","governor":4,"governorGloss":"go","dependent":5,"dependentGloss":"USA"},{"dep":"case","governor":7,"governorGloss":"London","dependent":6,"dependentGloss":"from"},{"dep":"nmod","governor":4,"governorGloss":"go","dependent":7,"dependentGloss":"London"},{"dep":"nmod:tmod","governor":4,"governorGloss":"go","dependent":8,"dependentGloss":"tomorrow"}],"enhancedDependencies":[{"dep":"ROOT","governor":0,"governorGloss":"ROOT","dependent":2,"dependentGloss":"have"},{"dep":"nsubj","governor":2,"governorGloss":"have","dependent":1,"dependentGloss":"I"},{"dep":"nsubj:xsubj","governor":4,"governorGloss":"go","dependent":1,"dependentGloss":"I"},{"dep":"mark","governor":4,"governorGloss":"go","dependent":3,"dependentGloss":"to"},{"dep":"xcomp","governor":2,"governorGloss":"have","dependent":4,"dependentGloss":"go"},{"dep":"dobj","governor":4,"governorGloss":"go","dependent":5,"dependentGloss":"USA"},{"dep":"case","governor":7,"governorGloss":"London","dependent":6,"dependentGloss":"from"},{"dep":"nmod:from","governor":4,"governorGloss":"go","dependent":7,"dependentGloss":"London"},{"dep":"nmod:tmod","governor":4,"governorGloss":"go","dependent":8,"dependentGloss":"tomorrow"}],"enhancedPlusPlusDependencies":[{"dep":"ROOT","governor":0,"governorGloss":"ROOT","dependent":2,"dependentGloss":"have"},{"dep":"nsubj","governor":2,"governorGloss":"have","dependent":1,"dependentGloss":"I"},{"dep":"nsubj:xsubj","governor":4,"governorGloss":"go","dependent":1,"dependentGloss":"I"},{"dep":"mark","governor":4,"governorGloss":"go","dependent":3,"dependentGloss":"to"},{"dep":"xcomp","governor":2,"governorGloss":"have","dependent":4,"dependentGloss":"go"},{"dep":"dobj","governor":4,"governorGloss":"go","dependent":5,"dependentGloss":"USA"},{"dep":"case","governor":7,"governorGloss":"London","dependent":6,"dependentGloss":"from"},{"dep":"nmod:from","governor":4,"governorGloss":"go","dependent":7,"dependentGloss":"London"},{"dep":"nmod:tmod","governor":4,"governorGloss":"go","dependent":8,"dependentGloss":"tomorrow"}],"sentimentValue":"2","sentiment":"Neutral","sentimentDistribution":[0.00817986707548,0.07195429217963,0.77991205801526,0.13108409728568,0.00886968544395],"sentimentTree":"(ROOT|sentiment=2|prob=0.780 (NP|sentiment=2|prob=0.996 I)\r\n (VP|sentiment=2|prob=0.847 (VBP|sentiment=2|prob=0.991 have)\r\n (S|sentiment=2|prob=0.917 (TO|sentiment=2|prob=0.990 to)\r\n (VP|sentiment=2|prob=0.759\r\n (@VP|sentiment=2|prob=0.814\r\n (@VP|sentiment=2|prob=0.788 (VB|sentiment=2|prob=0.997 go) (NP|sentiment=2|prob=0.631 USA))\r\n (PP|sentiment=2|prob=0.953 (IN|sentiment=2|prob=0.994 from) (NP|sentiment=2|prob=0.947 London)))\r\n (NP-TMP|sentiment=2|prob=0.941 tomorrow)))))","openie":[{"subject":"I","subjectSpan":[0,1],"relation":"go","relationSpan":[3,4],"object":"USA","objectSpan":[4,5]},{"subject":"I","subjectSpan":[0,1],"relation":"have","relationSpan":[1,2],"object":"go tomorrow","objectSpan":[3,8]},{"subject":"I","subjectSpan":[0,1],"relation":"have","relationSpan":[1,2],"object":"go","objectSpan":[3,4]},{"subject":"I","subjectSpan":[0,1],"relation":"have","relationSpan":[1,2],"object":"go from London tomorrow","objectSpan":[3,8]},{"subject":"I","subjectSpan":[0,1],"relation":"go from","relationSpan":[3,6],"object":"London","objectSpan":[6,7]},{"subject":"I","subjectSpan":[0,1],"relation":"go at_time","relationSpan":[3,4],"object":"tomorrow","objectSpan":[7,8]},{"subject":"I","subjectSpan":[0,1],"relation":"go USA at_time","relationSpan":[3,5],"object":"tomorrow","objectSpan":[7,8]},{"subject":"I","subjectSpan":[0,1],"relation":"have","relationSpan":[1,2],"object":"go from London","objectSpan":[3,7]},{"subject":"I","subjectSpan":[0,1],"relation":"go USA from","relationSpan":[3,6],"object":"London","objectSpan":[6,7]}],"entitymentions":[{"docTokenBegin":4,"docTokenEnd":5,"tokenBegin":4,"tokenEnd":5,"text":"USA","characterOffsetBegin":13,"characterOffsetEnd":16,"ner":"COUNTRY"},{"docTokenBegin":6,"docTokenEnd":7,"tokenBegin":6,"tokenEnd":7,"text":"London","characterOffsetBegin":22,"characterOffsetEnd":28,"ner":"CITY"},{"docTokenBegin":7,"docTokenEnd":8,"tokenBegin":7,"tokenEnd":8,"text":"tomorrow","characterOffsetBegin":29,"characterOffsetEnd":37,"ner":"DATE","normalizedNER":"OFFSET P1D","timex":{"tid":"t1","type":"DATE","altValue":"OFFSET P1D"}}],"tokens":[{"index":1,"word":"I","originalText":"I","lemma":"I","characterOffsetBegin":0,"characterOffsetEnd":1,"pos":"PRP","ner":"O","truecase":"UPPER","truecaseText":"I","before":"","after":" "},{"index":2,"word":"have","originalText":"have","lemma":"have","characterOffsetBegin":2,"characterOffsetEnd":6,"pos":"VBP","ner":"O","truecase":"LOWER","truecaseText":"have","before":" ","after":" "},{"index":3,"word":"to","originalText":"to","lemma":"to","characterOffsetBegin":7,"characterOffsetEnd":9,"pos":"TO","ner":"O","truecase":"LOWER","truecaseText":"to","before":" ","after":" "},{"index":4,"word":"go","originalText":"go","lemma":"go","characterOffsetBegin":10,"characterOffsetEnd":12,"pos":"VB","ner":"O","truecase":"LOWER","truecaseText":"go","before":" ","after":" "},{"index":5,"word":"USA","originalText":"USA","lemma":"USA","characterOffsetBegin":13,"characterOffsetEnd":16,"pos":"NNP","ner":"COUNTRY","truecase":"UPPER","truecaseText":"USA","before":" ","after":" "},{"index":6,"word":"from","originalText":"from","lemma":"from","characterOffsetBegin":17,"characterOffsetEnd":21,"pos":"IN","ner":"O","truecase":"LOWER","truecaseText":"from","before":" ","after":" "},{"index":7,"word":"London","originalText":"London","lemma":"London","characterOffsetBegin":22,"characterOffsetEnd":28,"pos":"NNP","ner":"CITY","truecase":"INIT_UPPER","truecaseText":"London","before":" ","after":" "},{"index":8,"word":"tomorrow","originalText":"tomorrow","lemma":"tomorrow","characterOffsetBegin":29,"characterOffsetEnd":37,"pos":"NN","ner":"DATE","normalizedNER":"OFFSET P1D","truecase":"INIT_UPPER","truecaseText":"Tomorrow","before":" ","after":"","timex":{"tid":"t1","type":"DATE","altValue":"OFFSET P1D"}}]}]}


#6

Ya , It recognize today as date and return value like “P1D”, But How can we convert the P1D value into real time date value format(mm/dd/yyyy) ?


#7

I haven’t tried this, found it while reading something else. See if it helps you:

The duckling library does a great job of turning expressions like “next Thursday at 8pm” into actual datetime objects that you can use, e.g.

"next Thursday at 8pm" => {"value":"2018-05-31T20:00:00.000+01:00"}


#8

how do we get the username , password , service url


#9

I setup my own server using below documentation: