INamedEntityCollector::Add Method

Adds a single (potential) named entity to this INamedEntityCollector collection, as identified in a tokenized span of the input string being parsed.


HRESULT Add(      
    ULONG beginSpan,
    ULONG endSpan,
    ULONG beginActual,
    ULONG endActual,
    IEntity *pType,
    LPCWSTR pszValue,


  • beginSpan
    [in]  The beginning of the overall token span, including any leading quotation marks.
  • endSpan
    [in]  The end of the overall token span including any trailing quotation marks.
  • beginActual
    [in]  The beginning of the part of the token span that identifies the potential named entity.
  • endActual
    [in]  The end of the part of the token span that identifies the potential named entity.
  • pType
    [in]  The semantic type of the named entity.
  • pszValue
    [in]  The name of the entity as a string.
  • certainty
    [in]  One of the following values:
    Value Information
    NEC_LOW It could be this named entity, but additional evidence is advisable.
    NEC_MEDIUM It is likely this named entity; it is okay to use it.
    NEC_HIGH It almost certainly is this named entity; it should be okay to discard other possibilities.

Return Value

Returns S_OK if successful, or an error value otherwise.


When a query parser parses an input string into condition nodes, the parser invokes an IConditionGenerator object that, in turn, invokes INamedEntityCollector::Add to collect possible named entities in the input string. The IConditionGenerator object must call the this method for each potential named entity it recognizes in the input string. For each entity, the condition generator must provide the following information:

  • what part of the input string it covers
  • the semantic type of the named entity
  • a string representation of the value of the named entity
  • the level of certainty that the input really is that named entity

If the named entity was used in the interpretation of the input string, the IConditionGenerator::GenerateForLeaf method of the condition generator will be invoked with the value string as one of the arguments.

The following relationship must be maintained between the four first arguments: beginSpan = beginActual < endActual = endSpan.