/// <summary>Extracts one entity mention</summary>
        private static AceEntityMention ParseEntityMention(INode node)
        {
            string     id      = GetAttributeValue(node, "ID");
            string     type    = GetAttributeValue(node, "TYPE");
            string     ldctype = GetAttributeValue(node, "LDCTYPE");
            AceCharSeq extent  = ParseCharSeq(GetChildByName(node, "extent"));
            AceCharSeq head    = ParseCharSeq(GetChildByName(node, "head"));

            return(new AceEntityMention(id, type, ldctype, extent, head));
        }
示例#2
0
 public AceEntityMention(string id, string type, string ldctype, AceCharSeq extent, AceCharSeq head)
     : base(id, extent)
 {
     mType              = type;
     mLdctype           = ldctype;
     mHead              = head;
     mExtent            = extent;
     mHeadTokenPosition = -1;
     mParent            = null;
     mRelationMentions  = new List <AceRelationMention>();
     mEventMentions     = new List <AceEventMention>();
 }
        // buf.toString(),
        /// <summary>Makes an ACE entity from the span [startToken, endToken)</summary>
        private void MakeEntity(int startToken, int endToken, int id, string type, string subtype)
        {
            string    eid = mId + "-E" + id;
            AceEntity ent = new AceEntity(eid, type, subtype, "SPC");

            AddEntity(ent);
            AceCharSeq       cseq = MakeCharSeq(startToken, endToken);
            string           emid = mId + "-E" + id + "-1";
            AceEntityMention entm = new AceEntityMention(emid, "NOM", "NOM", cseq, cseq);

            AddEntityMention(entm);
            ent.AddMention(entm);
        }
        public virtual string ToXml(int offset)
        {
            StringBuilder buffer = new StringBuilder();

            AceElement.AppendOffset(buffer, offset);
            buffer.Append("<" + mentionType + "_mention_argument REFID=\"" + mContent.GetId() + "\" ROLE=\"" + mRole + "\">\n");
            //buffer.append(getContent().toXml(offset + 2));
            AceCharSeq ext = GetContent().GetExtent();

            buffer.Append(ext.ToXml("extent", offset + 2));
            buffer.Append("\n");
            AceElement.AppendOffset(buffer, offset);
            buffer.Append("</" + mentionType + "_mention_argument>");
            return(buffer.ToString());
        }
        /// <summary>Extracts info about one relation mention</summary>
        private static AceEventMention ParseEventMention(INode node, AceDocument doc)
        {
            string     id     = GetAttributeValue(node, "ID");
            AceCharSeq extent = ParseCharSeq(GetChildByName(node, "extent"));
            AceCharSeq anchor = ParseCharSeq(GetChildByName(node, "anchor"));
            // create the mention
            AceEventMention mention = new AceEventMention(id, extent, anchor);
            // find the mention args
            IList <INode> args = GetChildrenByName(node, "event_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.AddEventMention(mention);
                    mention.AddArg(am, role);
                }
            }
            return(mention);
        }
        /// <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);
        }
 protected internal AceMention(string id, AceCharSeq extent)
     : base(id)
 {
     mExtent = extent;
 }
示例#8
0
 public AceRelationMention(string id, AceCharSeq extent, string lc)
     : base(id, extent)
 {
     mLexicalCondition = lc;
     mArguments        = new AceRelationMentionArgument[2];
 }
示例#9
0
 public virtual void SetAnchor(AceCharSeq anchor)
 {
     mAnchor = anchor;
 }
示例#10
0
 public AceEventMention(string id, AceCharSeq extent, AceCharSeq anchor)
     : base(id, extent)
 {
     mRolesToArguments = Generics.NewHashMap();
     this.mAnchor      = anchor;
 }