SubSpanGuard

class SubSpanGuard(stopwords: Set<String> = Vocabulary.STOPWORDS, qualifierOpeners: Set<String> = Vocabulary.QUALIFIER_OPENERS) : MatchGuard

Rejects a match where one prompt is the other plus a clause that narrows the question.

How do I deploy a Rails app and How do I deploy a Rails app on Heroku share every word the shorter one has, so overlap is perfect and LexicalDivergenceGuard sees nothing. They embed close for the same reason. And they need different answers, because the second is asking about Heroku.

This is the gap between the lexical guards and the dev.kmemo.Verifier. The other guards look for a word that changed; nothing here changed, something was added, and what was added is the part that decides the answer.

The three conditions, and why a looser rule does not work

The naive version — "some clause in one prompt has no counterpart in the other" — refuses genuine paraphrases in bulk, because people frame questions differently: I am working on a REST client and need to parse an ISO 8601 timestamp in Java is the same question as How do I parse an ISO 8601 timestamp in Java, and its first clause matches nothing. So all three of these must hold:

  1. One prompt's content words contain the other's, compared with Text.isSameWord so a typo or a spelling variant is not a difference. Two prompts that were merely reworded fail here, which is what keeps My connection to the server keeps dropping after a few minutes of sitting idle from being read as a narrowed form of How do I stop my SSH session from timing out.

  2. The added words all sit in one span. Framing spreads across a sentence; a qualifier is local. The REST client example adds words to two different spans and is left alone.

  3. That span opens with a qualifier, one of Vocabulary.QUALIFIER_OPENERSon, for, with, without, after, and the rest. on Heroku qualifies the question. I am working on a REST client opens with a pronoun and does not.

Each condition is a way of demanding that the addition be the answer-bearing kind rather than merely present, which is the same asymmetry every guard here is built on: a wrong rejection costs one API call, a wrong acceptance costs a wrong answer.

Parameters

stopwords

function words removed before the prompts are compared.

qualifierOpeners

words that begin a clause narrowing a question rather than framing it.

Constructors

Link copied to clipboard
constructor(stopwords: Set<String> = Vocabulary.STOPWORDS, qualifierOpeners: Set<String> = Vocabulary.QUALIFIER_OPENERS)

Properties

Link copied to clipboard
open override val name: String

Short stable identifier, surfaced in dev.kmemo.CacheLookup.Miss.detail.

Functions

Link copied to clipboard
open override fun evaluate(query: String, candidate: String): GuardVerdict

Judges serving the response cached for candidate in answer to query.