예제 #1
0
 /**
  * <summary> The method checks for the TIME entities using regular expressions. After that, if the expression is a TIME
  * expression, it also assigns the previous texts, which are numbers, TIME tag.</summary>
  * <param name="sentence">The sentence for which TIME named entities checked.</param>
  */
 protected override void AutoDetectTime(AnnotatedSentence.AnnotatedSentence sentence)
 {
     for (var i = 0; i < sentence.WordCount(); i++)
     {
         var word          = (AnnotatedWord)sentence.GetWord(i);
         var wordLowercase = word.GetName().ToLower(new CultureInfo("tr"));
         if (word.GetParse() != null)
         {
             if (Word.IsTime(wordLowercase))
             {
                 word.SetNamedEntityType("TIME");
                 if (i > 0)
                 {
                     AnnotatedWord previous = (AnnotatedWord)sentence.GetWord(i - 1);
                     if (previous.GetParse().ContainsTag(MorphologicalTag.CARDINAL))
                     {
                         previous.SetNamedEntityType("TIME");
                     }
                 }
             }
         }
     }
 }
예제 #2
0
        /**
         * <summary> The method checks for the MONEY entities using regular expressions. After that, if the expression is a MONEY
         * expression, it also assigns the previous text, which may included numbers or some monetarial texts, MONEY tag.</summary>
         * <param name="sentence">The sentence for which MONEY named entities checked.</param>
         */
        protected override void AutoDetectMoney(AnnotatedSentence.AnnotatedSentence sentence)
        {
            for (var i = 0; i < sentence.WordCount(); i++)
            {
                var word          = (AnnotatedWord)sentence.GetWord(i);
                var wordLowercase = word.GetName().ToLower(new CultureInfo("tr"));
                if (word.GetParse() != null)
                {
                    if (Word.IsMoney(wordLowercase))
                    {
                        word.SetNamedEntityType("MONEY");
                        var j = i - 1;
                        while (j >= 0)
                        {
                            AnnotatedWord previous = (AnnotatedWord)sentence.GetWord(j);
                            if (previous.GetParse() != null && (previous.GetName().Equals("amerikan") ||
                                                                previous.GetParse()
                                                                .ContainsTag(MorphologicalTag.REAL) ||
                                                                previous.GetParse()
                                                                .ContainsTag(MorphologicalTag.CARDINAL) ||
                                                                previous.GetParse()
                                                                .ContainsTag(MorphologicalTag.NUMBER)))
                            {
                                previous.SetNamedEntityType("MONEY");
                            }
                            else
                            {
                                break;
                            }

                            j--;
                        }
                    }
                }
            }
        }
예제 #3
0
        public AnnotatedWord ToAnnotatedWord(int wordIndex)
        {
            AnnotatedWord annotatedWord = new AnnotatedWord(GetTurkishWordAt(wordIndex));

            if (LayerExists(ViewLayerType.INFLECTIONAL_GROUP))
            {
                annotatedWord.SetParse(GetMorphologicalParseAt(wordIndex).ToString());
            }

            if (LayerExists(ViewLayerType.META_MORPHEME))
            {
                annotatedWord.SetMetamorphicParse(GetMetamorphicParseAt(wordIndex).ToString());
            }

            if (LayerExists(ViewLayerType.SEMANTICS))
            {
                annotatedWord.SetSemantic(GetSemanticAt(wordIndex));
            }

            if (LayerExists(ViewLayerType.NER))
            {
                annotatedWord.SetNamedEntityType(GetLayerData(ViewLayerType.NER));
            }

            if (LayerExists(ViewLayerType.PROPBANK))
            {
                annotatedWord.SetArgument(GetArgument().ToString());
            }

            if (LayerExists(ViewLayerType.SHALLOW_PARSE))
            {
                annotatedWord.SetShallowParse(GetShallowParseAt(wordIndex));
            }

            return(annotatedWord);
        }