vi3k6i5 / flashtext

Extract Keywords from sentence or Replace keywords in sentences.
MIT License
5.59k stars 599 forks source link

Feature request: add a dictionary for KeywordProcessor #16

Closed kootenpv closed 6 years ago

kootenpv commented 6 years ago

I would like:

len(kp)
"x" in kp

Maybe kp can subclass dict!?

Maybe the "value" of the dictionary can actually be the same as you'd expect from what you add at "add_keyword".

kp = KeywordProcessor()
kp.add_keyword("x", "X")

Expected results:

>>> len(kp)
1
>>> "x" in kp
True
>>> kp["x"]
"X"
vi3k6i5 commented 6 years ago
  1. Added features to Get all keywords in the corpus:
    >>> keyword_processor.get_all_keywords()
    >>> {'j2ee': 'Java', 'python': 'Python'}
  2. Added feature to check 'x' in kp
  3. Added feature to add and remove keywords as:
    del kp['x']

    All of this is in develop branch right now. Need to add more test cases before I can merge them to the master branch and release it.

vi3k6i5 commented 6 years ago

Added in flashtext-2.4 :)