Esempio n. 1
0
        private void addMatch(WordObject word, bool isUserInput, List <WordObject> newSentence, IEnumerable <Ientity> match)
        {
            Ientity entity = null;

            if (match.Count() > 1)
            {
                var list = match.ToList();
                list.Sort((x, y) => entitySelector(x) - entitySelector(y));
                entity = list.FirstOrDefault();
            }
            else
            {
                entity = match.FirstOrDefault();
            }

            if (!isUserInput)
            {
                var newWord = word.clone();;
                newWord.Text  = entity.entityValue;
                newWord.Lemma = entity.entityValue;
                newWord.WordT = WordObject.typeFromString(entity.entityType);
                newSentence.Add(newWord);
            }
            else
            {
                foreach (var w in match)
                {
                    var newWord = word.clone();;
                    newWord.Text  = w.entityValue;
                    newWord.Lemma = w.entityValue;
                    newWord.WordT = WordObject.typeFromString(w.entityType);
                    newSentence.Add(newWord);
                }
            }
        }
Esempio n. 2
0
        private void WordObjectFromEntity(List <WordObject> sentence, List <WordObject> newSentence, IentityBase ent)
        {
            var newWord = sentence[ent.entityID].clone();

            newWord.WordT = WordObject.typeFromString(ent.entityType);

            if (ent.entityType == "organizationWord")
            {
                newWord.Amount = amountType.plural;
                newWord.Gender = genderType.masculine;
            }
            else if (ent.entityType == "locationWord")
            {
                newWord.Amount = amountType.singular;
                newWord.Gender = genderType.feminine;
            }
            else if (ent.entityType == "eventWord")
            {
                newWord.Amount = amountType.singular;
            }


            IMultyEntity mEnt;

            if (ent.entityValue.Split(' ').Count() > 0)
            {
                newWord.Text = ent.entityValue;
                if ((mEnt = ent as IMultyEntity) != null)
                {
                    newWord.Lemma = mEnt.parts.Split(';')[0];
                }
                else
                {
                    newWord.Lemma = newWord.Text;
                }
            }
            else
            {
                newWord.Lemma = ent.entityValue;
            }

            newWord.WordT = WordObject.typeFromString(ent.entityType);
            newSentence.Add(newWord);
        }