ctakes-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dlig...@apache.org
Subject svn commit: r1696838 - /ctakes/sandbox/ctakes-wsd/src/main/java/org/apache/ctakes/index/IndexSentences.java
Date Thu, 20 Aug 2015 18:39:20 GMT
Author: dligach
Date: Thu Aug 20 18:39:20 2015
New Revision: 1696838

URL: http://svn.apache.org/r1696838
Log:
updated for lucene 4.0; disabled stopword list when indexing

Modified:
    ctakes/sandbox/ctakes-wsd/src/main/java/org/apache/ctakes/index/IndexSentences.java

Modified: ctakes/sandbox/ctakes-wsd/src/main/java/org/apache/ctakes/index/IndexSentences.java
URL: http://svn.apache.org/viewvc/ctakes/sandbox/ctakes-wsd/src/main/java/org/apache/ctakes/index/IndexSentences.java?rev=1696838&r1=1696837&r2=1696838&view=diff
==============================================================================
--- ctakes/sandbox/ctakes-wsd/src/main/java/org/apache/ctakes/index/IndexSentences.java (original)
+++ ctakes/sandbox/ctakes-wsd/src/main/java/org/apache/ctakes/index/IndexSentences.java Thu
Aug 20 18:39:20 2015
@@ -25,8 +25,10 @@ import org.apache.ctakes.typesystem.type
 import org.apache.ctakes.utils.Utils;
 import org.apache.lucene.analysis.Analyzer;
 import org.apache.lucene.analysis.standard.StandardAnalyzer;
+import org.apache.lucene.analysis.util.CharArraySet;
 import org.apache.lucene.document.Document;
 import org.apache.lucene.document.Field;
+import org.apache.lucene.document.TextField;
 import org.apache.lucene.index.IndexWriter;
 import org.apache.lucene.index.IndexWriterConfig;
 import org.apache.lucene.store.Directory;
@@ -74,6 +76,9 @@ public class IndexSentences {
    */
   public static class RelationContextPrinter extends JCasAnnotator_ImplBase {
     
+    final static String searchField = "text";
+    final static String indexLocation = "/Users/dima/Boston/Data/DeepPhe/Index/";
+    
     IndexWriter indexWriter;
     
     @Override
@@ -81,8 +86,8 @@ public class IndexSentences {
       
       super.initialize(aContext);
       try {
-        Directory directory = FSDirectory.open(new File("/Users/dima/Boston/Data/DeepPhe/Index"));
-        Analyzer analyzer = new StandardAnalyzer(Version.LUCENE_40);
+        Directory directory = FSDirectory.open(new File(indexLocation));
+        Analyzer analyzer = new StandardAnalyzer(Version.LUCENE_40, CharArraySet.EMPTY_SET);
         IndexWriterConfig indexWriterConfig = new IndexWriterConfig(Version.LUCENE_40, analyzer);
         indexWriter = new IndexWriter(directory, indexWriterConfig);
       } catch (IOException e) {
@@ -108,7 +113,8 @@ public class IndexSentences {
         Document document = new Document();
         String withLineBreaks = sentence.getCoveredText();
         String noLineBreaks = withLineBreaks.replace("\n", " ");
-        document.add(new Field("content", noLineBreaks, Field.Store.YES, Field.Index.ANALYZED,
Field.TermVector.YES));
+        // document.add(new Field("content", noLineBreaks, Field.Store.YES, Field.Index.ANALYZED,
Field.TermVector.YES));
+        document.add(new Field(searchField, noLineBreaks, TextField.TYPE_STORED));
         try {
           indexWriter.addDocument(document);
         } catch (IOException e) {



Mime
View raw message