Exemple #1
0
 /// <summary>
 /// Returns true if the specified span intersects with this span.
 /// </summary>
 /// <param name="span">
 /// The span to compare with this span. 
 /// </param>
 /// <returns>
 /// true is the spans overlap; false otherwise. 
 /// </returns>
 public bool Intersects(Span span)
 {
     int spanStart = span.Start;
     //either span's start is in this or this's start is in span
     return (this.Contains(span) || span.Contains(this) ||
         (mStart <= spanStart && spanStart < mEnd ||
         spanStart <= mStart && mStart < span.End));
 }
        private void AddNames(string tag, List<Span>names, Parse[] tokens, Parse lineParse)
        {
            for (int currentName = 0, nameCount = names.Count; currentName < nameCount; currentName++)
            {
                Span nameTokenSpan = names[currentName];
                Parse startToken = tokens[nameTokenSpan.Start];
                Parse endToken = tokens[nameTokenSpan.End];
                Parse commonParent = startToken.GetCommonParent(endToken);

                if (commonParent != null)
                {
                    Span nameSpan = new Span(startToken.Span.Start, endToken.Span.End);
                    if (nameSpan.Equals(commonParent.Span))
                    {

                        commonParent.Insert(new Parse(commonParent.Text, nameSpan, tag, 1.0));
                    }
                    else
                    {
                        Parse[] kids = commonParent.GetChildren();
                        bool crossingKids = false;
                        for (int currentKid = 0, kidCount = kids.Length; currentKid < kidCount; currentKid++)
                        {
                            if (nameSpan.Crosses(kids[currentKid].Span))
                            {
                                crossingKids = true;
                            }
                        }
                        if (!crossingKids)
                        {
                            commonParent.Insert(new Parse(commonParent.Text, nameSpan, tag, 1.0));
                        }
                        else
                        {
                            if (commonParent.Type == "NP")
                            {
                                Parse[] grandKids = kids[0].GetChildren();
                                if (grandKids.Length > 1 && nameSpan.Contains(grandKids[grandKids.Length - 1].Span))
                                {
                                    commonParent.Insert(new Parse(commonParent.Text, commonParent.Span, tag, 1.0));
                                }
                            }
                        }
                    }

                }
            }
        }
Exemple #3
0
 /// <summary>
 /// Returns true if the specified span crosses this span.
 /// </summary>
 /// <param name="span">
 /// The span to compare with this span.
 /// </param>
 /// <returns>
 /// true if the specified span overlaps this span and contains a non-overlapping section; false otherwise.
 /// </returns>
 public bool Crosses(Span span)
 {
     int spanStart = span.Start;
     //either span's Start is in this or this's Start is in span
     return (!this.Contains(span) && !span.Contains(this) &&
         (mStart <= spanStart && spanStart < mEnd ||
         spanStart <= mStart && mStart < span.End));
 }