1. muzny
  2. WiktionaryIdioms

Commits

muzny  committed 3e8ac76

Lots of commenting! Adding ant capabilities.

  • Participants
  • Parent commits adf948f
  • Branches master

Comments (0)

Files changed (33)

File WiktionaryIdioms/bin/.gitignore

View file
  • Ignore whitespace
 /config
 /detector
 /fileio
-/mysql

File WiktionaryIdioms/build.xml

View file
  • Ignore whitespace
+<project name="WiktionaryIdioms" default="dist" basedir=".">
+        <description>
+        WiktionaryIdioms build file
+    </description>
+        <!-- set global properties for this build -->
+        <property file="build.properties" />
+        <property name="version" value="1.0" />
+        <property name="build" location="build" />
+        <property name="build.src" location="build.src" />
+        <property name="dist" location="dist" />
+        <property name="lib" location="lib" />
+	  	<property name="src" location="src" />
+
+        <path id="classpath">
+                <fileset dir="${lib}">
+                        <include name="**/*.jar" />
+                </fileset>
+        </path>
+
+        <target name="init">
+                <!-- Create the time stamp -->
+                <tstamp />
+                <!-- Create the build directory structure used by compile -->
+                <mkdir dir="${build}" />
+                <mkdir dir="${build.src}" />
+                <copy todir="${build.src}" >
+                        <fileset dir="${src}" includes="**/*.java" />
+                </copy>
+        </target>
+
+        <target name="compile" depends="init" description="compile the source ">
+                <!-- Compile the java code from ${src} into ${build} -->
+                <javac debug="true" srcdir="${build.src}" destdir="${build}">
+                    <classpath refid="classpath" />
+                </javac>
+        </target>
+
+        <target name="dist" depends="compile" description="generate the distribution">
+                <!-- Create the distribution directory -->
+                <mkdir dir="${dist}" />
+                <delete file="MANIFEST.MF" />
+                <manifest file="MANIFEST.MF">
+                        <attribute name="Main-Class" value="${mainclass}" />
+                </manifest>
+
+                <jar jarfile="${dist}/${ant.project.name}-${version}.jar" manifest="MANIFEST.MF">
+                        <fileset dir="${build}" />
+                        <fileset dir="${build.src}" />
+                        <zipgroupfileset dir="${lib}" includes="*.jar" />
+                </jar>
+                
+                <delete file="MANIFEST.MF" />
+        </target>
+
+        <target name="clean" description="clean up">
+                <!-- Delete the ${build} and ${dist} directory trees -->
+                <delete dir="${build}" />
+                <delete dir="${build.src}" />
+                <delete dir="${dist}" />
+        </target>
+</project>

File WiktionaryIdioms/src/classifier/classifiers/ClassificationResult.java

  • Ignore whitespace
-package classifier.classifiers;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.TreeMap;
-
-import classifier.model.ClassifierEvaluationUtils;
-import classifier.model.Sense;
-
-
-public class ClassificationResult {
-	public List<Integer> features;
-	public int iterations;
-	public double learningRate;
-	public List<double[]> prs;
-	public List<TreeMap<Integer, List<Sense>>> foldResults;
-	public TreeMap<Integer, List<Sense>> results;
-	
-	public ClassificationResult() {
-		
-	}
-	
-	public ClassificationResult(List<Integer> features, int iterations, double learningRate) {
-		this.features = features;
-		this.iterations = iterations;
-		this.learningRate = learningRate;
-		prs = new ArrayList<double[]>();
-	}
-	
-	public void setFoldResults(List<TreeMap<Integer, List<Sense>>> results) {
-		this.foldResults = results;
-	}
-	
-	public void setResults(TreeMap<Integer, List<Sense>> results) {
-		this.results = results;
-	}
-	
-	public void addPrecisionRecall(double[] pr) {
-		prs.add(pr);
-	}
-	
-	public void setPrecisionRecalls(List<double[]> prs) {
-		this.prs = prs; 
-	}
-	
-	public double getAverageFScore() {
-		return ClassifierEvaluationUtils.getAverageFMeasure(prs);
-	}
-	
-	public boolean isUnaryClassifier() {
-		return ClassifierEvaluationUtils.getAllOneClassifier(prs);
-	}
-	
-	public double getAveragePrecisionRecallDiff() {
-		double total = 0;
-		for (double[] pr : prs) {
-			total += Math.abs(pr[0] - pr[1]);
-		}
-		return total / prs.size();
-	}
-	
-	public String toString() {
-		String s = "Features: " + features + "\n";
-
-		s += "iterations: " + iterations + "\n";
-		s += "learningRate: " + learningRate + "\n";
-		for (double[] pr : prs) {
-			s += "p: " + pr[0] + "; ";
-			s += "r: " + pr[1] + "; ";
-			s += "f: " + ClassifierEvaluationUtils.getFMeasure(pr) + "\n";
-		}
-		s += Arrays.toString(ClassifierEvaluationUtils.getAveragedPrecisionRecall(prs)) + "\n";
-		s += getAverageFScore() + "\n";
-		return s;
-	}
-}

File WiktionaryIdioms/src/classifier/classifiers/Classifier.java

View file
  • Ignore whitespace
+/**
+ * The classifier is the class that can be extended and work with all of the classifier
+ * experiments to produce a classification model. It is based off of the Perceptron
+ * algorithm, and is therefore most easily extendible to Perceptron-based learning
+ * algorithms.
+ */
+
+
 package classifier.classifiers;
 
 import java.util.ArrayList;
 	protected double[] weights;
 	protected List<Integer> featureTypes;
 	
