NCSemanticEntityParser

class NCSemanticEntityParser extends NCEntityParser with LazyLogging

Semantic entity parser implementation.

This synonyms based parser provides simple yet powerful way to find domain specific data in the input text. It is configured via NCSemanticElement list which represents all possible named entities that this parser can detect.

Semantic elements can be configured via YAML or JSON files in special format or passed in this parser as programmatically prepared list. Semantic elements contain set of synonyms which can use special macros. These macros also can be provided via YAML and JSON files or passed directly in case of programmatically prepared NCSemanticElement list.

Example of YAML elements definition.

macros:
 "<OF>": "{of|for|per}"
 "<CUR>": "{current|present|now|local}"
 "<TIME>": "{time <OF> day|day time|date|time|moment|datetime|hour|o'clock|clock|date time}"
elements:
 - id: "x:time"
   description: "Date and/or time token indicator."
   synonyms:
     - "{<CUR>|_} <TIME>"
     - "what <TIME> {is it now|now|is it|_}"

Given this simple definition the x:time element can be detected by a large number of synonyms like day time, local day time, time of day, local time of day, what hour is it, etc.

Value parameters:
elements

Programmatically prepared NCSemanticElement instances. Note that either the model or elements must be supplied at least.

macros

Macros map which are used for extracting NCSemanticElement synonyms defined via macros. More information at https://nlpcraft.apache.org/built-in-entity-parser.html#macros.

mdlResOpt

Optional relative path, absolute path, classpath resource or URL to YAML or JSON semantic model which contains NCSemanticElement definitions. Note that either the model or elements must be supplied at least.

parser

NCTokenParser implementation which will be used for NCSemanticElement synonyms tokenization. It should be same implementation as used in NCPipeline.getTokenParser.

stemmer

NCStemmer implementation which used to match tokens and given NCSemanticElement synonyms.

See also:
Source:
NCSemanticEntityParser.scala
trait LazyLogging
class Object
trait Matchable
class Any

Value members

Constructors

def this(stemmer: NCStemmer, parser: NCTokenParser, macros: Map[String, String], elements: List[NCSemanticElement])

Creates NCSemanticEntityParser instance with given parameters.

Creates NCSemanticEntityParser instance with given parameters.

Value parameters:
elements

NCSemanticElement list.

macros

Macros map. Empty by default.

parser

NCTokenParser implementation.

stemmer

NCStemmer implementation for synonyms language.

Source:
NCSemanticEntityParser.scala
def this(stemmer: NCStemmer, parser: NCTokenParser, elements: List[NCSemanticElement])

Creates NCSemanticEntityParser instance with given parameters.

Creates NCSemanticEntityParser instance with given parameters.

Value parameters:
elements

NCSemanticElement list.

parser

NCTokenParser implementation.

stemmer

NCStemmer implementation for synonyms language.

Source:
NCSemanticEntityParser.scala
def this(stemmer: NCStemmer, parser: NCTokenParser, mdlRes: String)

Creates NCSemanticEntityParser instance with given parameters.

Creates NCSemanticEntityParser instance with given parameters.

Value parameters:
mdlRes

Relative path, absolute path, classpath resource or URL to YAML or JSON semantic model definition.

parser

NCTokenParser implementation.

stemmer

NCStemmer implementation for synonyms language.

Source:
NCSemanticEntityParser.scala

Concrete methods

override def parse(req: NCRequest, cfg: NCModelConfig, toks: List[NCToken]): List[NCEntity]

Parses and converts given list of tokens into the list of entities.

Parses and converts given list of tokens into the list of entities.

Definition Classes
Source:
NCSemanticEntityParser.scala

Inherited methods

Called when the component starts. Default implementation is no-op.

Called when the component starts. Default implementation is no-op.

Value parameters:
cfg

Configuration of the model this component is associated with.

Inherited from:
NCLifecycle
Source:
NCLifecycle.scala

Called when the component stops. Default implementation is no-op.

Called when the component stops. Default implementation is no-op.

Value parameters:
cfg

Configuration of the model this component is associated with.

Inherited from:
NCLifecycle
Source:
NCLifecycle.scala

Inherited fields

lazy protected val logger: Logger
Inherited from:
LazyLogging
Source:
Logging.scala