protected internal override bool ValidOutcome(string outcome, Util.Sequence sequence) { if (_continueStartMap.ContainsKey(outcome)) { string[] tags = sequence.Outcomes.ToArray(); int lastTagIndex = tags.Length - 1; if (lastTagIndex == -1) { return(false); } else { string lastTag = tags[lastTagIndex]; if (lastTag == outcome) { return(true); } if (lastTag == _continueStartMap[outcome]) { return(true); } if (lastTag == MaximumEntropyParser.OtherOutcome) { return(false); } return(false); } } return(true); }
/// <summary> /// This method determines whether the outcome is valid for the preceding sequence. /// This can be used to implement constraints on what sequences are valid. /// </summary> /// <param name="outcome"> /// The outcome. /// </param> /// <param name="sequence"> /// The preceding sequence of outcome assignments. /// </param> /// <returns> /// true if the outcome is valid for the sequence, false otherwise. /// </returns> protected internal override bool ValidOutcome(string outcome, Util.Sequence sequence) { if (outcome.StartsWith("I-")) { string[] tags = sequence.Outcomes.ToArray(); int lastTagIndex = tags.Length - 1; if (lastTagIndex == -1) { return(false); } else { string lastTag = tags[lastTagIndex]; if (lastTag == "O") { return(false); } if (lastTag.Substring(2) != outcome.Substring(2)) { return(false); } } } return(true); }
public virtual ArrayList Tag(ArrayList tokens) { if (mUnicodeMapping) { MapUnicodeCharsInTokens(tokens); } mBestSequence = Beam.BestSequence(tokens, null); return(new ArrayList(mBestSequence.Outcomes)); }
public virtual string[] Tag(string[] _tokens) { ArrayList tokens = new ArrayList(_tokens); if (mUnicodeMapping) { MapUnicodeCharsInTokens(tokens); } mBestSequence = Beam.BestSequence(tokens, null); return(mBestSequence.Outcomes.ToArray()); }
/// <summary> /// This method determines whether the outcome is valid for the preceding sequence. /// This can be used to implement constraints on what sequences are valid. /// </summary> /// <param name="outcome"> /// The outcome. /// </param> /// <param name="sequence"> /// The preceding sequence of outcome assignments. /// </param> /// <returns> /// true if the outcome is valid for the sequence, false otherwise. /// </returns> protected override bool ValidOutcome(string outcome, Util.Sequence sequence) { if (outcome.StartsWith("I-", StringComparison.Ordinal)) { var tags = sequence.Outcomes.ToArray(); var lastTagIndex = tags.Length - 1; if (lastTagIndex == -1) { return(false); } var lastTag = tags[lastTagIndex]; if (lastTag == "O") { return(false); } if (lastTag.Substring(2) != outcome.Substring(2)) { return(false); } } return(true); }
/// <summary> /// Performs a chunking operation. /// </summary> /// <param name="tokens"> /// Object array of tokens /// </param> /// <param name="tags"> /// String array of POS tags corresponding to the tokens in the object array /// </param> /// <returns> /// String array containing a value for each token, indicating the chunk that that token belongs to. /// </returns> public virtual string[] Chunk(object[] tokens, string[] tags) { mBestSequence = mBeam.BestSequence(new ArrayList(tokens), new object[] { tags }); return(mBestSequence.Outcomes.ToArray()); }
/// <summary> /// Performs a chunking operation. /// </summary> /// <param name="tokens"> /// ArrayList of tokens /// </param> /// <param name="tags"> /// ArrayList of tags corresponding to the tokens /// </param> /// <returns> /// ArrayList of results, containing a value for each token, indicating the chunk that that token belongs to. /// </returns> public virtual ArrayList Chunk(ArrayList tokens, ArrayList tags) { mBestSequence = mBeam.BestSequence(tokens, new object[] { (string[])tags.ToArray(typeof(string)) }); return(new ArrayList(mBestSequence.Outcomes)); }
public virtual string[] Tag(string[] _tokens) { ArrayList tokens = new ArrayList(_tokens); if (mUnicodeMapping) { MapUnicodeCharsInTokens(tokens); } mBestSequence = Beam.BestSequence(tokens, null); return mBestSequence.Outcomes.ToArray(); }
public virtual ArrayList Tag(ArrayList tokens) { if (mUnicodeMapping) { MapUnicodeCharsInTokens(tokens); } mBestSequence = Beam.BestSequence(tokens, null); return new ArrayList(mBestSequence.Outcomes); }
/// <summary> /// Performs a chunking operation. /// </summary> /// <param name="tokens"> /// ArrayList of tokens /// </param> /// <param name="tags"> /// ArrayList of tags corresponding to the tokens /// </param> /// <returns> /// ArrayList of results, containing a value for each token, indicating the chunk that that token belongs to. /// </returns> public virtual ArrayList Chunk(ArrayList tokens, ArrayList tags) { mBestSequence = mBeam.BestSequence(tokens, new object[] { (string[]) tags.ToArray(typeof(string)) }); return new ArrayList(mBestSequence.Outcomes); }
protected internal override bool ValidSequence(int index, ArrayList inputSequence, Util.Sequence outcomesSequence, string outcome) { if (_maxentPosTagger.TagDictionary == null) { return(true); } else { string[] tags = _maxentPosTagger.TagDictionary.GetTags(inputSequence[index].ToString()); if (tags == null) { return(true); } else { return(new ArrayList(tags).Contains(outcome)); } } }
// Methods ---------------- /// <summary>Performs a chunking operation</summary> /// <param name="tokens">Object array of tokens</param> /// <param name="tags">string array of POS tags corresponding to the tokens in the object array</param> /// <returns>string array containing a value for each token, indicating the chunk that that token belongs to</returns> public virtual string[] Chunk(string[] tokens, string[] tags) { _bestSequence = Beam.BestSequence(tokens, new object[]{tags}); return _bestSequence.Outcomes.ToArray(); }
// Methods ---------------- /// <summary>Performs a chunking operation</summary> /// <param name="tokens">Object array of tokens</param> /// <param name="tags">string array of POS tags corresponding to the tokens in the object array</param> /// <returns>string array containing a value for each token, indicating the chunk that that token belongs to</returns> public virtual string[] Chunk(string[] tokens, string[] tags) { _bestSequence = Beam.BestSequence(tokens, new object[] { tags }); return(_bestSequence.Outcomes.ToArray()); }
/// Stream of training events /// </param> /// <param name="iterations"> /// number of training iterations to perform. /// </param>
} /// <summary> /// Trains a POS tag maximum entropy model. /// </summary>
public virtual string[] Tag(string[] tokens) { mBestSequence = Beam.BestSequence(new ArrayList(tokens), null); return mBestSequence.Outcomes.ToArray(); }
public virtual ArrayList Tag(ArrayList tokens) { mBestSequence = Beam.BestSequence(tokens, null); return new ArrayList(mBestSequence.Outcomes); }
/// <summary> /// Performs a chunking operation. /// </summary> /// <param name="tokens"> /// Object array of tokens /// </param> /// <param name="tags"> /// String array of POS tags corresponding to the tokens in the object array /// </param> /// <returns> /// String array containing a value for each token, indicating the chunk that that token belongs to. /// </returns> public virtual string[] Chunk(object[] tokens, string[] tags) { mBestSequence = mBeam.BestSequence(new ArrayList(tokens), new object[]{tags}); return mBestSequence.Outcomes.ToArray(); }
/// <summary> /// This method determines wheter the outcome is valid for the preceding sequence. /// This can be used to implement constraints on what sequences are valid. /// </summary> /// <param name="outcome"> /// The outcome. /// </param> /// <param name="sequence"> /// The preceding sequence of outcomes assignments. /// </param> /// <returns> /// true if the outcome is valid for the sequence, false otherwise. /// </returns> protected internal virtual bool ValidOutcome(string outcome, Util.Sequence sequence) { return(true); }
protected internal override bool ValidSequence(int index, ArrayList inputSequence, Util.Sequence outcomesSequence, string outcome) { return(mMaxentChunker.ValidOutcome(outcome, outcomesSequence)); }
/// <summary> /// Associates tags to a collection of tokens. /// This collection of tokens should represent a sentence. /// </summary> /// <param name="tokens">The collection of tokens as strings</param> /// <returns>The collection of tags as strings</returns> public virtual string[] Tag(string[] tokens) { _bestSequence = Beam.BestSequence(tokens, null); return(_bestSequence.Outcomes.ToArray()); }
/// <summary> /// Associates tags to a collection of tokens. /// This collection of tokens should represent a sentence. /// </summary> /// <param name="tokens">The collection of tokens as strings</param> /// <returns>The collection of tags as strings</returns> public virtual string[] Tag(string[] tokens) { _bestSequence = Beam.BestSequence(tokens, null); return _bestSequence.Outcomes.ToArray(); }
public virtual string[] GetContext(int index, List <string> sequence, Util.Sequence outcomesSequence, object[] additionalContext) { return(GetContext(index, sequence, outcomesSequence.Outcomes, (IDictionary <string, string>)additionalContext[0])); }