stephbuon / posextract

Grammatical information extraction methods designed for the analysis of historical and contemporary textual corpora.
MIT License
3 stars 0 forks source link

TypeError: Argument 'other' has incorrect type (expected spacy.tokens.token.Token, got ADVCLVerbPhrase) #150

Closed stephbuon closed 1 year ago

stephbuon commented 1 year ago

Code:

from posextract import grammatical_triples

sent = 'The effect of such an Amendment would be that if there were schools where there was no voluntary contributions at all, those schools ought not to be taken into account in any way whatever, because they had done nothing to help themselves.'

triples = grammatical_triples.extract(sent)

for triple in triples:
    print(triple)

Error:

TypeError Traceback (most recent call last) Cell In [43], line 4 1 from posextract import grammatical_triples ----> 4 triples = grammatical_triples.extract(sent) 6 for triple in triples: 7 print(triple)

File ~\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\posextract\grammatical_triples.py:226, in extract(input_object, combine_adj, lemmatize, add_aux, verbose, want_dataframe, prep_phrase, compound_subject, compound_object) 224 for i, doc in enumerate(input_object): 225 doc = nlp(doc) --> 226 extractions = graph_tokens(doc, verbose=verbose) 227 output_extractions.extend(extractions) 229 # Look for additional triples due to conj dependency

File ~\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\posextract\grammatical_triples.py:129, in graph_tokens(doc, verbose) 126 if verbose: 127 print('Matched verb phrase %s: %s' % (match_type, repr(verb_phrase))) --> 129 triple_extractions.extend(visit_verb(verb_phrase, [], [], verbose=verbose)) 131 for triple in triple_extractions: 132 h = triple.get_triple_hash()

File ~\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\posextract\grammatical_triples.py:73, in visit_verb(verb, parent_subjects, parent_objects, verbose) 70 if verbose: print('\tconsidering triple:', subject, verb, poa if poa else '', obj) 72 for rule in rule_funcs: ... (...) 86 # if curr_verb.pos != VERB: 87 # return False

TypeError: Argument 'other' has incorrect type (expected spacy.tokens.token.Token, got ADVCLVerbPhrase)

stephbuon commented 1 year ago

Another sentence that returns the same error:

In a painful road of memories, desolation and reconciliation, both brothers rediscover their mutual love for each other, as Manny tries to inspire Dan to stay clean and earn a living decently.

stephbuon commented 1 year ago

Another sentence:

It charted within the top 40 in several countries, but had mediocre success overall and was less popular than the previous singles from Love.

stephbuon commented 1 year ago

Bug is fixed.