public ILabel NewLabel(ILabel oldLabel) { if (oldLabel is CoreLabel) { return(new CoreLabel((CoreLabel)oldLabel)); } else { //Map the old interfaces to the correct key/value pairs //Don't need to worry about HasIndex, which doesn't appear in any legacy code var label = new CoreLabel(); if (oldLabel is IHasWord) { label.SetWord(((IHasWord)oldLabel).GetWord()); } if (oldLabel is IHasTag) { label.SetTag(((IHasTag)oldLabel).Tag()); } if (oldLabel is IHasOffset) { label.SetBeginPosition(((IHasOffset)oldLabel).BeginPosition()); label.SetEndPosition(((IHasOffset)oldLabel).EndPosition()); } if (oldLabel is IHasCategory) { label.SetCategory(((IHasCategory)oldLabel).Category()); } if (oldLabel is IHasIndex) { label.SetIndex(((IHasIndex)oldLabel).Index()); } label.SetValue(oldLabel.Value()); return(label); } }
/// <summary> /// Construct an IndexedWord from a CoreLabel just as for a CoreMap. /// <i>Implementation note:</i> this is a the same as the constructor /// that takes a CoreMap, but is needed to ensure unique most specific /// type inference for selecting a constructor at compile-time. /// </summary> /// <param name="w">A Label to initialize this IndexedWord from</param> public IndexedWord(CoreLabel w) { label = w; }
/// <summary> /// Default constructor; uses {@link CoreLabel} default constructor /// </summary> public IndexedWord() { label = new CoreLabel(); }
/// <summary> /// Returns a new CoreLabel instance based on the contents of the given /// CoreLabel. It copies the contents of the other CoreLabel. /// <i>Implementation note:</i> this is a the same as the constructor /// that takes a CoreMap, but is needed to ensure unique most specific /// type inference for selecting a constructor at compile-time. /// </summary> /// <param name="label">The CoreLabel to copy</param> public CoreLabel(CoreLabel label) : this((ICoreMap)label) { }
public ILabelFactory LabelFactory() { return(CoreLabel.Factory()); }