japerk / nltk-trainer

Train NLTK objects with zero code
http://nltk-trainer.readthedocs.org/en/latest/
Apache License 2.0
747 stars 225 forks source link

Fix analyze_classifier_coverage when using --ngrams parameter #30

Closed aleksandrpanteleymonov closed 9 years ago

aleksandrpanteleymonov commented 9 years ago

If you use analyze_classifier_coverage.py with --ngrams parameter (e.g. --ngrams 1 2 3) it throws an exception: Traceback (most recent call last): File "analyze_classifier_coverage.py", line 152, in feat = bag_of_words(norm_words(t)) File "analyze_classifier_coverage.py", line 110, in norm_words return reduce(operator.add, [words if n == 1 else ngrams(words, n) for n in args.ngrams]) TypeError: can only concatenate list (not "generator") to list

Made the code consistent with train_classifier.py

japerk commented 9 years ago

Thanks!