示例#1
0
        static bool _processLinks(Pullenti.Semantic.SemGraph gr)
        {
            bool ret = false;

            for (int i = 0; i < gr.Objects.Count; i++)
            {
                Pullenti.Semantic.SemObject obj = gr.Objects[i];
                for (int j = obj.LinksFrom.Count - 1; j >= 0; j--)
                {
                    Pullenti.Semantic.SemLink li = obj.LinksFrom[j];
                    if (li.Typ != Pullenti.Semantic.SemLinkType.Pacient)
                    {
                        continue;
                    }
                    bool exi = false;
                    foreach (Pullenti.Semantic.SemLink ll in obj.LinksFrom)
                    {
                        if (ll != li && ll.Typ == Pullenti.Semantic.SemLinkType.Agent && ll.Target == li.Target)
                        {
                            exi = true;
                        }
                    }
                    if (exi)
                    {
                        if (obj.BeginChar > li.Target.BeginChar)
                        {
                            gr.RemoveLink(li);
                            ret = true;
                        }
                    }
                }
            }
            return(ret);
        }
示例#2
0
        static bool _processParticiples(Pullenti.Semantic.SemGraph gr)
        {
            bool ret = false;

            for (int i = 0; i < gr.Objects.Count; i++)
            {
                Pullenti.Semantic.SemObject obj = gr.Objects[i];
                if (obj.Typ != Pullenti.Semantic.SemObjectType.Participle)
                {
                    continue;
                }
                Pullenti.Semantic.SemLink own = null;
                bool has = false;
                foreach (Pullenti.Semantic.SemLink li in obj.LinksTo)
                {
                    if (li.Typ == Pullenti.Semantic.SemLinkType.Participle)
                    {
                        own = li;
                    }
                    else
                    {
                        has = true;
                    }
                }
                if (!has)
                {
                    continue;
                }
                if (own == null)
                {
                    Pullenti.Semantic.SemObject dum = new Pullenti.Semantic.SemObject(gr)
                    {
                        Typ = Pullenti.Semantic.SemObjectType.Noun
                    };
                    if (obj.Morph != null)
                    {
                        dum.Morph = new Pullenti.Morph.MorphWordForm()
                        {
                            Class = Pullenti.Morph.MorphClass.Noun, Number = obj.Morph.Number, Gender = obj.Morph.Gender, Case = obj.Morph.Case
                        }
                    }
                    ;
                    gr.Objects.Add(dum);
                    own = gr.AddLink(Pullenti.Semantic.SemLinkType.Participle, dum, obj, "какой", false, null);
                    ret = true;
                }
                for (int j = obj.LinksTo.Count - 1; j >= 0; j--)
                {
                    Pullenti.Semantic.SemLink li = obj.LinksTo[j];
                    if (li.Typ == Pullenti.Semantic.SemLinkType.Participle)
                    {
                        continue;
                    }
                    bool exi = false;
                    foreach (Pullenti.Semantic.SemLink ll in li.Source.LinksFrom)
                    {
                        if (ll.Target == own.Source)
                        {
                            exi = true;
                        }
                    }
                    if (exi)
                    {
                        gr.RemoveLink(li);
                    }
                    else
                    {
                        obj.LinksTo.RemoveAt(j);
                        li.m_Target = own.Source;
                    }
                    ret = true;
                }
            }
            return(ret);
        }