src.dackar.RCA.ner.hybrid_ner.classifier ======================================== .. py:module:: src.dackar.RCA.ner.hybrid_ner.classifier Classes ------- .. autoapisummary:: src.dackar.RCA.ner.hybrid_ner.classifier.TrainingExample src.dackar.RCA.ner.hybrid_ner.classifier.SpanClassifier Module Contents --------------- .. py:class:: TrainingExample Minimal supervised example for the span classifier. - doc_text: full document text - start/end: span offsets in doc_text - label: gold label (must exist in schema.label_to_group) .. py:attribute:: doc_text :type: str .. py:attribute:: start :type: int .. py:attribute:: end :type: int .. py:attribute:: label :type: str .. py:class:: SpanClassifier(context_window_chars = 50, top_k = 3, min_prob = 0.25) Lightweight ML span classifier placeholder using scikit-learn. Purpose: - Propose label hypotheses for candidates that are currently unlabeled ("defer"). Usage: - clf = SpanClassifier() - clf.fit(examples, schema) - pipeline = HybridNERPipeline(..., classifier=clf) If scikit-learn is not available, this becomes a no-op (safe). .. py:attribute:: context_window_chars :value: 50 .. py:attribute:: top_k :value: 3 .. py:attribute:: min_prob :value: 0.25 .. py:attribute:: _is_trained :value: False .. py:attribute:: _vectorizer :value: None .. py:attribute:: _model :value: None .. py:attribute:: _sklearn_ok :value: False .. py:method:: fit(examples, schema) .. py:method:: predict(doc, candidates, schema) .. py:method:: _featurize(text, start, end)