diff options
author | AhmedHamed <ahmedhamed3699@gmail.com> | 2024-07-05 21:41:26 +0300 |
---|---|---|
committer | Andreas Heinisch <andreas.heinisch@yahoo.de> | 2024-09-03 09:59:16 +0200 |
commit | d05e0be5f4ab2bdb31d6cf14528a9a8ee5ac965c (patch) | |
tree | 1dc8194db01b3376bc7adddfe0d56abefaf926f3 /include | |
parent | 5b0256f30ee154edb28b999bc4faba2453fc32b8 (diff) |
tdf#161543 Enhance the searching functionality in FD & FW
Change-Id: I1a21595228f886c942ae46d90e41705443d31550
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/170073
Reviewed-by: Heiko Tietze <heiko.tietze@documentfoundation.org>
Reviewed-by: Andreas Heinisch <andreas.heinisch@yahoo.de>
Tested-by: Jenkins
Diffstat (limited to 'include')
-rw-r--r-- | include/unotools/textsearch.hxx | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/include/unotools/textsearch.hxx b/include/unotools/textsearch.hxx index 753534166098..3b06c93549d5 100644 --- a/include/unotools/textsearch.hxx +++ b/include/unotools/textsearch.hxx @@ -27,6 +27,9 @@ #include <ostream> +#define WLD_THRESHOLD 3 +#define SMALL_STRING_THRESHOLD 4 + class CharClass; namespace com::sun::star::lang { struct Locale; } @@ -209,6 +212,30 @@ public: /* replace back references in the replace string by the sub expressions from the search result */ static void ReplaceBackReferences( OUString& rReplaceStr, std::u16string_view rStr, const css::util::SearchResult& rResult ); + + /** + * @brief Search for a string in a another one based on similarity + * @param rString The string we compare with + * @param rSearchString The search term + * @param rSimilarityScore The similarity score (sent by reference to be filled) + * @return True if the search term is found, false otherwise + */ + static bool SimilaritySearch(const OUString& rString, const OUString& rSearchString, + ::std::pair<sal_Int32, sal_Int32>& rSimilarityScore); + /** + * @brief Get similarity score between two strings + * according to the length of the common substring and its position + * @param rString The string we compare with + * @param rSearchString The search term + * @param nInitialScore The initial score + * @param bFromStart True if the search is from the start + * @return Score if the search term is found in the text, -1 otherwise + */ + static sal_Int32 GetSubstringSimilarity(std::u16string_view rString, + std::u16string_view rSearchString, + sal_Int32& nInitialScore, const bool bFromStart); + static sal_Int32 GetWeightedLevenshteinDistance(const OUString& rString, + const OUString& rSearchString); }; } // namespace utl |