def _suggest(self, text, project, params): self.debug('Suggesting subjects for text "{}..." (len={})'.format( text[:20], len(text))) vectors = project.vectorizer.transform([text]) docsim = self._index[vectors[0]] fullresult = VectorSuggestionResult(docsim, project.subjects) return fullresult.filter(limit=int(self.params['limit']))
def _suggest(self, text, params): self.debug('Suggesting subjects for text "{}..." (len={})'.format( text[:20], len(text))) tokens = self.project.analyzer.tokenize_words(text) vectors = self.vectorizer.transform([" ".join(tokens)]) docsim = self._index[vectors[0]] fullresult = VectorSuggestionResult(docsim, self.project.subjects) return fullresult.filter(limit=int(params['limit']))
def _prediction_to_result(self, prediction, params): vector = np.zeros(len(self.project.subjects), dtype=np.float32) for score, subject_id in prediction: vector[subject_id] = score result = VectorSuggestionResult(vector) return result.filter(self.project.subjects, limit=int(params['limit']))