-	public Classifier(int numIterations, double errorBound, double learningRate, List<Integer> featureTypes) {
+	/**
+	 * A classifier is defined by the parameters that this constructor takes in. The initially
+	 * constructed classifier has null weights, which become set by calling train.
+	 * @param numIterations - The number of times to fully iterate through the entire set
+	 * of data points.
+	 * @param errorBound - The error level under which the classifier should stop iterating
+	 * even if it hasn't reached numIterations yet. Typically set to a small number.
+	 * @param learningRate - The learning rate, or discount factor that helps determine how
+	 * much a classifier learns from each update it performs.
+	 * @param featureTypes - Which features the classifier uses. Should be a list of the
+	 * integers corresponding to the features in classifier.features.numeric.Feature.
+	 */
+	public Classifier(int numIterations, double errorBound,
+						double learningRate, List<Integer> featureTypes) {
 		this.numIterations = numIterations;
 		this.errorBound = errorBound;
 		this.learningRate = learningRate;
 		this.featureTypes = featureTypes;
 	}
 	
+	/**
+	 * Load a classifier from a saved classifier model. This classifier typically
+	 * does not need to learn new weights, because it will have loaded them from the
+	 * ClassifierModel, meaning that you should not run the train method.
+	 * @param model - ClassifierModel to load
+	 */
 	public Classifier(ClassifierModel model) {
 		this.numIterations = model.numIterations;
 		this.errorBound = model.errorBound;
 		this.weights = model.weights;
 	}
 		
+	/**
+	 * Method for training the classifier, i.e. learning the weights.
+	 * @param data - training data for the classifier - each ClassifierData
+	 * should have the features passed into the Classifier constructor set.
+	 * @return The resulting classifier model, containing the number of iterations,
+	 * error bound, learning rate, feature types, and weights of the classifier
+	 * after it has finished training.
+	 */
 	public abstract ClassifierModel train(List<ClassifierData> data);
 	
 	/**
 		return predictions;
 	}
 	
+	/**
+	 * Accessor method for the weights learned during training.
+	 * @return a copy of the weights array. This should be an array of length
+	 * ((number of features + 1) * number of classes)
+	 */
 	public double[] getWeights() {
 		return Arrays.copyOf(weights, weights.length);
 	}
 	
+	
+	/**
+	 * Predict the label of a single ClassifierData based on the weights learned
+	 * during training.
+	 * @param point - ClassifierData to be classified.
+	 * @return - int label that had the highest score according to the learned weights.
+	 */
 	public int predict(ClassifierData point) {
 
 		double maxPred = 0;
 		return bestClass;
 	}
 	
+	/**
+	 * Predict the classification result for a single ClassifierData point 
+	 * according to the model learned during training.
+	 * @param point - ClassifierData to be classified.
+	 * @return - The Result for the data point. The Result contains information
+	 * about what values the classifier assigned to each possible class.
+	 */
+	public Result predictResultGeneral(ClassifierData point) {
+
+		Result r = new Result(point);
+		for (int label : Sense.getClasses()) {
+			double pred = 0;
+			double[] phiVals = ClassifierData.phi(point, label, featureTypes);
+			for (int i = 0; i < weights.length; i++) {
+				pred += (weights[i] * phiVals[i]);
+			}
+			r.addPrediction(label, pred);
+		}
+		return r;
+	}	
+	
+	/**
+	 * Predict the classification result for a single ClassifierData point 
+	 * according to the model learned during training.
+	 * @param point - ClassifierData to be classified.
+	 * @return - The Result for the data point. The Result contains information
+	 * about what values the classifier assigned to the idiomatic vs. literal label.
+	 */
 	public Result predictResult(ClassifierData point) {
 
 		double litPred = 0;
 		return new Result(point, litPred, idiomPred);
 	}
 	
+	/**
+	 * Set the number of iterations for the classifier to perform during training.
+	 * @param iters - number of iterations (should not be 0 or negative)
+	 */
 	public void setIterations(int iters) {
 		this.numIterations = iters;
 	}
 	
+	/**
+	 * Set the error bound for the classifier to honor during training.
+	 * @param error - new error bound
+	 */
 	public void setErrorBound(double error) {
 		this.errorBound = error;
 	}
 	
+	/**
+	 * Set the learning rate for the classifier during training.
+	 * @param learn - new error rate <0, 1]
+	 */
 	public void setLearningRate(double learn) {
 		this.learningRate = learn;
 	}
 	
+	/**
+	 * Accessor method for the number of iterations.
+	 * @return - number of iterations for the current model.
+	 */
 	public int getIterations() {
 		return this.numIterations;
 	}
 	
+	/**
+	 * Accessor method for the error bound.
+	 * @return - Error bound for the current model.
+	 */
 	public double getErrorBound() {
 		return errorBound;
 	}
 	
+	/**
+	 * Accessor method for the learning rate.
+	 * @return - Learning rate for the current model.
+	 */
 	public double getLearningRate() {
 		return learningRate;
 	}
 	
+	/**
+	 * Accessor method for the feature types.
+	 * @return - Feature types for the current model.
+	 */
 	public List<Integer> getFeatureTypes() {
 		List<Integer> copy = new ArrayList<Integer>(featureTypes);
 		return copy;

File WiktionaryIdioms/src/classifier/classifiers/Perceptron.java

View file
  • Ignore whitespace
+/**
+ * A classifier that implements the Perceptron algorithm, performing averaged
+ * updates. This means that it does one update every iteration through the entire
+ * set of training data, and that this update is an averaged update.
+ */
+
 package classifier.classifiers;
 
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashMap;
 import java.util.List;
-import java.util.Map;
-import java.util.TreeMap;
 
 import classifier.model.ClassifierData;
 import classifier.model.ClassifierModel;
-import classifier.model.Result;
-import classifier.model.Sense;
-
 
 public class Perceptron extends Classifier {
 	
 			totalUpdate[i] = totalUpdate[i] + (learningRate * (correctPhis[i] - wrongPhis[i]));	
 		}
 	}
-	
-	public Result predictResultGeneral(Sense point) {
-
-		Result r = new Result(point);
-		for (int label : Sense.getClasses()) {
-			double pred = 0;
-			double[] phiVals = Sense.phi(point, label, featureTypes);
-			for (int i = 0; i < weights.length; i++) {
-				pred += (weights[i] * phiVals[i]);
-			}
-			r.addPrediction(label, pred);
-		}
-		return r;
-	}	
 }

File WiktionaryIdioms/src/classifier/classifiers/TrustingPerceptron.java

View file
  • Ignore whitespace
