protected internal override void Add(IList <CoreLabel> tokens, string sentid, bool addProcessedText)
 {
     try
     {
         SetIndexWriter();
         Org.Apache.Lucene.Document.Document doc = new Org.Apache.Lucene.Document.Document();
         foreach (CoreLabel l in tokens)
         {
             foreach (KeyValuePair <string, string> en in transformCoreLabeltoString.Apply(l))
             {
                 doc.Add(new StringField(en.Key, en.Value, Field.Store.Yes));
             }
             //, ANALYZED));
             if (addProcessedText)
             {
                 string ptxt = l.Get(typeof(PatternsAnnotations.ProcessedTextAnnotation));
                 if (!stopWords.Contains(ptxt.ToLower()))
                 {
                     doc.Add(new StringField(Token.GetKeyForClass(typeof(PatternsAnnotations.ProcessedTextAnnotation)), ptxt, Field.Store.Yes));
                 }
             }
         }
         //, ANALYZED));
         doc.Add(new StringField("sentid", sentid, Field.Store.Yes));
         if (tokens != null && saveTokens)
         {
             doc.Add(new Field("tokens", GetProtoBufAnnotation(tokens), LuceneFieldType.NotIndexed));
         }
         indexWriter.AddDocument(doc);
     }
     catch (IOException e)
     {
         throw new Exception(e);
     }
 }
 private void AddPatterns(string id, IDictionary <int, ICollection <E> > p, bool commit)
 {
     try
     {
         SetIndexWriter();
         Org.Apache.Lucene.Document.Document doc = new Org.Apache.Lucene.Document.Document();
         doc.Add(new StringField("sentid", id, Field.Store.Yes));
         doc.Add(new Field("patterns", GetBytes(p), LuceneFieldType.NotIndexed));
         indexWriter.AddDocument(doc);
         if (commit)
         {
             indexWriter.Commit();
         }
     }
     catch (IOException e)
     {
         //closeIndexWriter();
         throw new Exception(e);
     }
 }