Home > Class Reference > %SYS namespace > %iKnow.Stemming.DefaultStemmer


class %iKnow.Stemming.DefaultStemmer extends %iKnow.Stemmer

This class encapsulates logic to instantiate, use and amend stemmers for different languages. Plugin selection behavior per language is as follows: if a valid Hunspell affix and dictionary file is found in the /dev/hunspell subdirectory of your installation location (either named [language code]_*.aff or in a subdirectory named after the language code), a HunspellStemmer object will be instantiated to treat stemming requests for that language. If no such library is found, the corresponding TextStemmer will be instantiated.

If the StemWord() method is invoked for a particular language, this class will first look up the supplied string in the list of exceptions. If no exceptions are found (either default exceptions supplied with iKnow or custom exceptions in the Rule table for this namespace), the StemWord method of the instantiated Stemmer plugin object will be invoked. If the plugin supports returning multiple results, these will be filtered and only the first result satisfying the corresponding rules (stored in the iKnow language model or the Rule) will be returned.

Property Inventory (Including Private)

Method Inventory (Including Private)

Properties (Including Private)

property DefaultLanguage as %String [ InitialExpression = "en" ];
Default language to use when not specified in calls to Stem()
Property methods: DefaultLanguageDisplayToLogical(), DefaultLanguageGet(), DefaultLanguageIsValid(), DefaultLanguageLogicalToDisplay(), DefaultLanguageLogicalToOdbc(), DefaultLanguageNormalize(), DefaultLanguageSet()

Methods (Including Private)

private method %OnNew(pDefaultLanguage As %String) as %Status
Inherited description: This callback method is invoked by the %New() method to provide notification that a new instance of an object is being created.

If this method returns an error then the object will not be created.

It is passed the arguments provided in the %New call. When customizing this method, override the arguments with whatever variables and types you expect to receive from %New(). For example, if you're going to call %New, passing 2 arguments, %OnNew's signature could be:

Method %OnNew(dob as %Date = "", name as %Name = "") as %Status If instead of returning a %Status code this returns an oref and this oref is a subclass of the current class then this oref will be the one returned to the caller of %New method.

private method LoadRules(pLanguage As %String, pPlugin As %String) as %Status
Retrieves a set of rules to customize or overrule plugin output, based on default rules returned by GetDefaultRules() and the content of the %iKnow.Stemming.Rule table. Any result retrieved by a plugin will have to pass these rules (where applicable) or it will not be returned. Note that this may result in no results to be passed back at all!
method Reload() as %Status
Reloads underlying stemmer implementations and rules
private method StemWordHunspell(pStemmer As %iKnow.Stemming.HunspellStemmer, pToken As %String, pLanguage As %String, pLexType As %Integer = $$$ENTTYPECONCEPT, pEntity As %String = "") as %String
Starting point for advanced resolution of hunspell stemming results. Stems pToken using pStemmer by testing it first in the capitalization supplied initially and then with initcaps and all-caps in case no stem was found. Relays to StemWordHunspellRules() for the actual stemming.
private method StemWordHunspellRules(pStemmer As %iKnow.Stemming.HunspellStemmer, pToken As %String, pLanguage As %String, pLexType As %Integer = $$$ENTTYPECONCEPT, pEntity As %String = "", Output pHasMatch As %Boolean) as %String
For a given token, goes through all the results presented by Hunspell and then decides which option to return (if any at all), based on the rules returned by GetHunspellRules(), using context information such as pLexType

Inherited Members

Inherited Properties (Including Private)

Inherited Methods (Including Private)