Author: rwesten
Date: Tue Jun 16 12:29:06 2015
New Revision: 1685794

URL: http://svn.apache.org/r1685794
Log:
minor: Storing an FST with no entries caused an NPE. Now it is checked if their 
are phrases present. If not the built FST is ignored. NOTE: This can happen if 
their are labels for a language, but all such labels are fully removed by the 
configured Analyzers

Modified:
    
stanbol/trunk/entityhub/indexing/destination/solryard/src/main/java/org/apache/stanbol/entityhub/indexing/destination/solryard/fst/CorpusCreationTask.java

Modified: 
stanbol/trunk/entityhub/indexing/destination/solryard/src/main/java/org/apache/stanbol/entityhub/indexing/destination/solryard/fst/CorpusCreationTask.java
URL: 
http://svn.apache.org/viewvc/stanbol/trunk/entityhub/indexing/destination/solryard/src/main/java/org/apache/stanbol/entityhub/indexing/destination/solryard/fst/CorpusCreationTask.java?rev=1685794&r1=1685793&r2=1685794&view=diff
==============================================================================
--- 
stanbol/trunk/entityhub/indexing/destination/solryard/src/main/java/org/apache/stanbol/entityhub/indexing/destination/solryard/fst/CorpusCreationTask.java
 (original)
+++ 
stanbol/trunk/entityhub/indexing/destination/solryard/src/main/java/org/apache/stanbol/entityhub/indexing/destination/solryard/fst/CorpusCreationTask.java
 Tue Jun 16 12:29:06 2015
@@ -72,11 +72,15 @@ public class CorpusCreationTask implemen
                 log.warn("Unable to delete existing FST fiel for 
{}",corpusInfo);
             }
         }
-        try {
-            corpus.save(corpusInfo.fst);
-        } catch (IOException e) {
-            log.warn("Unable to store FST corpus " + corpusInfo + " to "
-                    + corpusInfo.fst.getAbsolutePath() + "!", e);
+        if(corpus.getPhrases() != null){ //the FST is not empty
+            try { //NOTE saving an empty corpus results in a NPE
+                corpus.save(corpusInfo.fst);
+            } catch (IOException e) {
+                log.warn("Unable to store FST corpus " + corpusInfo + " to "
+                        + corpusInfo.fst.getAbsolutePath() + "!", e);
+            }
+        } else {
+           log.info("FST for {} is empty ... no FST will be 
stored",corpusInfo); 
         }
     }
     


Reply via email to