Suggester class

Suggests text completions.

Uses a modified version of term frequency - inverse document frequency weighting to allow ordering not just by relevance but by term order similarity to search sentence.

Makes the assumption that terms closer to start (more proximal) of both search and suggestion strings are more important than later (more distal) terms.

tf is replaced by a value "term proximality" (tp) that is inversely proprtional to the distance of the term from the start of suggestion string. Eg:

Let f : ℕ>0K is a pairwise distinct sequence of terms as returned by TermMapping such that f(x) = term at index x.

Then tp is given by g : K → ℕ | g(x) = 1/f-1(x)

Constructors

Suggester(TermMapping termMapping, {bool caseSensitive = false, bool unicode = true, double termIdfWeighting = 1, double termProximalityWeighting = 1, double sharedSequenceLengthWeighting = 1})
Construct a new Suggester
Suggester.fromJson(TermMapping termMapping, dynamic json, {bool unicode = true, double termIdfWeighting = 1, double termProximalityWeighting = 1, double sharedSequenceLengthWeighting = 1})
Construct a new Suggester from json.

Properties

caseSensitive bool
Specify case sensitivity of termMapping.
final
entries UnmodifiableMapView<String, Entry>
Unmodifiable view of current entries
final
hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
sharedSequenceLengthWeighting double
Shared sequence length contribution to term weighting
final
termIdfWeighting double
Term idf contribution to term weighting
final
termMapping TermMapping
The TermMapping used to convert an entry to a list of terms.
final
termProximalityWeighting double
Term proximality contribution to term weighting.
final
unicode bool
True if termMapping uses unicode RegExp. Javascript has trouble with Unicode RegExp so set to false if running in browser.
final

Methods

add(String entryValue, {int? subScore}) bool
Add entryValue to the set of possible suggestions.
addAll(Iterable<String> entries) → void
Equivilent to add for all entries.
createSuggestion(String entryValue) Suggestion
Create suggestion directly from entryValue.
entriesBySubScore() Iterable<Entry>
Return an iterable over all entries ordered by:
mapTerms(String entry, {bool fallBackToSearchString = false}) Iterable<String>
Use suggester TermMapping to map entry to a pairwise distinct sequence of terms. If fallBackToSearchString is true then entry is returned as single token if termMapping generates no tokens
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
setAllEntrySubScores(int subScore) → void
Set subScore to subScore for all entries
sizeOf() int
Return approximate size of Suggester instance in memory
suggest(String searchString, {int maxEditDistance = 0}) Iterable<Suggestion>
Return Iterable of Suggestion based upon searchString.
suggestFromTerms(Iterable<String> searchTerms, {int maxEditDistance = 0}) Iterable<Suggestion>
Return Iterable of Suggestion based upon searchTerms aquired from a TermMapping.
toJson() Map<String, dynamic>
Return json encodable object representing this Suggester
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited