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 use Regular Expression with FlashText #118

Open
BluePanda-io opened this issue Nov 7, 2020 · 4 comments
Open

How to use Regular Expression with FlashText #118

BluePanda-io opened this issue Nov 7, 2020 · 4 comments

Comments

@BluePanda-io
Copy link

BluePanda-io commented Nov 7, 2020

This is probably an easy question that is already been answered but unfortunately, I can't figure this out or find someone that did already.

How can I use FlashText for Regex patterns?

Something that comes to mind a possible ways but doesn't work is:

from flashtext import KeywordProcessor
keyword_processor = KeywordProcessor()
keyword_processor.add_keyword('Big')
keyword_processor.add_keyword(r'\d{5}')
keywords_found = keyword_processor.extract_keywords('I love big Appsle 23234 ands Bay Area. 12345', span_info=True)
print(keywords_found)

As a result, we will have "big" and the corresponding position and "23234, 12345" and the corresponding position

Thank you for taking the time to answer me and excited to use your great library

@thakur-nandan
Copy link
Collaborator

Hi @milts10 ,

Unfortunately flashtext cannot handle regex patterns. You should use the regex module instead.

Kind regards,
Nandan Thakur

@BluePanda-io
Copy link
Author

Thank you so much for answering,

I am sorry for being such a newbie but what is the regex module and can I find the position of the regex using this module?

Basically, the only thing that I need is to input 2 different regexes for example and get back the position of this regex in the input text

Thank you for your time!!!!!

@JJwangbilin
Copy link

Thank you so much for answering,

I am sorry for being such a newbie but what is the regex module and can I find the position of the regex using this module?

Basically, the only thing that I need is to input 2 different regexes for example and get back the position of this regex in the input text

Thank you for your time!!!!!

@milts10 hello,I have the same question,How did you solve it?

@Littlecowherd
Copy link

@JJwangbilin Are you looking for this?

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

4 participants