kneser-ney icon indicating copy to clipboard operation
kneser-ney copied to clipboard

TypeError: ngrams() got an unexpected keyword argument 'pad_symbol'

Open kindraywind opened this issue 9 years ago • 1 comments

Environment: Python 3.5.2 nltk 3.2.1

reproduce step: python3 example.py

error message:

Traceback (most recent call last):
  File "example.py", line 8, in <module>
    lm = KneserNeyLM(3, gut_ngrams, end_pad_symbol='<s>')
  File "/Users/username/kneser-ney/kneser_ney.py", line 24, in __init__
    self.lm = self.train(ngrams)
  File "/Users/username/kneser-ney/kneser_ney.py", line 33, in train
    kgram_counts = self._calc_adj_counts(Counter(ngrams))
  File "/usr/local/Cellar/python3/3.5.2_3/Frameworks/Python.framework/Versions/3.5/lib/python3.5/collections/__init__.py", line 530, in __init__
    self.update(*args, **kwds)
  File "/usr/local/Cellar/python3/3.5.2_3/Frameworks/Python.framework/Versions/3.5/lib/python3.5/collections/__init__.py", line 617, in update
    _count_elements(self, iterable)
  File "example.py", line 7, in <genexpr>
    pad_left=True, pad_right=True, pad_symbol='<s>'))
TypeError: ngrams() got an unexpected keyword argument 'pad_symbol'

kindraywind avatar Oct 14 '16 06:10 kindraywind

Change it to (right_pad_symbol='</s>', left_pad_symbol='<s>')

zotroneneis avatar Oct 30 '17 14:10 zotroneneis