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 2011/05/25 09:35:46 UTC

svn commit: r1127413 - in /incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools: namefind/DefaultNameContextGenerator.java namefind/NameFinderME.java util/featuregen/BigramNameFeatureGenerator.java

Author: joern
Date: Wed May 25 07:35:46 2011
New Revision: 1127413

URL: http://svn.apache.org/viewvc?rev=1127413&view=rev
Log:
OPENNLP-184 Moved BigramNameFeatureGenerator to feature gen package

Added:
    incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/util/featuregen/BigramNameFeatureGenerator.java   (with props)
Modified:
    incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/namefind/DefaultNameContextGenerator.java
    incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/namefind/NameFinderME.java

Modified: incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/namefind/DefaultNameContextGenerator.java
URL: http://svn.apache.org/viewvc/incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/namefind/DefaultNameContextGenerator.java?rev=1127413&r1=1127412&r2=1127413&view=diff
==============================================================================
--- incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/namefind/DefaultNameContextGenerator.java (original)
+++ incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/namefind/DefaultNameContextGenerator.java Wed May 25 07:35:46 2011
@@ -21,8 +21,8 @@ import java.util.ArrayList;
 import java.util.List;
 
 import opennlp.tools.util.featuregen.AdaptiveFeatureGenerator;
+import opennlp.tools.util.featuregen.BigramNameFeatureGenerator;
 import opennlp.tools.util.featuregen.CachedFeatureGenerator;
-import opennlp.tools.util.featuregen.FeatureGeneratorAdapter;
 import opennlp.tools.util.featuregen.FeatureGeneratorUtil;
 import opennlp.tools.util.featuregen.OutcomePriorFeatureGenerator;
 import opennlp.tools.util.featuregen.PreviousMapFeatureGenerator;
@@ -135,22 +135,4 @@ public class DefaultNameContextGenerator
 
     return features.toArray(new String[features.size()]);
   }
-}
-
-class BigramNameFeatureGenerator extends FeatureGeneratorAdapter {
-
-  public void createFeatures(List<String> features, String[] tokens, int index, String[] previousOutcomes) {
-    String wc = FeatureGeneratorUtil.tokenFeature(tokens[index]);
-    //bi-gram features 
-    if (index > 0) {
-      features.add("pw,w="+tokens[index-1]+","+tokens[index]);
-      String pwc = FeatureGeneratorUtil.tokenFeature(tokens[index-1]);
-      features.add("pwc,wc="+pwc+","+wc);
-    }
-    if (index+1 < tokens.length) {
-      features.add("w,nw="+tokens[index]+","+tokens[index+1]);
-      String nwc = FeatureGeneratorUtil.tokenFeature(tokens[index+1]); 
-      features.add("wc,nc="+wc+","+nwc);
-    }
-  } 
 }
\ No newline at end of file

Modified: incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/namefind/NameFinderME.java
URL: http://svn.apache.org/viewvc/incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/namefind/NameFinderME.java?rev=1127413&r1=1127412&r2=1127413&view=diff
==============================================================================
--- incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/namefind/NameFinderME.java (original)
+++ incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/namefind/NameFinderME.java Wed May 25 07:35:46 2011
@@ -50,6 +50,7 @@ import opennlp.tools.util.Span;
 import opennlp.tools.util.TrainingParameters;
 import opennlp.tools.util.featuregen.AdaptiveFeatureGenerator;
 import opennlp.tools.util.featuregen.AdditionalContextFeatureGenerator;
+import opennlp.tools.util.featuregen.BigramNameFeatureGenerator;
 import opennlp.tools.util.featuregen.CachedFeatureGenerator;
 import opennlp.tools.util.featuregen.OutcomePriorFeatureGenerator;
 import opennlp.tools.util.featuregen.PreviousMapFeatureGenerator;

Added: incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/util/featuregen/BigramNameFeatureGenerator.java
URL: http://svn.apache.org/viewvc/incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/util/featuregen/BigramNameFeatureGenerator.java?rev=1127413&view=auto
==============================================================================
--- incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/util/featuregen/BigramNameFeatureGenerator.java (added)
+++ incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/util/featuregen/BigramNameFeatureGenerator.java Wed May 25 07:35:46 2011
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreemnets.  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.util.featuregen;
+
+import java.util.List;
+
+public class BigramNameFeatureGenerator extends FeatureGeneratorAdapter {
+
+  public void createFeatures(List<String> features, String[] tokens, int index, String[] previousOutcomes) {
+    String wc = FeatureGeneratorUtil.tokenFeature(tokens[index]);
+    //bi-gram features 
+    if (index > 0) {
+      features.add("pw,w="+tokens[index-1]+","+tokens[index]);
+      String pwc = FeatureGeneratorUtil.tokenFeature(tokens[index-1]);
+      features.add("pwc,wc="+pwc+","+wc);
+    }
+    if (index+1 < tokens.length) {
+      features.add("w,nw="+tokens[index]+","+tokens[index+1]);
+      String nwc = FeatureGeneratorUtil.tokenFeature(tokens[index+1]); 
+      features.add("wc,nc="+wc+","+nwc);
+    }
+  } 
+}
\ No newline at end of file

Propchange: incubator/opennlp/trunk/opennlp-tools/src/main/java/opennlp/tools/util/featuregen/BigramNameFeatureGenerator.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain