You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@manifoldcf.apache.org by kw...@apache.org on 2016/01/27 19:59:01 UTC

svn commit: r1727154 - /manifoldcf/branches/CONNECTORS-1270/connectors/opennlp/connector/src/main/java/org/apache/manifoldcf/agents/transformation/opennlp/OpenNlpExtractor.java

Author: kwright
Date: Wed Jan 27 18:59:01 2016
New Revision: 1727154

URL: http://svn.apache.org/viewvc?rev=1727154&view=rev
Log:
Add getModelList() method to find list of available model files

Modified:
    manifoldcf/branches/CONNECTORS-1270/connectors/opennlp/connector/src/main/java/org/apache/manifoldcf/agents/transformation/opennlp/OpenNlpExtractor.java

Modified: manifoldcf/branches/CONNECTORS-1270/connectors/opennlp/connector/src/main/java/org/apache/manifoldcf/agents/transformation/opennlp/OpenNlpExtractor.java
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-1270/connectors/opennlp/connector/src/main/java/org/apache/manifoldcf/agents/transformation/opennlp/OpenNlpExtractor.java?rev=1727154&r1=1727153&r2=1727154&view=diff
==============================================================================
--- manifoldcf/branches/CONNECTORS-1270/connectors/opennlp/connector/src/main/java/org/apache/manifoldcf/agents/transformation/opennlp/OpenNlpExtractor.java (original)
+++ manifoldcf/branches/CONNECTORS-1270/connectors/opennlp/connector/src/main/java/org/apache/manifoldcf/agents/transformation/opennlp/OpenNlpExtractor.java Wed Jan 27 18:59:01 2016
@@ -40,6 +40,7 @@ import org.apache.manifoldcf.agents.inte
 import org.apache.manifoldcf.agents.interfaces.RepositoryDocument;
 import org.apache.manifoldcf.agents.interfaces.ServiceInterruption;
 import org.apache.manifoldcf.agents.system.Logging;
+import org.apache.manifoldcf.agents.system.ManifoldCF;
 import org.apache.manifoldcf.agents.transformation.BaseTransformationConnector;
 import org.apache.manifoldcf.core.interfaces.IHTTPOutput;
 import org.apache.manifoldcf.core.interfaces.IPostParameters;
@@ -64,9 +65,12 @@ public class OpenNlpExtractor extends Ba
 
   protected static final String[] activitiesList = new String[] { ACTIVITY_EXTRACT };
 
+  protected final File fileDirectory = ManifoldCF.getFileProperty(ManifoldCF.fileResourcesProperty);
+
   /** We handle up to 64K in memory; after that we go to disk. */
   protected static final long inMemoryMaximumFile = 65536;
 
+  
   /**
    * Return a list of activities that this connector generates. The connector
    * does NOT need to be connected before this method is called.
@@ -530,6 +534,23 @@ public class OpenNlpExtractor extends Ba
     throw new ManifoldCFException(e.getMessage(),e);
   }
 
+  protected String[] getModelList() throws ManifoldCFException {
+    if (fileDirectory == null) {
+      return new String[0];
+    }
+    final String[] files = fileDirectory.list(new FileFilter());
+    // Sort it!!
+    java.util.Arrays.sort(files);
+    return files;
+  }
+  
+  protected static class FileFilter implements FilenameFilter {
+    @Override
+    public boolean accept(final File dir, final String name) {
+      return new File(dir, name).isFile();
+    }
+  }
+  
   /** An instance of this class receives characters in 64K chunks, and needs to accumulate
   * extracted metadata that this transformer will pass down.
   */