+/**
+ * A classifier that implements the same training algorithm as the Perceptron,
+ * except that it attempts to bootstrap itself by "trusting" its classifications
+ * after each iteration of training, therefore pretending that the points that
+ * it most strongly believed were idiomatic will be counted as idiomatic, even if
+ * their official label is literal.
+ * 
+ * Warning: this classifier is less ready to do more than two-dimensional classification
+ * than the regular Perceptron class.
+ */
+
+package classifier.classifiers;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import classifier.model.ClassifierData;
+import classifier.model.ClassifierModel;
+import classifier.model.Result;
+
+
+public class TrustingPerceptron extends Classifier {
+	// This field controls what percentage of the training examples the classifier
+	// will pretend are positive (idiomatic) examples.
+	// .8 means that the top 20% of "most positively idiomatic" examples will be regarded
+	// as idiomatic the next iteration no matter their "true" label.
+	public static final double POS_CUTOFF = .8;
+
+	private int numIterations;
+	private double errorBound;
+	private double learningRate;
+	private double[] weights;
+	private List<Integer> featureTypes;
+	
+	public TrustingPerceptron(int numIterations, double errorBound, 
+			double learningRate, List<Integer> featureTypes) {
+		super(numIterations, errorBound, learningRate, featureTypes);
+	}
+	
+	public TrustingPerceptron(ClassifierModel model) {
+		super(model);
+	}
+	
+	public ClassifierModel train(List<ClassifierData> data) {
+		if (data.size() == 0) {
+			return null;
+		}
+		Set<ClassifierData> incognito = new HashSet<ClassifierData>();
+		Map<Integer, List<ClassifierData>> incogPreds = new HashMap<Integer, List<ClassifierData>>();
+		// Start with 0 weights
+		weights = new double[(featureTypes.size() + 1) * ClassifierData.getClasses().size()];
+		
+		int iters = 0;
+		double iterationError = errorBound;
+		while (iters < numIterations && iterationError >= errorBound) {
+			iters++;
+			
+			iterationError = 0;
+			
+			// accumulate update
+			double[] totalUpdate = new double[weights.length];
+			// Visit the training instances one by one.
+			for (int i = 0; i < data.size(); i++) {
+				// Make a prediction
+				int prediction = predict(data.get(i));
+		
+				int correctLabel = data.get(i).getLabel();
+				// If it is an incognito positive, make sure that it is still an error
+				if (incognito.contains(data.get(i))) {
+					// the label should actually be 1
+					correctLabel = 1;
+					
+					// count what it was predicted as
+					if (!incogPreds.containsKey(prediction)) {
+						incogPreds.put(prediction, new ArrayList<ClassifierData>());
+					}
+					incogPreds.get(prediction).add(data.get(i));
+				}
+				
+				// If wrong, adjust weights
+				if (prediction != correctLabel) {
+					
+					update(totalUpdate, data.get(i), prediction, correctLabel);
+					// Accumulate iteration error.
+
+					iterationError += 1;
+				}
+			}
+			// Update the weights by adding the averaged update
+			averagedUpdateWeights(totalUpdate, data.size());
+			
+			iterationError = (iterationError / data.size());
+			
+			// Update the incognito set
+			incognito = getUpdatedIncognito(incogPreds, data);
+			incogPreds = new HashMap<Integer, List<ClassifierData>>();
+			
+			// Uncomment this to see how many examples the classifier is pretending are
+			// idiomatic but actually aren't.
+			//System.out.println("The incognito set size is: " + incognito.size());
+		}
+		return new ClassifierModel(this);
+	}
+	
+	private Set<ClassifierData> getUpdatedIncognito(
+			Map<Integer, List<ClassifierData>> incogPreds, List<ClassifierData> data) {
+		Set<ClassifierData> incognito = new HashSet<ClassifierData>();
+		
+		// If it classified the incognito sense correctly previously, keep it in the incognito set
+		if (incogPreds.containsKey(1)) {
+			incognito.addAll(incogPreds.get(1));
+		}
+		
+		// For the rest of the data, if it is a "negative" example, see if it actually looks positive.
+		List<Result> testResult = testGetSortedDeltas(data);
+		
+		double positiveCutoff = getPositiveCutoff(testResult);
+		for (Result r : testResult) {
+			if (r.getDifference() >= positiveCutoff) {
+				incognito.add(r.getClassifierData());
+			}
+		}
+		
+		return incognito;
+	}
+	
+	private double getPositiveCutoff(List<Result> results) {
+		// We want to get the number that POS_CUTOFF percent of positive examples are above
+		List<Result> positives = new ArrayList<Result>();
+		for (Result r : results) {
+			if (r.getClassifierData().getLabel() == 1) {
+				positives.add(r);
+			}
+		}
+		
+		int numBelowCutoff = (int) Math.floor(positives.size() * POS_CUTOFF);
+		
+		// Cutoff is the difference value at the numBelowCutoff - 1th element
+		return positives.get(numBelowCutoff - 1).getDifference();
+	}
+	
+	
+	private void averagedUpdateWeights(double[] totalUpdate, int numExamples) {
+		for (int i = 0; i < weights.length; i++) {
+			weights[i] += (totalUpdate[i] / (numExamples * 1.0));
+		}
+	}
+
+	private void update(double[] totalUpdate, ClassifierData point, int pred, int correct) {
+		double[] correctPhis = ClassifierData.phi(point, correct, featureTypes);
+		double[] wrongPhis = ClassifierData.phi(point, pred, featureTypes);
+		for (int i = 0; i < totalUpdate.length; i++) {
+			totalUpdate[i] = totalUpdate[i] + (learningRate * (correctPhis[i] - wrongPhis[i]));	
+		}
+	}
+}

File WiktionaryIdioms/src/classifier/classifiers/UntrustingPerceptron.java

  • Ignore whitespace
