Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to add new words for existing object? #39

Open
gambastyle opened this issue Sep 29, 2022 · 2 comments
Open

How to add new words for existing object? #39

gambastyle opened this issue Sep 29, 2022 · 2 comments

Comments

@gambastyle
Copy link

gambastyle commented Sep 29, 2022

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 gambastyle changed the title How to add new words for exisint object? How to add new words for existing object? Sep 29, 2022
@seperman
Copy link
Owner

seperman commented Dec 9, 2022

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
Copy link

bMorgan01 commented Apr 19, 2023

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants