Beispiel #1
0
 /// <summary>
 /// Computes the head parses for this parse and its sub-parses and stores this information
 /// in the parse data structure.
 /// </summary>
 /// <param name="rules">
 /// The head rules which determine how the head of the parse is computed.
 /// </param>
 public virtual void UpdateHeads(IHeadRules rules)
 {
     if (_parts != null && _parts.Count != 0)
     {
         for (int currentPart = 0, partCount = _parts.Count; currentPart < partCount; currentPart++)
         {
             Parse currentParse = _parts[currentPart];
             currentParse.UpdateHeads(rules);
         }
         Head = rules.GetHead(_parts.ToArray(), Type) ?? this;
     }
     else
     {
         Head = this;
     }
 }
Beispiel #2
0
 /// <summary>
 /// Computes the head parses for this parse and its sub-parses and stores this information
 /// in the parse data structure.
 /// </summary>
 /// <param name="rules">
 /// The head rules which determine how the head of the parse is computed.
 /// </param>
 public virtual void UpdateHeads(IHeadRules rules)
 {
     if (mParts != null && mParts.Count != 0)
     {
         for (int currentPart = 0, partCount = mParts.Count; currentPart < partCount; currentPart++)
         {
             Parse currentParse = mParts[currentPart];
             currentParse.UpdateHeads(rules);
         }
         mHead = rules.GetHead(mParts.ToArray(), mType);
         if (mHead == null)
         {
             mHead = this;
         }
     }
     else
     {
         mHead = this;
     }
 }
Beispiel #3
0
        private void AddNewEvents()
        {
            string parseString = mDataReader.NextToken();
            //System.Console.WriteLine("ParserEventStream.AddNewEvents: " + parseString);
            List <SharpEntropy.TrainingEvent> events = new List <SharpEntropy.TrainingEvent>();
            Parse rootParse = Parse.FromParseString(parseString);

            rootParse.UpdateHeads(mHeadRules);
            Parse[] chunks = GetInitialChunks(rootParse);
            if (mEventType == EventType.Tag)
            {
                AddTagEvents(events, chunks);
            }
            else if (mEventType == EventType.Chunk)
            {
                AddChunkEvents(events, chunks);
            }
            else
            {
                AddParseEvents(events, chunks);
            }
            mEvents = events.ToArray();
        }