Skip to main content
Version: 2025.1

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.

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);

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​

string

the 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​

string

the 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​

any

the search pattern.


getText​

getText(): string

Returns​

string

the 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​

pAnalyzer
string | number | boolean

the analyzer used for the analysis.

Returns​

AnalyzeRequest

setPatterns​

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​

pPatterns
any

Returns​

AnalyzeRequest

the search pattern.


Example​

request.setPatterns({"plain":"Corsa", "after":"Corsa*"});

setText​

setText(pText): AnalyzeRequest

Sets the text to be analysed.

Parameters​

pText
string | number | boolean

Returns​

AnalyzeRequest

setUseStopWords​

setUseStopWords(pUseStopWords): AnalyzeRequest

Specifies whether stop words are filtered during analysis. Default is false.

Parameters​

pUseStopWords
boolean

true if stop words are filtered.

Returns​

AnalyzeRequest

useDefaultOperatorAND​

useDefaultOperatorAND(): AnalyzeRequest

Specifies that AND is used as the default operator for the text analysis.

Returns​

AnalyzeRequest

useDefaultOperatorOR​

useDefaultOperatorOR(): AnalyzeRequest

Specifies that OR is used as the default operator for the text analysis.

Returns​

AnalyzeRequest

useStopWords​

useStopWords(): boolean

Specifies whether stop words are filtered during analysis. Default is false.

Returns​

boolean

true if stop words are filtered.