Exemple #1
0
 /// <summary>
 /// Constructor for setting docID, sentenceIndex, and
 /// index without any other annotations.
 /// </summary>
 /// <param name="docID">The document ID (arbitrary string)</param>
 /// <param name="sentenceIndex">The sentence number in the document (normally 0-based)</param>
 /// <param name="index">The index of the word in the sentence (normally 0-based)</param>
 public IndexedWord(string docID, int sentenceIndex, int index)
 {
     label = new CoreLabel();
     label.Set(typeof(CoreAnnotations.DocIDAnnotation), docID);
     label.Set(typeof(CoreAnnotations.SentenceIndexAnnotation), sentenceIndex);
     label.Set(typeof(CoreAnnotations.IndexAnnotation), index);
 }
        public static IList <CoreLabel> ToCoreLabelListWithCharacterOffsets(string[] words, string[] tags)
        {
            System.Diagnostics.Debug.Assert(tags.Length == words.Length);
            IList <CoreLabel> tokens = new List <CoreLabel>(words.Length);
            int offset = 0;

            for (int i = 0; i < sz; i++)
            {
                CoreLabel cl = new CoreLabel();
                cl.SetWord(words[i]);
                cl.SetTag(tags[i]);
                cl.Set(typeof(CoreAnnotations.CharacterOffsetBeginAnnotation), offset);
                offset += words[i].Length;
                cl.Set(typeof(CoreAnnotations.CharacterOffsetEndAnnotation), offset);
                offset++;
                // assume one space between words :-)
                tokens.Add(cl);
            }
            return(tokens);
        }
        public static IList <CoreLabel> ToCoreLabelList(string[] words, string[] tags, string[] answers)
        {
            System.Diagnostics.Debug.Assert(tags.Length == words.Length);
            System.Diagnostics.Debug.Assert(answers.Length == words.Length);
            IList <CoreLabel> tokens = new List <CoreLabel>(words.Length);

            for (int i = 0; i < sz; i++)
            {
                CoreLabel cl = new CoreLabel();
                cl.SetWord(words[i]);
                cl.SetTag(tags[i]);
                cl.Set(typeof(CoreAnnotations.AnswerAnnotation), answers[i]);
                tokens.Add(cl);
            }
            return(tokens);
        }
Exemple #4
0
 public virtual VALUE Set <Value>(Type key, VALUE value)
 {
     return(label.Set(key, value));
 }