clips / clips/pattern

Documents not sortable in py3

Open
#273 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
8.9k
Forks
1.6k
PR merge metrics
No merged PRs in 30d

Description

We're having an issue with pattern==3.6 where if there are duplicates, etc in the model documents, getting the nsmallest fails for vector_space_search:

from pattern.en import lexeme
from pattern.vector import Document, LEMMA, TFIDF, Model
responses = ['it is works great.  ', 'bristles are soft and compact enough', 'the aftertaste isnt as bad as others. ', 'i dont know. it isnt something i think about.', 'bristles are soft and compact enough']
exclude = ['t', 'im']
docs = [Document(response, stemmer=LEMMA, name=str(i), exclude=exclude, stopwords=False) for i, response in enumerate(responses)]
m = Model(documents=docs, weight=TFIDF)
results = m.search(words=lexeme('bristle'), top=100)

Results in:

image

(if you're wondering, here's why it works in py2 - from https://docs.python.org/2/library/stdtypes.html#comparisons)
image

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the failure with the provided Python example, then trace Model.search into vector_space_search and the nsmallest call for duplicate Documents. Done means the search completes under Python 3.6 and returns the expected sorted results when duplicate documents are present.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
machine-learning
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.