-package classifier.classifiers;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.TreeMap;
-
-import classifier.model.ClassifierData;
-import classifier.model.ClassifierModel;
-import classifier.model.Result;
-import classifier.model.Sense;
-
-
-public class UntrustingPerceptron extends Classifier {
-	public static final double POS_CUTOFF = .8;
-
-	private int numIterations;
-	private double errorBound;
-	private double learningRate;
-	private double[] weights;
-	private List<Integer> featureTypes;
-	
-	public UntrustingPerceptron(int numIterations, double errorBound, double learningRate, List<Integer> featureTypes) {
-		super(numIterations, errorBound, learningRate, featureTypes);
-	}
-	
-	public UntrustingPerceptron(ClassifierModel model) {
-		super(model);
-	}
-	
-	public ClassifierModel train(List<ClassifierData> data) {
-		if (data.size() == 0) {
-			return null;
-		}
-		Set<ClassifierData> incognito = new HashSet<ClassifierData>();
-		Map<Integer, List<ClassifierData>> incogPreds = new HashMap<Integer, List<ClassifierData>>();
-		// Start with 0 weights
-		weights = new double[(featureTypes.size() + 1) * ClassifierData.getClasses().size()];
-		
-		int iters = 0;
-		double iterationError = errorBound;
-		while (iters < numIterations && iterationError >= errorBound) {
-			iters++;
-			
-			iterationError = 0;
-			
-			// accumulate update
-			double[] totalUpdate = new double[weights.length];
-			// Visit the training instances one by one.
-			for (int i = 0; i < data.size(); i++) {
-				// Make a prediction
-				int prediction = predict(data.get(i));
-		
-				int correctLabel = data.get(i).getLabel();
-				// If it is an incognito positive, make sure that it is still an error
-				if (incognito.contains(data.get(i))) {
-					// the label should actually be 1
-					correctLabel = 1;
-					
-					// count what it was predicted as
-					if (!incogPreds.containsKey(prediction)) {
-						incogPreds.put(prediction, new ArrayList<ClassifierData>());
-					}
-					incogPreds.get(prediction).add(data.get(i));
-				}
-				
-				// If wrong, adjust weights
-				if (prediction != correctLabel) {
-					
-					update(totalUpdate, data.get(i), prediction, correctLabel);
-					// Accumulate iteration error.
-
-					iterationError += 1;
-				}
-			}
-			// Update the weights by adding the averaged update
-			averagedUpdateWeights(totalUpdate, data.size());
-			
-			iterationError = (iterationError / data.size());
-			
-			// Update the incognito set
-			incognito = getUpdatedIncognito(incogPreds, data);
-			incogPreds = new HashMap<Integer, List<ClassifierData>>();
-			
-			//System.out.println("The incognito set size is: " + incognito.size());
-		}
-		return new ClassifierModel(this);
-	}
-	
-	private Set<ClassifierData> getUpdatedIncognito(
-			Map<Integer, List<ClassifierData>> incogPreds, List<ClassifierData> data) {
-		Set<ClassifierData> incognito = new HashSet<ClassifierData>();
-		
-		// If it classified the incognito sense correctly previously, keep it in the incognito set
-		if (incogPreds.containsKey(1)) {
-			incognito.addAll(incogPreds.get(1));
-		}
-		
-		// For the rest of the data, if it is a "negative" example, see if it actually looks positive.
-		List<Result> testResult = testGetSortedDeltas(data);
-		
-		double positiveCutoff = getPositiveCutoff(testResult);
-		for (Result r : testResult) {
-			if (r.getDifference() >= positiveCutoff) {
-				incognito.add(r.getClassifierData());
-			}
-		}
-		
-		return incognito;
-	}
-	
-	private double getPositiveCutoff(List<Result> results) {
-		// We want to get the number that POS_CUTOFF percent of positive examples are above
-		List<Result> positives = new ArrayList<Result>();
-		for (Result r : results) {
-			if (r.getClassifierData().getLabel() == 1) {
-				positives.add(r);
-			}
-		}
-		
-		int numBelowCutoff = (int) Math.floor(positives.size() * POS_CUTOFF);
-		
-		// Cutoff is the difference value at the numBelowCutoff - 1th element
-		return positives.get(numBelowCutoff - 1).getDifference();
-	}
-	
-	
-	private void averagedUpdateWeights(double[] totalUpdate, int numExamples) {
-		for (int i = 0; i < weights.length; i++) {
-			weights[i] += (totalUpdate[i] / (numExamples * 1.0));
-		}
-	}
-
-	private void update(double[] totalUpdate, ClassifierData point, int pred, int correct) {
-		double[] correctPhis = ClassifierData.phi(point, correct, featureTypes);
-		double[] wrongPhis = ClassifierData.phi(point, pred, featureTypes);
-		for (int i = 0; i < totalUpdate.length; i++) {
-			totalUpdate[i] = totalUpdate[i] + (learningRate * (correctPhis[i] - wrongPhis[i]));	
-		}
-	}
-}

File WiktionaryIdioms/src/classifier/config/ClassifierConfigs.java

View file
  • Ignore whitespace
