Skip to content

Commit 769d6b5

Browse files
committed
Merge pull request #475 from rzanoli/release
Release 1.1.4
2 parents 253912f + 5ccf895 commit 769d6b5

File tree

262 files changed

+22551
-1002
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

262 files changed

+22551
-1002
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,6 @@ common/bin/
1717
lap/bin/
1818
uima.log
1919

20+
.metadata
21+
lap/src/null223365410
22+
.gitignore

alignmentedas/pom.xml

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?xml version="1.0"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
<parent>
5+
<groupId>eu.excitementproject</groupId>
6+
<artifactId>eop</artifactId>
7+
<version>1.1.4</version>
8+
</parent>
9+
<artifactId>alignmentedas</artifactId>
10+
<name>alignmentedas</name>
11+
<url>http://maven.apache.org</url>
12+
<properties>
13+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
14+
</properties>
15+
<dependencies>
16+
<!-- EOP modules -->
17+
<dependency>
18+
<groupId>eu.excitementproject</groupId>
19+
<artifactId>core</artifactId>
20+
<version>1.1.4</version>
21+
</dependency>
22+
<dependency>
23+
<groupId>eu.excitementproject</groupId>
24+
<artifactId>lap</artifactId>
25+
<version>1.1.4</version>
26+
</dependency>
27+
</dependencies>
28+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
package eu.excitementproject.eop.alignmentedas;
2+
3+
import java.io.File;
4+
import java.io.IOException;
5+
import java.util.List;
6+
7+
import org.apache.commons.io.FileUtils;
8+
import org.apache.log4j.BasicConfigurator;
9+
import org.apache.log4j.Level;
10+
import org.apache.log4j.Logger;
11+
import org.apache.uima.jcas.JCas;
12+
13+
import eu.excitementproject.eop.alignmentedas.p1eda.P1EDATemplate;
14+
import eu.excitementproject.eop.alignmentedas.p1eda.TEDecisionWithAlignment;
15+
import eu.excitementproject.eop.alignmentedas.p1eda.instances.SimpleWordCoverageDE;
16+
import eu.excitementproject.eop.alignmentedas.p1eda.instances.SimpleWordCoverageEN;
17+
import eu.excitementproject.eop.alignmentedas.p1eda.instances.SimpleWordCoverageIT;
18+
import eu.excitementproject.eop.alignmentedas.p1eda.sandbox.WNVOMT;
19+
import eu.excitementproject.eop.alignmentedas.p1eda.sandbox.WithVO;
20+
import eu.excitementproject.eop.alignmentedas.p1eda.sandbox.WithoutVO;
21+
import eu.excitementproject.eop.common.EDAException;
22+
import eu.excitementproject.eop.lap.LAPException;
23+
import eu.excitementproject.eop.lap.dkpro.TreeTaggerDE;
24+
import eu.excitementproject.eop.lap.dkpro.TreeTaggerEN;
25+
import eu.excitementproject.eop.lap.dkpro.TreeTaggerIT;
26+
import eu.excitementproject.eop.lap.implbase.LAP_ImplBase;
27+
28+
/**
29+
* A simple (EOP)-RTE XML data runner for P1EDA configurations
30+
*
31+
*/
32+
@SuppressWarnings("unused")
33+
public class P1EdaRTERunner
34+
{
35+
public static void main( String[] args )
36+
{
37+
BasicConfigurator.configure();
38+
Logger.getRootLogger().setLevel(Level.INFO); // set INFO to hide Debug info.
39+
40+
try
41+
{
42+
// Prepare LAP and EDA (here, both for English) and eval on RTE3 (again, EN)
43+
LAP_ImplBase lapEN = new TreeTaggerEN();
44+
P1EDATemplate p1edaEN = new SimpleWordCoverageEN(); // Put your (configured, instance) P1EDA here...
45+
evaluateOnRTE3EN(lapEN, p1edaEN, false); // set final argument true, if lap has not been changed from last call. (to reuse saved XMI files)
46+
47+
// use evaluateOnRTE3DE for German
48+
// LAP_ImplBase lapDE = new TreeTaggerDE();
49+
// P1EDATemplate p1edaDE = new SimpleWordCoverageDE();
50+
// evaluateOnRTE3DE(lapDE, p1edaDE, false);
51+
52+
// use evaluateOnRTE3IT for Italian
53+
// LAP_ImplBase lapIT = new TreeTaggerIT();
54+
// P1EDATemplate p1edaIT = new SimpleWordCoverageIT();
55+
// evaluateOnRTE3IT(lapIT, p1edaIT, false);
56+
57+
}
58+
catch(Exception e)
59+
{
60+
System.err.println("Run stopped with an exception: " + e.getMessage());
61+
}
62+
63+
}
64+
65+
public static void evaluateOnRTE3EN(LAP_ImplBase lap, P1EDATemplate p1eda, boolean isXmiAlreadyPreprocessed) throws LAPException, EDAException, IOException
66+
{
67+
File rteTrainingXML = new File("../core/src/main/resources/data-set/English_dev.xml");
68+
File rteTestingXML = new File("../core/src/main/resources/data-set/English_test.xml");
69+
70+
evaluateOnRTEData(lap, p1eda, rteTrainingXML, rteTestingXML, isXmiAlreadyPreprocessed);
71+
}
72+
73+
public static void evaluateOnRTE3DE(LAP_ImplBase lap, P1EDATemplate p1eda, boolean isXmiAlreadyPreprocessed) throws LAPException, EDAException, IOException
74+
{
75+
File rteTrainingXML = new File("../core/src/main/resources/data-set/German_dev.xml");
76+
File rteTestingXML = new File("../core/src/main/resources/data-set/German_test.xml");
77+
78+
evaluateOnRTEData(lap, p1eda, rteTrainingXML, rteTestingXML, isXmiAlreadyPreprocessed);
79+
}
80+
81+
public static void evaluateOnRTE3IT(LAP_ImplBase lap, P1EDATemplate p1eda, boolean isXmiAlreadyPreprocessed) throws LAPException, EDAException, IOException
82+
{
83+
File rteTrainingXML = new File("../core/src/main/resources/data-set/Italian_dev.xml");
84+
File rteTestingXML = new File("../core/src/main/resources/data-set/Italian_test.xml");
85+
86+
evaluateOnRTEData(lap, p1eda, rteTrainingXML, rteTestingXML, isXmiAlreadyPreprocessed);
87+
}
88+
89+
public static void evaluateOnRTEData(LAP_ImplBase lap, P1EDATemplate p1eda, File trainXML, File testXML, boolean xmiAlreadyPreprocessed) throws LAPException, EDAException, IOException
90+
{
91+
File trainXmiDir = new File("target/trainingXmis/");
92+
File evalXmiDir = new File("target/testingXmis/");
93+
94+
if (!xmiAlreadyPreprocessed)
95+
{
96+
runLAPForXmis(lap, trainXML, trainXmiDir);
97+
runLAPForXmis(lap, testXML, evalXmiDir);
98+
}
99+
100+
// Train the instance, and save model.
101+
//File classifierModel = new File ("target/cModel.model");
102+
File classifierModel = new File (CLASSIFIER_MODEL_NAME);
103+
p1eda.startTraining(trainXmiDir, classifierModel);
104+
105+
// evaluate with test(eval) data
106+
List<Double> evalResult = p1eda.evaluateModelWithGoldXmis(evalXmiDir);
107+
108+
System.out.println("(accuracy, f1, prec, recall, true positive ratio, true negative ratio)");
109+
System.out.println(evalResult.toString());
110+
}
111+
112+
public static void runLAPForXmis(LAP_ImplBase lap, File rteInputXML, File xmiDir) throws LAPException, IOException
113+
{
114+
115+
if (xmiDir.exists()) {
116+
// delete all contents
117+
FileUtils.deleteDirectory(xmiDir);
118+
}
119+
xmiDir.mkdirs();
120+
121+
lap.processRawInputFormat(rteInputXML, xmiDir);
122+
}
123+
124+
static int unused;
125+
static final String CLASSIFIER_MODEL_NAME = "target/temp.cmodel";
126+
}

0 commit comments

Comments
 (0)