src.dackar.pipelines.PhraseEntityMatcher ======================================== .. py:module:: src.dackar.pipelines.PhraseEntityMatcher Attributes ---------- .. autoapisummary:: src.dackar.pipelines.PhraseEntityMatcher.logger Classes ------- .. autoapisummary:: src.dackar.pipelines.PhraseEntityMatcher.PhraseEntityMatcher Functions --------- .. autoapisummary:: src.dackar.pipelines.PhraseEntityMatcher.create_phrase_matcher_component Module Contents --------------- .. py:data:: logger .. py:function:: create_phrase_matcher_component(nlp, name, label, patterns, asSpan) .. py:class:: PhraseEntityMatcher(nlp, label, patterns, asSpan=True, callback=None) Bases: :py:obj:`object` Phrase Entity Recognition class How to use it: .. code-block:: python from PhraseEntityMatcher import PhraseEntityMatcher nlp = spacy.load("en_core_web_sm") phraseList = ["safety cage", "cage", "pump"] pmatcher = PhraseEntityMatcher(nlp, 'ssc', phraseList) doc = nlp("The shaft deflection is causing the safety cage to rattle. Pumps not experiencing enough flow for the pumps to keep the check valves open during test. Pump not experiencing enough flow during test. Shaft made noise. Vibration seems like it is coming from the shaft.") updatedDoc = pmatcher(doc) or: .. code-block:: python nlp.add_pipe('phrase_entity_matcher', config={"label": "ssc", "patterns":["safety cage", "pump"], "asSpan":True}) newDoc = nlp(doc.text) .. py:attribute:: name :value: 'phrase_entity_matcher' .. py:attribute:: matcher .. py:attribute:: asSpan :value: True .. py:method:: __call__(doc, replace=False) :param doc: spacy.tokens.doc.Doc, the processed document using nlp pipelines :param replace: if True, relabel duplicated entity with new label :type replace: bool