class documentation
class CoreNLPParser(GenericCoreNLPParser): (source)
Constructor: CoreNLPParser(url, encoding, tagtype)
>>> parser = CoreNLPParser(url='http://localhost:9000')
>>> next( ... parser.raw_parse('The quick brown fox jumps over the lazy dog.') ... ).pretty_print() # doctest: +NORMALIZE_WHITESPACE ROOT | S _______________|__________________________ | VP | | _________|___ | | | PP | | | ________|___ | NP | | NP | ____|__________ | | _______|____ | DT JJ JJ NN VBZ IN DT JJ NN . | | | | | | | | | | The quick brown fox jumps over the lazy dog .
>>> (parse_fox, ), (parse_wolf, ) = parser.raw_parse_sents( ... [ ... 'The quick brown fox jumps over the lazy dog.', ... 'The quick grey wolf jumps over the lazy fox.', ... ] ... )
>>> parse_fox.pretty_print() # doctest: +NORMALIZE_WHITESPACE ROOT | S _______________|__________________________ | VP | | _________|___ | | | PP | | | ________|___ | NP | | NP | ____|__________ | | _______|____ | DT JJ JJ NN VBZ IN DT JJ NN . | | | | | | | | | | The quick brown fox jumps over the lazy dog .
>>> parse_wolf.pretty_print() # doctest: +NORMALIZE_WHITESPACE ROOT | S _______________|__________________________ | VP | | _________|___ | | | PP | | | ________|___ | NP | | NP | ____|_________ | | _______|____ | DT JJ JJ NN VBZ IN DT JJ NN . | | | | | | | | | | The quick grey wolf jumps over the lazy fox .
>>> (parse_dog, ), (parse_friends, ) = parser.parse_sents( ... [ ... "I 'm a dog".split(), ... "This is my friends ' cat ( the tabby )".split(), ... ] ... )
>>> parse_dog.pretty_print() # doctest: +NORMALIZE_WHITESPACE ROOT | S _______|____ | VP | ________|___ NP | NP | | ___|___ PRP VBP DT NN | | | | I 'm a dog
>>> parse_friends.pretty_print() # doctest: +NORMALIZE_WHITESPACE ROOT | S ____|___________ | VP | ___________|_____________ | | NP | | _______|_________ | | NP PRN | | _____|_______ ____|______________ NP | NP | | NP | | | ______|_________ | | ___|____ | DT VBZ PRP$ NNS POS NN -LRB- DT NN -RRB- | | | | | | | | | | This is my friends ' cat -LRB- the tabby -RRB-
>>> parse_john, parse_mary, = parser.parse_text( ... 'John loves Mary. Mary walks.' ... )
>>> parse_john.pretty_print() # doctest: +NORMALIZE_WHITESPACE ROOT | S _____|_____________ | VP | | ____|___ | NP | NP | | | | | NNP VBZ NNP . | | | | John loves Mary .
>>> parse_mary.pretty_print() # doctest: +NORMALIZE_WHITESPACE ROOT | S _____|____ NP VP | | | | NNP VBZ . | | | Mary walks .
Special cases
>>> next( ... parser.raw_parse( ... 'NASIRIYA, Iraq—Iraqi doctors who treated former prisoner of war ' ... 'Jessica Lynch have angrily dismissed claims made in her biography ' ... 'that she was raped by her Iraqi captors.' ... ) ... ).height() 20
>>> next( ... parser.raw_parse( ... "The broader Standard & Poor's 500 Index <.SPX> was 0.46 points lower, or " ... '0.05 percent, at 997.02.' ... ) ... ).height() 9
Method | make |
Undocumented |
Class Variable | parser |
Undocumented |
Constant | _OUTPUT |
Undocumented |
Inherited from GenericCoreNLPParser
:
Method | __init__ |
Undocumented |
Method | api |
Undocumented |
Method | parse |
Parse multiple sentences. |
Method | parse |
Parse a piece of text. |
Method | raw |
Parse a sentence. |
Method | raw |
Parse multiple sentences. |
Method | raw |
Tag multiple sentences. |
Method | tag |
Tag a list of tokens. |
Method | tag |
Tag multiple sentences. |
Method | tokenize |
Tokenize a string of text. |
Instance Variable | encoding |
Undocumented |
Instance Variable | session |
Undocumented |
Instance Variable | tagtype |
Undocumented |
Instance Variable | url |
Undocumented |
Inherited from ParserI
(via GenericCoreNLPParser
):
Method | grammar |
No summary |
Method | parse |
When possible this list is sorted from most likely to least likely. |
Method | parse |
No summary |
Method | parse |
No summary |
Inherited from TokenizerI
(via GenericCoreNLPParser
, ParserI
):
Method | span |
Identify the tokens using integer offsets (start_i, end_i), where s[start_i:end_i] is the corresponding token. |
Method | span |
Apply self.span_tokenize() to each element of strings. I.e.: |
Method | tokenize |
Apply self.tokenize() to each element of strings. I.e.: |
Inherited from TaggerI
(via GenericCoreNLPParser
, ParserI
, TokenizerI
):
Method | evaluate |
Score the accuracy of the tagger against the gold standard. Strip the tags from the gold standard text, retag it using the tagger, then compute the accuracy score. |
Method | _check |
Undocumented |