Sentence Structure Identification - Spacy
I intend to identify the sentence structure in English using spacy and textacy. For example: The cat sat on the mat - SVO , The cat jumped and picked up the biscuit - SVV0. The cat
Solution 1:
Issue 1: The SVO are overwritten. Why?
This is textacy
issue. This part is not working very well, see this blog
Issue 2: How to identify the sentence as SVOO SVO SVVO etc.?
You should parse the dependency tree. SpaCy
provides the information, you just need to write a set of rules to extract it out, using .head
, .left
, .right
and .children
attributes.
>>for word in text:
print('%10s %5s %10s %10s %s'%(word.text, word.tag_, word.dep_, word.pos_, word.head.text_))
The DT det DET cat
cat NN nsubj NOUN sat
sat VBD ROOT VERB sat
on IN prep ADP sat
the DT det DET mat
mat NN pobj NOUN on
. . punct PUNCT sat
of IN ROOT ADP of
the DT det DET lab
art NN compound NOUN lab
lab NN pobj NOUN of
. . punct PUNCT of
The DT det DET cat
cat NN nsubj NOUN jumped
jumped VBD ROOT VERB jumped
and CC cc CCONJ jumped
picked VBD conj VERB jumped
up RP prt PART picked
the DT det DET biscuit
biscuit NN dobj NOUN picked
. . punct PUNCT jumped
The DT det DET cat
cat NN nsubj NOUN ate
ate VBD ROOT VERB ate
biscuit NN dobj NOUN ate
and CC cc CCONJ biscuit
cookies NNS conj NOUN biscuit
. . punct PUNCT ate
I recommend you look at this code, just add pobj
to the list of OBJECTS
, and you will get your SVO and SVOO covered. With a little fiddling you can get SVVO also.
Post a Comment for "Sentence Structure Identification - Spacy"