private List <Entity> CreateOrganizationEntities(List <Entity> entities, string text)
        {
            ProcessorService.Initialize(MorphLang.RU | MorphLang.EN);
            OrganizationAnalyzer.Initialize();
            using (Processor proc = ProcessorService.CreateSpecificProcessor(OrganizationAnalyzer.ANALYZER_NAME))
            {
                AnalysisResult ar = proc.Process(new SourceOfAnalysis(text));
                foreach (var org in ar.Entities)
                {
                    if (org is OrganizationReferent)
                    {
                        var    orgEntitiName    = org.ToString();
                        string entityproperties = null;

                        var    props         = org.Slots;
                        string newProperties = null;
                        foreach (var prop in props)
                        {
                            var name  = prop.TypeName.ToString();
                            var value = prop.Value.ToString();
                            newProperties += name += " = " + value + ";";
                        }
                        var existingEntity = entities.Find(m => m.Value.Equals(orgEntitiName));
                        if (existingEntity != null)
                        {
                            entityproperties = existingEntity.Properties;
                            if (entityproperties != newProperties)
                            {
                                newProperties += entityproperties;
                            }
                            entities.Remove(existingEntity);
                        }
                        entities.Add(new Entity(orgEntitiName, newProperties, EntitiesType.person));
                    }
                }
                return(entities);
            }
        }
Ejemplo n.º 2
0
        public static void Initialize()
        {
            _terminCollection = new TerminCollection();
            Termin tContract = new Termin("контракт", MorphLang.RU, true);

            tContract.AddAbridge("гос.контракт");
            tContract.AddAbridge("г.контракт");
            tContract.AddAbridge("гос.к-т");
            _terminCollection.Add(tContract);

            _opfTerminCollection = new TerminCollection();
            Termin tOpf = new Termin("ОБЩЕСТВО С ОГРАНИЧЕННОЙ ОТВЕТСВЕННОСТЬЮ");

            tOpf.AddAbridge("ООО");
            tOpf.AddVariant("ЗАКРЫТОЕ АКЦИОНЕРНОЕ ОБЩЕСТВО");
            tOpf.AddAbridge("ЗАО");
            _opfTerminCollection.Add(tOpf);

            OrganizationAnalyzer.Initialize();
            UriAnalyzer.Initialize();
            DateAnalyzer.Initialize();
            ProcessorService.RegisterAnalyzer(new MyAnalyzer());
        }