Revision: 19216
http://sourceforge.net/p/gate/code/19216
Author: markagreenwood
Date: 2016-04-09 08:31:03 +0000 (Sat, 09 Apr 2016)
Log Message:
-----------
moved some more tests into the jape plugin, all but the ontology jape test
works as I haven't mavenized the ontology plugin yet
Modified Paths:
--------------
gate/branches/sawdust2/.classpath
gate/branches/sawdust2/plugins/ANNIE/pom.xml
gate/branches/sawdust2/plugins/ANNIE/src/test/java/com/ontotext/gate/gazetteer/TestHashGazetteer.java
gate/branches/sawdust2/plugins/ANNIE/src/test/java/gate/creole/tokeniser/TestTokeniser.java
gate/branches/sawdust2/plugins/ANNIE/src/test/java/gate/jape/functest/BaseJapeTests.java
gate/branches/sawdust2/plugins/ANNIE/src/test/java/gate/jape/functest/TestConstraints.java
gate/branches/sawdust2/plugins/ANNIE/src/test/java/gate/jape/functest/TestJape.java
gate/branches/sawdust2/plugins/ANNIE/src/test/resources/tests/jape/jape-test.xgapp
gate/branches/sawdust2/plugins/Tools/creole.xml
Added Paths:
-----------
gate/branches/sawdust2/plugins/ANNIE/src/test/java/gate/
gate/branches/sawdust2/plugins/ANNIE/src/test/java/gate/creole/
gate/branches/sawdust2/plugins/ANNIE/src/test/java/gate/creole/gazetteer/
gate/branches/sawdust2/plugins/ANNIE/src/test/java/gate/creole/gazetteer/TestGazetteer.java
gate/branches/sawdust2/plugins/ANNIE/src/test/java/gate/creole/tokeniser/
gate/branches/sawdust2/plugins/ANNIE/src/test/java/gate/jape/
gate/branches/sawdust2/plugins/ANNIE/src/test/resources/jape/
gate/branches/sawdust2/plugins/ANNIE/src/test/resources/tests/demo.owl
gate/branches/sawdust2/plugins/ANNIE/src/test/resources/tests/jape/
Removed Paths:
-------------
gate/branches/sawdust2/src/test/gate/creole/coref/
gate/branches/sawdust2/src/test/gate/creole/gazetteer/TestGazetteer.java
gate/branches/sawdust2/src/test/gate/creole/tokeniser/
gate/branches/sawdust2/src/test/gate/jape/
gate/branches/sawdust2/src/test/gate/resources/gate.ac.uk/tests/jape/
gate/branches/sawdust2/src/test/gate/resources/jape/
Modified: gate/branches/sawdust2/.classpath
===================================================================
--- gate/branches/sawdust2/.classpath 2016-04-09 08:29:56 UTC (rev 19215)
+++ gate/branches/sawdust2/.classpath 2016-04-09 08:31:03 UTC (rev 19216)
@@ -1,7 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src/main"/>
+ <classpathentry kind="src" path="src/test"/>
<classpathentry kind="con"
path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry exported="true" kind="con"
path="org.apache.ivyde.eclipse.cpcontainer.IVYDE_CONTAINER/?project=GATE&ivyXmlPath=ivy.xml&confs=*"/>
- <classpathentry kind="output" path="classes/main"/>
+ <classpathentry kind="output" path="classes/test"/>
</classpath>
Modified: gate/branches/sawdust2/plugins/ANNIE/pom.xml
===================================================================
--- gate/branches/sawdust2/plugins/ANNIE/pom.xml 2016-04-09 08:29:56 UTC
(rev 19215)
+++ gate/branches/sawdust2/plugins/ANNIE/pom.xml 2016-04-09 08:31:03 UTC
(rev 19216)
@@ -70,7 +70,16 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-report-plugin</artifactId>
+ <version>2.19.1</version>
</plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-project-info-reports-plugin</artifactId>
+ <version>2.9</version>
+ <configuration>
+
<dependencyLocationsEnabled>false</dependencyLocationsEnabled>
+ </configuration>
+ </plugin>
</plugins>
</reporting>
Modified:
gate/branches/sawdust2/plugins/ANNIE/src/test/java/com/ontotext/gate/gazetteer/TestHashGazetteer.java
===================================================================
---
gate/branches/sawdust2/plugins/ANNIE/src/test/java/com/ontotext/gate/gazetteer/TestHashGazetteer.java
2016-04-09 08:29:56 UTC (rev 19215)
+++
gate/branches/sawdust2/plugins/ANNIE/src/test/java/com/ontotext/gate/gazetteer/TestHashGazetteer.java
2016-04-09 08:31:03 UTC (rev 19216)
@@ -14,12 +14,7 @@
import gate.FeatureMap;
import gate.Gate;
import gate.Plugin;
-
-import java.net.URL;
-
-import junit.framework.Test;
import junit.framework.TestCase;
-import junit.framework.TestSuite;
/**
* Tests the HashGazetteer.
@@ -31,8 +26,10 @@
/** Fixture set up */
@Override
public void setUp() throws Exception {
- Gate.runInSandbox(true);
- Gate.init();
+ if (!Gate.isInitialised()) {
+ Gate.runInSandbox(true);
+ Gate.init();
+ }
Gate.getCreoleRegister().registerPlugin(new
Plugin.Maven("uk.ac.gate.plugins", "annie", "9.0-SNAPSHOT"));
}
@@ -46,8 +43,6 @@
Document doc =
Factory.newDocument(this.getClass().getResource("/tests/doc0.html"));
- System.out.println(doc.getFeatures().get("gate.SourceURL"));
-
//create a default gazetteer
FeatureMap params = Factory.newFeatureMap();
HashGazetteer gaz = (HashGazetteer) Factory.createResource(
Copied:
gate/branches/sawdust2/plugins/ANNIE/src/test/java/gate/creole/gazetteer/TestGazetteer.java
(from rev 19211,
gate/branches/sawdust2/src/test/gate/creole/gazetteer/TestGazetteer.java)
===================================================================
---
gate/branches/sawdust2/plugins/ANNIE/src/test/java/gate/creole/gazetteer/TestGazetteer.java
(rev 0)
+++
gate/branches/sawdust2/plugins/ANNIE/src/test/java/gate/creole/gazetteer/TestGazetteer.java
2016-04-09 08:31:03 UTC (rev 19216)
@@ -0,0 +1,159 @@
+/*
+ * TestGazetteer.java
+ *
+ * Copyright (c) 1995-2012, The University of Sheffield. See the file
+ * COPYRIGHT.txt in the software or at http://gate.ac.uk/gate/COPYRIGHT.txt
+ *
+ * This file is part of GATE (see http://gate.ac.uk/), and is free
+ * software, licenced under the GNU Library General Public License,
+ * Version 2, June 1991 (in the distribution as file licence.html,
+ * and also available at http://gate.ac.uk/gate/licence.html).
+ *
+ * Valentin Tablan, 25/10/2000
+ *
+ * $Id$
+ */
+
+package gate.creole.gazetteer;
+
+import gate.AnnotationSet;
+import gate.Document;
+import gate.Factory;
+import gate.FeatureMap;
+import gate.Gate;
+import gate.Plugin;
+
+import java.io.File;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+public class TestGazetteer extends TestCase {
+
+ public TestGazetteer(String name) {
+ super(name);
+ }
+
+ /** Fixture set up */
+ @Override
+ public void setUp() throws Exception {
+ if (!Gate.isInitialised()) {
+ Gate.runInSandbox(true);
+ Gate.init();
+ }
+
+ Gate.getCreoleRegister().registerPlugin(new
Plugin.Maven("uk.ac.gate.plugins", "annie", "9.0-SNAPSHOT"));
+ }
+
+ @Override
+ public void tearDown() throws Exception {
+ } // tearDown
+
+ /** Test the default tokeniser */
+ public void testDefaultGazetteer() throws Exception {
+ //get a document
+ Document doc =
Factory.newDocument(this.getClass().getResource("/tests/doc0.html"));
+
+ //create a default gazetteer
+ DefaultGazetteer gaz = (DefaultGazetteer) Factory.createResource(
+ "gate.creole.gazetteer.DefaultGazetteer");
+
+ //runtime stuff
+ gaz.setDocument(doc);
+ gaz.setAnnotationSetName("GazetteerAS");
+ //test with default parameters
+ gaz.execute();
+ AnnotationSet resultAS = doc.getAnnotations("GazetteerAS");
+ assertEquals("Wrong number of annotations produced",63, resultAS.size());
+ resultAS.clear();
+
+ //test with partial words
+ gaz.setWholeWordsOnly(false);
+ gaz.execute();
+ assertEquals("Wrong number of annotations produced", 400, resultAS.size());
+ gaz.setWholeWordsOnly(true);
+ resultAS.clear();
+
+ //test with prefix matching
+ gaz.setLongestMatchOnly(false);
+ gaz.execute();
+ assertEquals("Wrong number of annotations produced", 78, resultAS.size());
+ gaz.setLongestMatchOnly(true);
+ resultAS.clear();
+ Factory.deleteResource(gaz);
+
+ //test with case insensitive
+ FeatureMap fm = Factory.newFeatureMap();
+ fm.put(DefaultGazetteer.DEF_GAZ_CASE_SENSITIVE_PARAMETER_NAME, false);
+ gaz = (DefaultGazetteer) Factory.createResource(
+ "gate.creole.gazetteer.DefaultGazetteer", fm);
+ gaz.setDocument(doc);
+ gaz.setAnnotationSetName("GazetteerAS");
+ gaz.execute();
+ assertEquals("Wrong number of annotations generated", 104,
resultAS.size());
+ gaz.setCaseSensitive(true);
+ resultAS.clear();
+ Factory.deleteResource(gaz);
+ Factory.deleteResource(doc);
+ }
+
+ /**
+ * Tests additions and deletions from the gazetteer in both case
+ * sensitive and case insensitive modes
+ */
+ public void testDynamicMethods() throws Exception {
+
+
+ for (int i = 0 ; i < 2 ; ++i) {
+
+ FeatureMap params = Factory.newFeatureMap();
+ params.put(DefaultGazetteer.DEF_GAZ_CASE_SENSITIVE_PARAMETER_NAME, i !=
0);
+
+ DefaultGazetteer gaz = (DefaultGazetteer) Factory.createResource(
+ "gate.creole.gazetteer.DefaultGazetteer",params);
+
+ Document doc = Factory.newDocument("RandomWord gazetteer tester");
+ gaz.setDocument(doc);
+
+ gaz.execute();
+ assertEquals("Wrong number of lookup annotations in dynamic test 1/3",
0, doc.getAnnotations().get("Lookup").size());
+ doc.getAnnotations().clear();
+
+ Lookup lookup = new Lookup("random.lst","random","word","en");
+ gaz.add("RandomWord", lookup);
+
+ gaz.execute();
+ assertEquals("Wrong number of lookup annotations in dynamic test 2/3",
1, doc.getAnnotations().get("Lookup").size());
+ doc.getAnnotations().clear();
+
+ gaz.removeLookup("RandomWord", lookup);
+ gaz.execute();
+ assertEquals("Wrong number of lookup annotations in dynamic test 3/3",
0, doc.getAnnotations().get("Lookup").size());
+
+ Factory.deleteResource(gaz);
+
+ }
+
+ }
+
+ /** Test suite routine for the test runner */
+ public static Test suite() {
+ return new TestSuite(TestGazetteer.class);
+ } // suite
+
+ public static void main(String[] args) {
+ try{
+ Gate.init();
+ Gate.getCreoleRegister().registerDirectories((new
File(Gate.getPluginsHome(),"ANNIE")).toURI().toURL());
+ TestGazetteer testGaz = new TestGazetteer("");
+ testGaz.setUp();
+ testGaz.testDefaultGazetteer();
+ testGaz.testDynamicMethods();
+ testGaz.tearDown();
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ } // main
+
+} // TestGazetteer
Modified:
gate/branches/sawdust2/plugins/ANNIE/src/test/java/gate/creole/tokeniser/TestTokeniser.java
===================================================================
--- gate/branches/sawdust2/src/test/gate/creole/tokeniser/TestTokeniser.java
2016-04-08 18:22:42 UTC (rev 19211)
+++
gate/branches/sawdust2/plugins/ANNIE/src/test/java/gate/creole/tokeniser/TestTokeniser.java
2016-04-09 08:31:03 UTC (rev 19216)
@@ -17,22 +17,28 @@
package gate.creole.tokeniser;
-import java.net.URL;
+import gate.Document;
+import gate.Factory;
+import gate.Gate;
+import gate.Plugin;
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
-import junit.framework.*;
-
-import gate.*;
-import gate.corpora.TestDocument;
-
public class TestTokeniser extends TestCase{
public TestTokeniser(String name) {
super(name);
}
- /** Fixture set up */
@Override
public void setUp() throws Exception {
+ if (!Gate.isInitialised()) {
+ Gate.runInSandbox(true);
+ Gate.init();
+ }
+
+ Gate.getCreoleRegister().registerPlugin(new
Plugin.Maven("uk.ac.gate.plugins", "annie", "9.0-SNAPSHOT"));
}
@Override
@@ -42,9 +48,8 @@
/** Test the default tokeniser */
public void testDefaultTokeniser() throws Exception {
//get a document
- Document doc = Factory.newDocument(
- new URL(TestDocument.getTestServerName() + "tests/doc0.html")
- );
+ Document doc =
Factory.newDocument(this.getClass().getResource("/tests/doc0.html"));
+
//create a default tokeniser
DefaultTokeniser tokeniser = (DefaultTokeniser) Factory.createResource(
"gate.creole.tokeniser.DefaultTokeniser");
Modified:
gate/branches/sawdust2/plugins/ANNIE/src/test/java/gate/jape/functest/BaseJapeTests.java
===================================================================
--- gate/branches/sawdust2/src/test/gate/jape/functest/BaseJapeTests.java
2016-04-08 18:22:42 UTC (rev 19211)
+++
gate/branches/sawdust2/plugins/ANNIE/src/test/java/gate/jape/functest/BaseJapeTests.java
2016-04-09 08:31:03 UTC (rev 19216)
@@ -21,6 +21,7 @@
import gate.Factory;
import gate.FeatureMap;
import gate.Gate;
+import gate.Plugin;
import gate.Resource;
import gate.creole.AbstractLanguageAnalyser;
import gate.creole.ExecutionException;
@@ -32,18 +33,14 @@
import java.io.File;
import java.io.IOException;
-import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
-import java.util.Properties;
import java.util.Set;
import java.util.TreeSet;
import junit.framework.TestCase;
-import org.apache.log4j.BasicConfigurator;
import org.apache.log4j.Logger;
-import org.apache.log4j.PropertyConfigurator;
/**
* Tests for Constraint predicate logic
@@ -54,59 +51,31 @@
private static final Logger logger = Logger.getLogger(BaseJapeTests.class);
- protected static final String DEFAULT_DATA_FILE =
"jape/InputTexts/AveShort";
+ protected static final String DEFAULT_DATA_FILE =
"/jape/InputTexts/AveShort";
public BaseJapeTests(String name) {
- super(name);
- setUpGate(); //TODO remove when figure out why TestConstraints won't
start
+ super(name);
}
/**
* Initializes GATE and sets up plug-ins. The operation is idempotent.
*/
- protected static void setUpGate() {
- if (Gate.isInitialised()) {
- logger.warn("GATE already intialized and set up for JAPE Transducer
tests.");
-
- }
- else {
+ @Override
+ public void setUp() throws Exception {
+ if (!Gate.isInitialised()) {
+ Gate.runInSandbox(true);
+ //TODO remove this once all plugins can be found via maven
+ //Gate.setPluginsHome(new
File("/home/mark/gate-top/externals/gate/plugins/"));
+ Gate.init();
+ }
+
-
+ Gate.getCreoleRegister().registerPlugin(new
Plugin.Maven("uk.ac.gate.plugins", "annie", "9.0-SNAPSHOT"));
- Properties logConfProps = new Properties();
- InputStream logConfStream =
BaseJapeTests.class.getResourceAsStream("log4j-test.properties");
- assert logConfStream != null : "Cannot locate LOG4J properties file";
- try {
- logConfProps.load(logConfStream);
- logConfStream.close();
- } catch (IOException e2) {
- logger.warn("Unable to load logging properties.");
- BasicConfigurator.configure();
- }
-
- PropertyConfigurator.configure(logConfProps);
-
- if (System.getProperty("gate.home") == null)
- System.setProperty("gate.home", ".");
- try {
- Gate.init();
- } catch (GateException e1) {
- String errMsg = "Unable to initialize GATE";
- logger.fatal(errMsg);
- throw new RuntimeException(errMsg);
- }
- logger.debug("GATE home is: " + Gate.getGateHome().getAbsolutePath());
-
- if (!Gate.getPluginsHome().isDirectory()) {
- String errMsg = "GATE home and plug-in directory set up failure.";
- logger.fatal(errMsg);
- throw new RuntimeException(errMsg);
- }
- }
/** CHANGE THIS if JAPE Transducer need more plug-ins */
- final File[] plugInsToLoad = { new File(Gate.getPluginsHome(),
"Ontology") };
+ final File[] plugInsToLoad = {};//{ new File(Gate.getPluginsHome(),
"Ontology") };
for (File plugInDir : plugInsToLoad) {
try {
@@ -116,13 +85,7 @@
}
}
- try {
- registerCREOLE((transducerType == TransducerType.CLASSIC) ? new
File(Gate.getPluginsHome(), "ANNIE") : transducerType.getPlugInDir());
- } catch (Exception e) {
- String errMsg = "JAPE Transducer plug-in cannot be loaded.";
- logger.fatal(errMsg);
- throw new RuntimeException(errMsg);
- }
+
}
private static void registerCREOLE(File plugInDir) throws GateException {
@@ -168,7 +131,7 @@
throw new IllegalArgumentException("Document or JAPE file must not
be null");
}
FeatureMap params = Factory.newFeatureMap();
- URL japeUrl = Files.getGateResource(japeFile);
+ URL japeUrl = BaseJapeTests.class.getResource(japeFile);
if (japeUrl == null) {
throw new IllegalArgumentException("Resource with relative path: "
+ japeFile + " is missing.");
}
@@ -225,7 +188,7 @@
protected Set<Annotation> doTest(String docResourcePath, String
japeResourcePath, AnnotationCreator ac,
String ontologyURL) throws Exception {
- Document doc =
Factory.newDocument(Files.getGateResourceAsString(docResourcePath));
+ Document doc =
Factory.newDocument(BaseJapeTests.class.getResource(docResourcePath));
return doTest(doc, japeResourcePath, ac, ontologyURL);
}
Modified:
gate/branches/sawdust2/plugins/ANNIE/src/test/java/gate/jape/functest/TestConstraints.java
===================================================================
--- gate/branches/sawdust2/src/test/gate/jape/functest/TestConstraints.java
2016-04-08 18:22:42 UTC (rev 19211)
+++
gate/branches/sawdust2/plugins/ANNIE/src/test/java/gate/jape/functest/TestConstraints.java
2016-04-09 08:31:03 UTC (rev 19216)
@@ -21,7 +21,7 @@
import gate.Factory;
import gate.FeatureMap;
import gate.Gate;
-import gate.corpora.TestDocument;
+import gate.jape.JapeFactory;
import gate.jape.Transducer;
import gate.jape.parser.ParseCpsl;
import gate.jape.parser.ParseException;
@@ -902,7 +902,7 @@
"EqualAndNotExistance", "OntoTest", "OntoTest2"};
Set<Annotation> actualResults = doTest(DEFAULT_DATA_FILE, japeFile,
- basicAnnotCreator, TestDocument.getTestServerName() +
"tests/demo.owl");
+ basicAnnotCreator,
this.getClass().getResource("/tests/demo.owl").toString());
Out.println(actualResults);
compareResults(expectedResults, actualResults);
}
@@ -1395,12 +1395,12 @@
add(14, 16, "D", feat);
feat = Factory.newFeatureMap();
- feat.put("ontology", TestDocument.getTestServerName() +
"tests/demo.owl");
+ feat.put("ontology", this.getClass().getResource("tests/demo.owl"));
feat.put("class", "Businessman");
add(16, 18, "D", feat);
feat = Factory.newFeatureMap();
- feat.put("ontology", TestDocument.getTestServerName() +
"tests/demo.owl");
+ feat.put("ontology", this.getClass().getResource("tests/demo.owl"));
feat.put("class", "Country");
add(18, 19, "D", feat);
return as;
@@ -1415,26 +1415,10 @@
*/
protected static void parseJapeString(String japeRules) throws
ParseException {
StringReader sr = new StringReader(japeRules);
- ParseCpsl parser = Factory.newJapeParser(sr, new HashMap<String,
Object>());
+ ParseCpsl parser = JapeFactory.newJapeParser(sr, new HashMap<String,
Object>());
Transducer transducer = parser.MultiPhaseTransducer();
transducer.finish(Gate.getClassLoader());
}
- /* Set up for Runners */
-
- public static Test suite() {
- Test suite = new TestSetup(new TestSuite(TestConstraints.class)) {
- @Override
- protected void setUp() {
- setUpGate();
- logger.info("GATE initialized and fixure set up.");
- }
- };
- return suite;
- }
-
- // main method for running this test as a standalone test
- public static void main(String[] args) {
- junit.textui.TestRunner.run(TestConstraints.suite());
- }
+
} // class TestJape
Modified:
gate/branches/sawdust2/plugins/ANNIE/src/test/java/gate/jape/functest/TestJape.java
===================================================================
--- gate/branches/sawdust2/src/test/gate/jape/functest/TestJape.java
2016-04-08 18:22:42 UTC (rev 19211)
+++
gate/branches/sawdust2/plugins/ANNIE/src/test/java/gate/jape/functest/TestJape.java
2016-04-09 08:31:03 UTC (rev 19216)
@@ -38,10 +38,6 @@
import java.net.URL;
import java.util.Set;
-import junit.extensions.TestSetup;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
import org.apache.commons.io.output.NullOutputStream;
import org.apache.log4j.Logger;
@@ -77,7 +73,7 @@
return doc.getAnnotations();
}
};
- Set<Annotation> res = doTest("texts/doc0.html", "/jape/TestABC.jape",
ac);
+ Set<Annotation> res = doTest("/tests/doc0.html", "/jape/TestABC.jape",
ac);
Out.println(res);
assertEquals(res.toString(), 3, res.size());
compareStartOffsets(res, 2, 2, 2);
@@ -98,7 +94,7 @@
public void testApplicationModes() throws PersistenceException,
ResourceInstantiationException,
IOException, ExecutionException {
//load the application
- URL applicationURL =
Files.getGateResource("gate.ac.uk/tests/jape/jape-test.xgapp");
+ URL applicationURL =
TestJape.class.getResource("/tests/jape/jape-test.xgapp");
CorpusController application = (CorpusController) PersistenceManager
.loadObjectFromUrl(applicationURL);
//load the test file
@@ -141,7 +137,7 @@
features.put("orth", "upperInitial");
doc.getAnnotations().add(new Long(0), new Long(8), "Token",
features);
- doTest(doc, "tests/RhsError.jape", null, null);
+ doTest(doc, "jape/tests/RhsError.jape", null, null);
fail("Bad JAPE grammar didn't throw an exception");
} catch (Exception e) {
if (logger.isDebugEnabled())
@@ -151,7 +147,7 @@
} // testRhsErrorMessages
public void testBrill() throws IOException, GateException, Exception {
- String japeFile =
"/gate.ac.uk/tests/jape/control_mode_tests/brill_test.jape";
+ String japeFile = "/tests/jape/control_mode_tests/brill_test.jape";
String[] expectedResults = { "Find_A", "Find_A", "Find_A_B",
"Find_A_B", "Find_A_B_C" };
AnnotationCreator annotCreator = new BaseAnnotationCreator() {
@@ -176,7 +172,7 @@
} // testBrill()
public void testAppeltMode() throws IOException, GateException, Exception {
- String japeFile =
"/gate.ac.uk/tests/jape/control_mode_tests/appelt_test.jape";
+ String japeFile = "/tests/jape/control_mode_tests/appelt_test.jape";
String[] expectedResults = { "Find_A_B_C" };
AnnotationCreator annotCreator = new BaseAnnotationCreator() {
@@ -200,7 +196,7 @@
} // testAppelt()
public void testAllMode() throws IOException, GateException, Exception {
- String japeFile =
"/gate.ac.uk/tests/jape/control_mode_tests/all_mode_test.jape";
+ String japeFile = "/tests/jape/control_mode_tests/all_mode_test.jape";
String[] expectedResults = { "Find_A", "Find_A", "Find_A_B",
"Find_A_B", "Find_A_B_C", "Find_A",
"Find_A_B", "Find_B_C" };
@@ -240,7 +236,7 @@
FeatureMap features = Factory.newFeatureMap();
features.put("orth", "upperInitial");
doc.getAnnotations().add(new Long(0), new Long(8), "Token",
features);
- doTest(doc, "tests/RhsError2.jape", null, null);
+ doTest(doc, "jape/tests/RhsError2.jape", null, null);
fail("Bad JAPE grammar (2) didn't throw an exception");
} catch (Exception e) {
// success
@@ -250,18 +246,6 @@
} // testRhsErrorMessages2
- public static Test suite() {
- Test suite = new TestSetup(new TestSuite(TestJape.class)) {
- @Override
- protected void setUp() {
- setUpGate();
- logger.info("GATE initialized and fixure set up.");
- }
- };
- return suite;
- }
- public static void main(String... args) {
- junit.textui.TestRunner.run(TestJape.suite());
- }
+
} // class TestJape
Copied: gate/branches/sawdust2/plugins/ANNIE/src/test/resources/tests/demo.owl
(from rev 19211,
gate/branches/sawdust2/src/test/gate/resources/gate.ac.uk/tests/demo.owl)
===================================================================
--- gate/branches/sawdust2/plugins/ANNIE/src/test/resources/tests/demo.owl
(rev 0)
+++ gate/branches/sawdust2/plugins/ANNIE/src/test/resources/tests/demo.owl
2016-04-09 08:31:03 UTC (rev 19216)
@@ -0,0 +1,62 @@
+<?xml version="1.0"?>
+<rdf:RDF
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
+ xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
+ xmlns:owl="http://www.w3.org/2002/07/owl#"
+ xmlns="http://www.owl-ontologies.com/unnamed.owl#"
+ xml:base="http://www.owl-ontologies.com/unnamed.owl">
+ <owl:Ontology rdf:about=""/>
+ <owl:Class rdf:ID="Person"/>
+ <owl:Class rdf:ID="Charity">
+ <rdfs:subClassOf>
+ <owl:Class rdf:ID="Organization"/>
+ </rdfs:subClassOf>
+ </owl:Class>
+ <owl:Class rdf:ID="Company">
+ <rdfs:subClassOf rdf:resource="#Organization"/>
+ </owl:Class>
+ <owl:Class rdf:ID="Ministry">
+ <rdfs:subClassOf>
+ <owl:Class rdf:ID="Government"/>
+ </rdfs:subClassOf>
+ </owl:Class>
+ <owl:Class rdf:ID="Province">
+ <rdfs:subClassOf>
+ <owl:Class rdf:ID="Location"/>
+ </rdfs:subClassOf>
+ </owl:Class>
+ <owl:Class rdf:ID="Sportsman">
+ <rdfs:subClassOf rdf:resource="#Person"/>
+ </owl:Class>
+ <owl:Class rdf:ID="Department">
+ <rdfs:subClassOf>
+ <owl:Class rdf:about="#Government"/>
+ </rdfs:subClassOf>
+ </owl:Class>
+ <owl:Class rdf:ID="MoneyAmount"/>
+ <owl:Class rdf:ID="City">
+ <rdfs:subClassOf rdf:resource="#Location"/>
+ </owl:Class>
+ <owl:Class rdf:ID="Region">
+ <rdfs:subClassOf rdf:resource="#Location"/>
+ </owl:Class>
+ <owl:Class rdf:ID="Politician">
+ <rdfs:subClassOf rdf:resource="#Person"/>
+ </owl:Class>
+ <owl:Class rdf:ID="MediaPerson">
+ <rdfs:subClassOf rdf:resource="#Person"/>
+ </owl:Class>
+ <owl:Class rdf:ID="Businessman">
+ <rdfs:subClassOf rdf:resource="#Person"/>
+ </owl:Class>
+ <owl:Class rdf:about="Government">
+ <rdfs:subClassOf rdf:resource="#Organization"/>
+ </owl:Class>
+ <owl:Class rdf:ID="Date"/>
+ <owl:Class rdf:ID="Country">
+ <rdfs:subClassOf rdf:resource="#Location"/>
+ </owl:Class>
+</rdf:RDF>
+
+<!-- Created with Protege (with OWL Plugin 2.1, Build 284)
http://protege.stanford.edu -->
Modified:
gate/branches/sawdust2/plugins/ANNIE/src/test/resources/tests/jape/jape-test.xgapp
===================================================================
---
gate/branches/sawdust2/src/test/gate/resources/gate.ac.uk/tests/jape/jape-test.xgapp
2016-04-08 18:22:42 UTC (rev 19211)
+++
gate/branches/sawdust2/plugins/ANNIE/src/test/resources/tests/jape/jape-test.xgapp
2016-04-09 08:31:03 UTC (rev 19216)
@@ -1,10 +1,6 @@
<gate.util.persistence.GateApplication>
<urlList class="gate.util.persistence.CollectionPersistence">
- <localList>
- <gate.util.persistence.PersistenceManager-URLHolder>
- <urlString>$gatehome$plugins/ANNIE</urlString>
- </gate.util.persistence.PersistenceManager-URLHolder>
- </localList>
+ <localList/>
<collectionType>java.util.ArrayList</collectionType>
</urlList>
<application
class="gate.util.persistence.SerialAnalyserControllerPersistence">
Modified: gate/branches/sawdust2/plugins/Tools/creole.xml
===================================================================
--- gate/branches/sawdust2/plugins/Tools/creole.xml 2016-04-09 08:29:56 UTC
(rev 19215)
+++ gate/branches/sawdust2/plugins/Tools/creole.xml 2016-04-09 08:31:03 UTC
(rev 19216)
@@ -3,7 +3,7 @@
<CREOLE-DIRECTORY>
<JAR SCAN="true">tools.jar</JAR>
- <REQUIRES GROUP="uk.ac.gate" ARTIFACT="ANNIE" VERSION="9"/>
+ <REQUIRES GROUP="uk.ac.gate.plugins" ARTIFACT="annie"
VERSION="9.0-SNAPSHOT"/>
</CREOLE-DIRECTORY>
Deleted:
gate/branches/sawdust2/src/test/gate/creole/gazetteer/TestGazetteer.java
===================================================================
--- gate/branches/sawdust2/src/test/gate/creole/gazetteer/TestGazetteer.java
2016-04-09 08:29:56 UTC (rev 19215)
+++ gate/branches/sawdust2/src/test/gate/creole/gazetteer/TestGazetteer.java
2016-04-09 08:31:03 UTC (rev 19216)
@@ -1,156 +0,0 @@
-/*
- * TestGazetteer.java
- *
- * Copyright (c) 1995-2012, The University of Sheffield. See the file
- * COPYRIGHT.txt in the software or at http://gate.ac.uk/gate/COPYRIGHT.txt
- *
- * This file is part of GATE (see http://gate.ac.uk/), and is free
- * software, licenced under the GNU Library General Public License,
- * Version 2, June 1991 (in the distribution as file licence.html,
- * and also available at http://gate.ac.uk/gate/licence.html).
- *
- * Valentin Tablan, 25/10/2000
- *
- * $Id$
- */
-
-package gate.creole.gazetteer;
-
-import gate.AnnotationSet;
-import gate.Document;
-import gate.Factory;
-import gate.FeatureMap;
-import gate.Gate;
-import gate.corpora.TestDocument;
-
-import java.io.File;
-import java.net.URL;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-public class TestGazetteer extends TestCase {
-
- public TestGazetteer(String name) {
- super(name);
- }
-
- /** Fixture set up */
- @Override
- public void setUp() throws Exception {
- }
-
- @Override
- public void tearDown() throws Exception {
- } // tearDown
-
- /** Test the default tokeniser */
- public void testDefaultGazetteer() throws Exception {
- //get a document
- Document doc = Factory.newDocument(
- new URL(TestDocument.getTestServerName() + "tests/doc0.html")
- );
-
- //create a default gazetteer
- DefaultGazetteer gaz = (DefaultGazetteer) Factory.createResource(
- "gate.creole.gazetteer.DefaultGazetteer");
-
- //runtime stuff
- gaz.setDocument(doc);
- gaz.setAnnotationSetName("GazetteerAS");
- //test with default parameters
- gaz.execute();
- AnnotationSet resultAS = doc.getAnnotations("GazetteerAS");
- assertEquals("Wrong number of annotations produced",63, resultAS.size());
- resultAS.clear();
-
- //test with partial words
- gaz.setWholeWordsOnly(false);
- gaz.execute();
- assertEquals("Wrong number of annotations produced", 400, resultAS.size());
- gaz.setWholeWordsOnly(true);
- resultAS.clear();
-
- //test with prefix matching
- gaz.setLongestMatchOnly(false);
- gaz.execute();
- assertEquals("Wrong number of annotations produced", 78, resultAS.size());
- gaz.setLongestMatchOnly(true);
- resultAS.clear();
- Factory.deleteResource(gaz);
-
- //test with case insensitive
- FeatureMap fm = Factory.newFeatureMap();
- fm.put(DefaultGazetteer.DEF_GAZ_CASE_SENSITIVE_PARAMETER_NAME, false);
- gaz = (DefaultGazetteer) Factory.createResource(
- "gate.creole.gazetteer.DefaultGazetteer", fm);
- gaz.setDocument(doc);
- gaz.setAnnotationSetName("GazetteerAS");
- gaz.execute();
- assertEquals("Wrong number of annotations generated", 104,
resultAS.size());
- gaz.setCaseSensitive(true);
- resultAS.clear();
- Factory.deleteResource(gaz);
- Factory.deleteResource(doc);
- }
-
- /**
- * Tests additions and deletions from the gazetteer in both case
- * sensitive and case insensitive modes
- */
- public void testDynamicMethods() throws Exception {
-
-
- for (int i = 0 ; i < 2 ; ++i) {
-
- FeatureMap params = Factory.newFeatureMap();
- params.put(DefaultGazetteer.DEF_GAZ_CASE_SENSITIVE_PARAMETER_NAME, i !=
0);
-
- DefaultGazetteer gaz = (DefaultGazetteer) Factory.createResource(
- "gate.creole.gazetteer.DefaultGazetteer",params);
-
- Document doc = Factory.newDocument("RandomWord gazetteer tester");
- gaz.setDocument(doc);
-
- gaz.execute();
- assertEquals("Wrong number of lookup annotations in dynamic test 1/3",
0, doc.getAnnotations().get("Lookup").size());
- doc.getAnnotations().clear();
-
- Lookup lookup = new Lookup("random.lst","random","word","en");
- gaz.add("RandomWord", lookup);
-
- gaz.execute();
- assertEquals("Wrong number of lookup annotations in dynamic test 2/3",
1, doc.getAnnotations().get("Lookup").size());
- doc.getAnnotations().clear();
-
- gaz.removeLookup("RandomWord", lookup);
- gaz.execute();
- assertEquals("Wrong number of lookup annotations in dynamic test 3/3",
0, doc.getAnnotations().get("Lookup").size());
-
- Factory.deleteResource(gaz);
-
- }
-
- }
-
- /** Test suite routine for the test runner */
- public static Test suite() {
- return new TestSuite(TestGazetteer.class);
- } // suite
-
- public static void main(String[] args) {
- try{
- Gate.init();
- Gate.getCreoleRegister().registerDirectories((new
File(Gate.getPluginsHome(),"ANNIE")).toURI().toURL());
- TestGazetteer testGaz = new TestGazetteer("");
- testGaz.setUp();
- testGaz.testDefaultGazetteer();
- testGaz.testDynamicMethods();
- testGaz.tearDown();
- } catch(Exception e) {
- e.printStackTrace();
- }
- } // main
-
-} // TestGazetteer
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Find and fix application performance issues faster with Applications Manager
Applications Manager provides deep performance insights into multiple tiers of
your business applications. It resolves application problems quickly and
reduces your MTTR. Get your free trial! http://pubads.g.doubleclick.net/
gampad/clk?id=1444514301&iu=/ca-pub-7940484522588532
_______________________________________________
GATE-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gate-cvs