/// <summary>
        ///
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        /// <remarks>Need to change returned UnknownEntity's Value.</remarks>
        private IEntity CreateOrdinalEntity(string word, FullLemmaInfo info)
        {
            if (!this.GramTable.ContainsKey(info.CommonMF.Gramcode))
            {
                throw new Exception("Gramcode error");
            }

            if (info == FullLemmaInfo.Unknown)
            {
                return(null);
            }

            IEntity result = null;

            PartOfSpeech pos = this.GramTable[info.CommonMF.Gramcode].PartOfSpeech;

            if (pos == PartOfSpeech.Noun)
            {
                result = new ClassEntity(info.CommonLemma);
            }
            else if (pos == PartOfSpeech.Adjective ||
                     pos == PartOfSpeech.AdjectiveFull ||
                     pos == PartOfSpeech.AdjectiveShort)
            {
                result = new PropertyEntity(info.CommonLemma);
            }
            else
            {
                result = new UnknownEntity(info.CommonLemma);
            }

            result.PartOfSpeech = pos;
            return(result);
        }
Example #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        /// <remarks>Need to change returned UnknownEntity's Value.</remarks>
        private IEntity CreateSimpleEntity(string word, FullLemmaInfo info)
        {
            if (!this.GramTable.ContainsKey(info.CommonMF.Gramcode))
            {
                throw new Exception("Gramcode error");
            }

            if (info == FullLemmaInfo.Unknown)
            {
                return(null);
            }

            IEntity result = null;

            PartOfSpeech pos, currentPos;

            try
            {
                pos        = this.GramTable[info.CommonMF.Gramcode].PartOfSpeech;
                currentPos = this.GramTable[info.CurrentMF.Gramcode].PartOfSpeech;
            }
            catch
            {
                return(CreateUnknownEntity(word));
            }


            if (pos == PartOfSpeech.Noun)
            {
                result = new ClassEntity(info.CommonLemma);
                result.PartOfSpeech = currentPos;
            }
            else if (pos == PartOfSpeech.Adjective ||
                     pos == PartOfSpeech.AdjectiveFull ||
                     pos == PartOfSpeech.AdjectiveShort)
            {
                result = new PropertyEntity(info.CommonLemma);
                result.PartOfSpeech = currentPos;
            }
            else
            {
                result = new UnknownEntity(info.CommonLemma);
                result.PartOfSpeech = currentPos;
            }

            result.MorphologicalInfo = info;
            return(result);
        }
Example #3
0
        public override bool Analyze(IEnumerable <ResolvedMethod <Node> > starts)
        {
            var initialState     = new UnknownEntity();
            var emptyInvocation  = new OperationEdge <Node>(0, new NopStatement(), 0);
            var initialStackData = new MyStackData(emptyInvocation, initialState, false);

            var pdvm = (MyPdvm)InternalSimulation.Pdvm;

            pdvm.SetForcedExecutor(InternalSimulation.ForceExecute);

            var contexts = starts.Select(
                start => InternalSimulation.Load(start.Start, initialState, initialStackData)).ToList();

            InternalSimulation.Run();

            return(true);
        }
Example #4
0
        public IEntity Translate(IDictionary[] dictionaries, string word)
        {
            if (dictionaries == null || dictionaries.Length == 0)
            {
                return(new UnknownEntity(word));
            }
            IEntity result = new UnknownEntity(word);

            foreach (IDictionary dictionary in dictionaries)
            {
                result = dictionary.Translate(word);
                if (!(result is UnknownEntity))
                {
                    return(result);
                }
            }
            int integer;

            if (int.TryParse(word, out integer))
            {
                return(new IntegerEntity(integer));
            }
            return(result);
        }
Example #5
0
 protected string PrintEntity(UnknownEntity unknownEntity)
 {
     return(string.Empty);
 }