public virtual string ToString(CoreLabel.OutputFormat format) { return(reln + "(" + gov.ToString(format) + ", " + dep.ToString(format) + ")"); }
public virtual string ToString(CoreLabel.OutputFormat format) { return(label.ToString(format) + ToPrimes()); }
public string ToString(CoreLabel.OutputFormat format) { return(label.ToString(format)); }
public string ToString(CoreLabel.OutputFormat format) { return(Reln + "(" + Gov.ToString(format) + ", " + Dep.ToString(format) + ")"); }
/// <summary>Returns a formatted string representing this label.</summary> /// <remarks> /// Returns a formatted string representing this label. The /// desired format is passed in as a /// <c>String</c> /// . /// Currently supported formats include: /// <ul> /// <li>"value": just prints the value</li> /// <li>"{map}": prints the complete map</li> /// <li>"value{map}": prints the value followed by the contained /// map (less the map entry containing key /// <c>CATEGORY_KEY</c> /// )</li> /// <li>"value-index": extracts a value and an integer index from /// the contained map using keys /// <c>INDEX_KEY</c> /// , /// respectively, and prints them with a hyphen in between</li> /// <li>"value-tag" /// <li>"value-tag-index" /// <li>"value-index{map}": a combination of the above; the index is /// displayed first and then not shown in the map that is displayed</li> /// <li>"word": Just the value of HEAD_WORD_KEY in the map</li> /// </ul> /// <p> /// Map is printed in alphabetical order of keys. /// </remarks> public virtual string ToString(CoreLabel.OutputFormat format) { StringBuilder buf = new StringBuilder(); switch (format) { case CoreLabel.OutputFormat.Value: { buf.Append(Value()); break; } case CoreLabel.OutputFormat.Map: { IDictionary map2 = new SortedList(); foreach (Type key in this.KeySet()) { map2[key.FullName] = Get(key); } buf.Append(map2); break; } case CoreLabel.OutputFormat.ValueMap: { buf.Append(Value()); IDictionary map2 = new SortedList(asClassComparator); foreach (Type key in this.KeySet()) { map2[key] = Get(key); } Sharpen.Collections.Remove(map2, typeof(CoreAnnotations.ValueAnnotation)); buf.Append(map2); break; } case CoreLabel.OutputFormat.ValueIndex: { buf.Append(Value()); int index = this.Get(typeof(CoreAnnotations.IndexAnnotation)); if (index != null) { buf.Append('-').Append((index)); } break; } case CoreLabel.OutputFormat.ValueTag: { buf.Append(Value()); string tag = Tag(); if (tag != null) { buf.Append(TagSeparator).Append(tag); } break; } case CoreLabel.OutputFormat.ValueTagIndex: { buf.Append(Value()); string tag = Tag(); if (tag != null) { buf.Append(TagSeparator).Append(tag); } int index = this.Get(typeof(CoreAnnotations.IndexAnnotation)); if (index != null) { buf.Append('-').Append((index)); } break; } case CoreLabel.OutputFormat.ValueIndexMap: { buf.Append(Value()); int index = this.Get(typeof(CoreAnnotations.IndexAnnotation)); if (index != null) { buf.Append('-').Append((index)); } IDictionary <string, object> map2 = new SortedDictionary <string, object>(); foreach (Type key in this.KeySet()) { string cls = key.FullName; // special shortening of all the Annotation classes int idx = cls.IndexOf('$'); if (idx >= 0) { cls = Sharpen.Runtime.Substring(cls, idx + 1); } map2[cls] = this.Get(key); } Sharpen.Collections.Remove(map2, "IndexAnnotation"); Sharpen.Collections.Remove(map2, "ValueAnnotation"); if (!map2.IsEmpty()) { buf.Append(map2); } break; } case CoreLabel.OutputFormat.Word: { // TODO: maybe we should unify word() and value(). [cdm 2015] I think not, rather maybe remove value and redefine category. buf.Append(Word()); break; } case CoreLabel.OutputFormat.WordIndex: { buf.Append(this.Get(typeof(CoreAnnotations.TextAnnotation))); int index = this.Get(typeof(CoreAnnotations.IndexAnnotation)); if (index != null) { buf.Append('-').Append((index)); } break; } case CoreLabel.OutputFormat.ValueTagNer: { buf.Append(Value()); string tag = Tag(); if (tag != null) { buf.Append(TagSeparator).Append(tag); } if (Ner() != null) { buf.Append(TagSeparator).Append(Ner()); } break; } case CoreLabel.OutputFormat.LemmaIndex: { buf.Append(Lemma()); int index_1 = this.Get(typeof(CoreAnnotations.IndexAnnotation)); if (index_1 != null) { buf.Append('-').Append((index_1)); } break; } case CoreLabel.OutputFormat.All: { foreach (Type en in this.KeySet()) { buf.Append(';').Append(en).Append(':').Append(this.Get(en)); } break; } default: { throw new ArgumentException("Unknown format " + format); } } return(buf.ToString()); }