+package classifier.config;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.NoSuchElementException;
+
+
+import org.apache.commons.configuration.ConfigurationException;
+import org.apache.commons.configuration.XMLConfiguration;
+
+import classifier.classifiers.Classifier;
+import classifier.classifiers.Perceptron;
+import classifier.classifiers.TrustingPerceptron;
+import classifier.model.ClassifierModel;
+
+public class ClassifierConfigs {
+
+	
+	public static final String DEFAULT = "default";
+	public static final String EQUAL_DIST = "equalDist";
+	public static final String PERCENTS = "percents";
+	public static final String FOLDS = "folds";
+	public static final String LEARNING_RATE = "learningRate";
+	public static final String ITERATIONS = "iterations";
+	public static final String VERBOSE = "verbose";
+	public static final String FEATURES = "features";
+	public static final String ERROR_BOUND = "errorBound";
+	public static final String STRATIFIED = "stratified";
+	public static final String SENSES_PATH = "trainPath";
+	public static final String TRAIN_PATH = "trainPath";
+	public static final String TEST_PATH = "testPath";
+	public static final String CLASSIFIER_TYPE = "classifierType";
+	public static final String OUTFILE = "output.file";
+	public static final String GROUP = "group";
+
+	
+	private static ClassifierConfigs instance;
+	
+	private XMLConfiguration xmlInst;
+	
+	private String section;
+	
+	private ClassifierConfigs() {
+		try {
+			xmlInst = new XMLConfiguration(GeneralConfigs.CLASSIFIER_CONFIGS);
+			section = DEFAULT;
+		} catch (ConfigurationException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+	}
+	
+	private ClassifierConfigs(String path) {
+		try {
+			xmlInst = new XMLConfiguration(path);
+			section = DEFAULT;
+		} catch (ConfigurationException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+	}
+	
+	public static ClassifierConfigs getInstance() {
+		if (instance == null) {
+			instance = new ClassifierConfigs();
+		}
+		return instance;
+	}
+	
+	public static ClassifierConfigs getInstance(String path) {
+		if (instance == null) {
+			instance = new ClassifierConfigs(path);
+		}
+		return instance;
+	}
+	
+	public String getSString(String name) {
+		String result = xmlInst.getString(section + "." + name);
+		if (result == null || result.length() == 0) {
+			result = xmlInst.getString(DEFAULT + "." + name);
+		}
+		return result;
+	}
+	
+	public String[] getSStringArray(String name) {
+		String[] result = xmlInst.getStringArray(section + "." + name);
+		if (result == null || result.length == 0) {
+			result = xmlInst.getStringArray(DEFAULT + "." + name);
+		}
+		return result;
+	}
+	
+	public Integer getSInt(String name) {
+		int result;
+		try {
+			result = xmlInst.getInt(section + "." + name);
+		} catch (Exception e) {
+			try {
+				result = xmlInst.getInt(DEFAULT + "." + name);
+			} catch (Exception f) {
+				return null;
+			}
+		}
+		return result;
+	}
+	
+	public boolean getSBool(String name) {
+		boolean result;
+		try {
+			result = xmlInst.getBoolean(section + "." + name);
+		} catch (NoSuchElementException e) {
+			result = xmlInst.getBoolean(DEFAULT + "." + name, false);
+		}
+		return result;
+	}
+	
+	public double getSDouble(String name) {
+		double result;
+		try {
+			result = xmlInst.getDouble(section + "." + name);
+		} catch (NoSuchElementException e) {
+			result = xmlInst.getDouble(DEFAULT + "." + name);
+		}
+		return result;
+	}
+	
+	public void addConfig(String name, String value) {
+		xmlInst.addProperty(name, value);
+	}
+	
+	
+	public void setSection(String name) {
+		section = name;
+	}
+	
+	public List<Integer> getSFeatures(String name) {
+		// Now analyze which features we should be using
+		String[] feats = getSStringArray(name);
+		List<Integer> featuresToUse = new ArrayList<Integer>();
+		for (String num : feats) {
+			featuresToUse.add(Integer.parseInt(num));
+		}
+		return featuresToUse;
+	}
+	
+	public Classifier getSClassifier() {		
+		int iters = getSInt(ITERATIONS);
+		double errorBound = getSDouble(ERROR_BOUND);
+		double learningRate = getSInt(LEARNING_RATE);
+		List<Integer> feats = getSFeatures(FEATURES);
+
+		return getClassifier(iters, errorBound, learningRate, feats);
+	}
+	
+	public Classifier getClassifier(int iters, double errorBound, double learningRate, List<Integer> feats) {
+		String type = getSString(CLASSIFIER_TYPE);
+		if (type.equals("trusting")) {
+			return new TrustingPerceptron(iters, errorBound, learningRate, feats);
+		} else if (type.equals("perceptron")) {
+			// type.equals("perceptron")
+			return new Perceptron(iters, errorBound, learningRate, feats);
+		}
+		return null;
+	}
+	
+	public Classifier getClassifier(ClassifierModel clm) {
+		String type = getSString(CLASSIFIER_TYPE);
+		if (type.equals("untrusting")) {
+			return new TrustingPerceptron(clm);
+		} else if (type.equals("perceptron")) {
+			// type.equals("perceptron")
+			return new Perceptron(clm);
+		}
+		return null;
+	}
+
+}

File WiktionaryIdioms/src/classifier/config/GeneralConfigs.java

View file
  • Ignore whitespace
+package classifier.config;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.commons.configuration.ConfigurationException;
+import org.apache.commons.configuration.XMLConfiguration;
+
+public class GeneralConfigs {
+	public static final String ESA_CONFIGS = "./config/esaconfig.xml";
+	public static final String DB_CONFIGS = "./config/dbconfig.xml";
+	public static final String CLASSIFIER_CONFIGS = "./config/classifierconfig.xml";
+	public static final String FEATURE_CONFIGS = "./config/featureconfig.xml";
+	public static final String DETECTOR_CONFIGS = "./config/detectorconfig.xml";
+
+	
+	private static Map<String, XMLConfiguration> xmlInsts;
+	
+	private static void initialize(String path) {
+		if (xmlInsts == null) {
+			xmlInsts = new HashMap<String, XMLConfiguration>();
+		}
+		if (!xmlInsts.containsKey(path)) {
+			try {
+				xmlInsts.put(path, new XMLConfiguration(path));
+			} catch (ConfigurationException e) {
+				// TODO Auto-generated catch block
+				e.printStackTrace();
+			}
+		}
+	}
+	
+	public static String getString(String path, String name) {
+		initialize(path);
+		return xmlInsts.get(path).getString(name);
+	}
+	
+}

File WiktionaryIdioms/src/classifier/experiments/BasicApply.java

View file
  • Ignore whitespace
 import java.util.TreeMap;
 
 import classifier.classifiers.Classifier;
+import classifier.config.ClassifierConfigs;
 import classifier.model.ClassifierData;
 import classifier.model.ClassifierModel;
 import classifier.model.Result;
 import classifier.model.Sense;
-import config.ClassifierConfigs;
 
 public class BasicApply implements Experiment {
 	public static final String CONFIG_STR = "BasicApply";

File WiktionaryIdioms/src/classifier/experiments/Bootstrapping.java

View file
  • Ignore whitespace
 
 
 import classifier.classifiers.Classifier;
+import classifier.config.ClassifierConfigs;
 import classifier.model.ClassifierData;
 import classifier.model.ClassifierEvaluationUtils;
 import classifier.model.ClassifierModel;
 import classifier.model.Result;
 import classifier.model.Sense;
 import classifier.utilities.ClassifierDataUtils;
-import config.ClassifierConfigs;
 
 public class Bootstrapping implements Experiment {
 	public static final String CONFIG_STR = "Bootstrapping";

File WiktionaryIdioms/src/classifier/experiments/CompareFeatures.java

View file
  • Ignore whitespace
 import java.util.Map;
 
 import classifier.classifiers.Classifier;
+import classifier.config.ClassifierConfigs;
 import classifier.model.ClassifierData;
 
-import config.ClassifierConfigs;
 
 public class CompareFeatures implements Experiment {
 	public static final String CONFIG_STR = "CompareFeatures";

File WiktionaryIdioms/src/classifier/experiments/CompareGroups.java

View file
  • Ignore whitespace
 import java.util.Map;
 
 import classifier.classifiers.Classifier;
+import classifier.config.ClassifierConfigs;
 import classifier.features.numeric.Feature;
 import classifier.model.ClassifierData;
 
-import config.ClassifierConfigs;
 
 public class CompareGroups implements Experiment {
 	public static final String CONFIG_STR = "CompareGroups";

File WiktionaryIdioms/src/classifier/experiments/Experiment.java

View file
  • Ignore whitespace
 
 import java.util.List;
 
+import classifier.config.ClassifierConfigs;
 import classifier.model.ClassifierData;
 
-import config.ClassifierConfigs;
 
 public interface Experiment {
 

File WiktionaryIdioms/src/classifier/experiments/GridSearch.java

View file
  • Ignore whitespace
 import java.util.TreeMap;
 
 import classifier.classifiers.Classifier;
+import classifier.config.ClassifierConfigs;
 import classifier.features.numeric.Feature;
 import classifier.model.ClassifierData;
 import classifier.model.ClassifierModel;
 import classifier.model.Result;
 import classifier.model.Sense;
-import config.ClassifierConfigs;
 
 public class GridSearch implements Experiment {
 	public static final String CONFIG_STR = "GridSearch";

File WiktionaryIdioms/src/classifier/experiments/LabelData.java

View file
  • Ignore whitespace
 
 
 import classifier.classifiers.Classifier;
+import classifier.config.ClassifierConfigs;
+import classifier.config.GeneralConfigs;
 import classifier.model.ClassifierData;
 import classifier.model.ClassifierEvaluationUtils;
 import classifier.model.ClassifierModel;
 import classifier.model.Result;
 import classifier.utilities.ClassifierDataUtils;
-import config.ClassifierConfigs;
-import config.GeneralConfigs;
 
 public class LabelData {
 

File WiktionaryIdioms/src/classifier/experiments/RunClassifierExperimentFromFiles.java

View file
  • Ignore whitespace
 import java.util.Arrays;
 import java.util.List;
 
+import classifier.config.ClassifierConfigs;
+import classifier.config.GeneralConfigs;
 import classifier.model.ClassifierData;
 import classifier.utilities.ClassifierDataUtils;
 
-import config.ClassifierConfigs;
-import config.GeneralConfigs;
 
 public class RunClassifierExperimentFromFiles {
 

File WiktionaryIdioms/src/classifier/experiments/RunExperiment.java

View file
  • Ignore whitespace
 import java.util.Arrays;
 import java.util.List;
 
+import classifier.config.ClassifierConfigs;
+import classifier.config.GeneralConfigs;
 import classifier.model.ClassifierData;
 import classifier.utilities.ClassifierDataUtils;
 
-import config.ClassifierConfigs;
-import config.GeneralConfigs;
 
 public class RunExperiment {
-	public static final String SENSE_TRAIN_WHERE = " WHERE data_set = \"train\" AND gloss != \"\" ";
+	public static final String SENSE_TRAIN_WHERE = " WHERE data_set = \"train\" ";
 	public static final String SENSE_DEV_WHERE = 
-			" WHERE gloss != \"\" AND data_set=\"dev\" AND corrected_label IS NOT NULL " +
+			" WHERE data_set=\"dev\" AND corrected_label IS NOT NULL " +
 			"AND label != -1 AND specific_definition = \"\"";
 	public static final String SENSE_TEST_WHERE = 
-			" WHERE gloss != \"\" AND data_set=\"test\" AND corrected_label IS NOT NULL " +
+			" WHERE data_set=\"test\" AND corrected_label IS NOT NULL " +
 			"AND corrected_label != -1 AND specific_definition = \"\"";
 
 

File WiktionaryIdioms/src/classifier/features/strings/Specific.java

View file
  • Ignore whitespace
 import java.util.Scanner;
 import java.util.Set;
 
-import config.ClassifierConfigs;
-import config.GeneralConfigs;
+import classifier.config.ClassifierConfigs;
+import classifier.config.GeneralConfigs;
+
 
 import de.tudarmstadt.ukp.wiktionary.api.IWiktionaryEdition;
 import de.tudarmstadt.ukp.wiktionary.api.IWiktionarySense;

File WiktionaryIdioms/src/classifier/model/ClassifierData.java

View file
  • Ignore whitespace
 		}
 	}
 	
-	public ClassifierData(String title, int label) {
-		this.title = title;
-		this.label = label;
-		
-		this.features = new TreeMap<Integer, Double>();
-		
-		if (classes == null) {
-			classes = new ArrayList<Integer>();
-		}
-		if (!classes.contains(label)) {
-			classes.add(label);
-		}
-	}
-	
 	public String getParse() {
 		return parse;
 	}

File WiktionaryIdioms/src/classifier/model/ClassifierEvaluationUtils.java

View file
  • Ignore whitespace
 		return pr;
 	}
 	
-	public static double[] getAveragedPrecisionRecall(List<double[]> prs) {
-		double[] total = new double[2];
-		for (double[] pr : prs) {
-			total[0] += pr[0];
-			total[1] += pr[1];
-		}
-		total[0] = total[0] / (prs.size() * 1.0);
-		total[1] = total[1] / (prs.size() * 1.0);
-		return total;
-	}
-	
-	public static double[] getAveragePrecisionRecall(List<TreeMap<Integer, List<ClassifierData>>> overallResults) {
-		List<double[]> prs = new ArrayList<double[]>();
-		for (TreeMap<Integer, List<ClassifierData>> fResult : overallResults) {
-			double[] pr = getPrecisionRecall(fResult, 1);
-			prs.add(pr);
-		}
-		return getAveragedPrecisionRecall(prs);
-	}
-	
-	
-	public static List<double[]> getPrecisionRecalls(List<TreeMap<Integer, List<ClassifierData>>> overallResults) {
-		List<double[]> prs = new ArrayList<double[]>();
-		for (TreeMap<Integer, List<ClassifierData>> fResult : overallResults) {
-			double[] pr = getPrecisionRecall(fResult, 1);
-			prs.add(pr);
-		}
-		return prs;
-	}
-
-	
-	public static double getAverageFMeasure(List<double[]> prs) {
-		double total = 0;
-		for (double[] pr : prs) {
-			total += getFMeasure(pr);
-		}
-		return total / (1.0 * prs.size());
-	}
-	
 	// Method considers recall of 1 wrong
 	public static boolean getAllOneClassifier(List<double[]> prs) {
 		for (double[] pr : prs) {
 		return false;
 	}
 	
-	// Method considers recall of 1 wrong
-	public static boolean getAllOneClassifier(TreeMap<Integer, List<ClassifierData>> results) {
-		double[] pr = getPrecisionRecall(results, 1);
-		if (pr[1] == 1 || pr[1] == 0) {
-			return true;
-		}
-		return false;
-	}
-	
 	public static int[][] getConfusionMatrix(TreeMap<Integer, List<ClassifierData>> data, Map<Integer, Integer> classIndexes) {
 		int[][] confMatrix = new int[data.size()][data.size()];
 

File WiktionaryIdioms/src/classifier/model/ClassifierSettings.java

  • Ignore whitespace
-package classifier.model;
-
-import java.util.List;
-import java.util.Map;
-
-import classifier.classifiers.Classifier;
-
-public class ClassifierSettings {
-	public List<Integer> featuresToUse;
-	public Map<Integer, List<Sense>> folds;
-	public Classifier classy;
-	public boolean verbose;
-	public List<Sense> train;
-	public List<Sense> test;
-	public int iterationsMax;
-	public double errorBound;
-	public double learningDelta;
-}

File WiktionaryIdioms/src/classifier/model/ProportionalBaseline.java

View file
  • Ignore whitespace
 import java.util.Random;
 import java.util.TreeMap;
 
+import classifier.config.GeneralConfigs;
 import classifier.utilities.ClassifierDataUtils;
 
-import config.GeneralConfigs;
 
 public class ProportionalBaseline {
 

File WiktionaryIdioms/src/classifier/model/Result.java

View file
  • Ignore whitespace
 		this.idiomScore = idiomScore;
 	}
 	
-	public Result(Sense s) {
+	public Result(ClassifierData s) {
 		data = s;
 		scores = new HashMap<Integer, Double>();
 	}

File WiktionaryIdioms/src/classifier/utilities/DataUtils.java

View file
  • Ignore whitespace
 package classifier.utilities;
 
-import java.util.ArrayList;
-import java.util.HashMap;
 import java.util.List;
-import java.util.Map;
-import java.util.Random;
 
 import mysql.utilities.MySQLConnection;
 
 import classifier.model.DataPoint;
 
-
-import de.tudarmstadt.ukp.wiktionary.api.IWiktionaryEdition;
-import de.tudarmstadt.ukp.wiktionary.api.IWiktionaryPage;
-import de.tudarmstadt.ukp.wiktionary.api.entry.WiktionaryIterator;
-
 public class DataUtils {
 	
-	public static List<Long> getIdsFromPageTitles(IWiktionaryEdition wkt, List<String> titles) {
-		List<Long> results = new ArrayList<Long>();
-		for (String title : titles) {
-			IWiktionaryPage page = wkt.getPageForWord(title);
-			if (page != null) {
-				results.add(page.getId());
-			}
-		}
-		return results;
-	}
-
-	public static long[] getRandomPageSet(IWiktionaryEdition wkt, int size, int maxLookThrough) {
-		WiktionaryIterator<IWiktionaryPage> wit = wkt.getAllPages();
-		long[] results = new long[maxLookThrough];
-		int num = 0;
-		while (wit.hasNext() && maxLookThrough > num) {
-			IWiktionaryPage page = wit.next();
-			long id = page.getId();
-			results[num] = id;
-			num++;
-		}
-		return pickSample(results, size, new Random());
-	}
-	
-	public static long[] pickSample(long[] population, int nSamplesNeeded, Random r) {
-		  long[] ret = new long[nSamplesNeeded];
-		  int nPicked = 0, i = 0;
-		  int nLeft = population.length;
-		  while (nSamplesNeeded > 0) {
-		    int rand = r.nextInt(nLeft);
-		    if (rand < nSamplesNeeded) {
-		      ret[nPicked++] = population[i];
-		      nSamplesNeeded--;
-		    }
-		    nLeft--;
-		    i++;
-		  }
-		  return ret;
-	}
-	
-	public static Map<Integer, List<DataPoint>> getFolds(String database, String table) {
-		MySQLConnection moby = MySQLConnection.getInstance("localhost", database, "root", "");
-		List<String> select = new ArrayList<String>();
-		select.add("page_id");
-		select.add("title");
-		select.add("label");
-		select.add("fold_num");
-		List<String[]> results = moby.selectQuery(select, table, "");
-		Map<Integer, List<DataPoint>> folds = new HashMap<Integer, List<DataPoint>>();
-		// Go and put the results into the appropriate slot of the map.
-		for (String[] result : results) {
-			Long id = Long.parseLong(result[select.indexOf("page_id")]);
-			int label = Integer.parseInt(result[select.indexOf("label")]);
-			int foldNum = Integer.parseInt(result[select.indexOf("fold_num")]);
-			if (! folds.containsKey(foldNum)) {
-				folds.put(foldNum, new ArrayList<classifier.model.DataPoint>());
-			}
-			folds.get(foldNum).add(new DataPoint(id,result[select.indexOf("title")], label));
-		}
-		return folds;
-	}
-	
 	public static void insertData(String database, String table, List<String> whatToInsert, List<DataPoint> data) {
 		MySQLConnection moby = MySQLConnection.getInstance("localhost", database, "root", "");
 		moby.insertDataPointsInto(whatToInsert, data, table);

File WiktionaryIdioms/src/config/ClassifierConfigs.java

  • Ignore whitespace
-package config;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.NoSuchElementException;
-
-
-import org.apache.commons.configuration.ConfigurationException;
-import org.apache.commons.configuration.XMLConfiguration;
-
-import classifier.classifiers.Classifier;
-import classifier.classifiers.Perceptron;
-import classifier.classifiers.UntrustingPerceptron;
-import classifier.model.ClassifierModel;
-
-public class ClassifierConfigs {
-
-	
-	public static final String DEFAULT = "default";
-	public static final String EQUAL_DIST = "equalDist";
-	public static final String PERCENTS = "percents";
-	public static final String FOLDS = "folds";
-	public static final String LEARNING_RATE = "learningRate";
-	public static final String ITERATIONS = "iterations";
-	public static final String VERBOSE = "verbose";
-	public static final String FEATURES = "features";
-	public static final String ERROR_BOUND = "errorBound";
-	public static final String STRATIFIED = "stratified";
-	public static final String SENSES_PATH = "trainPath";
-	public static final String TRAIN_PATH = "trainPath";
-	public static final String TEST_PATH = "testPath";
-	public static final String CLASSIFIER_TYPE = "classifierType";
-	public static final String OUTFILE = "output.file";
-	public static final String GROUP = "group";
-
-	
-	private static ClassifierConfigs instance;
-	
-	private XMLConfiguration xmlInst;
-	
-	private String section;
-	
-	private ClassifierConfigs() {
-		try {
-			xmlInst = new XMLConfiguration(GeneralConfigs.CLASSIFIER_CONFIGS);
-			section = DEFAULT;
-		} catch (ConfigurationException e) {
-			// TODO Auto-generated catch block
-			e.printStackTrace();
-		}
-	}
-	
-	private ClassifierConfigs(String path) {
-		try {
-			xmlInst = new XMLConfiguration(path);
-			section = DEFAULT;
-		} catch (ConfigurationException e) {
-			// TODO Auto-generated catch block
-			e.printStackTrace();
-		}
-	}
-	
-	public static ClassifierConfigs getInstance() {
-		if (instance == null) {
-			instance = new ClassifierConfigs();
-		}
-		return instance;
-	}
-	
-	public static ClassifierConfigs getInstance(String path) {
-		if (instance == null) {
-			instance = new ClassifierConfigs(path);
-		}
-		return instance;
-	}
-	
-	public String getSString(String name) {
-		String result = xmlInst.getString(section + "." + name);
-		if (result == null || result.length() == 0) {
-			result = xmlInst.getString(DEFAULT + "." + name);
-		}
-		return result;
-	}
-	
-	public String[] getSStringArray(String name) {
-		String[] result = xmlInst.getStringArray(section + "." + name);
-		if (result == null || result.length == 0) {
-			result = xmlInst.getStringArray(DEFAULT + "." + name);
-		}
-		return result;
-	}
-	
-	public Integer getSInt(String name) {
-		int result;
-		try {
-			result = xmlInst.getInt(section + "." + name);
-		} catch (Exception e) {
-			try {
-				result = xmlInst.getInt(DEFAULT + "." + name);
-			} catch (Exception f) {
-				return null;
-			}
-		}
-		return result;
-	}
-	
-	public boolean getSBool(String name) {
-		boolean result;
-		try {
-			result = xmlInst.getBoolean(section + "." + name);
-		} catch (NoSuchElementException e) {
-			result = xmlInst.getBoolean(DEFAULT + "." + name, false);
-		}
-		return result;
-	}
-	
-	public double getSDouble(String name) {
-		double result;
-		try {
-			result = xmlInst.getDouble(section + "." + name);
-		} catch (NoSuchElementException e) {
-			result = xmlInst.getDouble(DEFAULT + "." + name);
-		}
-		return result;
-	}
-	
-	public void addConfig(String name, String value) {
-		xmlInst.addProperty(name, value);
-	}
-	
-	
-	public void setSection(String name) {
-		section = name;
-	}
-	
-	public List<Integer> getSFeatures(String name) {
-		// Now analyze which features we should be using
-		String[] feats = getSStringArray(name);
-		List<Integer> featuresToUse = new ArrayList<Integer>();
-		for (String num : feats) {
-			featuresToUse.add(Integer.parseInt(num));
-		}
-		return featuresToUse;
-	}
-	
-	public Classifier getSClassifier() {		
-		int iters = getSInt(ITERATIONS);
-		double errorBound = getSDouble(ERROR_BOUND);
-		double learningRate = getSInt(LEARNING_RATE);
-		List<Integer> feats = getSFeatures(FEATURES);
-
-		return getClassifier(iters, errorBound, learningRate, feats);
-	}
-	
-	public Classifier getClassifier(int iters, double errorBound, double learningRate, List<Integer> feats) {
-		String type = getSString(CLASSIFIER_TYPE);
-		if (type.equals("untrusting")) {
-			return new UntrustingPerceptron(iters, errorBound, learningRate, feats);
-		} else if (type.equals("perceptron")) {
-			// type.equals("perceptron")
-			return new Perceptron(iters, errorBound, learningRate, feats);
-		}
-		return null;
-	}
-	
-	public Classifier getClassifier(ClassifierModel clm) {
-		String type = getSString(CLASSIFIER_TYPE);
-		if (type.equals("untrusting")) {
-			return new UntrustingPerceptron(clm);
-		} else if (type.equals("perceptron")) {
-			// type.equals("perceptron")
-			return new Perceptron(clm);
-		}
-		return null;
-	}
-
-}

File WiktionaryIdioms/src/config/GeneralConfigs.java

  • Ignore whitespace
-package config;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.apache.commons.configuration.ConfigurationException;
-import org.apache.commons.configuration.XMLConfiguration;
-
-public class GeneralConfigs {
-	public static final String ESA_CONFIGS = "./config/esaconfig.xml";
-	public static final String DB_CONFIGS = "./config/dbconfig.xml";
-	public static final String CLASSIFIER_CONFIGS = "./config/classifierconfig.xml";
-	public static final String FEATURE_CONFIGS = "./config/featureconfig.xml";
-	public static final String DETECTOR_CONFIGS = "./config/detectorconfig.xml";
-
-	
-	private static Map<String, XMLConfiguration> xmlInsts;
-	
-	private static void initialize(String path) {
-		if (xmlInsts == null) {
-			xmlInsts = new HashMap<String, XMLConfiguration>();
-		}
-		if (!xmlInsts.containsKey(path)) {
-			try {
-				xmlInsts.put(path, new XMLConfiguration(path));
-			} catch (ConfigurationException e) {
-				// TODO Auto-generated catch block
-				e.printStackTrace();
-			}
-		}
-	}
-	
-	public static String getString(String path, String name) {
-		initialize(path);
-		return xmlInsts.get(path).getString(name);
-	}
-	
-}

File WiktionaryIdioms/src/detector/experiments/GoldenLabelsExperiment.java

View file
  • Ignore whitespace
 import java.util.List;
 import java.util.Set;
 
-import config.GeneralConfigs;
 
+import classifier.config.GeneralConfigs;
 import classifier.features.dependency.Pair;
 import classifier.model.ClassifierData;
 import classifier.model.Sense;

File WiktionaryIdioms/src/detector/experiments/IdentificationIncorporatedExperiment.java

View file
  • Ignore whitespace
 import java.util.Set;
 
 
-import config.GeneralConfigs;
 
 import classifier.classifiers.Classifier;
 import classifier.classifiers.Perceptron;
+import classifier.config.GeneralConfigs;
 import classifier.features.dependency.Pair;
 import classifier.model.ClassifierData;
 import classifier.model.ClassifierModel;

File WiktionaryIdioms/src/detector/experiments/RunDetectorExperiment.java

View file
  • Ignore whitespace
 import java.util.List;
 import java.util.TreeMap;
 
-import config.GeneralConfigs;
 
 import classifier.classifiers.Classifier;
 import classifier.classifiers.Perceptron;
+import classifier.config.GeneralConfigs;
 import classifier.model.ClassifierData;
 import classifier.model.ClassifierModel;
 import classifier.utilities.ClassifierDataUtils;

File WiktionaryIdioms/src/detector/experiments/RunDetectorExperimentFromFiles.java

View file
  • Ignore whitespace
 import java.util.Map;
 import java.util.TreeMap;
 
-import config.ClassifierConfigs;
 
 import classifier.classifiers.Classifier;
 import classifier.classifiers.Perceptron;
+import classifier.config.ClassifierConfigs;
 import classifier.model.ClassifierData;
 import classifier.model.ClassifierModel;
 import classifier.utilities.ClassifierDataUtils;

File WiktionaryIdioms/src/detector/methods/DetectorMethod.java

View file
  • Ignore whitespace
 
 import mysql.utilities.MySQLConnection;
 
+import classifier.config.GeneralConfigs;
 import classifier.model.ClassifierData;
 
-import config.GeneralConfigs;
 import classifier.utilities.ClassifierDataUtils;
 import classifier.utilities.StopWords;
 

File WiktionaryIdioms/src/detector/model/Example.java

View file
  • Ignore whitespace
 	private String text;
 	private TreeMap<Integer, Double> features;
 	private Date publication;
-	
 	public String key;
 	
-	public Example(int label, String title, String text) {
-		super(title, label);
-		this.text = text;
-	}
-	
 	public Example(int label, String title, String text, String key) {
 		super(key, title, label);
 		this.text = text;
 
 	@Override
 	public void printPrettyString(List<Integer> featuresToUse) {
-		// TODO Auto-generated method stub
+		System.out.println("UNIMPLEMENTED");
 		
 	}