Skip to main content

%iKnow.Classification.Classifier

abstract class %iKnow.Classification.Classifier extends %Library.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

Method Inventory

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 = Classifier_sys_CategorizeSQL ]
Projected as the stored procedure: Classifier_sys_CategorizeSQL
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)

Inherited Members

Inherited Methods

FeedbackOpens in a new tab