fast-autocomplete icon indicating copy to clipboard operation
fast-autocomplete copied to clipboard

How to add new words for existing object?

Open gambastyle opened this issue 3 years ago • 2 comments

Hi, I really like this library, works very well.

I have 1.5 million names and each has at least 2-3 synonyms. It take 12 hours to create autocomplete object, after which I couldn't find a way to add new words and synonyms. Can you please advise?

Thanks!

gambastyle avatar Sep 29 '22 06:09 gambastyle

Hey @gambastyle Sorry I didn't get back to you earlier. I need to rewrite this library with Cython to be optimized for handling that size of input words. I have not had the time to do so. It is cool that you are pushing it to its limits!

seperman avatar Dec 09 '22 18:12 seperman

Sorry to revive this long-dead thread, but I have the same question.

My input size is no where near this big, but I still need to be able to update an existing object with new words/synonyms. In my case I've made an AutoComplete family of subclasses. Each different subclass will have a different set of words to choose from. Unfortunately it is not so simple as to set self.synonyms and self.words in the __init__ for a given subclass.

See this extremely simplified example:

from fast_autocomplete import AutoComplete

class Animal(AutoComplete):
    def __init__(self):
        super().__init__(dict())

        self.words = {"eat": {}, "sleep": {}, "drink": {}, "walk": {}}

class Dog(Animal):
    def __init__(self):
        super().__init__()

        self.words["bark"] = {}
        self.words["wag"] = {}

class Human(Animal):
    def __init__(self):
        super().__init__()

        self.words["code"] = {}
        self.words["file taxes"] = {}

Any ideas? Should I just rework what I have so the classes each have own their own instance AutoComplete with a different set of words?

bMorgan01 avatar Apr 19 '23 23:04 bMorgan01