in nlpcraft/src/main/scala/org/apache/nlpcraft/nlp/parsers/NCSemanticEntityParser.scala [302:322]
def match0(txt: String) = chunk.regex.matcher(txt).matches()
match0(tok.getText) || match0(tok.getText.toLowerCase)
}
if found then add(elemType, Option.when(s.value != null)(s.value))
// Deletes redundant.
hs = hs.distinct
val del = mutable.ArrayBuffer.empty[Holder]
// 1. Look at each element with its value.
for (((_, _), seq) <- hs.groupBy(h => (h.elemType, h.value)) if seq.size > 1)
// 2. If some variants are duplicated - keep only one, with most tokens counts.
val seqIdxs = seq.zipWithIndex
for ((h, idx) <- seqIdxs if !del.contains(h))
del ++= seqIdxs.filter { (_, oIdx) => oIdx != idx }.map { (h, _) => h }.filter(_.tokensSet.subsetOf(h.tokensSet))
hs --= del
hs.toSeq.map(h => {