Extracting Function Tags from Parsed Sentence (usi

2019-07-20 10:37发布

问题:

Looking at the Penn Treebank tagset (http://web.mit.edu/6.863/www/PennTreebankTags.html#RB) there is a section called "Function Tags" that would be extremely helpful for a project I am working on. I know the Stanford Parser uses the Penn Treebank tagset for its EnglishPCFG grammar so I am hoping there is support for Function Tags.

Using the Stanford Parser and NLTK I have parsed sentences with Clause, Phrase and Word level tags as well as Universal Dependencies, but I have not found a way to get Function Tags from a parsed sentence.

parser=StanfordParser(model_path="edu/stanford/nlp/models/lexparser/englishPCFG.ser.gz")
parsed = parser.raw_parse("Jack payed up to 5% more for each unit")
for line in parsed:
    print line

Prints out:

(ROOT
  (S
    (NP (NNP Jack))
    (VP
      (VBD payed)
      (PRT (RP up))
      (PP (TO to) (NP (QP (CD 5) (NN %) (JJR more))))
      (PP (IN for) (NP (DT each) (NN unit))))))

For this example I would like there to be a -EXT (extent) functional tag with the preposition "up to 5% more", though I am unsure of what the actual output would look like.

Is it possible to view the function tags of a parsed sentence using the Stanford Parser and NLTK? If so, how do I accomplish this?