| Total Complexity | 3 |
| Total Lines | 11 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | """Backend that returns most similar subjects based on similarity in sparse |
||
| 12 | class VectorCorpus: |
||
|
1 ignored issue
–
show
|
|||
| 13 | """A class that wraps a text corpus so it can be iterated as lists of |
||
| 14 | vectors, by using a dictionary to map words to integers.""" |
||
| 15 | |||
| 16 | def __init__(self, corpus, dictionary): |
||
| 17 | self.corpus = corpus |
||
| 18 | self.dictionary = dictionary |
||
| 19 | |||
| 20 | def __iter__(self): |
||
| 21 | for doc in self.corpus: |
||
| 22 | yield self.dictionary.doc2bow(doc) |
||
| 23 | |||
| 44 |