Detectors
Last updated
Was this helpful?
Last updated
Was this helpful?
Was this helpful?
Detectors are a higher level analysis functions that run on top of processors to get a more curated and specific results. Technically, any function that utilize and analyse the tokens, POS tags, and/or dependencies can be considered a detector.
Typically, detector function should be added to the Fin.Run
function prototype. So whenever a new instance is created the detector function can be applied on the processing result which resides on the context (this
object) of the instance.
The reason that Fin has been designed to have it's detectors on the prototype, not as part of the core processors, is that the detector function might cause performance issues. So you can call detector function only when you need them.
A very basic example that will just return the number of sentences in a given instance.
import {Run} from "finnlp";
Run.prototype.sentencesCount = function () {
return this.sentence.length;
}
import * as Fin from "finnlp";
declare module "finnlp" {
export interface Run {
sentencesCount: () => number;
}
I'm maintaining few useful detectors, have a look at them if you want more elaborate examples: