Exemplo n.º 1
0
        /// <summary>Extracts info about one relation mention</summary>
        private static AceRelationMention ParseRelationMention(INode node, AceDocument doc)
        {
            string     id     = GetAttributeValue(node, "ID");
            AceCharSeq extent = ParseCharSeq(GetChildByName(node, "extent"));
            string     lc     = GetAttributeValue(node, "LEXICALCONDITION");
            // create the mention
            AceRelationMention mention = new AceRelationMention(id, extent, lc);
            // find the mention args
            IList <INode> args = GetChildrenByName(node, "relation_mention_argument");

            foreach (INode arg in args)
            {
                string           role  = GetAttributeValue(arg, "ROLE");
                string           refid = GetAttributeValue(arg, "REFID");
                AceEntityMention am    = doc.GetEntityMention(refid);
                if (am != null)
                {
                    am.AddRelationMention(mention);
                    if (Sharpen.Runtime.EqualsIgnoreCase(role, "arg-1"))
                    {
                        mention.GetArgs()[0] = new AceRelationMentionArgument(role, am);
                    }
                    else
                    {
                        if (Sharpen.Runtime.EqualsIgnoreCase(role, "arg-2"))
                        {
                            mention.GetArgs()[1] = new AceRelationMentionArgument(role, am);
                        }
                        else
                        {
                            throw new Exception("Invalid relation mention argument role: " + role);
                        }
                    }
                }
            }
            return(mention);
        }