Skip to content

Commit

Permalink
Merge pull request #376 from rzanoli/release
Browse files Browse the repository at this point in the history
Release 1.1.2
  • Loading branch information
rzanoli committed Mar 21, 2014
2 parents f8c06f7 + bf735d8 commit dc8595a
Show file tree
Hide file tree
Showing 287 changed files with 28,687 additions and 8,710 deletions.
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
Excitement-Open-Platform
========================

The EXCITEMENT Open Platform (EOP) is an open source software platform containing state-of-the-art algorithms for recognizing texual entailment relations:

_given two text fragments, one named text and the other named hypothesis, the task consists in recognizing whether the hypothesis can be inferred from the text_
This repository contains both the code and the documentation (i.e. wiki pages) of the next Excitement Open Platform (EOP) release. EOP is an open source software platform containing state-of-the-art algorithms for recognizing texual entailment relations: _given two text fragments, one named text and the other named hypothesis, the task consists in recognizing whether the hypothesis can be inferred from the text_


__Master Branch Status:__ [![Build Status](http://hlt-services4.fbk.eu:8080/jenkins/job/master_branch/badge/icon)](http://hlt-services4.fbk.eu:8080/jenkins/job/master_branch/)
4 changes: 2 additions & 2 deletions biutee/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>eu.excitementproject</groupId>
<artifactId>eop</artifactId>
<version>1.1.1</version>
<version>1.1.2</version>
</parent>
<artifactId>biutee</artifactId>
<name>biutee</name>
Expand Down Expand Up @@ -36,7 +36,7 @@
<dependency>
<groupId>eu.excitementproject</groupId>
<artifactId>transformations</artifactId>
<version>1.1.1</version>
<version>1.1.2</version>
</dependency>

</dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,56 @@ public class ClassifierFactory
public static double SVM_SLACK_COEFFICIENT = BiuteeConstants.SVM_SLACK_COEFFICIENT;
public static double LOGISTIC_REGRESSION_LEARNING_RATE= 0.005;

public ClassifierFactory(Boolean useF1Classifier)
{
this.useF1Classifier = useF1Classifier;
}


public LinearTrainableStorableClassifier getProperClassifier(boolean datasetNatureF1) throws ClassifierException
{
return getProperClassifierForSearch(datasetNatureF1);
}

public LinearTrainableStorableClassifier getProperClassifierForSearch(boolean datasetNatureF1) throws ClassifierException
{
boolean f1 = false;
if (this.useF1Classifier!=null)
{
f1 = this.useF1Classifier.booleanValue();
}
else
{
f1 = datasetNatureF1;
}

if (f1)
{
logger.info("Using F1 optimized classifier");
return getF1Classifier();
}
else
{
logger.info("Using accuracy optimized classifier");
return getByPoolLinearClassifier();
}
}

@Deprecated
public TrainableStorableClassifier getDefaultClassifier() throws ClassifierException
{
logger.info("getDefaultClassifier()");
return getByPoolLinearClassifier();
}

@Deprecated
public LinearTrainableStorableClassifier getDefaultClassifierForSearch() throws ClassifierException
{
logger.info("getDefaultClassifierForSearch()");
return getByPoolLinearClassifier();
}


@Deprecated
public LinearTrainableStorableClassifier getF1Classifier() throws ClassifierException
{
logger.info("getF1Classifier() returns new GradientAscentClassifier(0.0, 0.01, new F_alpha_DerivativeCalculator(Constants.F1_CLASSIFIER_GAMMA_FOR_SIGMOID),Constants.F1_CLASSIFIER_GAMMA_FOR_SIGMOID)");
Expand Down Expand Up @@ -166,7 +203,8 @@ protected TrainableClassifier getDefaultSvmClassifier() throws ClassifierExcepti

return new SvmLightClassifier(trainingParameters);
}

private final Boolean useF1Classifier;

private static Logger logger = Logger.getLogger(ClassifierFactory.class);

}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import eu.excitementproject.eop.biutee.classifiers.Classifier;
import eu.excitementproject.eop.biutee.classifiers.LabeledSample;
import eu.excitementproject.eop.biutee.utilities.BiuteeException;
import eu.excitementproject.eop.common.datastructures.immutable.ImmutableList;
import eu.excitementproject.eop.common.datastructures.immutable.ImmutableListWrapper;

/**
* Holds the entailment-decisions of a full dataset of T-H pairs.
Expand Down Expand Up @@ -96,6 +98,29 @@ public Vector<LabeledSample> getResultsAsLabeledSamples() throws BiuteeException
}
return samples;
}

///// Standard getters:


/**
* Returns the proofs
* @return the proofs
*/
public ImmutableList<InstanceAndProof<I, P>> getProofs()
{
return new ImmutableListWrapper<>(proofs);
}


/**
* Returns the classifier for predictions
* @return the classifier for predictions
*/
public Classifier getClassifierForPredictions()
{
return classifierForPredictions;
}



protected final List<InstanceAndProof<I, P>> proofs;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,26 @@ public class TimeStatistics implements Serializable
private static final long serialVersionUID = 2588315787317423702L;

public static TimeStatistics fromTimeElapsedTracker(TimeElapsedTracker tracker)
{
return fromTimeElapsedTracker(tracker,null,null);
}

public static TimeStatistics fromTimeElapsedTracker(TimeElapsedTracker tracker, Long numberOfExpandedElements, Long numberOfGeneratedElements)
{
long cputime = tracker.getCpuTimeElapsed();
long worldtime = tracker.getWorldClockElapsed();
return new TimeStatistics(cputime,worldtime);
return new TimeStatistics(cputime,worldtime,numberOfExpandedElements,numberOfGeneratedElements);
}


public TimeStatistics(long cpuTimeNanoSeconds, long worldClockTimeMilliSeconds)
public TimeStatistics(long cpuTimeNanoSeconds, long worldClockTimeMilliSeconds,
Long numberOfExpandedElements,Long numberOfGeneratedElements)
{
super();
this.cpuTimeNanoSeconds = cpuTimeNanoSeconds;
this.worldClockTimeMilliSeconds = worldClockTimeMilliSeconds;
this.numberOfExpandedElements = numberOfExpandedElements;
this.numberOfGeneratedElements = numberOfGeneratedElements;
}


Expand All @@ -39,18 +48,33 @@ public long getWorldClockTimeMilliSeconds()
{
return worldClockTimeMilliSeconds;
}
public Long getNumberOfExpandedElements()
{
return numberOfExpandedElements;
}
public Long getNumberOfGeneratedElements()
{
return numberOfGeneratedElements;
}





@Override
public String toString()
{
return "Cpu Time (ns) = "
String ret = "Cpu Time (ns) = "
+ String.format("%,d", getCpuTimeNanoSeconds())
+ ", World Clock Time (ms) = "
+ String.format("%,d",getWorldClockTimeMilliSeconds()) ;
+ String.format("%,d",getWorldClockTimeMilliSeconds());

if ( (numberOfExpandedElements!=null) && (numberOfGeneratedElements!=null) )
{
ret = ret
+ ", Number of expanded elements = "
+ String.format("%,d",getNumberOfExpandedElements())
+ ", Number of generated elements = "
+ String.format("%,d",getNumberOfGeneratedElements());
}
return ret;
}


Expand All @@ -59,4 +83,6 @@ public String toString()

private final long cpuTimeNanoSeconds;
private final long worldClockTimeMilliSeconds;
private final Long numberOfExpandedElements;
private final Long numberOfGeneratedElements;
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,16 @@
import static eu.excitementproject.eop.biutee.utilities.BiuteeConstants.LEARNING_MODEL_FILE_SEARCH_INDICATOR;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Vector;

import org.apache.log4j.Logger;


import eu.excitementproject.eop.biutee.classifiers.LabeledSample;
import eu.excitementproject.eop.biutee.classifiers.LinearTrainableStorableClassifier;
import eu.excitementproject.eop.biutee.classifiers.TrainableStorableClassifier;
Expand Down Expand Up @@ -63,29 +65,36 @@ public Trainer(Dataset<I> dataset,

public void train() throws BiuteeException
{
verifyInput();
classifierForSearch = classifierGenerator.createReasonableGuessClassifier();
iterationNumber = 0;
Double successRatePreviousIteration = null;
Double successRateCurrentIteration = null;
do
try
{
if (samplesLastIteration!=null)
verifyInput();
classifierForSearch = classifierGenerator.createReasonableGuessClassifier();
iterationNumber = 0;
Double successRatePreviousIteration = null;
Double successRateCurrentIteration = null;
do
{
samplesOfOlderIterations.add(samplesLastIteration);
if (samplesLastIteration!=null)
{
samplesOfOlderIterations.add(samplesLastIteration);
}
iterate();
storeClassifiers();

successRatePreviousIteration = successRateCurrentIteration;
successRateCurrentIteration = resultsLastIteration.getSuccessRate();
++iterationNumber;

logIterationResults();
endOfIterationEntryPoint();
}
iterate();
storeClassifiers();

successRatePreviousIteration = successRateCurrentIteration;
successRateCurrentIteration = resultsLastIteration.getSuccessRate();
++iterationNumber;

logIterationResults();
endOfIterationEntryPoint();
while (!isMainLoopDone(iterationNumber,successRatePreviousIteration,successRateCurrentIteration));
logger.info("Training done. Results of last iteration:\n"+resultsLastIteration.print());
}
catch (IOException e)
{
throw new BiuteeException("IO failure. Please see nested exception.",e);
}
while (!isMainLoopDone(iterationNumber,successRatePreviousIteration,successRateCurrentIteration));
logger.info("Training done. Results of last iteration:\n"+resultsLastIteration.print());
}

/**
Expand Down Expand Up @@ -162,7 +171,7 @@ private void iterate() throws BiuteeException
resultsLastIteration.compute();
}

private void logIterationResults() throws BiuteeException
private void logIterationResults() throws BiuteeException, IOException
{
logger.info("Iteration done.\nProofs:");
Iterator<String> detailsIterator = resultsLastIteration.instanceDetailsIterator();
Expand All @@ -172,6 +181,19 @@ private void logIterationResults() throws BiuteeException
logger.info(details);
}
logger.info("Current iteration result summary:\n"+resultsLastIteration.print());


if (BiuteeConstants.SAVE_SERIALIZED_RESULTS)
{
File serFile = new File(BiuteeConstants.RESULTS_SER_FILE_PREFIX+"_"+iterationNumber+BiuteeConstants.RESULTS_SER_FILE_POSTFIX);
logger.info("Iteration "+iterationNumber+" done."
+ " Saving results in ser file to "+serFile.getName());
try(ObjectOutputStream serStream = new ObjectOutputStream(new FileOutputStream(serFile)))
{
serStream.writeObject(resultsLastIteration.getProofs());
}
ExperimentManager.getInstance().register(serFile);
}
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@
*/
public class AccuracyClassifierGenerator extends DefaultAbstractClassifierGenerator
{
public AccuracyClassifierGenerator(FeatureVectorStructureOrganizer featureVectorStructure, File modelForSearch, File modelForPredictions)
public AccuracyClassifierGenerator(ClassifierFactory classifierFactory, FeatureVectorStructureOrganizer featureVectorStructure, File modelForSearch, File modelForPredictions)
{
super(featureVectorStructure, modelForSearch, modelForPredictions);
super(classifierFactory, featureVectorStructure, modelForSearch, modelForPredictions);
}

public AccuracyClassifierGenerator(FeatureVectorStructureOrganizer featureVectorStructure)
public AccuracyClassifierGenerator(ClassifierFactory classifierFactory, FeatureVectorStructureOrganizer featureVectorStructure)
{
super(featureVectorStructure);
super(classifierFactory, featureVectorStructure);
}


Expand All @@ -33,7 +33,7 @@ public LinearTrainableStorableClassifier createTrainableClassifierForSearch() th
{
try
{
return new ClassifierFactory().getDefaultClassifierForSearch();
return classifierFactory.getProperClassifierForSearch(false);
}
catch (ClassifierException e)
{
Expand All @@ -46,7 +46,7 @@ public TrainableStorableClassifier createTrainableClassifierForPredictions() thr
{
try
{
return new ClassifierFactory().getDefaultClassifier();
return classifierFactory.getProperClassifier(false);
}
catch (ClassifierException e)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import eu.excitementproject.eop.biutee.classifiers.Classifier;
import eu.excitementproject.eop.biutee.classifiers.ClassifierException;
import eu.excitementproject.eop.biutee.classifiers.ClassifierFactory;
import eu.excitementproject.eop.biutee.classifiers.LinearClassifier;
import eu.excitementproject.eop.biutee.classifiers.LinearTrainableStorableClassifier;
import eu.excitementproject.eop.biutee.rteflow.endtoend.ClassifierGenerator;
Expand All @@ -22,19 +23,22 @@
public abstract class DefaultAbstractClassifierGenerator extends ClassifierGenerator
{
public DefaultAbstractClassifierGenerator(
ClassifierFactory classifierFactory,
FeatureVectorStructureOrganizer featureVectorStructure,
File modelForSearch, File modelForPredictions)
{
super();
this.classifierFactory = classifierFactory;
this.featureVectorStructure = featureVectorStructure;
this.modelForSearch = modelForSearch;
this.modelForPredictions = modelForPredictions;
}


public DefaultAbstractClassifierGenerator(FeatureVectorStructureOrganizer featureVectorStructure)
public DefaultAbstractClassifierGenerator(ClassifierFactory classifierFactory, FeatureVectorStructureOrganizer featureVectorStructure)
{
super();
this.classifierFactory = classifierFactory;
this.featureVectorStructure = featureVectorStructure;
this.modelForSearch = null;
this.modelForPredictions = null;
Expand All @@ -46,7 +50,7 @@ public LinearTrainableStorableClassifier createReasonableGuessClassifier() throw
{
try
{
ReasonableGuessCreator reasonableGuessCreator = new ReasonableGuessCreator(featureVectorStructure);
ReasonableGuessCreator reasonableGuessCreator = new ReasonableGuessCreator(classifierFactory,featureVectorStructure);
reasonableGuessCreator.create();
return reasonableGuessCreator.getClassifier();
}
Expand Down Expand Up @@ -87,6 +91,7 @@ public Classifier loadClassifierForPredictions() throws BiuteeException
}


protected final ClassifierFactory classifierFactory;
protected final FeatureVectorStructureOrganizer featureVectorStructure;
private final File modelForSearch; // might be null
private final File modelForPredictions; // might be null
Expand Down
Loading

0 comments on commit dc8595a

Please sign in to comment.