seperman / fast-autocomplete

Fast Autocomplete: When Elastcsearch suggestions are not fast and flexible enough
MIT License
271 stars 40 forks source link

How to add new words for existing object? #39

Open gambastyle opened 2 years ago

gambastyle commented 2 years ago

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!

seperman commented 1 year ago

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!

bMorgan01 commented 1 year ago

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?