Nasty.Operations.QA.CandidateScorer (Nasty v0.3.0)

View Source

Generic sentence scoring for Question Answering.

Scores sentences for relevance to a question using:

  • Keyword matching (lemma overlap)
  • Entity type matching (expected answer type)
  • Position bias (earlier sentences preferred)

Summary

Functions

Scores a sentence for relevance to a question.

Functions

score_sentence(sentence, question_analysis, all_sentences, config)

Scores a sentence for relevance to a question.

Returns a score between 0.0 and 1.0+, where higher scores indicate more relevant sentences.

Scoring Components

  • Base score: 0.1 (allows fallback even with no keyword matches)
  • Keyword match: 0.6 weight
  • Entity type: 0.2 weight
  • Position: 0.2 weight