Closed easonnie closed 6 years ago
Here's a way to do it.
keyword_processor.add_keyword('java_2e', ['java', 'product management', 'big word'])
EDIT: This is in the docs.
Thanks a lot!
Here's a way to do it.
keyword_processor.add_keyword('java_2e', ['java', 'product management', 'big word'])
EDIT: This is in the docs.
Hi @rmNULL. Could you please share the link to the docs where I can find this example? I've looked here and here but can't find a add_keyword
with a str, List[str]
signature.
Thanks.
Hi @leobeeson the comment is outdated. I haven't used this software since long, the current way to do this looks like this on the documentation
from flashtext import KeywordProcessor
keyword_processor = KeywordProcessor()
keyword_dict = {
"java": ["java_2e", "java programing"],
"product management": ["PM", "product manager"]
}
# {'clean_name': ['list of unclean names']}
keyword_processor.add_keywords_from_dict(keyword_dict)
# Or add keywords from a list:
keyword_processor.add_keywords_from_list(["java", "python"])
keyword_processor.extract_keywords('I am a product manager for a java_2e platform')
# output ['product management', 'java']
Thanks @rmNULL, though your answer still works, particularly for the use case in the original question of triggering multiple entries by a same keyword (i.e. one-to-many instance-to-entity mapping).
I tried your sample code and still runs in flashtext 2.7, but I couldn't find the add_keyword
with a str, List[str]
signature (which allows for one-to-many instance-to-entity mapping) in the current documentation.
If we try to do this using the example in the current documentation, flashtext only returns one of the entries ("clean_name") with the desired keyword "unclean name").
Once again, thanks!
I was trying to use a key word dict like this:
I thought the keyword
"jave_2e"
would trigger both"java"
and"product management"
.However, the output for the following code is:
Output:
Expected output:
It seems to be confused. I was wondering what is the correct way to trigger multiple entries by the same keyword.