/// <summary> /// Copy Constructor - relies on /// <see cref="CoreLabel"/> /// copy constructor /// It will set the value, and if the word is not set otherwise, set /// the word to the value. /// </summary> /// <param name="w">A Label to initialize this IndexedWord from</param> public IndexedWord(ILabel w) { if (w is CoreLabel) { this.label = (CoreLabel)w; } else { label = new CoreLabel(w); if (label.Word() == null) { label.SetWord(label.Value()); } } }
public virtual string Word() { return(label.Word()); }
public static string WordToString <T>(T o, bool justValue, string separator) { if (justValue && o is ILabel) { if (o is CoreLabel) { CoreLabel l = (CoreLabel)o; string w = l.Value(); if (w == null) { w = l.Word(); } return(w); } else { return(((ILabel)o).Value()); } } else { if (o is CoreLabel) { CoreLabel l = ((CoreLabel)o); string w = l.Value(); if (w == null) { w = l.Word(); } if (l.Tag() != null) { if (separator == null) { return(w + CoreLabel.TagSeparator + l.Tag()); } else { return(w + separator + l.Tag()); } } return(w); } else { // an interface that covered these next four cases would be // nice, but we're moving away from these data types anyway if (separator != null && o is TaggedWord) { return(((TaggedWord)o).ToString(separator)); } else { if (separator != null && o is LabeledWord) { return(((LabeledWord)o).ToString(separator)); } else { if (separator != null && o is WordLemmaTag) { return(((WordLemmaTag)o).ToString(separator)); } else { if (separator != null && o is WordTag) { return(((WordTag)o).ToString(separator)); } else { return(o.ToString()); } } } } } } }