From 6c2c592257c806b5c826d49dd26472f513170002 Mon Sep 17 00:00:00 2001 From: Hendy Irawan Date: Fri, 11 Jul 2014 07:08:47 -0430 Subject: [PATCH] Improvements for preparation to separate test data into plain text files. Refs #103. --- build.xml | 28 ++++++++++++++++++++-- src/java_test/relex/test/TestRelEx.java | 26 +++++++++++++++----- src/java_test/relex/test/TestStanford.java | 23 ++++++++++++++---- 3 files changed, 64 insertions(+), 13 deletions(-) diff --git a/build.xml b/build.xml index e757ecb0e..8f02296ef 100644 --- a/build.xml +++ b/build.xml @@ -1,5 +1,5 @@ - + @@ -59,10 +59,30 @@ - + + + + + + + + + + + + + + + + + @@ -112,6 +132,7 @@ + @@ -124,6 +145,7 @@ includeantruntime="false" source="${source}" target="${target}"> + @@ -161,12 +183,14 @@ + + diff --git a/src/java_test/relex/test/TestRelEx.java b/src/java_test/relex/test/TestRelEx.java index f950d90d6..39b3f6421 100644 --- a/src/java_test/relex/test/TestRelEx.java +++ b/src/java_test/relex/test/TestRelEx.java @@ -19,6 +19,9 @@ import java.util.ArrayList; import java.util.Collections; +import org.junit.BeforeClass; +import org.junit.Test; + import relex.ParsedSentence; import relex.RelationExtractor; import relex.Sentence; @@ -26,16 +29,20 @@ public class TestRelEx { - private RelationExtractor re; + private static RelationExtractor re; private int pass; private int fail; private int subpass; private int subfail; private static ArrayList sentfail= new ArrayList(); + @BeforeClass + public static void setUpClass() { + re = new RelationExtractor(); + } + public TestRelEx() { - re = new RelationExtractor(); pass = 0; fail = 0; subpass = 0; @@ -82,7 +89,7 @@ public boolean test_sentence (String sent, String sf) //parser-unary-relation-output arrayList "urgot" for unary relationships for (int i=0; i< exp.size(); i++) { - if(!brgot.contains((String)exp.get(i))) + if(!brgot.contains(exp.get(i))) { if(!urgot.contains(exp.get(i))) { @@ -821,7 +828,14 @@ public boolean test_extraposition() public static void main(String[] args) { + setUpClass(); TestRelEx ts = new TestRelEx(); + ts.runTests(); + } + + @Test + public void runTests() { + TestRelEx ts = this; boolean rc = true; rc &= ts.test_comparatives(); @@ -829,11 +843,11 @@ public static void main(String[] args) rc &= ts.test_Conjunction(); if (rc) { - System.err.println("Tested " + ts.pass + " sentences, test passed OK"); + System.err.println("Tested " + pass + " sentences, test passed OK"); } else { System.err.println("Test failed\n\t" + - ts.fail + " sentences failed\n\t" + - ts.pass + " sentences passed"); + fail + " sentences failed\n\t" + + pass + " sentences passed"); } System.err.println("******************************"); diff --git a/src/java_test/relex/test/TestStanford.java b/src/java_test/relex/test/TestStanford.java index 7694ef996..9f05b8ac9 100644 --- a/src/java_test/relex/test/TestStanford.java +++ b/src/java_test/relex/test/TestStanford.java @@ -19,6 +19,9 @@ import java.util.ArrayList; import java.util.Collections; +import org.junit.BeforeClass; +import org.junit.Test; + import relex.ParsedSentence; import relex.RelationExtractor; import relex.Sentence; @@ -26,15 +29,19 @@ public class TestStanford { - private RelationExtractor re; + private static RelationExtractor re; private int pass; private int fail; private static ArrayList sentfail= new ArrayList(); private static ArrayList sentfailpostag= new ArrayList(); + @BeforeClass + public static void setUpClass() { + re = new RelationExtractor(); + } + public TestStanford() { - re = new RelationExtractor(); re.do_stanford = true; pass = 0; fail = 0; @@ -135,7 +142,13 @@ public boolean test_tagged_sentence (String sent, String sf) public static void main(String[] args) { + setUpClass(); TestStanford ts = new TestStanford(); + } + + @Test + public void runTests() { + TestStanford ts = this; boolean rc = true; // The parses below were compared to the Stanford parser, circa @@ -546,13 +559,13 @@ public static void main(String[] args) if (rc) { - System.err.println("Tested " + ts.pass + " sentences, test passed OK"); + System.err.println("Tested " + pass + " sentences, test passed OK"); } else { System.err.println("Test failed\n\t" + - ts.fail + " sentences failed\n\t" + - ts.pass + " sentences passed"); + fail + " sentences failed\n\t" + + pass + " sentences passed"); } System.err.println("********************************************************");