Exemple #1
0
            private void ApplyReportToSentence(WordSemanticsAnalysisReport report)
            {
                var currentSemantics = text.Sentences.ElementAt(this.sentenceId).Semantics;

                if (!report.Semantics.IsUnknown)
                {
                    currentSemantics.Add(report.Semantics);
                }
            }
Exemple #2
0
            public void GoToNextWord(WordSemanticsAnalysisReport report)
            {
                this.ApplyReportToSentence(report);

                var currentSentence = text.Sentences.ElementAt(sentenceId);

                wordId += 1;

                if (wordId >= currentSentence.Words.Count())
                {
                    // next sentence
                    sentenceId++;
                    wordId = 0;
                }
            }
Exemple #3
0
        public WordSemanticsAnalysisReport AnalyzeWordAsNamedEntity(Word word, Context context)
        {
            var bestReport = this.namedEntityTypes.Select(type => type.Analyze(word, context))
                             .Where(report => report != null)
                             .OrderByDescending(report => report.Semantics.Words.Count())
                             .FirstOrDefault();

            if (bestReport == null)
            {
                bestReport = new WordSemanticsAnalysisReport {
                    Semantics = new UnknownWordSemantics(word),
                };
            }

            return(bestReport);
        }