You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@opennlp.apache.org by jo...@apache.org on 2012/03/30 15:11:03 UTC

svn commit: r1307395 - in /opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools: cmdline/StreamFactoryRegistry.java formats/CorefSampleStreamFactory.java

Author: joern
Date: Fri Mar 30 13:11:03 2012
New Revision: 1307395

URL: http://svn.apache.org/viewvc?rev=1307395&view=rev
Log:
OPENNLP-486 Added a factory to produce the default Coref Sample stream.

Added:
    opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/formats/CorefSampleStreamFactory.java   (with props)
Modified:
    opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/cmdline/StreamFactoryRegistry.java

Modified: opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/cmdline/StreamFactoryRegistry.java
URL: http://svn.apache.org/viewvc/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/cmdline/StreamFactoryRegistry.java?rev=1307395&r1=1307394&r2=1307395&view=diff
==============================================================================
--- opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/cmdline/StreamFactoryRegistry.java (original)
+++ opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/cmdline/StreamFactoryRegistry.java Fri Mar 30 13:11:03 2012
@@ -17,12 +17,34 @@
 
 package opennlp.tools.cmdline;
 
-import opennlp.tools.formats.*;
-import opennlp.tools.formats.ad.*;
-
 import java.util.HashMap;
 import java.util.Map;
 
+import opennlp.tools.formats.BioNLP2004NameSampleStreamFactory;
+import opennlp.tools.formats.ChunkerSampleStreamFactory;
+import opennlp.tools.formats.Conll02NameSampleStreamFactory;
+import opennlp.tools.formats.Conll03NameSampleStreamFactory;
+import opennlp.tools.formats.ConllXPOSSampleStreamFactory;
+import opennlp.tools.formats.ConllXSentenceSampleStreamFactory;
+import opennlp.tools.formats.ConllXTokenSampleStreamFactory;
+import opennlp.tools.formats.CorefSampleStreamFactory;
+import opennlp.tools.formats.DocumentSampleStreamFactory;
+import opennlp.tools.formats.LeipzigDocumentSampleStreamFactory;
+import opennlp.tools.formats.NameSampleDataStreamFactory;
+import opennlp.tools.formats.NameToSentenceSampleStreamFactory;
+import opennlp.tools.formats.NameToTokenSampleStreamFactory;
+import opennlp.tools.formats.POSToSentenceSampleStreamFactory;
+import opennlp.tools.formats.POSToTokenSampleStreamFactory;
+import opennlp.tools.formats.ParseSampleStreamFactory;
+import opennlp.tools.formats.SentenceSampleStreamFactory;
+import opennlp.tools.formats.TokenSampleStreamFactory;
+import opennlp.tools.formats.WordTagSampleStreamFactory;
+import opennlp.tools.formats.ad.ADChunkSampleStreamFactory;
+import opennlp.tools.formats.ad.ADNameSampleStreamFactory;
+import opennlp.tools.formats.ad.ADPOSSampleStreamFactory;
+import opennlp.tools.formats.ad.ADSentenceSampleStreamFactory;
+import opennlp.tools.formats.ad.ADTokenSampleStreamFactory;
+
 /**
  * Registry for object stream factories.
  */
@@ -39,7 +61,8 @@ public final class StreamFactoryRegistry
     SentenceSampleStreamFactory.registerFactory();
     TokenSampleStreamFactory.registerFactory();
     WordTagSampleStreamFactory.registerFactory();
-
+    CorefSampleStreamFactory.registerFactory();
+    
     NameToSentenceSampleStreamFactory.registerFactory();
     NameToTokenSampleStreamFactory.registerFactory();
     POSToSentenceSampleStreamFactory.registerFactory();

Added: opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/formats/CorefSampleStreamFactory.java
URL: http://svn.apache.org/viewvc/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/formats/CorefSampleStreamFactory.java?rev=1307395&view=auto
==============================================================================
--- opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/formats/CorefSampleStreamFactory.java (added)
+++ opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/formats/CorefSampleStreamFactory.java Fri Mar 30 13:11:03 2012
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package opennlp.tools.formats;
+
+import java.io.FileInputStream;
+
+import opennlp.tools.cmdline.ArgumentParser;
+import opennlp.tools.cmdline.CmdLineUtil;
+import opennlp.tools.cmdline.StreamFactoryRegistry;
+import opennlp.tools.cmdline.params.LanguageFormatParams;
+import opennlp.tools.coref.CorefSample;
+import opennlp.tools.coref.CorefSampleDataStream;
+import opennlp.tools.util.ObjectStream;
+import opennlp.tools.util.ParagraphStream;
+import opennlp.tools.util.PlainTextByLineStream;
+
+public class CorefSampleStreamFactory extends LanguageSampleStreamFactory<CorefSample> {
+
+  interface Parameters extends LanguageFormatParams {
+  }
+  
+  protected CorefSampleStreamFactory() {
+    super(Parameters.class);
+  }
+
+  public static void registerFactory() {
+    StreamFactoryRegistry.registerFactory(CorefSample.class,
+        StreamFactoryRegistry.DEFAULT_FORMAT, new CorefSampleStreamFactory());
+  }
+  
+  public ObjectStream<CorefSample> create(String[] args) {
+    Parameters params = ArgumentParser.parse(args, Parameters.class);
+
+    language = params.getLang();
+
+    CmdLineUtil.checkInputFile("Data", params.getData());
+    FileInputStream sampleDataIn = CmdLineUtil.openInFile(params.getData());
+
+    ObjectStream<String> lineStream = new ParagraphStream(new PlainTextByLineStream(sampleDataIn
+        .getChannel(), params.getEncoding()));
+
+    return new CorefSampleDataStream(lineStream);
+  }
+}

Propchange: opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/formats/CorefSampleStreamFactory.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain