Skip to content

computeidf func issue #3

@codehaza

Description

@codehaza

when i run the code the result was 0 for all words

first issue is idfDict = dict.fromkeys(docList[0].keys(), 0)
i changed it to idfDict = dict.fromkeys(list(wordDict.keys())[0], 0)
OR idfDict = dict.fromkeys(wordDict.keys()), 0)

_second the problem comes from the computeidf func

AttributeError Traceback (most recent call last)
in
4 idfDict = dict.fromkeys(list(wordDict.keys())[0], 0)
5 for doc in wordDict:
----> 6 for word, val in doc.items():
7 if val > 0:
8 idfDict[word] += 1

AttributeError: 'str' object has no attribute 'items'_

str here means the doc

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions