Exemplo n.º 1
0
        internal EntityIndex(string[] words, UtteranceLinker linker, int entityHypCount)
        {
            _words   = words.ToArray();
            _matches = new List <EntityMatch> [_words.Length];

            for (var i = 0; i < _matches.Length; ++i)
            {
                _matches[i] = new List <EntityMatch>();
            }

            initialize(linker, entityHypCount);
        }
Exemplo n.º 2
0
        private void initialize(UtteranceLinker linker, int entityHypCount)
        {
            for (var wordIndex = 0; wordIndex < _words.Length; ++wordIndex)
            {
                var missingWords = _words.Skip(wordIndex);
                for (var ngramLength = 1; ngramLength <= 4; ++ngramLength)
                {
                    if (wordIndex + ngramLength > _words.Length)
                    {
                        break;
                    }

                    var ngram = string.Join(" ", missingWords.Take(ngramLength));
                    foreach (var entity in linker.GetValidEntities(ngram, entityHypCount))
                    {
                        var match = new EntityMatch(entity, wordIndex, ngramLength);
                        _matches[wordIndex].Add(match);
                    }
                }
            }
        }
 internal PopularityMaximizationLinker(FreebaseDbProvider db, string verbsLexicon = null)
 {
     _linker = new UtteranceLinker(db, verbsLexicon);
 }