Exemple #1
0
        public NounPhrase GetNounPhrase(string[] sentence, string[] target)
        {
            var targetCandidates = GetAllNounPhrases(sentence, target);

            TargetCandidate bestCandidate = null;
            float           bestScore     = float.NegativeInfinity;

            foreach (var phrase in targetCandidates)
            {
                var input = new ModelInput
                {
                    Child         = phrase.IsChildOfRoot(),
                    Morphological = (float)phrase.IsMorphologicalSimiliar(lemmatizer),
                    Sentiment     = phrase.IsConnectedToSentiment(),
                    Wiki          = phrase.IsWikipediaTitle(wiki),
                    Word2Vec      = (float)phrase.GetWord2VecCosineSimilarity(word2VecVocabulary),
                    WordNet       = phrase.GetWordNetPathLength(wordNetEngine)
                };

                ModelOutput result = predictionEngine.Predict(input);

                if (result.Score > bestScore)
                {
                    bestCandidate = phrase;
                    bestScore     = result.Score;
                }
            }

            return(bestCandidate.NounPhrase);
        }
Exemple #2
0
 public object[] GetTrainFeatures(TargetCandidate candidate)
 {
     return(new object[] {
         candidate.IsChildOfRoot(),
         candidate.IsWikipediaTitle(wiki),
         candidate.IsConnectedToSentiment(),
         candidate.IsMorphologicalSimiliar(lemmatizer),
         candidate.GetWordNetPathLength(wordNetEngine),
         candidate.GetWord2VecCosineSimilarity(word2VecVocabulary)
     });
 }