flashtext icon indicating copy to clipboard operation
flashtext copied to clipboard

add_keywords_from_list when every element in a list has extra information

Open suchee opened this issue 6 years ago • 3 comments

is there a way to add keywords with extra information from a list efficiently? I am currently looping and adding each of the keyword with the "add_keyword", but loading the data seems to be taking a non trivial amount of time.

suchee avatar Jan 23 '18 06:01 suchee

Can you give a small sample example, how the data will be like?

PS: there are many methods to load including from dictionary, file, list.. I am assuming you have gone through them and they are not satisfying your use case.

vi3k6i5 avatar Jan 23 '18 06:01 vi3k6i5

for instance, in your documentation I can add a key word with extra information with :

kp.add_keyword('Delhi', ('Location', 'Delhi'))

while for a list : keyword_processor.add_keywords_from_list(["Delhi", "Bombay"])

What I want is: a way where I can use add_keywords_from_list but where each element also has the category information. I hope it is clear? Currently what I do is run through my list and do something like kp.add_keyword('Delhi', ('Location', 'Delhi')) individually. I just wonder if it can be done more efficiently?

Perhaps: keyword_processor.add_keywords_from_list([('Delhi', ('Location', 'Delhi')), ('Bombay', ('Location', 'Bombay'))])

suchee avatar Jan 23 '18 07:01 suchee

Got it.

So even if you pass the whole thing in a bulk, like a dictionary or a list of lists, it will still be iterated internally. So it will take the same amount of time.

How many terms do you have ?

I am just curious how much time is going in initialisation?

vi3k6i5 avatar Jan 23 '18 09:01 vi3k6i5