Ejemplo n.º 1
0
 /// <summary>Compares the labels of the two mentions</summary>
 /// <param name="otherEnt"/>
 /// <param name="useSubType"/>
 public virtual bool LabelEquals(Edu.Stanford.Nlp.IE.Machinereading.Structure.EntityMention otherEnt, bool useSubType)
 {
     if (((type != null && otherEnt.type != null && type.Equals(otherEnt.type)) || (type == null && otherEnt.type == null)) && (!useSubType || ((subType != null && otherEnt.subType != null && subType.Equals(otherEnt.subType)) || (subType == null &&
                                                                                                                                                                                                                                      otherEnt.subType == null))))
     {
         return(true);
     }
     return(false);
 }
Ejemplo n.º 2
0
 /*
  * @Override
  * public boolean equals(Object other) {
  * if(! (other instanceof EntityMention)) return false;
  * ExtractionObject o = (ExtractionObject) other;
  * if(o.objectId.equals(objectId) && o.sentence == sentence) return true;
  * return false;
  * }
  */
 public override bool Equals(object other)
 {
     if (!(other is Edu.Stanford.Nlp.IE.Machinereading.Structure.EntityMention))
     {
         return(false);
     }
     Edu.Stanford.Nlp.IE.Machinereading.Structure.EntityMention otherEnt = (Edu.Stanford.Nlp.IE.Machinereading.Structure.EntityMention)other;
     return(Equals(otherEnt, true));
 }
Ejemplo n.º 3
0
 /// <summary>Compares the text spans of the two entity mentions.</summary>
 /// <param name="otherEnt"/>
 public virtual bool TextEquals(Edu.Stanford.Nlp.IE.Machinereading.Structure.EntityMention otherEnt)
 {
     //
     // we attempt three comparisons:
     // a) if syntactic heads are defined we consider two texts similar if they have the same syntactic head
     //    (this is necessary because in NFL we compare entities with different spans but same heads, e.g. "49ers" vs "San Francisco 49ers"
     // b) if head spans are defined we consider two texts similar if they have the same head span
     // c) if extent spans are defined we consider two texts similar if they have the same extent span
     //
     if (syntacticHeadTokenPosition != -1 && otherEnt.syntacticHeadTokenPosition != -1)
     {
         if (syntacticHeadTokenPosition == otherEnt.syntacticHeadTokenPosition)
         {
             return(true);
         }
         return(false);
     }
     if (headTokenSpan != null && otherEnt.headTokenSpan != null)
     {
         if (headTokenSpan.Equals(otherEnt.headTokenSpan))
         {
             return(true);
         }
         return(false);
     }
     if (extentTokenSpan != null && otherEnt.extentTokenSpan != null)
     {
         if (extentTokenSpan.Equals(otherEnt.extentTokenSpan))
         {
             return(true);
         }
         return(false);
     }
     if (!this.GetExtentString().Equals(otherEnt.GetExtentString()))
     {
         return(false);
     }
     return(false);
 }
Ejemplo n.º 4
0
        public virtual bool Equals(Edu.Stanford.Nlp.IE.Machinereading.Structure.EntityMention otherEnt, bool useSubType)
        {
            //
            // two mentions are equal if they are over the same sentence,
            // have the same head span, the same type/subtype, and the same text.
            // We need this for scoring NER, and in various places in KBP
            //
            if (sentence.Get(typeof(CoreAnnotations.TextAnnotation)).Equals(otherEnt.sentence.Get(typeof(CoreAnnotations.TextAnnotation))) && TextEquals(otherEnt) && LabelEquals(otherEnt, useSubType))
            {
                return(true);
            }

            /*
             * if(((headTokenSpan != null && headTokenSpan.equals(otherEnt.headTokenSpan)) ||
             * (extentTokenSpan != null && extentTokenSpan.equals(otherEnt.extentTokenSpan))) &&
             * ((type != null && otherEnt.type != null && type.equals(otherEnt.type)) || (type == null && otherEnt.type == null)) &&
             * (! useSubType || ((subType != null && otherEnt.subType != null && subType.equals(otherEnt.subType)) || (subType == null && otherEnt.subType == null))) &&
             * AnnotationUtils.getTextContent(sentence, headTokenSpan).equals(AnnotationUtils.getTextContent(otherEnt.getSentence(), otherEnt.headTokenSpan))){
             * return true;
             * }
             */
            return(false);
        }
Ejemplo n.º 5
0
 public virtual bool HeadIncludes(Edu.Stanford.Nlp.IE.Machinereading.Structure.EntityMention otherEnt, bool useSubType)
 {
     return(otherEnt.GetSyntacticHeadTokenPosition() >= GetHeadTokenStart() && otherEnt.GetSyntacticHeadTokenPosition() < GetHeadTokenEnd() && ((type != null && otherEnt.type != null && type.Equals(otherEnt.type)) || (type == null && otherEnt.type
                                                                                                                                                                                                                          == null)) && (!useSubType || ((subType != null && otherEnt.subType != null && subType.Equals(otherEnt.subType)) || (subType == null && otherEnt.subType == null))));
 }