AnalyzeRequest
A request for the text analysis. It ist required to provide valid values for the text and patterns. All other settings are optional. If not otherwise specified the request searches for stop words and uses the text.ANALYZER_TYPE_TEXT and the default operator AND.
Methods
getAnalyzer
getAnalyzer():
string
Returns the explicit analyzer used for the text analysis. If no analyzer is set, the default text.ANALYZER_TYPE_TEXT is used.
Returns
stringthe explicitly used analyzer or null if it is not set.
getDefaultOperator
getDefaultOperator():
string
Returns the explicit default operator used for the text analysis. If no default operator is set, the default operator AND is used.
Returns
stringthe explicitly used default operator or null if it is not set.
getPatterns
getPatterns():
any
The search patterns (as a map with keys and values).
Returns
anythe search pattern.
getText
getText():
string
Returns
stringthe text to be analyzed.
setAnalyzer
setAnalyzer(
pAnalyzer):AnalyzeRequest
Returns the explicit analyzer used for the text analysis. If set to null, the default text.ANALYZER_TYPE_TEXT is used. Constants are defined for all valid analyzers in the text module. All analyzer constants start with ANALYZER_TYPE, e.g. text.ANALYZER_TYPE_TEXT, text.ANALYZER_TYPE_PLAIN or text.ANALYZER_TYPE_SIMPLE.
Parameters
string | number | booleanthe analyzer used for the analysis.
Returns
AnalyzeRequestsetPatterns
setPatterns(
pPatterns):AnalyzeRequest
Sets the search patterns. Expected is a map with unique keys and the actual patterns as values. The results for the individual search patterns in the return can be read out via the keys.
Parameters
anyReturns
AnalyzeRequestthe search pattern.
Example
request.setPatterns({"plain":"Corsa", "after":"Corsa*"});
setText
setText(
pText):AnalyzeRequest
Sets the text to be analysed.
Parameters
string | number | booleanReturns
AnalyzeRequestsetUseStopWords
setUseStopWords(
pUseStopWords):AnalyzeRequest
Specifies whether stop words are filtered during analysis. Default is false.
Parameters
booleantrue if stop words are filtered.
Returns
AnalyzeRequestuseDefaultOperatorAND
useDefaultOperatorAND():
AnalyzeRequest
Specifies that AND is used as the default operator for the text analysis.
Returns
AnalyzeRequestuseDefaultOperatorOR
useDefaultOperatorOR():
AnalyzeRequest
Specifies that OR is used as the default operator for the text analysis.
Returns
AnalyzeRequestuseStopWords
useStopWords():
boolean
Specifies whether stop words are filtered during analysis. Default is false.
Returns
booleantrue if stop words are filtered.
Example
var data= "My first car was a Vauxhall Corsa 1.4. The next one was a red Corsa.";
// Create the patterns as a map with keys and values var patternArr = new Object();
patternArr["plain"] = "Corsa";
patternArr["after"] = "Corsa*";
patternArr["all"] = "*Corsa*";
// Create a new empty request object. var analysisRequest = text.createAnalyzeTextRequest();
analysisRequest.setText(data); // Set the text will be analyzed.
analysisRequest.setPatterns(patternArr); // Set the search pattern
analysisRequest.setUseStopWords(true); // Specify if stop words should be filtered.
analysisRequest.setAnalyzer(text.ANALYZER_TYPE_TEXT); // Specify the explizit type of analyzer.
analysisRequest.useDefaultOperatorOR(); // Specify the default operator used for the patterns.
// Perform the analysis. var res = text.analyze(analysisRequest);