erre-quadro/spikex

labelX pipeline errors out

hp0404 opened this issue · 0 comments

  • spikex version: 0.5.2
  • Python version: 3.7.11
  • Operating System: google.cloud

Description

Describe what you were trying to get done.

  • I was trying to test the labelX pipeline

Tell us what happened, what went wrong, and what you expected to happen.

  • Copied the example from README

What I Did

from spacy import load as spacy_load
from spikex.pipes import LabelX

nlp = spacy_load("en_core_web_sm")
doc = nlp("looking for a computer system engineer")
patterns = [
  [{"LOWER": "computer"}, {"LOWER": "system"}],
  [{"LOWER": "system"}, {"LOWER": "engineer"}],
]
labelx = LabelX(vocab=nlp.vocab, labelings=("TEST", patterns), validate=True, only_longest=True)
doc = labelx(doc)
for labeling in doc._.labelings:
  print(labeling, f"[{labeling.label_}]")
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-4-da0684755206> in <module>()
      9   [{"LOWER": "system"}, {"LOWER": "engineer"}],
     10 ]
---> 11 labelx = LabelX(vocab=nlp.vocab, labelings=("TEST", patterns), validate=True, only_longest=True)
     12 doc = labelx(doc)
     13 for labeling in doc._.labelings:

/usr/local/lib/python3.7/dist-packages/spikex/pipes/labels.py in __init__(self, vocab, labelings, validate, only_longest)
     32         if not labelings or labelings is None:
     33             return
---> 34         for label, patterns in labelings:
     35             self.add(label, patterns)
     36 

ValueError: too many values to unpack (expected 2)