Learning
Documentation
Community
Open Exchange
Global Masters
Home / Class Reference / ENSLIB namespace / %iKnow.Classification.Classifier
Private  Storage   

%iKnow.Classification.Classifier


abstract class %iKnow.Classification.Classifier extends
%RegisteredObject

This is the superclass for executable Text Categorization models. Upon compiling a subclass of this class, the required internal code will be generated to support the class' main methods %Categorize and %CategorizeText. To invoke a Text Categorization model on free text:

set tClassifier = ##class(User.MyClassifier).%New()
write tClassifier.%CategorizeText(.tCategories, "The helicopter was not flying at a sufficiently high altitude ...")
zwrite tCategories

To invoke it on a source in an iKnow domain:

set tClassifier = ##class(User.MyClassifier).%New("iKnow", [domain name])
write tClassifier.%Categorize(.tCategories, tSourceId)
zwrite tCategories

Inventory


Parameters Properties Methods Queries Indices ForeignKeys Triggers
32


Summary


Methods
%AddToSaveSet %Categorize %CategorizeSQL %CategorizeText
%ClassIsLatestVersion %ClassName %ConstructClone %DispatchClassMethod
%DispatchGetModified %DispatchGetProperty %DispatchMethod %DispatchSetModified
%DispatchSetMultidimProperty %DispatchSetProperty %Extends %GetCategories
%GetParameter %GetTerms %IsA %IsModified
%New %NormalizeObject %ObjectModified %OriginalNamespace
%PackageName %RemoveFromSaveSet %SerializeObject %SetModified
%ValidateObject


Methods


• method %Categorize(Output pCategories, pSourceId As %Integer, pMode As %String = "", pDomainSpec As %String = "") as %Status

This method runs the Text Categorization model defined in Classifier against the document identified by pSourceId. When this method returns, pCategories will contain all candidate categories for this document, sorted by decreasing score: pCategories(n) = $lb([category name], [score]) The entry with the highest score (pCategories(1)) is this model's best prediction.

If this Classifier instance has not been initialized with a reference to an iKnow or other domain, supply pMode="iKnow" and the domain name as pDomainSpec to point this classifier to the right location.

• classmethod %CategorizeSQL(pText As %String = "", pConfig As %String = "", Output pSC As %String = "") as %String [ SQLProc = ]
Static method to categorize a text fragment, returning the most likely category the text belongs to. See also %CategorizeText
• method %CategorizeText(Output pCategories, pText As %String = "", pConfig As %String = "") as %Status

This method runs the Text Categorization model defined in Classifier against the free text pText. When this method returns, pCategories will contain all candidate categories for this document, sorted by decreasing score: pCategories(n) = $lb([category name], [score]) The entry with the highest score (pCategories(1)) is this model's best prediction.

Optionally a %iKnow.Configuration's name can be passed in through pConfig to override the default configuration to use when indexing the text, for example to use a language model other than the default English (or automatically detect the right language to use).

• classmethod %GetCategories(Output pCategories) as %Status
Returns an array containing the categories specified in this classifier: pTerms(n) = $lb(name, description, recordCount, spec)
• classmethod %GetTerms(Output pTerms) as %Status
Returns an array containing the terms specified in this classifier: pTerms(n) = $lb(stringRepresentation, type, negationPolicy, countPolicy, displayName)