Installation and usage
Installation and Usage
Installation
To install via NPM:
Usage
Example:
Processing
If you console.log
the processed
instance variable, you'll get something like this:
Detection
As we've mentioned earlier, the above processing result might not be very useful in a real world use case.
However, you should consider it as the starting point on which you build your detectors to get useful information out of the passed text.
What you would want to build is what's called detectors those are just functions that should be added to the Run
function prototype and utilize the above processing result to get more meaningful results.
For example, a detector may utilize the above object and since the sentence in question have an infinitive verb as it's ROOT
, then sentence must be in present tense.
How to write detectors
WARNING The following example illustrate how to write detectors in TypeScript. The same way is applicable in JavaScript but without the ambient declaration (
declare module
) and without the type declarations.
The following example will detect what's being an object to negative sentiment.
Using the above detector:
The above example should give:
Please note that the above example is just a demonstration of how you can write detectors. If you need a negative sentiment detector, there are many things you should consider. In fact, I maintain a sentiment detector extension that you should check out for a more sophisticated example.
Pre & Post Processors
Preprocessors and postprocessors are function that can be hooked in the the main Run
function either to intercept the input or modify the result.
The following example will look for "alex" and change it into "Alex".
An example of postprocessors is a function that converts all the verb POS tag annotations into "VERB"
.
JavaScript & TypeScript
This library is written in TypeScript and compiled to JavaScript, so you can import the library in both and have type safety and auto completion in TypeScript or just use it as any regular node module if you want to.
Last updated