コード例 #1
0
 /// <summary>
 /// Copy Constructor - relies on {@link 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.GetWord() == null)
         {
             label.SetWord(label.Value());
         }
     }
 }
コード例 #2
0
ファイル: CoreLabel.cs プロジェクト: finalnlp/OpenNlp-1
            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);
                }
            }
コード例 #3
0
 public void SetWord(string word)
 {
     label.SetWord(word);
 }