Open xesaad opened 2 years ago
Update: I believe that this issue is due to the following: if the BasicReferenceRecognizer
does not detect an aspect, the professor
component sets scores = [0,0,0]
, which is a list of integers. When scores
is then normalised by dividing by its norm, the error is raised because you are dividing an int
when you really want to divide a float
(of course, there may also be a ZeroDivisionError
lurking here!)
Suggestion:
scores = [0.0, 0.0, 0.0]
.scores = np.max([e.scores for e in examples], axis=0).astype(float)
.I tried to open a PR to fix these suggestions myself, but unfortunately I don't have permission to push to this repository. I hope that these suggestions help with resolving this issue!
Thank you for the suggestion! Fixed my problem @xesaad
Hi there! I am a new and frequent user of this great package, which also comes with a few inevitable GitHub issues 😅
When I initialize the pipeline as follows:
I receive the following error:
I realise this is because the
BasicReferenceRecognizer
needs to be trained in order to select weights. This leads me to two questions/issues:BasicReferenceRecognizer
class has notrain
method. Is there another way in which to train it, or any ways to load a pretrained model from the package? From the unit tests for theBasicReferenceRecognizer
I found there were two pre-trained models,'absa/basic_reference_recognizer-rest-0.1'
and'absa/basic_reference_recognizer-lapt-0.1'
, but on trying to initialize with these I received anImportError
.BasicReferenceRecognizer
withweights=(-0.025, 44)
as is done in this line. However, upon making predictions I get an error in thePipeline
at thepostprocess
step:/tmp/ipykernel_514/1002360698.py in predict(text, aspect) 16 output_batch = nlp.predict(input_batch) 17 predictions = nlp.review(tokenized_examples, output_batch) ---> 18 completed_task = nlp.postprocess(task, predictions) 19 completed_subtask = completed_task.subtasks[aspect] 20 return completed_subtask
/pyenv/versions/3.8.5/envs/seo-advice-page/lib/python3.8/site-packages/aspect_based_sentiment_analysis/pipelines.py in postprocess(task, batch_examples) 301 aspect, = {e.aspect for e in examples} 302 scores = np.max([e.scores for e in examples], axis=0) --> 303 scores /= np.linalg.norm(scores, ord=1) 304 sentiment_id = np.argmax(scores).astype(int) 305 aspect_document = CompletedSubTask(
TypeError: ufunc 'true_divide' output (typecode 'd') could not be coerced to provided output parameter (typecode 'l') according to the casting rule ''same_kind''