Author: beylerian
Date: Sun Jun 5 16:19:13 2016
New Revision: 1746930
URL: http://svn.apache.org/viewvc?rev=1746930&view=rev
Log:
OPENNLP-843 - moved contextgen implementations to top dir, need to make a
common model and params for supervised approaches
Modified:
opennlp/sandbox/opennlp-wsd/ (props changed)
opennlp/sandbox/opennlp-wsd/src/main/java/opennlp/tools/disambiguator/IMSWSDContextGenerator.java
opennlp/sandbox/opennlp-wsd/src/main/java/opennlp/tools/disambiguator/IMSWSDSequenceValidator.java
opennlp/sandbox/opennlp-wsd/src/main/java/opennlp/tools/disambiguator/OSCCWSDContextGenerator.java
opennlp/sandbox/opennlp-wsd/src/main/java/opennlp/tools/disambiguator/WSDContextGenerator.java
opennlp/sandbox/opennlp-wsd/src/main/java/opennlp/tools/disambiguator/WSDModel.java
opennlp/sandbox/opennlp-wsd/src/main/java/opennlp/tools/disambiguator/WSDParameters.java
opennlp/sandbox/opennlp-wsd/src/main/java/opennlp/tools/disambiguator/WSDisambiguatorFactory.java
opennlp/sandbox/opennlp-wsd/src/main/java/opennlp/tools/disambiguator/ims/DefaultIMSContextGenerator.java
opennlp/sandbox/opennlp-wsd/src/main/java/opennlp/tools/disambiguator/ims/DefaultIMSSequenceValidator.java
opennlp/sandbox/opennlp-wsd/src/main/java/opennlp/tools/disambiguator/ims/IMSContextGenerator.java
opennlp/sandbox/opennlp-wsd/src/main/java/opennlp/tools/disambiguator/ims/IMSFactory.java
opennlp/sandbox/opennlp-wsd/src/main/java/opennlp/tools/disambiguator/ims/IMSModel.java
opennlp/sandbox/opennlp-wsd/src/main/java/opennlp/tools/disambiguator/ims/IMSParameters.java
opennlp/sandbox/opennlp-wsd/src/main/java/opennlp/tools/disambiguator/oscc/DefaultOSCCContextGenerator.java
opennlp/sandbox/opennlp-wsd/src/main/java/opennlp/tools/disambiguator/oscc/OSCCContextGenerator.java
opennlp/sandbox/opennlp-wsd/src/main/java/opennlp/tools/disambiguator/oscc/OSCCFactory.java
opennlp/sandbox/opennlp-wsd/src/main/java/opennlp/tools/disambiguator/oscc/OSCCModel.java
opennlp/sandbox/opennlp-wsd/src/main/java/opennlp/tools/disambiguator/oscc/OSCCParameters.java
Propchange: opennlp/sandbox/opennlp-wsd/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Sun Jun 5 16:19:13 2016
@@ -0,0 +1 @@
+.idea
Modified:
opennlp/sandbox/opennlp-wsd/src/main/java/opennlp/tools/disambiguator/IMSWSDContextGenerator.java
URL:
http://svn.apache.org/viewvc/opennlp/sandbox/opennlp-wsd/src/main/java/opennlp/tools/disambiguator/IMSWSDContextGenerator.java?rev=1746930&r1=1746929&r2=1746930&view=diff
==============================================================================
---
opennlp/sandbox/opennlp-wsd/src/main/java/opennlp/tools/disambiguator/IMSWSDContextGenerator.java
(original)
+++
opennlp/sandbox/opennlp-wsd/src/main/java/opennlp/tools/disambiguator/IMSWSDContextGenerator.java
Sun Jun 5 16:19:13 2016
@@ -1,5 +1,163 @@
+/*
+ * 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.disambiguator;
-public class IMSWSDContextGenerator {
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashSet;
+
+public class IMSWSDContextGenerator implements WSDContextGenerator {
+
+ private String[] extractPosOfSurroundingWords(int index, String[] tags,
+ int windowSize) {
+
+ String[] windowTags = new String[2 * windowSize + 1];
+
+ int j = 0;
+
+ for (int i = index - windowSize; i < index + windowSize; i++) {
+ if (i < 0 || i >= tags.length) {
+ windowTags[j] = "null";
+ } else {
+ windowTags[j] = tags[i].toLowerCase();
+ }
+ j++;
+ }
+
+ return windowTags;
+ }
+
+ public String[] extractSurroundingWords(int index, String[] toks,
+ String[] lemmas, int windowSize) {
+
+ // TODO consider the windowSize
+ ArrayList<String> contextWords = new ArrayList<String>();
+
+ for (int i = 0; i < toks.length; i++) {
+ if (lemmas != null) {
+ if (!WSDHelper.stopWords.contains(toks[i].toLowerCase()) && (index
+ != i)) {
+
+ String lemma = lemmas[i].toLowerCase().replaceAll("[^a-z_]", "")
+ .trim();
+
+ if (lemma.length() > 1) {
+ contextWords.add(lemma);
+ }
+
+ }
+ }
+ }
+
+ return contextWords.toArray(new String[contextWords.size()]);
+ }
+
+ private String[] extractLocalCollocations(int index, String[] sentence,
+ int ngram) {
+ /**
+ * Here the author used only 11 features of this type. the range was set to
+ * 3 (bigrams extracted in a way that they are at max separated by 1 word).
+ */
+
+ ArrayList<String> localCollocations = new ArrayList<String>();
+
+ for (int i = index - ngram; i <= index + ngram; i++) {
+
+ if (!(i < 0 || i > sentence.length - 2)) {
+ if ((i != index) && (i + 1 != index) && (i + 1 < index + ngram)) {
+ String lc = sentence[i] + " " + sentence[i + 1];
+ localCollocations.add(lc);
+ }
+ if ((i != index) && (i + 2 != index) && (i + 2 < index + ngram)) {
+ String lc = sentence[i] + " " + sentence[i + 2];
+ localCollocations.add(lc);
+ }
+ }
+
+ }
+ String[] res = new String[localCollocations.size()];
+ res = localCollocations.toArray(new String[localCollocations.size()]);
+
+ return res;
+ }
+
+ /**
+ * Get Context of a word To disambiguate
+ *
+ * @param index The index of the word to disambiguate
+ * @param tokens The tokens of the sentence / context
+ * @param tags The POS-tags of the sentence / context
+ * @param lemmas The lemmas of the sentence / context
+ * @param ngram The ngram to consider for context
+ * @param windowSize The context window
+ * @param model The list of unigrams
+ * @return The IMS context of the word to disambiguate
+ */
+ @Override public String[] getContext(int index, String[] tokens,
+ String[] tags, String[] lemmas, int ngram, int windowSize,
+ ArrayList<String> model) {
+
+ String[] posOfSurroundingWords = extractPosOfSurroundingWords(index,
tokens,
+ windowSize);
+
+ HashSet<String> surroundingWords = new HashSet<>();
+ surroundingWords.addAll(Arrays
+ .asList(extractSurroundingWords(index, tokens, lemmas, windowSize)));
+
+ String[] localCollocations = extractLocalCollocations(index, tokens,
ngram);
+
+ String[] serializedFeatures = new String[posOfSurroundingWords.length
+ + localCollocations.length + model.size()];
+
+ int i = 0;
+
+ for (String feature : posOfSurroundingWords) {
+ serializedFeatures[i] = "F" + i + "=" + feature;
+ i++;
+ }
+
+ for (String feature : localCollocations) {
+ serializedFeatures[i] = "F" + i + "=" + feature;
+ i++;
+ }
+ for (String word : model) {
+ if (surroundingWords.contains(word.toString())) {
+ serializedFeatures[i] = "F" + i + "=1";
+ } else {
+ serializedFeatures[i] = "F" + i + "=0";
+ }
+ i++;
+ }
+ return serializedFeatures;
+ }
+ /**
+ * Get Context of a word To disambiguate
+ *
+ * @param sample The sample of the word to disambiguate
+ * @param ngram The ngram to consider for context
+ * @param windowSize The context window
+ * @param model The list of unigrams
+ * @return The IMS context of the word to disambiguate
+ */
+ @Override public String[] getContext(WSDSample sample, int ngram,
+ int windowSize, ArrayList<String> model) {
+ return getContext(sample.getTargetPosition(), sample.getSentence(),
+ sample.getTags(), sample.getLemmas(), ngram, windowSize, model);
+ }
}
Modified:
opennlp/sandbox/opennlp-wsd/src/main/java/opennlp/tools/disambiguator/IMSWSDSequenceValidator.java
URL:
http://svn.apache.org/viewvc/opennlp/sandbox/opennlp-wsd/src/main/java/opennlp/tools/disambiguator/IMSWSDSequenceValidator.java?rev=1746930&r1=1746929&r2=1746930&view=diff
==============================================================================
---
opennlp/sandbox/opennlp-wsd/src/main/java/opennlp/tools/disambiguator/IMSWSDSequenceValidator.java
(original)
+++
opennlp/sandbox/opennlp-wsd/src/main/java/opennlp/tools/disambiguator/IMSWSDSequenceValidator.java
Sun Jun 5 16:19:13 2016
@@ -1,5 +1,50 @@
+/*
+ * 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.disambiguator;
public class IMSWSDSequenceValidator {
+ private boolean validOutcome(String outcome, String prevOutcome) {
+ if (outcome.startsWith("I-")) {
+ if (prevOutcome == null) {
+ return (false);
+ } else {
+ if (prevOutcome.equals("O")) {
+ return (false);
+ }
+ if (!prevOutcome.substring(2).equals(outcome.substring(2))) {
+ return (false);
+ }
+ }
+ }
+ return true;
+ }
+
+ protected boolean validOutcome(String outcome, String[] sequence) {
+ String prevOutcome = null;
+ if (sequence.length > 0) {
+ prevOutcome = sequence[sequence.length - 1];
+ }
+ return validOutcome(outcome, prevOutcome);
+ }
+
+ public boolean validSequence(int i, String[] sequence, String[] s,
+ String outcome) {
+ return validOutcome(outcome, s);
+ }
}
Modified:
opennlp/sandbox/opennlp-wsd/src/main/java/opennlp/tools/disambiguator/OSCCWSDContextGenerator.java
URL:
http://svn.apache.org/viewvc/opennlp/sandbox/opennlp-wsd/src/main/java/opennlp/tools/disambiguator/OSCCWSDContextGenerator.java?rev=1746930&r1=1746929&r2=1746930&view=diff
==============================================================================
---
opennlp/sandbox/opennlp-wsd/src/main/java/opennlp/tools/disambiguator/OSCCWSDContextGenerator.java
(original)
+++
opennlp/sandbox/opennlp-wsd/src/main/java/opennlp/tools/disambiguator/OSCCWSDContextGenerator.java
Sun Jun 5 16:19:13 2016
@@ -1,5 +1,109 @@
+/*
+ * 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.disambiguator;
-public class OSCCWSDContextGenerator {
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashSet;
+
+import net.sf.extjwnl.data.Synset;
+
+/**
+ * The default Context Generator of the OSCC approach
+ */
+public class OSCCWSDContextGenerator implements WSDContextGenerator {
+
+ public String[] extractSurroundingContextClusters(int index, String[] toks,
+ String[] tags, String[] lemmas, int windowSize) {
+
+ // TODO consider windowSize
+ ArrayList<String> contextClusters = new ArrayList<String>();
+
+ for (int i = 0; i < toks.length; i++) {
+ if (lemmas != null) {
+
+ if (!WSDHelper.stopWords.contains(toks[i].toLowerCase()) && (index
+ != i)) {
+
+ String lemma = lemmas[i].toLowerCase().replaceAll("[^a-z_]", "")
+ .trim();
+
+ WordPOS word = new WordPOS(lemma, tags[i]);
+
+ if (lemma.length() > 1) {
+ try {
+ ArrayList<Synset> synsets = word.getSynsets();
+ if (synsets != null && synsets.size() > 0) {
+ for (Synset syn : synsets) {
+ contextClusters.add(syn.getOffset() + "");
+ }
+ }
+ } catch (NullPointerException ex) {
+ // TODO tagger mistake add proper exception
+ }
+ }
+
+ }
+ }
+ }
+
+ return contextClusters.toArray(new String[contextClusters.size()]);
+
+ }
+
+ /**
+ * Get Context of a word To disambiguate
+ *
+ * @return The OSCC context of the word to disambiguate
+ */
+ @Override public String[] getContext(int index, String[] toks, String[] tags,
+ String[] lemmas, int ngram, int windowSize, ArrayList<String> model) {
+
+ HashSet<String> surroundingContextClusters = new HashSet<>();
+ surroundingContextClusters.addAll(Arrays.asList(
+ extractSurroundingContextClusters(index, toks, tags, lemmas,
+ windowSize)));
+
+ String[] serializedFeatures = new String[model.size()];
+
+ int i = 0;
+ for (String word : model) {
+ if (surroundingContextClusters.contains(word.toString())) {
+ serializedFeatures[i] = "F" + i + "=1";
+ } else {
+ serializedFeatures[i] = "F" + i + "=0";
+ }
+ i++;
+ }
+
+ return serializedFeatures;
+ }
+
+ public String[] getContext(WSDSample sample, int ngram, int windowSize,
+ ArrayList<String> model) {
+ return getContext(sample.getTargetPosition(), sample.getSentence(),
+ sample.getTags(), sample.getLemmas(), 0, windowSize, model);
+ }
}
+
+
+
+
Modified:
opennlp/sandbox/opennlp-wsd/src/main/java/opennlp/tools/disambiguator/WSDContextGenerator.java
URL:
http://svn.apache.org/viewvc/opennlp/sandbox/opennlp-wsd/src/main/java/opennlp/tools/disambiguator/WSDContextGenerator.java?rev=1746930&r1=1746929&r2=1746930&view=diff
==============================================================================
---
opennlp/sandbox/opennlp-wsd/src/main/java/opennlp/tools/disambiguator/WSDContextGenerator.java
(original)
+++
opennlp/sandbox/opennlp-wsd/src/main/java/opennlp/tools/disambiguator/WSDContextGenerator.java
Sun Jun 5 16:19:13 2016
@@ -26,15 +26,10 @@ import java.util.ArrayList;
*/
public interface WSDContextGenerator {
- String[] getIMSContext(int index, String[] toks, String[] tags, String[]
lemmas,
- int ngram, int windowSize, ArrayList<String> model);
+ public String[] getContext(int index, String[] toks, String[] tags,
+ String[] lemmas, int ngram, int windowSize, ArrayList<String> model);
- String[] getIMSContext(WSDSample sample, int ngram, int windowSize,
- ArrayList<String> model);
+ public String[] getContext(WSDSample sample, int ngram, int windowSize,
+ ArrayList<String> model);
- String[] getOSCCContext(int index, String[] toks, String[] tags, String[]
lemmas,
- int windowSize, ArrayList<String> model);
-
- String[] getOSCCContext(WSDSample sample, int windowSize,
- ArrayList<String> model);
}
Modified:
opennlp/sandbox/opennlp-wsd/src/main/java/opennlp/tools/disambiguator/WSDModel.java
URL:
http://svn.apache.org/viewvc/opennlp/sandbox/opennlp-wsd/src/main/java/opennlp/tools/disambiguator/WSDModel.java?rev=1746930&r1=1746929&r2=1746930&view=diff
==============================================================================
---
opennlp/sandbox/opennlp-wsd/src/main/java/opennlp/tools/disambiguator/WSDModel.java
(original)
+++
opennlp/sandbox/opennlp-wsd/src/main/java/opennlp/tools/disambiguator/WSDModel.java
Sun Jun 5 16:19:13 2016
@@ -34,6 +34,7 @@ import opennlp.tools.ml.model.MaxentMode
import opennlp.tools.util.InvalidFormatException;
import opennlp.tools.util.model.BaseModel;
+// TODO unify both supervised models
public class WSDModel extends BaseModel {
private static final String COMPONENT_NAME = "WSD";
@@ -82,8 +83,8 @@ public class WSDModel extends BaseModel
}
public WSDModel(String languageCode, String wordTag, int windowSize,
- int ngram, MaxentModel wsdModel, ArrayList<String> contextEntries,
- Map<String, String> manifestInfoEntries) {
+ int ngram, MaxentModel wsdModel, ArrayList<String> contextEntries,
+ Map<String, String> manifestInfoEntries) {
super(COMPONENT_NAME, languageCode, manifestInfoEntries);
artifactMap.put(WSD_MODEL_ENTRY_NAME, wsdModel);
@@ -97,9 +98,9 @@ public class WSDModel extends BaseModel
}
public WSDModel(String languageCode, String wordTag, int windowSize,
- int ngram, MaxentModel wsdModel, ArrayList<String> surroundingWords) {
+ int ngram, MaxentModel wsdModel, ArrayList<String> surroundingWords) {
this(languageCode, wordTag, windowSize, ngram, wsdModel, surroundingWords,
- null);
+ null);
}
public WSDModel(InputStream in) throws IOException, InvalidFormatException {
@@ -124,8 +125,7 @@ public class WSDModel extends BaseModel
return true;
}
- @Override
- protected void validateArtifactMap() throws InvalidFormatException {
+ @Override protected void validateArtifactMap() throws InvalidFormatException
{
super.validateArtifactMap();
if (!(artifactMap.get(WSD_MODEL_ENTRY_NAME) instanceof AbstractModel)) {
Modified:
opennlp/sandbox/opennlp-wsd/src/main/java/opennlp/tools/disambiguator/WSDParameters.java
URL:
http://svn.apache.org/viewvc/opennlp/sandbox/opennlp-wsd/src/main/java/opennlp/tools/disambiguator/WSDParameters.java?rev=1746930&r1=1746929&r2=1746930&view=diff
==============================================================================
---
opennlp/sandbox/opennlp-wsd/src/main/java/opennlp/tools/disambiguator/WSDParameters.java
(original)
+++
opennlp/sandbox/opennlp-wsd/src/main/java/opennlp/tools/disambiguator/WSDParameters.java
Sun Jun 5 16:19:13 2016
@@ -23,6 +23,7 @@ package opennlp.tools.disambiguator;
* Disambiguation Parameters
*
*/
+// TODO make default params for supervised approaches
public abstract class WSDParameters {
public static enum SenseSource {
Modified:
opennlp/sandbox/opennlp-wsd/src/main/java/opennlp/tools/disambiguator/WSDisambiguatorFactory.java
URL:
http://svn.apache.org/viewvc/opennlp/sandbox/opennlp-wsd/src/main/java/opennlp/tools/disambiguator/WSDisambiguatorFactory.java?rev=1746930&r1=1746929&r2=1746930&view=diff
==============================================================================
---
opennlp/sandbox/opennlp-wsd/src/main/java/opennlp/tools/disambiguator/WSDisambiguatorFactory.java
(original)
+++
opennlp/sandbox/opennlp-wsd/src/main/java/opennlp/tools/disambiguator/WSDisambiguatorFactory.java
Sun Jun 5 16:19:13 2016
@@ -1,5 +1,62 @@
+/*
+ * 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.disambiguator;
-public class WSDisambiguatorFactory {
+import opennlp.tools.util.BaseToolFactory;
+import opennlp.tools.util.InvalidFormatException;
+import opennlp.tools.util.ext.ExtensionLoader;
+
+public class WSDisambiguatorFactory extends BaseToolFactory {
+
+ /**
+ * Creates a {@link WSDisambiguatorFactory} that provides the default
implementation of
+ * the resources.
+ */
+ public WSDisambiguatorFactory() {
+
+ }
+
+ public static WSDisambiguatorFactory create(String subclassName)
+ throws InvalidFormatException {
+ if (subclassName == null) {
+ // will create the default factory
+ return new WSDisambiguatorFactory();
+ }
+ try {
+ WSDisambiguatorFactory theFactory = ExtensionLoader
+ .instantiateExtension(WSDisambiguatorFactory.class, subclassName);
+ return theFactory;
+ } catch (Exception e) {
+ String msg = "Could not instantiate the " + subclassName
+ + ". The initialization throw an exception.";
+ System.err.println(msg);
+ e.printStackTrace();
+ throw new InvalidFormatException(msg, e);
+ }
+ }
+
+ @Override public void validateArtifactMap() throws InvalidFormatException {
+ // no additional artifacts
+ }
+
+ public WSDContextGenerator getContextGenerator() {
+ // default can be IMS
+ return new IMSWSDContextGenerator();
+ }
-}
+}
\ No newline at end of file
Modified:
opennlp/sandbox/opennlp-wsd/src/main/java/opennlp/tools/disambiguator/ims/DefaultIMSContextGenerator.java
URL:
http://svn.apache.org/viewvc/opennlp/sandbox/opennlp-wsd/src/main/java/opennlp/tools/disambiguator/ims/DefaultIMSContextGenerator.java?rev=1746930&r1=1746929&r2=1746930&view=diff
==============================================================================
---
opennlp/sandbox/opennlp-wsd/src/main/java/opennlp/tools/disambiguator/ims/DefaultIMSContextGenerator.java
(original)
+++
opennlp/sandbox/opennlp-wsd/src/main/java/opennlp/tools/disambiguator/ims/DefaultIMSContextGenerator.java
Sun Jun 5 16:19:13 2016
@@ -30,13 +30,14 @@ import opennlp.tools.disambiguator.ims.W
/**
* The default Context Generator of IMS
*/
+// TODO remove this class later
public class DefaultIMSContextGenerator implements IMSContextGenerator {
public DefaultIMSContextGenerator() {
}
private String[] extractPosOfSurroundingWords(int index, String[] tags,
- int windowSize) {
+ int windowSize) {
String[] windowTags = new String[2 * windowSize + 1];
@@ -55,18 +56,18 @@ public class DefaultIMSContextGenerator
}
public String[] extractSurroundingWords(int index, String[] toks,
- String[] lemmas, int windowSize) {
+ String[] lemmas, int windowSize) {
- // TODO consider the windowSize
+ // TODO consider the windowSize
ArrayList<String> contextWords = new ArrayList<String>();
for (int i = 0; i < toks.length; i++) {
if (lemmas != null) {
- if (!WSDHelper.stopWords.contains(toks[i].toLowerCase())
- && (index != i)) {
+ if (!WSDHelper.stopWords.contains(toks[i].toLowerCase()) && (index
+ != i)) {
String lemma = lemmas[i].toLowerCase().replaceAll("[^a-z_]", "")
- .trim();
+ .trim();
if (lemma.length() > 1) {
contextWords.add(lemma);
@@ -80,7 +81,7 @@ public class DefaultIMSContextGenerator
}
private String[] extractLocalCollocations(int index, String[] sentence,
- int ngram) {
+ int ngram) {
/**
* Here the author used only 11 features of this type. the range was set to
* 3 (bigrams extracted in a way that they are at max separated by 1 word).
@@ -110,26 +111,23 @@ public class DefaultIMSContextGenerator
/**
* Get Context of a word To disambiguate
- *
- * @param word
- * : the word to disambiguate in the format {@link WTDIMS}
+ *
* @return The IMS context of the word to disambiguate
*/
- @Override
- public String[] getContext(int index, String[] toks, String[] tags,
- String[] lemmas, int ngram, int windowSize, ArrayList<String> model) {
+ @Override public String[] getContext(int index, String[] toks, String[] tags,
+ String[] lemmas, int ngram, int windowSize, ArrayList<String> model) {
String[] posOfSurroundingWords = extractPosOfSurroundingWords(index, toks,
- windowSize);
+ windowSize);
HashSet<String> surroundingWords = new HashSet<>();
- surroundingWords.addAll(Arrays.asList(extractSurroundingWords(index, toks,
- lemmas, windowSize)));
+ surroundingWords.addAll(
+ Arrays.asList(extractSurroundingWords(index, toks, lemmas, windowSize)));
String[] localCollocations = extractLocalCollocations(index, toks, ngram);
String[] serializedFeatures = new String[posOfSurroundingWords.length
- + localCollocations.length + model.size()];
+ + localCollocations.length + model.size()];
int i = 0;
@@ -158,10 +156,10 @@ public class DefaultIMSContextGenerator
}
public String[] getContext(WSDSample sample, int ngram, int windowSize,
- ArrayList<String> model) {
+ ArrayList<String> model) {
return getContext(sample.getTargetPosition(), sample.getSentence(),
- sample.getTags(), sample.getLemmas(), ngram, windowSize, model);
+ sample.getTags(), sample.getLemmas(), ngram, windowSize, model);
}
}
Modified:
opennlp/sandbox/opennlp-wsd/src/main/java/opennlp/tools/disambiguator/ims/DefaultIMSSequenceValidator.java
URL:
http://svn.apache.org/viewvc/opennlp/sandbox/opennlp-wsd/src/main/java/opennlp/tools/disambiguator/ims/DefaultIMSSequenceValidator.java?rev=1746930&r1=1746929&r2=1746930&view=diff
==============================================================================
---
opennlp/sandbox/opennlp-wsd/src/main/java/opennlp/tools/disambiguator/ims/DefaultIMSSequenceValidator.java
(original)
+++
opennlp/sandbox/opennlp-wsd/src/main/java/opennlp/tools/disambiguator/ims/DefaultIMSSequenceValidator.java
Sun Jun 5 16:19:13 2016
@@ -19,6 +19,7 @@ package opennlp.tools.disambiguator.ims;
import opennlp.tools.util.SequenceValidator;
+// TODO remove this class later
public class DefaultIMSSequenceValidator implements SequenceValidator<String> {
private boolean validOutcome(String outcome, String prevOutcome) {
@@ -46,7 +47,7 @@ public class DefaultIMSSequenceValidator
}
public boolean validSequence(int i, String[] sequence, String[] s,
- String outcome) {
+ String outcome) {
return validOutcome(outcome, s);
}
Modified:
opennlp/sandbox/opennlp-wsd/src/main/java/opennlp/tools/disambiguator/ims/IMSContextGenerator.java
URL:
http://svn.apache.org/viewvc/opennlp/sandbox/opennlp-wsd/src/main/java/opennlp/tools/disambiguator/ims/IMSContextGenerator.java?rev=1746930&r1=1746929&r2=1746930&view=diff
==============================================================================
---
opennlp/sandbox/opennlp-wsd/src/main/java/opennlp/tools/disambiguator/ims/IMSContextGenerator.java
(original)
+++
opennlp/sandbox/opennlp-wsd/src/main/java/opennlp/tools/disambiguator/ims/IMSContextGenerator.java
Sun Jun 5 16:19:13 2016
@@ -26,11 +26,12 @@ import opennlp.tools.disambiguator.WSDSa
/**
* Interface for {@link IMSME} context generators.
*/
+// TODO remove this class later
public interface IMSContextGenerator {
String[] getContext(int index, String[] toks, String[] tags, String[] lemmas,
- int ngram, int windowSize, ArrayList<String> model);
+ int ngram, int windowSize, ArrayList<String> model);
String[] getContext(WSDSample sample, int ngram, int windowSize,
- ArrayList<String> model);
+ ArrayList<String> model);
}
Modified:
opennlp/sandbox/opennlp-wsd/src/main/java/opennlp/tools/disambiguator/ims/IMSFactory.java
URL:
http://svn.apache.org/viewvc/opennlp/sandbox/opennlp-wsd/src/main/java/opennlp/tools/disambiguator/ims/IMSFactory.java?rev=1746930&r1=1746929&r2=1746930&view=diff
==============================================================================
---
opennlp/sandbox/opennlp-wsd/src/main/java/opennlp/tools/disambiguator/ims/IMSFactory.java
(original)
+++
opennlp/sandbox/opennlp-wsd/src/main/java/opennlp/tools/disambiguator/ims/IMSFactory.java
Sun Jun 5 16:19:13 2016
@@ -22,37 +22,37 @@ import opennlp.tools.util.InvalidFormatE
import opennlp.tools.util.SequenceValidator;
import opennlp.tools.util.ext.ExtensionLoader;
-public class IMSFactory extends BaseToolFactory {
-
- /**
- * Creates a {@link IMSFactory} that provides the default implementation of
- * the resources.
- * */
- public IMSFactory() {
-
- }
+// TODO remove this class later
+public class IMSFactory extends BaseToolFactory {
+
+ /**
+ * Creates a {@link IMSFactory} that provides the default implementation of
+ * the resources.
+ */
+ public IMSFactory() {
+
+ }
public static IMSFactory create(String subclassName)
- throws InvalidFormatException {
+ throws InvalidFormatException {
if (subclassName == null) {
// will create the default factory
return new IMSFactory();
}
try {
- IMSFactory theFactory = ExtensionLoader.instantiateExtension(
- IMSFactory.class, subclassName);
+ IMSFactory theFactory = ExtensionLoader
+ .instantiateExtension(IMSFactory.class, subclassName);
return theFactory;
} catch (Exception e) {
String msg = "Could not instantiate the " + subclassName
- + ". The initialization throw an exception.";
+ + ". The initialization throw an exception.";
System.err.println(msg);
e.printStackTrace();
throw new InvalidFormatException(msg, e);
}
}
- @Override
- public void validateArtifactMap() throws InvalidFormatException {
+ @Override public void validateArtifactMap() throws InvalidFormatException {
// no additional artifacts
}
Modified:
opennlp/sandbox/opennlp-wsd/src/main/java/opennlp/tools/disambiguator/ims/IMSModel.java
URL:
http://svn.apache.org/viewvc/opennlp/sandbox/opennlp-wsd/src/main/java/opennlp/tools/disambiguator/ims/IMSModel.java?rev=1746930&r1=1746929&r2=1746930&view=diff
==============================================================================
---
opennlp/sandbox/opennlp-wsd/src/main/java/opennlp/tools/disambiguator/ims/IMSModel.java
(original)
+++
opennlp/sandbox/opennlp-wsd/src/main/java/opennlp/tools/disambiguator/ims/IMSModel.java
Sun Jun 5 16:19:13 2016
@@ -36,6 +36,7 @@ import opennlp.tools.util.BaseToolFactor
import opennlp.tools.util.InvalidFormatException;
import opennlp.tools.util.model.BaseModel;
+// TODO remove this class later
public class IMSModel extends BaseModel {
private static final String COMPONENT_NAME = "IMSME";
@@ -84,9 +85,9 @@ public class IMSModel extends BaseModel
this.wordTag = wordTag;
}
- public IMSModel(String languageCode, String wordTag, int windowSize,
- int ngram, MaxentModel imsModel, ArrayList<String> surroundingWords,
- Map<String, String> manifestInfoEntries, IMSFactory factory) {
+ public IMSModel(String languageCode, String wordTag, int windowSize,
+ int ngram, MaxentModel imsModel, ArrayList<String> surroundingWords,
+ Map<String, String> manifestInfoEntries, IMSFactory factory) {
super(COMPONENT_NAME, languageCode, manifestInfoEntries, factory);
artifactMap.put(IMS_MODEL_ENTRY_NAME, imsModel);
@@ -94,17 +95,17 @@ public class IMSModel extends BaseModel
this.setManifestProperty(WINSIZE, windowSize + "");
this.setManifestProperty(NGRAM, ngram + "");
this.setManifestProperty(SURROUNDINGS,
- StringUtils.join(surroundingWords, ","));
+ StringUtils.join(surroundingWords, ","));
this.surroundingWords = surroundingWords;
checkArtifactMap();
}
public IMSModel(String languageCode, String wordTag, int windowSize,
- int ngram, MaxentModel imsModel, ArrayList<String> surroundingWords,
- IMSFactory factory) {
+ int ngram, MaxentModel imsModel, ArrayList<String> surroundingWords,
+ IMSFactory factory) {
this(languageCode, wordTag, windowSize, ngram, imsModel, surroundingWords,
- null, factory);
+ null, factory);
}
public IMSModel(InputStream in) throws IOException, InvalidFormatException {
@@ -139,8 +140,7 @@ public class IMSModel extends BaseModel
return true;
}
- @Override
- protected void validateArtifactMap() throws InvalidFormatException {
+ @Override protected void validateArtifactMap() throws InvalidFormatException
{
super.validateArtifactMap();
if (!(artifactMap.get(IMS_MODEL_ENTRY_NAME) instanceof AbstractModel)) {
@@ -161,14 +161,13 @@ public class IMSModel extends BaseModel
String surroundings = (String) manifest.get(SURROUNDINGS);
this.surroundingWords = new ArrayList(
- Arrays.asList(surroundings.split(",")));
+ Arrays.asList(surroundings.split(",")));
this.wordTag = (String) manifest.get(WORDTAG);
this.windowSize = Integer.parseInt((String) manifest.get(WINSIZE));
this.ngram = Integer.parseInt((String) manifest.get(NGRAM));
}
- @Override
- protected Class<? extends BaseToolFactory> getDefaultFactory() {
+ @Override protected Class<? extends BaseToolFactory> getDefaultFactory() {
return IMSFactory.class;
}
Modified:
opennlp/sandbox/opennlp-wsd/src/main/java/opennlp/tools/disambiguator/ims/IMSParameters.java
URL:
http://svn.apache.org/viewvc/opennlp/sandbox/opennlp-wsd/src/main/java/opennlp/tools/disambiguator/ims/IMSParameters.java?rev=1746930&r1=1746929&r2=1746930&view=diff
==============================================================================
---
opennlp/sandbox/opennlp-wsd/src/main/java/opennlp/tools/disambiguator/ims/IMSParameters.java
(original)
+++
opennlp/sandbox/opennlp-wsd/src/main/java/opennlp/tools/disambiguator/ims/IMSParameters.java
Sun Jun 5 16:19:13 2016
@@ -28,6 +28,7 @@ import opennlp.tools.disambiguator.WSDPa
* This class contains the parameters for the IMS approach as well as the
* directories containing the files used
*/
+// TODO remove this class later
public class IMSParameters extends WSDParameters {
protected String languageCode;
@@ -35,7 +36,7 @@ public class IMSParameters extends WSDPa
protected int ngram;
protected String trainingDataDirectory;
-
+
protected static final int DFLT_WIN_SIZE = 3;
protected static final int DFLT_NGRAM = 2;
protected static final String DFLT_LANG_CODE = "En";
@@ -44,19 +45,16 @@ public class IMSParameters extends WSDPa
/**
* This constructor takes only two parameters. The default language used is
* <i>English</i>
- *
- * @param windowSize
- * the size of the window used for the extraction of the features
- * qualified of Surrounding Words
- * @param ngram
- * the number words used for the extraction of features qualified of
- * Local Collocations
- * @param source
- * the source of the training data
+ *
+ * @param windowSize the size of the window used for the extraction of the
features
+ * qualified of Surrounding Words
+ * @param ngram the number words used for the extraction of features
qualified of
+ * Local Collocations
+ * @param senseSource the source of the training data
*/
public IMSParameters(int windowSize, int ngram, SenseSource senseSource,
- String trainingDataDirectory){
-
+ String trainingDataDirectory) {
+
this.languageCode = DFLT_LANG_CODE;
this.windowSize = windowSize;
this.ngram = ngram;
@@ -114,8 +112,7 @@ public class IMSParameters extends WSDPa
this.trainingDataDirectory = trainingDataDirectory;
}
- @Override
- public boolean isValid() {
+ @Override public boolean isValid() {
// TODO recheck this pattern switch to maps
return true;
}
Modified:
opennlp/sandbox/opennlp-wsd/src/main/java/opennlp/tools/disambiguator/oscc/DefaultOSCCContextGenerator.java
URL:
http://svn.apache.org/viewvc/opennlp/sandbox/opennlp-wsd/src/main/java/opennlp/tools/disambiguator/oscc/DefaultOSCCContextGenerator.java?rev=1746930&r1=1746929&r2=1746930&view=diff
==============================================================================
---
opennlp/sandbox/opennlp-wsd/src/main/java/opennlp/tools/disambiguator/oscc/DefaultOSCCContextGenerator.java
(original)
+++
opennlp/sandbox/opennlp-wsd/src/main/java/opennlp/tools/disambiguator/oscc/DefaultOSCCContextGenerator.java
Sun Jun 5 16:19:13 2016
@@ -31,33 +31,33 @@ import opennlp.tools.disambiguator.WordP
/**
* The default Context Generator of IMS
*/
+// TODO remove this class later
public class DefaultOSCCContextGenerator implements OSCCContextGenerator {
public DefaultOSCCContextGenerator() {
}
public String[] extractSurroundingContextClusters(int index, String[] toks,
- String[] tags, String[] lemmas, int windowSize) {
+ String[] tags, String[] lemmas, int windowSize) {
- // TODO consider windowSize
ArrayList<String> contextClusters = new ArrayList<String>();
for (int i = 0; i < toks.length; i++) {
if (lemmas != null) {
- if (!WSDHelper.stopWords.contains(toks[i].toLowerCase())
- && (index != i)) {
+ if (!WSDHelper.stopWords.contains(toks[i].toLowerCase()) && (index
+ != i)) {
String lemma = lemmas[i].toLowerCase().replaceAll("[^a-z_]", "")
- .trim();
+ .trim();
WordPOS word = new WordPOS(lemma, tags[i]);
-
+
if (lemma.length() > 1) {
try {
ArrayList<Synset> synsets = word.getSynsets();
if (synsets != null && synsets.size() > 0) {
- for (Synset syn : synsets){
+ for (Synset syn : synsets) {
contextClusters.add(syn.getOffset() + "");
}
}
@@ -76,17 +76,16 @@ public class DefaultOSCCContextGenerator
/**
* Get Context of a word To disambiguate
- *
+ *
* @return The OSCC context of the word to disambiguate
*/
- @Override
- public String[] getContext(int index, String[] toks, String[] tags,
- String[] lemmas, int windowSize, ArrayList<String> model) {
+ @Override public String[] getContext(int index, String[] toks, String[] tags,
+ String[] lemmas, int windowSize, ArrayList<String> model) {
HashSet<String> surroundingContextClusters = new HashSet<>();
- surroundingContextClusters
- .addAll(Arrays.asList(extractSurroundingContextClusters(index, toks,
- tags, lemmas, windowSize)));
+ surroundingContextClusters.addAll(Arrays.asList(
+ extractSurroundingContextClusters(index, toks, tags, lemmas,
+ windowSize)));
String[] serializedFeatures = new String[model.size()];
@@ -103,10 +102,11 @@ public class DefaultOSCCContextGenerator
return serializedFeatures;
}
- public String[] getContext(WSDSample sample, int windowSize,
ArrayList<String> model) {
+ public String[] getContext(WSDSample sample, int windowSize,
+ ArrayList<String> model) {
return getContext(sample.getTargetPosition(), sample.getSentence(),
- sample.getTags(), sample.getLemmas(), windowSize, model);
+ sample.getTags(), sample.getLemmas(), windowSize, model);
}
}
Modified:
opennlp/sandbox/opennlp-wsd/src/main/java/opennlp/tools/disambiguator/oscc/OSCCContextGenerator.java
URL:
http://svn.apache.org/viewvc/opennlp/sandbox/opennlp-wsd/src/main/java/opennlp/tools/disambiguator/oscc/OSCCContextGenerator.java?rev=1746930&r1=1746929&r2=1746930&view=diff
==============================================================================
---
opennlp/sandbox/opennlp-wsd/src/main/java/opennlp/tools/disambiguator/oscc/OSCCContextGenerator.java
(original)
+++
opennlp/sandbox/opennlp-wsd/src/main/java/opennlp/tools/disambiguator/oscc/OSCCContextGenerator.java
Sun Jun 5 16:19:13 2016
@@ -26,10 +26,12 @@ import opennlp.tools.disambiguator.WSDSa
/**
* Interface for {@link OSCCME} context generators.
*/
+// TODO remove this class later
public interface OSCCContextGenerator {
String[] getContext(int index, String[] toks, String[] tags, String[] lemmas,
int windowSize, ArrayList<String> model);
- String[] getContext(WSDSample sample, int windowSize, ArrayList<String>
model);
+ String[] getContext(WSDSample sample, int windowSize,
+ ArrayList<String> model);
}
Modified:
opennlp/sandbox/opennlp-wsd/src/main/java/opennlp/tools/disambiguator/oscc/OSCCFactory.java
URL:
http://svn.apache.org/viewvc/opennlp/sandbox/opennlp-wsd/src/main/java/opennlp/tools/disambiguator/oscc/OSCCFactory.java?rev=1746930&r1=1746929&r2=1746930&view=diff
==============================================================================
---
opennlp/sandbox/opennlp-wsd/src/main/java/opennlp/tools/disambiguator/oscc/OSCCFactory.java
(original)
+++
opennlp/sandbox/opennlp-wsd/src/main/java/opennlp/tools/disambiguator/oscc/OSCCFactory.java
Sun Jun 5 16:19:13 2016
@@ -21,37 +21,37 @@ import opennlp.tools.util.BaseToolFactor
import opennlp.tools.util.InvalidFormatException;
import opennlp.tools.util.ext.ExtensionLoader;
+// TODO remove this class later
public class OSCCFactory extends BaseToolFactory {
/**
* Creates a {@link OSCCFactory} that provides the default implementation of
* the resources.
- * */
+ */
public OSCCFactory() {
}
public static OSCCFactory create(String subclassName)
- throws InvalidFormatException {
+ throws InvalidFormatException {
if (subclassName == null) {
// will create the default factory
return new OSCCFactory();
}
try {
- OSCCFactory theFactory = ExtensionLoader.instantiateExtension(
- OSCCFactory.class, subclassName);
+ OSCCFactory theFactory = ExtensionLoader
+ .instantiateExtension(OSCCFactory.class, subclassName);
return theFactory;
} catch (Exception e) {
String msg = "Could not instantiate the " + subclassName
- + ". The initialization throw an exception.";
+ + ". The initialization throw an exception.";
System.err.println(msg);
e.printStackTrace();
throw new InvalidFormatException(msg, e);
}
}
- @Override
- public void validateArtifactMap() throws InvalidFormatException {
+ @Override public void validateArtifactMap() throws InvalidFormatException {
// no additional artifacts
}
Modified:
opennlp/sandbox/opennlp-wsd/src/main/java/opennlp/tools/disambiguator/oscc/OSCCModel.java
URL:
http://svn.apache.org/viewvc/opennlp/sandbox/opennlp-wsd/src/main/java/opennlp/tools/disambiguator/oscc/OSCCModel.java?rev=1746930&r1=1746929&r2=1746930&view=diff
==============================================================================
---
opennlp/sandbox/opennlp-wsd/src/main/java/opennlp/tools/disambiguator/oscc/OSCCModel.java
(original)
+++
opennlp/sandbox/opennlp-wsd/src/main/java/opennlp/tools/disambiguator/oscc/OSCCModel.java
Sun Jun 5 16:19:13 2016
@@ -35,6 +35,7 @@ import opennlp.tools.util.BaseToolFactor
import opennlp.tools.util.InvalidFormatException;
import opennlp.tools.util.model.BaseModel;
+// TODO remove this class later
public class OSCCModel extends BaseModel {
private static final String COMPONENT_NAME = "OSCCME";
@@ -72,27 +73,27 @@ public class OSCCModel extends BaseModel
this.wordTag = wordTag;
}
- public OSCCModel(String languageCode, String wordTag, int windowSize,
- MaxentModel osccModel, ArrayList<String> contextClusters,
- Map<String, String> manifestInfoEntries, OSCCFactory factory) {
+ public OSCCModel(String languageCode, String wordTag, int windowSize,
+ MaxentModel osccModel, ArrayList<String> contextClusters,
+ Map<String, String> manifestInfoEntries, OSCCFactory factory) {
super(COMPONENT_NAME, languageCode, manifestInfoEntries, factory);
artifactMap.put(OSCC_MODEL_ENTRY_NAME, osccModel);
this.setManifestProperty(WORDTAG, wordTag);
this.setManifestProperty(WINSIZE, windowSize + "");
-
+
this.setManifestProperty(CONTEXTCLUSTERS,
- StringUtils.join(contextClusters, ","));
+ StringUtils.join(contextClusters, ","));
this.contextClusters = contextClusters;
checkArtifactMap();
}
public OSCCModel(String languageCode, String wordTag, int windowSize,
- int ngram, MaxentModel osccModel, ArrayList<String> contextClusters,
- OSCCFactory factory) {
- this(languageCode, wordTag, windowSize, osccModel, contextClusters,
- null, factory);
+ int ngram, MaxentModel osccModel, ArrayList<String> contextClusters,
+ OSCCFactory factory) {
+ this(languageCode, wordTag, windowSize, osccModel, contextClusters, null,
+ factory);
}
public OSCCModel(InputStream in) throws IOException, InvalidFormatException {
@@ -117,8 +118,7 @@ public class OSCCModel extends BaseModel
return true;
}
- @Override
- protected void validateArtifactMap() throws InvalidFormatException {
+ @Override protected void validateArtifactMap() throws InvalidFormatException
{
super.validateArtifactMap();
if (!(artifactMap.get(OSCC_MODEL_ENTRY_NAME) instanceof AbstractModel)) {
@@ -139,13 +139,12 @@ public class OSCCModel extends BaseModel
String contextClusters = (String) manifest.get(CONTEXTCLUSTERS);
this.contextClusters = new ArrayList(
- Arrays.asList(contextClusters.split(",")));
+ Arrays.asList(contextClusters.split(",")));
this.wordTag = (String) manifest.get(WORDTAG);
this.windowSize = Integer.parseInt((String) manifest.get(WINSIZE));
}
- @Override
- protected Class<? extends BaseToolFactory> getDefaultFactory() {
+ @Override protected Class<? extends BaseToolFactory> getDefaultFactory() {
return OSCCFactory.class;
}
Modified:
opennlp/sandbox/opennlp-wsd/src/main/java/opennlp/tools/disambiguator/oscc/OSCCParameters.java
URL:
http://svn.apache.org/viewvc/opennlp/sandbox/opennlp-wsd/src/main/java/opennlp/tools/disambiguator/oscc/OSCCParameters.java?rev=1746930&r1=1746929&r2=1746930&view=diff
==============================================================================
---
opennlp/sandbox/opennlp-wsd/src/main/java/opennlp/tools/disambiguator/oscc/OSCCParameters.java
(original)
+++
opennlp/sandbox/opennlp-wsd/src/main/java/opennlp/tools/disambiguator/oscc/OSCCParameters.java
Sun Jun 5 16:19:13 2016
@@ -27,6 +27,7 @@ import opennlp.tools.disambiguator.WSDPa
* This class contains the parameters for the OSCC approach as well as the
* directories containing the files used
*/
+// TODO remove this class later
public class OSCCParameters extends WSDParameters {
protected String languageCode;
@@ -40,16 +41,13 @@ public class OSCCParameters extends WSDP
/**
* This constructor takes only two parameters. The default language used is
* <i>English</i>
- *
- * @param windowSize
- * the size of the window used for the extraction of the features
- * qualified of Surrounding Context Clusters
- *
- * @param source
- * the source of the training data
+ *
+ * @param windowSize the size of the window used for the extraction of the
features
+ * qualified of Surrounding Context Clusters
+ * @param senseSource the source of the training data
*/
public OSCCParameters(int windowSize, SenseSource senseSource,
- String trainingDataDirectory) {
+ String trainingDataDirectory) {
this.languageCode = DFLT_LANG_CODE;
this.windowSize = windowSize;
this.senseSource = senseSource;
@@ -105,8 +103,7 @@ public class OSCCParameters extends WSDP
this.trainingDataDirectory = trainingDataDirectory;
}
- @Override
- public boolean isValid() {
+ @Override public boolean isValid() {
// TODO make validity check
return true;
}