Skip to content

Allow custom definitions of in-word characters#2

Open
AlbertWeichselbraun wants to merge 3 commits intoneo-search:masterfrom
fhgr:master
Open

Allow custom definitions of in-word characters#2
AlbertWeichselbraun wants to merge 3 commits intoneo-search:masterfrom
fhgr:master

Conversation

@AlbertWeichselbraun
Copy link
Copy Markdown

This pull request allows specifying custom in-word characters for words by extending isPartialMatch in Trie.java, which improves the libraries flexibility in defining word boundaries.

Example:

// create a searcher that allows numbers and hyphens in words.
StringSearcher searcher = StringSearcher.builder().addSearchString("ER-Models")
                .addSearchString("Database").addSearchString("C2")
                .setIsInWordCharacter(ch -> Character.isAlphabetic(ch) || Character.isDigit(ch) || ch == '-').build();

Both the currently used onlyWholeWordsWhiteSpaceSeparated and onlyWholeWords flags can be expressed with a corresponding inWordCharacterexpression.
=> StringSearcherConfig.java has been adapted to continue supporting both flags as well.

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

Successfully merging this pull request may close these issues.

1 participant