0.2.0-dev Download ZIP
75 lines ·4.2 KB Raw
| 1 | <?xml version="1.0" encoding="UTF-8" ?> |
| 2 | <class name="FuzzySearch" inherits="RefCounted" api_type="core" experimental="The available options and handling of results may change in the future." xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd"> |
| 3 | <brief_description> |
| 4 | Provides fuzzy string searching and matching capabilities. |
| 5 | </brief_description> |
| 6 | <description> |
| 7 | The fuzzy search algorithm is designed to find target strings which mostly match a query string while allowing for breaks, typos, and out of order matches. |
| 8 | [codeblocks] |
| 9 | [gdscript] |
| 10 | var items := ["Potion of Healing", "Greater Health Potion", "Poison Vial"] |
| 11 | var fuzzy := FuzzySearch.new() |
| 12 | |
| 13 | for result in fuzzy.search_all("health potion", items): |
| 14 | # Prints "Greater Health Potion", "Potion of Healing" |
| 15 | print(result.target) |
| 16 | [/gdscript] |
| 17 | [csharp] |
| 18 | string[] items = ["Potion of Healing", "Greater Health Potion", "Poison Vial"]; |
| 19 | FuzzySearch fuzzy = new(); |
| 20 | |
| 21 | foreach (var result in fuzzy.SearchAll("health potion", items)) |
| 22 | { |
| 23 | // Prints "Greater Health Potion", "Potion of Healing" |
| 24 | GD.Print(result.Target); |
| 25 | } |
| 26 | [/csharp] |
| 27 | [/codeblocks] |
| 28 | </description> |
| 29 | <tutorials> |
| 30 | </tutorials> |
| 31 | <methods> |
| 32 | <method name="search" qualifiers="const"> |
| 33 | <return type="FuzzySearchMatch" /> |
| 34 | <param index="0" name="query" type="String" /> |
| 35 | <param index="1" name="target" type="String" /> |
| 36 | <description> |
| 37 | Searches the [param target] for [param query], returning a [FuzzySearchMatch] instance on success or [code]null[/code] otherwise. |
| 38 | </description> |
| 39 | </method> |
| 40 | <method name="search_all" qualifiers="const"> |
| 41 | <return type="FuzzySearchMatch[]" /> |
| 42 | <param index="0" name="query" type="String" /> |
| 43 | <param index="1" name="targets" type="PackedStringArray" /> |
| 44 | <description> |
| 45 | Searches all of [param targets] for [param query] and returns up to the top [member max_results] scoring values. The results are sorted by score in descending order. Low quality results are removed if [member filter_low_scores] is [code]true[/code]. |
| 46 | </description> |
| 47 | </method> |
| 48 | </methods> |
| 49 | <members> |
| 50 | <member name="case_sensitive" type="bool" setter="set_case_sensitive" getter="get_case_sensitive" default="false"> |
| 51 | Whether the query character casing should be matched exactly or not. |
| 52 | </member> |
| 53 | <member name="filter_cutoff" type="float" setter="set_filter_cutoff" getter="get_filter_cutoff" default="30.0"> |
| 54 | Minimum score for filtering results returned by [method search_all]. |
| 55 | </member> |
| 56 | <member name="filter_factor" type="float" setter="set_filter_factor" getter="get_filter_factor" default="0.1"> |
| 57 | Biases the filtering cutoff score between the average score and max score. Value should be between [code]0[/code] and [code]1[/code]. |
| 58 | </member> |
| 59 | <member name="filter_low_scores" type="bool" setter="set_filter_low_scores" getter="get_filter_low_scores" default="true"> |
| 60 | If [code]true[/code], lower quality matches are not returned by [method search_all]. The default filtering behavior is tuned to keep exact matches and reject significantly broken up matches. Setting this to [code]false[/code] can potentially improve results when searching a small number of items. |
| 61 | </member> |
| 62 | <member name="max_misses" type="int" setter="set_max_misses" getter="get_max_misses" default="2"> |
| 63 | Maximum number of non-matched characters in the query before skipping a target as non-matching. This option is ignored if [member use_exact_tokens] is [code]true[/code]. |
| 64 | </member> |
| 65 | <member name="max_results" type="int" setter="set_max_results" getter="get_max_results" default="100"> |
| 66 | Maximum number of results which can be returned by [method search_all]. |
| 67 | </member> |
| 68 | <member name="start_offset" type="int" setter="set_start_offset" getter="get_start_offset" default="0"> |
| 69 | Number of leading characters to omit from matching. For example, this can be used to skip a common prefix such as [code]res://[/code]. |
| 70 | </member> |
| 71 | <member name="use_exact_tokens" type="bool" setter="set_use_exact_tokens" getter="get_use_exact_tokens" default="false"> |
| 72 | If [code]true[/code], only targets which contain each token as a non-overlapping substring are returned. Gaps and missed characters are not considered valid matches, but [member case_sensitive] is still used. |
| 73 | </member> |
| 74 | </members> |
| 75 | </class> |