Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] bagofwords: Use vectorized 'BINARY' local weighting #342

Merged
merged 1 commit into from
May 4, 2018

Conversation

ales-erjavec
Copy link
Contributor

Issue

Using gensim==3.4.0

======================================================================
ERROR: test_binary (orangecontrib.text.tests.test_bowvectorizer.BowVectorizationTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/travis/build/biolab/orange3-text/orangecontrib/text/tests/test_bowvectorizer.py", line 22, in test_binary
    result = vect.transform(corpus)
  File "/home/travis/build/biolab/orange3-text/orangecontrib/text/vectorization/base.py", line 17, in transform
    return self._transform(corpus, source_dict)
  File "/home/travis/build/biolab/orange3-text/orangecontrib/text/vectorization/bagofwords.py", line 78, in _transform
    X = matutils.corpus2csc(model[temp_corpus], dtype=np.float, num_terms=len(dic)).T
  File "/home/travis/virtualenv/python3.4.6/lib/python3.4/site-packages/gensim/matutils.py", line 151, in corpus2csc
    for docno, doc in enumerate(corpus):
  File "/home/travis/virtualenv/python3.4.6/lib/python3.4/site-packages/gensim/interfaces.py", line 193, in __iter__
    yield self.obj[doc]
  File "/home/travis/virtualenv/python3.4.6/lib/python3.4/site-packages/gensim/models/tfidfmodel.py", line 376, in __getitem__
    tf_array = self.wlocal(np.array(tf_array))
  File "/home/travis/build/biolab/orange3-text/orangecontrib/text/vectorization/bagofwords.py", line 49, in <lambda>
    (BINARY, lambda tf: int(tf > 0)),
TypeError: only size-1 arrays can be converted to Python scalars
----------------------------------------------------------------------
Description of changes

Use vectorized 'BINARY' local weighting

Includes
  • Code changes
  • Tests
  • Documentation

Fix a TypeError when using gensim >= 3.4
@codecov-io
Copy link

codecov-io commented May 3, 2018

Codecov Report

Merging #342 into master will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##           master     #342   +/-   ##
=======================================
  Coverage   84.92%   84.92%           
=======================================
  Files          33       33           
  Lines        1864     1864           
  Branches      336      336           
=======================================
  Hits         1583     1583           
  Misses        242      242           
  Partials       39       39

@ajdapretnar ajdapretnar merged commit ec1745a into biolab:master May 4, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants