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

Error : Could not find an optimal move to supervise the parser. Usually, this means the GoldParse was not correct. For example, are all labels added to the model? #13

Open
Kitwradr opened this issue Jun 28, 2019 · 11 comments

Comments

@Kitwradr
Copy link

No description provided.

@Kitwradr
Copy link
Author

No changes were made to the code except filepaths , how to remove this error ?

@Kitwradr
Copy link
Author

Kitwradr commented Jun 28, 2019

Use this function and it'll get resolved , the problem was in upgraded version of spaCy

def trim_entity_spans(data: list) -> list:
    """Removes leading and trailing white spaces from entity spans.

    Args:
        data (list): The data to be cleaned in spaCy JSON format.

    Returns:
        list: The cleaned data.
    """
    invalid_span_tokens = re.compile(r'\s')

    cleaned_data = []
    for text, annotations in data:
        entities = annotations['entities']
        valid_entities = []
        for start, end, label in entities:
            valid_start = start
            valid_end = end
            while valid_start < len(text) and invalid_span_tokens.match(
                    text[valid_start]):
                valid_start += 1
            while valid_end > 1 and invalid_span_tokens.match(
                    text[valid_end - 1]):
                valid_end -= 1
            valid_entities.append([valid_start, valid_end, label])
        cleaned_data.append([text, {'entities': valid_entities}])

    return cleaned_data

@Satys
Copy link

Satys commented Jul 2, 2019

Could you fix this?

@Kitwradr
Copy link
Author

Kitwradr commented Jul 2, 2019

Yes use the above function @Satys

@Satys
Copy link

Satys commented Jul 2, 2019

@Kitwradr , thanks for the quick reply. Let me check!

@Ejigsonpeter
Copy link

Please can you update the code,
i have added the function to the code but its still not working

@Kitwradr
Copy link
Author

Kitwradr commented Aug 31, 2019

Did you use the function to clean the data ?

@nischaypandey
Copy link

What this re.compile for here? can u plz explain @Kitwradr

@Kitwradr
Copy link
Author

re.compile is a method of python's re library , it basically is used for creating a regular expression object , in this case for removing spaces

@nischaypandey
Copy link

@Kitwradr Thanks a lot got it:)

@avinash-969
Copy link

@Kitwradr can you update the code. I have added the function to the code but its still not working

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants