@Huntenkill working thankyou for help
Problem: Finding keywords in a text.
-
I am using BAS to create a tool that searches for keywords within scanned news articles and alerts me when encountering the keywords I enter. However, I am facing an issue where the keyword is part of another word. For example:
Keyword to search: "ksbank" ---> Detected keyword in the article: "riksbank"
I have considered adding spaces before and after the keyword I am searching for. However, in cases where the keyword is at the beginning or end of a text, BAS won't find it because there are no spaces before or after the keyword.
Is there any way to handle this problem effectively? Thank you!
-
@ptt-bds If you haven't come up with a workaround, the simplest way is already in your question.
You have given 3 possible cases, so you can use "Contains" in those 3 cases to search for results.
The data is processed instantly, so it won't take any more of your time.
There are many ways to deal with the problem, so do whatever you can to solve your problem.I will suggest you a piece of code you can try.
article = [[DOCUMENT]] keyword = [[KEYWORD]] var regex = new RegExp("\\b" + keyword + "\\b", "gi"); if (article.match(regex)) { [[STRING_CONTAINS]] = true } else { [[STRING_CONTAINS]] = false }[[DOCUMENT]] : The variable contains the text to be checked.
[[KEYWORD]] : Keywords to check
You will get the same [[STRING_CONTAINS]] result as using Contains. -
@BAS-Viet-Nam thanks bro. Mình đã xử lý bằng cách dùng Split sentences to words sau đó dùng Contains của List để check.