Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve CoreNLP Regression #3043

Merged
merged 1 commit into from
Sep 1, 2022
Merged

Conversation

tomaarsen
Copy link
Member

Hello!

Pull request overview

How to reproduce

from nltk.parse.corenlp import CoreNLPServer, CoreNLPParser

with CoreNLPServer() as server:
    sentence = "This is my sentence, which I'd like to get parsed."
    parser = CoreNLPParser(server.url)
    next(parser.parse_text(sentence)).pretty_print()

Before this PR

Traceback (most recent call last):
  File "c:\GitHub\nltk\nltk_0002.py", line 6, in <module>
    next(parser.parse_text(sentence)).pretty_print()
  File "c:\GitHub\nltk\nltk\parse\corenlp.py", line 298, in parse_text
    parsed_data = self.api_call(text, *args, **kwargs)
  File "c:\GitHub\nltk\nltk\parse\corenlp.py", line 252, in api_call
    return response.json(strict=self.strict_json)
AttributeError: 'CoreNLPParser' object has no attribute 'strict_json'

After this PR

                                     ROOT                                     
                                      |
                                      S                                       
  ____________________________________|____________________________________   
 |        VP                                                               |  
 |     ___|_________________                                               |  
 |    |                     NP                                             |  
 |    |         ____________|_________                                     |  
 |    |        |            |        SBAR                                  |  
 |    |        |            |     ____|________                            |  
 |    |        |            |    |             S                           |  
 |    |        |            |    |     ________|____                       |  
 |    |        |            |    |    |             VP                     |  
 |    |        |            |    |    |     ________|___                   |
 |    |        |            |    |    |    |            VP                 |
 |    |        |            |    |    |    |    ________|___               |
 |    |        |            |    |    |    |   |            S              |
 |    |        |            |    |    |    |   |            |              |
 |    |        |            |    |    |    |   |            VP             |
 |    |        |            |    |    |    |   |     _______|___           |
 |    |        |            |    |    |    |   |    |           VP         |
 |    |        |            |    |    |    |   |    |        ___|____      |
 NP   |        NP           |   WHNP  NP   |   |    |       |        VP    |
 |    |    ____|_____       |    |    |    |   |    |       |        |     |
 DT  VBZ PRP$        NN     ,   WDT  PRP  VBD  VB   TO      VB      VBN    .
 |    |   |          |      |    |    |    |   |    |       |        |     |
This  is  my      sentence  ,  which  I    'd like  to     get     parsed  .

I've simply moved strict_json fully to GenericCoreNLPParser.

  • Tom Aarsen

@stevenbird stevenbird merged commit 019737c into nltk:develop Sep 1, 2022
@tomaarsen tomaarsen deleted the regression/corenlp branch September 1, 2022 14:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants