sparknlp.annotator.matcher.rule_based_matcher#

Contains classes for the RuleBasedMatcher.

Module Contents#

Classes#

RuleBasedMatcher

Rule-based token matcher over multiple Spark NLP annotation columns.

RuleBasedMatcherModel

Instantiated model of RuleBasedMatcher.

class RuleBasedMatcher[source]#

Rule-based token matcher over multiple Spark NLP annotation columns.

Rules are supplied as JSON or JSONL. Each token pattern can combine attributes from token text, POS, lemmas, NER, dependency metadata, or custom mapped annotation columns. Matches are emitted as CHUNK annotations.

Input Annotation types

Output Annotation type

DOCUMENT, TOKEN, ...

CHUNK

inputAnnotatorTypes[source]#
outputAnnotatorType = 'chunk'[source]#
rules[source]#
rulesResource[source]#
setRules(value)[source]#

Sets inline JSON/JSONL rule definitions.

Parameters:
valuestr, dict, or list

JSON/JSONL string, one rule dict, or a list of rule dicts.

setRulesResource(path, read_as=ReadAs.TEXT, options={'format': 'text'})[source]#

Sets an external JSON or JSONL rules resource.

class RuleBasedMatcherModel(classname='com.johnsnowlabs.nlp.annotators.matcher.RuleBasedMatcherModel', java_model=None)[source]#

Instantiated model of RuleBasedMatcher.

name = 'RuleBasedMatcherModel'[source]#
inputAnnotatorTypes[source]#
outputAnnotatorType = 'chunk'[source]#
inputColumnTypes[source]#
rulesJson[source]#