src.dackar.RCA.ner.hybrid_ner.classifier

Classes

TrainingExample

Minimal supervised example for the span classifier.

SpanClassifier

Lightweight ML span classifier placeholder using scikit-learn.

Module Contents

class src.dackar.RCA.ner.hybrid_ner.classifier.TrainingExample[source]

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)

doc_text: str[source]
start: int[source]
end: int[source]
label: str[source]
class src.dackar.RCA.ner.hybrid_ner.classifier.SpanClassifier(context_window_chars=50, top_k=3, min_prob=0.25)[source]

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).

Parameters:
  • context_window_chars (int)

  • top_k (int)

  • min_prob (float)

context_window_chars = 50[source]
top_k = 3[source]
min_prob = 0.25[source]
_is_trained = False[source]
_vectorizer = None[source]
_model = None[source]
_sklearn_ok = False[source]
fit(examples, schema)[source]
Parameters:
Return type:

None

predict(doc, candidates, schema)[source]
Parameters:
Return type:

List[src.dackar.RCA.ner.hybrid_ner.models.CandidateSpan]

_featurize(text, start, end)[source]
Parameters:
  • text (str)

  • start (int)

  • end (int)

Return type:

str