Class TextStatisticsTransformer
java.lang.Object
com.norconex.importer.handler.transformer.impl.TextStatisticsTransformer
- All Implemented Interfaces:
Configurable<TextStatisticsTransformerConfig>,ConfigurableDocHandler<TextStatisticsTransformerConfig>,DocHandler
public class TextStatisticsTransformer
extends Object
implements ConfigurableDocHandler<TextStatisticsTransformerConfig>
Analyzes the content of the supplied document and adds statistical information about its content or field as metadata fields. Default behavior provide the statistics about the content. Refer to the following for the new metadata fields to be created along with their description.
| Field name | Description |
|---|---|
| document.stat.characterCount | Total number of characters (excluding carriage returns/line feed). |
| document.stat.wordCount | Total number of words. |
| document.stat.sentenceCount | Total number of sentences. |
| document.stat.paragraphCount | Total number of paragraph. |
| document.stat.averageWordCharacterCount | Average number of character in every words. |
| document.stat.averageSentenceCharacterCount | Average number of character in sentences (including non-word characters, such as spaces, or slashes). |
| document.stat.averageSentenceWordCount | Average number of words per sentences. |
| document.stat.averageParagraphCharacterCount | Average number of characters in paragraphs (including non-word characters, such as spaces, or slashes). |
| document.stat.averageParagraphSentenceCount | Average number of sentences per paragraphs. |
| document.stat.averageParagraphWordCount | Average number of words per paragraphs. |
You can specify a field matcher to obtain statistics about matching
fields instead.
When you do so, the field name will be inserted in the above
names, right after "document.stat.". E.g.:
document.stat.myfield.characterCount
Can be used both as a pre-parse (text-only) or post-parse handler.
- See Also:
-
Field Summary
Fields inherited from interface com.norconex.commons.lang.config.Configurable
PROPERTYFields inherited from interface com.norconex.importer.handler.DocHandler
NAME -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidanalyze(Reader input, Properties metadata, String field) protected booleanbooleanbooleanhandle(DocHandlerContext docCtx) Perform any operations on a document.inthashCode()toString()Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface com.norconex.importer.handler.DocHandler
close, init
-
Constructor Details
-
TextStatisticsTransformer
public TextStatisticsTransformer()
-
-
Method Details
-
handle
Description copied from interface:DocHandlerPerform any operations on a document.- Specified by:
handlein interfaceDocHandler- Parameters:
docCtx- the document handling context- Returns:
falseto stop processing and reject a document ortrueto proceed to the next configured handler.- Throws:
IOException- An I/O exception of some sort has occurred
-
analyze
-
getConfiguration
- Specified by:
getConfigurationin interfaceConfigurable<TextStatisticsTransformerConfig>
-
equals
-
canEqual
-
hashCode
public int hashCode() -
toString
-