From: <ku...@us...> - 2011-06-09 16:12:25
|
Revision: 2858 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=2858&view=rev Author: kurzum Date: 2011-06-09 16:12:18 +0000 (Thu, 09 Jun 2011) Log Message: ----------- added the webservice, the code is untested as i still can not compile DL-Learner at the moment, go to interfaces and start with mvn jetty:run Modified Paths: -------------- trunk/interfaces/pom.xml Added Paths: ----------- trunk/interfaces/src/main/java/org/dllearner/server/Rest.java trunk/interfaces/src/main/webapp/ trunk/interfaces/src/main/webapp/WEB-INF/ trunk/interfaces/src/main/webapp/WEB-INF/web.xml Modified: trunk/interfaces/pom.xml =================================================================== --- trunk/interfaces/pom.xml 2011-06-08 18:10:11 UTC (rev 2857) +++ trunk/interfaces/pom.xml 2011-06-09 16:12:18 UTC (rev 2858) @@ -1,88 +1,112 @@ <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"> - <modelVersion>4.0.0</modelVersion> + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> - <groupId>org.dllearner</groupId> - <artifactId>interfaces</artifactId> - <packaging>jar</packaging> - <name>Interfaces: GUI, CLI, Web Service </name> - <url>http://aksw.org/Projects/DLLearner</url> + <groupId>org.dllearner</groupId> + <artifactId>interfaces</artifactId> + <packaging>jar</packaging> + <name>Interfaces: GUI, CLI, Web Service</name> + <url>http://aksw.org/Projects/DLLearner</url> - <parent> - <groupId>org.dllearner</groupId> - <artifactId>dllearner-parent</artifactId> - <version>1.0-SNAPSHOT</version> - </parent> + <parent> + <groupId>org.dllearner</groupId> + <artifactId>dllearner-parent</artifactId> + <version>1.0-SNAPSHOT</version> + </parent> - <build> - <plugins> - <!--Surefire - for JUnits --> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-surefire-plugin</artifactId> - <configuration> - <excludes> - <exclude>org/dllearner/test/junit/OWLlinkTest.java</exclude> - </excludes> - </configuration> - </plugin> - <plugin> - <artifactId>jdeb</artifactId> - <groupId>org.vafer</groupId> - <version>0.8</version> - <executions> - <execution> - <phase>package</phase> - <goals> - <goal>jdeb</goal> - </goals> - <configuration> - <dataSet> - <data> - <src>${project.build.directory}/${project.build.finalName}.jar</src> - <type>file</type> - <mapper> - <type>perm</type> - <prefix>/usr/share/dllearner</prefix> - </mapper> - </data> - </dataSet> - </configuration> - </execution> - </executions> - </plugin> - </plugins> - </build> + <build> + <finalName>dl-learner</finalName> + <plugins> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>tomcat-maven-plugin</artifactId> + </plugin> + <plugin> + <groupId>org.mortbay.jetty</groupId> + <artifactId>maven-jetty-plugin</artifactId> + </plugin> + <!--Surefire - for JUnits --> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-surefire-plugin</artifactId> + <configuration> + <excludes> + <exclude>org/dllearner/test/junit/OWLlinkTest.java</exclude> + </excludes> + </configuration> + </plugin> + <plugin> + <artifactId>jdeb</artifactId> + <groupId>org.vafer</groupId> + <version>0.8</version> + <executions> + <execution> + <phase>package</phase> + <goals> + <goal>jdeb</goal> + </goals> + <configuration> + <dataSet> + <data> + <src>${project.build.directory}/${project.build.finalName}.jar</src> + <type>file</type> + <mapper> + <type>perm</type> + <prefix>/usr/share/dllearner</prefix> + </mapper> + </data> + </dataSet> + </configuration> + </execution> + </executions> + </plugin> + </plugins> + </build> - <dependencies> - <dependency> - <groupId>org.dllearner</groupId> - <artifactId>components-core</artifactId> - </dependency> + <dependencies> + <dependency> + <groupId>org.dllearner</groupId> + <artifactId>components-core</artifactId> + </dependency> - <!--Added the dependency of the core tests so that they will be accessible - from the tests in this component --> - <dependency> - <groupId>org.dllearner</groupId> - <artifactId>components-core</artifactId> - <classifier>tests</classifier> - <scope>test</scope> - </dependency> + <!--Added the dependency of the core tests so that they will be accessible + from the tests in this component --> + <dependency> + <groupId>org.dllearner</groupId> + <artifactId>components-core</artifactId> + <classifier>tests</classifier> + <scope>test</scope> + </dependency> - <dependency> - <groupId>org.dllearner</groupId> - <artifactId>components-ext</artifactId> - </dependency> - <dependency> - <groupId>com.jamonapi</groupId> - <artifactId>jamon</artifactId> - </dependency> + <dependency> + <groupId>org.dllearner</groupId> + <artifactId>components-ext</artifactId> + </dependency> + <dependency> + <groupId>com.jamonapi</groupId> + <artifactId>jamon</artifactId> + </dependency> - <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - <scope>test</scope> - </dependency> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <scope>test</scope> + </dependency> - </dependencies> + <dependency> + <groupId>javax.servlet</groupId> + <artifactId>servlet-api</artifactId> + </dependency> + <dependency> + <groupId>javax.servlet</groupId> + <artifactId>jsp-api</artifactId> + </dependency> + <dependency> + <groupId>javax.servlet</groupId> + <artifactId>jstl</artifactId> + </dependency> + + </dependencies> + + </project> Added: trunk/interfaces/src/main/java/org/dllearner/server/Rest.java =================================================================== --- trunk/interfaces/src/main/java/org/dllearner/server/Rest.java (rev 0) +++ trunk/interfaces/src/main/java/org/dllearner/server/Rest.java 2011-06-09 16:12:18 UTC (rev 2858) @@ -0,0 +1,140 @@ +package org.dllearner.server; + +import com.jamonapi.Monitor; +import com.jamonapi.MonitorFactory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.io.PrintWriter; +import java.net.URLEncoder; +import java.security.InvalidParameterException; + + +public abstract class Rest extends HttpServlet { + private static Logger log = LoggerFactory.getLogger(Rest.class); + + @Override + protected void doGet(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws ServletException, IOException { + handle(httpServletRequest, httpServletResponse); + } + + @Override + protected void doPost(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws ServletException, IOException { + handle(httpServletRequest, httpServletResponse); + } + + + /** + * * + * + * @param httpServletRequest + * @param httpServletResponse + * @throws ServletException + * @throws java.io.IOException + */ + private void handle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws ServletException, IOException { + Monitor mon = MonitorFactory.getTimeMonitor("NIFParameters.getInstance").start(); + String result = ""; + try { + //check parameters + String conf = ""; + if (isSet(httpServletRequest, "conf")) { + conf = httpServletRequest.getParameter("conf"); + } else { + throw new InvalidParameterException("No parameter 'conf' found. " + getDocumentation(httpServletRequest.getRequestURL().toString())); + } + + //output default is json + String output = "json"; + if (isSet(httpServletRequest, "output")) { + output = httpServletRequest.getParameter("output"); + //use the function one of + if (!oneOf(output, "json", "xml")) { + throw new InvalidParameterException("Wrong parameter value for \"output\", must be one of ( json, xml ) " + getDocumentation(httpServletRequest.getRequestURL().toString())); + } + } + + /** + * Do the magic here + */ + result = conf; + + PrintWriter pw = httpServletResponse.getWriter(); + log.debug("Request handled: " + logMonitor(mon.stop())); + pw.print(result); + pw.close(); + + } catch (IllegalArgumentException e) { + String msg = e.getMessage() + printParameterMap(httpServletRequest); + log.error(msg); + httpServletResponse.setContentType("text/plain"); + PrintWriter out = httpServletResponse.getWriter(); + out.println(msg); + out.close(); + + } catch (Exception e) { + String msg = "An error occured: " + e.getMessage() + printParameterMap(httpServletRequest); + log.error(msg, e); + httpServletResponse.setContentType("text/plain"); + PrintWriter out = httpServletResponse.getWriter(); + out.println(msg); + out.close(); + + } + + } + + + /** + * Examples are from NIF + * + * @param serviceUrl + * @return + */ + public static String getDocumentation(String serviceUrl) { + String doc = ""; + try { + doc = "\nExample1: \n " + serviceUrl + "?input=" + URLEncoder.encode("That's a lot of nuts! That'll be four bucks, baby! You want fries with that? ", "UTF-8") + "&type=text"; + doc += "\nExample2: \n " + serviceUrl + "?input=" + URLEncoder.encode("That's a lot of nuts! That's a lot of nuts! ", "UTF-8") + "&type=text"; + } catch (Exception e) { + log.error("", e); + } + return doc; + } + + public static boolean isSet(HttpServletRequest httpServletRequest, String name) { + log.trace("isSet(" + name + ")"); + log.trace(httpServletRequest.getParameterValues(name) + ""); + return httpServletRequest.getParameterValues(name) != null && httpServletRequest.getParameterValues(name).length == 1 && httpServletRequest.getParameter(name).length() > 0; + } + + public static boolean oneOf(String value, String... possibleValues) { + for (String s : possibleValues) { + if (s.equals(value)) { + return true; + } + } + return false; + } + + protected static String logMonitor(Monitor m) { + return "needed: " + m.getLastValue() + " ms. (" + m.getTotal() + " total)"; + } + + public static String printParameterMap(HttpServletRequest httpServletRequest) { + StringBuffer buf = new StringBuffer(); + for (Object key : httpServletRequest.getParameterMap().keySet()) { + buf.append("\nParameter: " + key + " Values: "); + for (String s : httpServletRequest.getParameterValues((String) key)) { + buf.append(((s.length() > 200) ? s.substring(0, 200) + "..." : s) + " "); + } + } + return buf.toString(); + } + +} Added: trunk/interfaces/src/main/webapp/WEB-INF/web.xml =================================================================== --- trunk/interfaces/src/main/webapp/WEB-INF/web.xml (rev 0) +++ trunk/interfaces/src/main/webapp/WEB-INF/web.xml 2011-06-09 16:12:18 UTC (rev 2858) @@ -0,0 +1,19 @@ +<!DOCTYPE web-app PUBLIC + "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" + "http://java.sun.com/dtd/web-app_2_3.dtd" > + +<web-app> + <display-name>DL-Learner</display-name> + + + <servlet> + <servlet-name>rest</servlet-name> + <servlet-class>org.dllearner.server.Rest</servlet-class> + </servlet> + + <servlet-mapping> + <servlet-name>rest</servlet-name> + <url-pattern>/rest</url-pattern> + </servlet-mapping> + +</web-app> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ku...@us...> - 2011-06-10 10:14:48
|
Revision: 2862 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=2862&view=rev Author: kurzum Date: 2011-06-10 10:14:42 +0000 (Fri, 10 Jun 2011) Log Message: ----------- fixed paths Modified Paths: -------------- trunk/interfaces/pom.xml trunk/interfaces/src/main/java/org/dllearner/server/Rest.java trunk/interfaces/src/main/webapp/WEB-INF/web.xml Modified: trunk/interfaces/pom.xml =================================================================== --- trunk/interfaces/pom.xml 2011-06-10 06:33:31 UTC (rev 2861) +++ trunk/interfaces/pom.xml 2011-06-10 10:14:42 UTC (rev 2862) @@ -15,16 +15,53 @@ </parent> <build> - <finalName>dl-learner</finalName> + <finalName>interfaces</finalName> <plugins> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>tomcat-maven-plugin</artifactId> </plugin> + <plugin> <groupId>org.mortbay.jetty</groupId> <artifactId>maven-jetty-plugin</artifactId> + <configuration> + <stopKey>stopKey</stopKey> + <stopPort>9999</stopPort> + <scanIntervalSeconds>1</scanIntervalSeconds> + <!--requestLog implementation="org.mortbay.jetty.NCSARequestLog"> + <filename>log/yyyy_mm_dd.request.log</filename> + <retainDays>90</retainDays> + <append>true</append> + <extended>false</extended> + <logTimeZone>GMT</logTimeZone> + </requestLog--> + </configuration> + <!--execution is used for testing--> + <executions> + <execution> + <id>start-jetty</id> + <phase>pre-integration-test</phase> + <goals> + <goal>run</goal> + </goals> + <configuration> + <scanIntervalSeconds>0</scanIntervalSeconds> + <daemon>true</daemon> + <stopKey>stopKey</stopKey> + <stopPort>9999</stopPort> + </configuration> + </execution> + <execution> + <id>stop-jetty</id> + <phase>post-integration-test</phase> + <goals> + <goal>stop</goal> + </goals> + </execution> + </executions> </plugin> + <!--Surefire - for JUnits --> <plugin> <groupId>org.apache.maven.plugins</groupId> Modified: trunk/interfaces/src/main/java/org/dllearner/server/Rest.java =================================================================== --- trunk/interfaces/src/main/java/org/dllearner/server/Rest.java 2011-06-10 06:33:31 UTC (rev 2861) +++ trunk/interfaces/src/main/java/org/dllearner/server/Rest.java 2011-06-10 10:14:42 UTC (rev 2862) @@ -15,7 +15,7 @@ import java.security.InvalidParameterException; -public abstract class Rest extends HttpServlet { +public class Rest extends HttpServlet { private static Logger log = LoggerFactory.getLogger(Rest.class); @Override Modified: trunk/interfaces/src/main/webapp/WEB-INF/web.xml =================================================================== --- trunk/interfaces/src/main/webapp/WEB-INF/web.xml 2011-06-10 06:33:31 UTC (rev 2861) +++ trunk/interfaces/src/main/webapp/WEB-INF/web.xml 2011-06-10 10:14:42 UTC (rev 2862) @@ -5,7 +5,6 @@ <web-app> <display-name>DL-Learner</display-name> - <servlet> <servlet-name>rest</servlet-name> <servlet-class>org.dllearner.server.Rest</servlet-class> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ku...@us...> - 2011-06-16 09:08:33
|
Revision: 2894 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=2894&view=rev Author: kurzum Date: 2011-06-16 09:08:23 +0000 (Thu, 16 Jun 2011) Log Message: ----------- removed jetty integration tests Modified Paths: -------------- trunk/interfaces/pom.xml trunk/interfaces/src/main/java/org/dllearner/server/nke/Geizhals2OWL.java trunk/interfaces/src/main/java/org/dllearner/server/nke/Learner.java Modified: trunk/interfaces/pom.xml =================================================================== --- trunk/interfaces/pom.xml 2011-06-16 09:01:30 UTC (rev 2893) +++ trunk/interfaces/pom.xml 2011-06-16 09:08:23 UTC (rev 2894) @@ -38,7 +38,7 @@ </requestLog> </configuration> <!--execution is used for testing--> - <executions> + <!--executions> <execution> <id>start-jetty</id> <phase>pre-integration-test</phase> @@ -59,7 +59,7 @@ <goal>stop</goal> </goals> </execution> - </executions> + </executions--> </plugin> <!--Surefire - for JUnits --> Modified: trunk/interfaces/src/main/java/org/dllearner/server/nke/Geizhals2OWL.java =================================================================== --- trunk/interfaces/src/main/java/org/dllearner/server/nke/Geizhals2OWL.java 2011-06-16 09:01:30 UTC (rev 2893) +++ trunk/interfaces/src/main/java/org/dllearner/server/nke/Geizhals2OWL.java 2011-06-16 09:08:23 UTC (rev 2894) @@ -23,9 +23,9 @@ public static final ClassIndexer index = new ClassIndexer(); public static final Geizhals2OWL geizhals2OWL = new Geizhals2OWL(); - public static Map<String, String> ramMap = new HashMap<String, String>(); - public static Map<String, String> harddriveMap = new HashMap<String, String>(); - public static Map<String, String> optischesLaufwerkMap = new HashMap<String, String>(); + public static final Map<String, String> ramMap = new HashMap<String, String>(); + public static final Map<String, String> harddriveMap = new HashMap<String, String>(); + public static final Map<String, String> optischesLaufwerkMap = new HashMap<String, String>(); public static final String prefix = "http://nke.aksw.org/geizhals/_"; //public static final String prefix = "http://geizhals.at/?cat=nb15w&xf="; Modified: trunk/interfaces/src/main/java/org/dllearner/server/nke/Learner.java =================================================================== --- trunk/interfaces/src/main/java/org/dllearner/server/nke/Learner.java 2011-06-16 09:01:30 UTC (rev 2893) +++ trunk/interfaces/src/main/java/org/dllearner/server/nke/Learner.java 2011-06-16 09:08:23 UTC (rev 2894) @@ -39,7 +39,6 @@ ModelUtils.write(model, new File("test.owl")); PipedOutputStream out = new PipedOutputStream(); model.write(out, Constants.RDFXML); -// PipedInputStream in = new PipedInputStream(out); RDFWriter writer = model.getWriter("RDF/XML"); ByteArrayOutputStream baos = new ByteArrayOutputStream(); writer.write(model, baos, ""); @@ -50,19 +49,12 @@ OWLOntologyManager manager = OWLManager.createOWLOntologyManager(); OWLOntology retOnt = null; try { - //retOnt = manager.createOntology(IRI.create("http://nke.aksw.org/tmp")); - // manager. - // manager.loadOntologyFromOntologyDocument() retOnt = manager.loadOntologyFromOntologyDocument(bs); } catch (OWLOntologyCreationException e) { e.printStackTrace(); } - // System.out.println(retOnt.getAxiomCount()); - // System.exit(0); - KnowledgeSource ks = new OWLAPIOntology(retOnt); -// KnowledgeSource ks = cm.knowledgeSource(null); ks.init(); // TODO: should the reasoner be initialised at every request or just once (?) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ku...@us...> - 2011-06-17 07:25:28
|
Revision: 2899 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=2899&view=rev Author: kurzum Date: 2011-06-17 07:25:21 +0000 (Fri, 17 Jun 2011) Log Message: ----------- geizhals Modified Paths: -------------- trunk/interfaces/pom.xml trunk/interfaces/src/main/java/org/dllearner/server/NKEGeizhals.java trunk/interfaces/src/main/java/org/dllearner/server/nke/Geizhals2OWL.java Added Paths: ----------- trunk/interfaces/src/main/resources/log4j.properties Modified: trunk/interfaces/pom.xml =================================================================== --- trunk/interfaces/pom.xml 2011-06-16 13:18:28 UTC (rev 2898) +++ trunk/interfaces/pom.xml 2011-06-17 07:25:21 UTC (rev 2899) @@ -33,7 +33,7 @@ <filename>log/yyyy_mm_dd.request.log</filename> <retainDays>90</retainDays> <append>true</append> - <extended>false</extended> + <extended>true</extended> <logTimeZone>GMT</logTimeZone> </requestLog> </configuration> Modified: trunk/interfaces/src/main/java/org/dllearner/server/NKEGeizhals.java =================================================================== --- trunk/interfaces/src/main/java/org/dllearner/server/NKEGeizhals.java 2011-06-16 13:18:28 UTC (rev 2898) +++ trunk/interfaces/src/main/java/org/dllearner/server/NKEGeizhals.java 2011-06-17 07:25:21 UTC (rev 2899) @@ -3,6 +3,7 @@ import com.hp.hpl.jena.ontology.OntClass; import com.jamonapi.Monitor; import com.jamonapi.MonitorFactory; +import org.apache.log4j.Logger; import org.dllearner.core.ComponentManager; import org.dllearner.core.owl.Description; import org.dllearner.core.owl.NamedClass; @@ -11,8 +12,6 @@ import org.dllearner.server.nke.Learner; import org.json.simple.JSONArray; import org.json.simple.JSONObject; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; @@ -22,12 +21,12 @@ import java.io.PrintWriter; import java.net.URLEncoder; import java.security.InvalidParameterException; -import java.util.HashSet; -import java.util.Set; +import java.util.SortedSet; +import java.util.TreeSet; public class NKEGeizhals extends HttpServlet { - private static Logger log = LoggerFactory.getLogger(NKEGeizhals.class); + private static Logger log = Logger.getLogger(NKEGeizhals.class); @Override @@ -52,6 +51,7 @@ private void handle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws ServletException, IOException { ComponentManager cm = ComponentManager.getInstance(); cm.freeAllComponents(); + Monitor mon = MonitorFactory.getTimeMonitor("NIFParameters.getInstance").start(); String result = ""; try { @@ -74,7 +74,7 @@ json = httpServletRequest.getParameter("data"); Geizhals2OWL.Result r = Geizhals2OWL.getInstance().handleJson(json); EvaluatedDescriptionPosNeg ed = new Learner().learn(r.pos, r.neg, r.getModel(), 20); - JSONObject concept = jsonForEd(ed); + JSONObject concept = jsonForEd(ed, httpServletRequest.getRequestURL().toString()); JSONObject j = new JSONObject(); j.put("learned", concept); JSONArray up = new JSONArray(); @@ -130,27 +130,43 @@ } - public static JSONObject jsonForEd(EvaluatedDescriptionPosNeg ed) { - Set<NamedClass> n = getNamedClasses(ed.getDescription(), new HashSet<NamedClass>()); + public static JSONObject jsonForEd(EvaluatedDescriptionPosNeg ed, String requestUrl) { + SortedSet<NamedClass> namedClasses = getNamedClasses(ed.getDescription(), new TreeSet<NamedClass>()); - //prepare retrieval string + String xf = getID(ed.getDescription(), namedClasses); + String link = "http://geizhals.at/?cat=nb15w&xf="+xf; + + JSONObject j = new JSONObject(); + j.put("link", link); + j.put("label", getLabel(ed.getDescription(), namedClasses)); + j.put("truePositives", EvaluatedDescriptionPosNeg.getJSONArray(ed.getCoveredPositives())); + j.put("falsePositives", EvaluatedDescriptionPosNeg.getJSONArray(ed.getNotCoveredPositives())); + j.put("trueNegatives", EvaluatedDescriptionPosNeg.getJSONArray(ed.getNotCoveredNegatives())); + j.put("falseNegatives", EvaluatedDescriptionPosNeg.getJSONArray(ed.getCoveredNegatives())); + j.put("kbsyntax", ed.getDescription().toKBSyntaxString()); + + log.info(link); + log.info(ed.toString()); + return j; + } + + public static String getID(Description d, SortedSet<NamedClass> namedClasses) { + //prepare retrieval string StringBuilder sb = new StringBuilder(); int x = 0; - for (NamedClass nc : n) { + for (NamedClass nc : namedClasses) { sb.append(nc.getName().replace(Geizhals2OWL.prefix, "")); - if (x < (n.size() - 1)) { + if (x < (namedClasses.size() - 1)) { sb.append("~"); } x++; } - sb.insert(0, "http://geizhals.at/?cat=nb15w&xf="); + return sb.toString(); + } - JSONObject j = new JSONObject(); - j.put("link", sb.toString()); - - j.put("kbsyntax", ed.getDescription().toKBSyntaxString()); - String mos = ed.getDescription().toManchesterSyntaxString(null, null); - for (NamedClass nc : n) { + public static String getLabel(Description d, SortedSet<NamedClass> namedClasses) { + String mos = d.toManchesterSyntaxString(null, null); + for (NamedClass nc : namedClasses) { String label = null; OntClass c = null; if ((c = Geizhals2OWL.labels.getOntClass(nc.getName())) != null && (label = c.getLabel(null)) != null) { @@ -159,16 +175,11 @@ mos = mos.replace(nc.getName(), nc.getName().replace(Geizhals2OWL.prefix, "")); } } - j.put("label", mos); - j.put("falsePositives", EvaluatedDescriptionPosNeg.getJSONArray(ed.getNotCoveredPositives())); - j.put("falseNegatives", EvaluatedDescriptionPosNeg.getJSONArray(ed.getCoveredNegatives())); + return mos; - log.info(sb.toString()); - log.info(ed.toString()); - return j; } - public static Set<NamedClass> getNamedClasses(Description d, Set<NamedClass> ret) { + public static SortedSet<NamedClass> getNamedClasses(Description d, SortedSet<NamedClass> ret) { if (d instanceof NamedClass) { ret.add((NamedClass) d); } Modified: trunk/interfaces/src/main/java/org/dllearner/server/nke/Geizhals2OWL.java =================================================================== --- trunk/interfaces/src/main/java/org/dllearner/server/nke/Geizhals2OWL.java 2011-06-16 13:18:28 UTC (rev 2898) +++ trunk/interfaces/src/main/java/org/dllearner/server/nke/Geizhals2OWL.java 2011-06-17 07:25:21 UTC (rev 2899) @@ -173,8 +173,6 @@ JSONArray pos = (JSONArray) j.get("pos"); JSONArray neg = (JSONArray) j.get("neg"); - System.out.println(j); - fill(pos, r.pos, model); fill(neg, r.neg, model); return r; Added: trunk/interfaces/src/main/resources/log4j.properties =================================================================== --- trunk/interfaces/src/main/resources/log4j.properties (rev 0) +++ trunk/interfaces/src/main/resources/log4j.properties 2011-06-17 07:25:21 UTC (rev 2899) @@ -0,0 +1,25 @@ +log4j.rootLogger=INFO, stdout, file + +log4j.appender.stdout=org.apache.log4j.ConsoleAppender +log4j.appender.stdout.layout=org.apache.log4j.PatternLayout +log4j.appender.stdout.layout.ConversionPattern=%d{HH:mm:ss} %-5p %-20c{1} :: %m%n + +log4j.appender.file=org.apache.log4j.FileAppender +log4j.appender.file.File=log/interfaces.log +log4j.appender.file.layout=org.apache.log4j.PatternLayout +log4j.appender.file.layout.ConversionPattern= %-4r [%t] %-5p %c %x - %m%n + +# Joseki server logging +log4j.logger.org.dllearner=INFO + +## log4j.logger.org.joseki.server.http.LocatorServletContext=ALL + +# Jena, including the Joseki client +#log4j.logger.com.hp.hpl.jena=WARN + +## log4j.logger.com.hp.hpl.jena.util.FileManager=ALL +## log4j.logger.com.hp.hpl.jena.util.LocatorURL=ALL +## log4j.logger.com.hp.hpl.jena.util.LocatorClassLoader=ALL +## log4j.logger.com.hp.hpl.jena.util.LocatorFile=ALL +## log4j.logger.com.hp.hpl.jena.util.LocationMapper=ALL + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sha...@us...> - 2011-08-20 13:42:49
|
Revision: 3076 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=3076&view=rev Author: shadowtm Date: 2011-08-20 13:42:42 +0000 (Sat, 20 Aug 2011) Log Message: ----------- Added the ConfigurationBasedPropertyOverrideConfigurer so that we could connect our conf files into the spring initialization process. Modified Paths: -------------- trunk/interfaces/pom.xml Added Paths: ----------- trunk/interfaces/src/main/java/org/dllearner/configuration/ trunk/interfaces/src/main/java/org/dllearner/configuration/spring/ trunk/interfaces/src/main/java/org/dllearner/configuration/spring/ConfigurationBasedPropertyOverrideConfigurer.java trunk/interfaces/src/test/java/org/dllearner/configuration/ trunk/interfaces/src/test/java/org/dllearner/configuration/spring/ trunk/interfaces/src/test/java/org/dllearner/configuration/spring/ConfigurationBasedPropertyOverrideConfigurerTest.java trunk/interfaces/src/test/java/org/dllearner/configuration/spring/TestBean.java trunk/interfaces/src/test/resources/org/dllearner/configuration/ trunk/interfaces/src/test/resources/org/dllearner/configuration/spring/ trunk/interfaces/src/test/resources/org/dllearner/configuration/spring/configuration-based-property-override-configurer-configuration.xml trunk/interfaces/src/test/resources/org/dllearner/configuration/spring/configurationBasedPropertyOverrideConfigurer.conf Modified: trunk/interfaces/pom.xml =================================================================== --- trunk/interfaces/pom.xml 2011-08-20 13:41:54 UTC (rev 3075) +++ trunk/interfaces/pom.xml 2011-08-20 13:42:42 UTC (rev 3076) @@ -21,6 +21,10 @@ <groupId>org.codehaus.mojo</groupId> <artifactId>tomcat-maven-plugin</artifactId> </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-resources-plugin</artifactId> + </plugin> <plugin> <groupId>org.mortbay.jetty</groupId> @@ -192,10 +196,14 @@ <artifactId>json-simple</artifactId> </dependency> - <dependency> - <groupId>org.springframework</groupId> - <artifactId>spring-context</artifactId> - </dependency> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-context</artifactId> + </dependency> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-beans</artifactId> + </dependency> </dependencies> Added: trunk/interfaces/src/main/java/org/dllearner/configuration/spring/ConfigurationBasedPropertyOverrideConfigurer.java =================================================================== --- trunk/interfaces/src/main/java/org/dllearner/configuration/spring/ConfigurationBasedPropertyOverrideConfigurer.java (rev 0) +++ trunk/interfaces/src/main/java/org/dllearner/configuration/spring/ConfigurationBasedPropertyOverrideConfigurer.java 2011-08-20 13:42:42 UTC (rev 3076) @@ -0,0 +1,184 @@ +package org.dllearner.configuration.spring; + +import org.dllearner.configuration.IConfiguration; +import org.springframework.beans.PropertyValue; +import org.springframework.beans.factory.config.BeanDefinition; +import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; +import org.springframework.beans.factory.config.PropertyOverrideConfigurer; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +/** + * Created by IntelliJ IDEA. + * User: Chris + * Date: 8/18/11 + * Time: 9:12 PM + * <p/> + * Extending the Custom Property Override Configurer so that we can use our IConfiguration objects + * in conjunction with a Spring Based Configuration. + */ +public class ConfigurationBasedPropertyOverrideConfigurer extends PropertyOverrideConfigurer { + + + private final IConfiguration configuration; + private boolean ignoreInvalidKeys = false; + private List<String> componentKeyPrefixes = new ArrayList<String>(); + + /** + * Primary Constructor. + * + * @param configuration The DL-Learner Configuration object. + * @param ignoreInvalidKeys Consult the PropertyOverrideConfigurer documentation for the usage of this variable. + */ + public ConfigurationBasedPropertyOverrideConfigurer(IConfiguration configuration, boolean ignoreInvalidKeys) { + super(); + this.configuration = configuration; + this.ignoreInvalidKeys = ignoreInvalidKeys; + setIgnoreInvalidKeys(false); + } + + @Override + protected void applyPropertyValue(ConfigurableListableBeanFactory factory, String beanName, String property, String value) { + + BeanDefinition bd = getBeanDefinition(factory, beanName); + + Object obj = buildObject(beanName, property); + + applyPropertyValue(factory, beanName, property, bd, obj); + + + } + + /** + * Build the object represented by beanName.property as it is represented in the configuration. + * + * @param beanName The bean name of the object to build + * @param property The property name of the object to build + * @return The object represented by beanName.property + */ + protected Object buildObject(String beanName, String property) { + StringBuilder objKey = buildObjectKey(beanName, property); + return configuration.getObjectValue(objKey.toString()); + } + + /** + * Get the Bean Definition for a particular bean. + * + * @param factory The factory to get the bean from. + * @param beanName The bean to get. + * @return The bean definition of beanName + */ + protected BeanDefinition getBeanDefinition(ConfigurableListableBeanFactory factory, String beanName) { + BeanDefinition bd = factory.getBeanDefinition(beanName); + while (bd.getOriginatingBeanDefinition() != null) { + bd = bd.getOriginatingBeanDefinition(); + } + return bd; + } + + /** + * Apply obj to a property value. + * @param factory + * @param beanName + * @param property + * @param bd + * @param obj + */ + private void applyPropertyValue(ConfigurableListableBeanFactory factory, String beanName, String property, BeanDefinition bd, Object obj) { + /** Check if Object represents a ReferencedBean */ + String referencedBeanName = getReferencedBeanName(obj); + if (referencedBeanName != null && !referencedBeanName.isEmpty()) { + applyBeanReferencePropertyValue(factory, beanName, property, referencedBeanName); + } else { + /** We have a regular property value */ + applyRegularPropertyValue(property, bd, obj); + } + } + + private void applyRegularPropertyValue(String property, BeanDefinition bd, Object obj) { + PropertyValue pv = new PropertyValue(property, obj); + pv.setOptional(ignoreInvalidKeys); + bd.getPropertyValues().addPropertyValue(pv); + } + + /** + * Apply a bean reference to beanName.property in the given factory. + * + * @param factory The factory to use. + * @param beanName The bean name + * @param property The property name. + * @param referencedBean The referenced bean to set as bean.property in factory. + */ + private void applyBeanReferencePropertyValue(ConfigurableListableBeanFactory factory, String beanName, String property, String referencedBean) { + BeanDefinition bd = getBeanDefinition(factory, beanName); + /** You have to get the bean definition of the referenced bean here - don't try to get the bean itself or you'll get a objects which aren't completely initialized yet */ + Object obj = factory.getBeanDefinition(referencedBean); + bd.getPropertyValues().addPropertyValue(property, obj); + } + + /** + * Build the object key which is just name beanName.property or beanName if property is null. + * @param beanName First part of the key. + * @param property Second part of the key (after the period). + * @return The object key. + */ + private StringBuilder buildObjectKey(String beanName, String property) { + StringBuilder objName = new StringBuilder(); + objName.append(beanName); + if (property != null && !property.isEmpty()) { + objName.append("."); + objName.append(property); + } + return objName; + } + + /** + * Determine if value is a name of a referenced bean. + * <p/> + * This will return the name of the referenced bean if it does. If not, it will return null. + * + * @param object The object to check. + * @return True if we need to do custom loading of this value, false if we can use the parent. + */ + protected String getReferencedBeanName(Object object) { + + String result = null; + + boolean found = false; + + Iterator<String> itr = getComponentKeyPrefixes().iterator(); + + if (object instanceof String) { + String value = (String) object; + while (!found && itr.hasNext()) { + String prefix = itr.next(); + if (value.startsWith(prefix)) { + found = true; + result = value.substring(prefix.length()); + } + } + } + return result; + + } + + /** + * Get the list of prefixes that cause us to do custom loading. + * + * @return The list of prefixes that cause us to do custom loading. + */ + public List<String> getComponentKeyPrefixes() { + return componentKeyPrefixes; + } + + /** + * Set the list of prefixes that cause us to do custom loading. + * + * @param componentKeyPrefixes the list of prefixes that cause us to do custom loading. + */ + public void setComponentKeyPrefixes(List<String> componentKeyPrefixes) { + this.componentKeyPrefixes = componentKeyPrefixes; + } +} Added: trunk/interfaces/src/test/java/org/dllearner/configuration/spring/ConfigurationBasedPropertyOverrideConfigurerTest.java =================================================================== --- trunk/interfaces/src/test/java/org/dllearner/configuration/spring/ConfigurationBasedPropertyOverrideConfigurerTest.java (rev 0) +++ trunk/interfaces/src/test/java/org/dllearner/configuration/spring/ConfigurationBasedPropertyOverrideConfigurerTest.java 2011-08-20 13:42:42 UTC (rev 3076) @@ -0,0 +1,87 @@ +package org.dllearner.configuration.spring; + +import junit.framework.Assert; +import org.dllearner.confparser2.ConfParserConfiguration; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.springframework.context.ConfigurableApplicationContext; +import org.springframework.context.support.ClassPathXmlApplicationContext; +import org.springframework.core.io.ClassPathResource; +import org.springframework.core.io.Resource; + +/** + * Created by IntelliJ IDEA. + * User: Chris + * Date: 8/19/11 + * Time: 5:52 PM + * <p/> + * Test For our ConfigurationBasedPropertyOverrideConfigurere. It works as part of a ConfigurableApplicationContext + * so we test it via a context. + */ +public class ConfigurationBasedPropertyOverrideConfigurerTest { + + + private ConfigurableApplicationContext context; + + @Before + public void setUp() throws Exception { + + Resource confFile = new ClassPathResource("/org/dllearner/configuration/spring/configurationBasedPropertyOverrideConfigurer.conf"); + ConfParserConfiguration configuration = new ConfParserConfiguration(confFile); + + ConfigurationBasedPropertyOverrideConfigurer configurer = new ConfigurationBasedPropertyOverrideConfigurer(configuration, false); + configurer.setProperties(configuration.getProperties()); + configurer.getComponentKeyPrefixes().add("component:"); + configurer.getComponentKeyPrefixes().add(":"); + + + String springConfigurationLocation = "/org/dllearner/configuration/spring/configuration-based-property-override-configurer-configuration.xml"; + String[] springConfigurationFiles = new String[1]; + springConfigurationFiles[0] = springConfigurationLocation; + context = new ClassPathXmlApplicationContext(springConfigurationFiles, false); + + context.addBeanFactoryPostProcessor(configurer); + context.refresh(); + + } + + @After + public void tearDown() throws Exception { + + } + + @Test + public void testMethods() { + TestBean testBean = context.getBean("testBean", TestBean.class); + + validateFirstBean(testBean); + TestBean secondBean = testBean.getComponent(); + validateSecondBean(secondBean); + validateThirdBean(secondBean.getComponent()); + } + + private void validateThirdBean(TestBean thirdBean) { + Assert.assertEquals(thirdBean.getIntValue(), (Integer) 3); + } + + private void validateFirstBean(TestBean testBean) { + Assert.assertEquals(testBean.getSimpleValue(), "simple value example"); + Assert.assertEquals(testBean.getIntValue(), (Integer) 23); + Assert.assertEquals(testBean.getDoubleValue(), (Double) 78.5); + Assert.assertTrue(testBean.getSetValue().contains("a")); + Assert.assertTrue(testBean.getMapValue().get("a").equals("b")); + Assert.assertTrue(testBean.getComponent() != null); + } + + private void validateSecondBean(TestBean secondBean) { + Assert.assertEquals(secondBean.getSimpleValue(), "second bean example"); + Assert.assertEquals(secondBean.getIntValue(), (Integer) 85); + Assert.assertEquals(secondBean.getDoubleValue(), (Double) 178.5); + Assert.assertTrue(secondBean.getSetValue().contains("e")); + Assert.assertTrue(secondBean.getMapValue().get("f").equals("g")); + Assert.assertTrue(secondBean.getComponent() != null); + } + + +} Added: trunk/interfaces/src/test/java/org/dllearner/configuration/spring/TestBean.java =================================================================== --- trunk/interfaces/src/test/java/org/dllearner/configuration/spring/TestBean.java (rev 0) +++ trunk/interfaces/src/test/java/org/dllearner/configuration/spring/TestBean.java 2011-08-20 13:42:42 UTC (rev 3076) @@ -0,0 +1,88 @@ +package org.dllearner.configuration.spring; + +import java.util.Map; +import java.util.Set; + +/** + * Created by IntelliJ IDEA. + * User: Chris + * Date: 8/19/11 + * Time: 2:55 PM + * + * Test Bean for testing that we can store all the types we need. + */ +public class TestBean { + + private String simpleValue; + private TestBean component; + private Integer intValue; + private Double doubleValue; + private Set setValue; + private Map mapValue; + private Set positiveValues; + private Set negativeValues; + + public String getSimpleValue() { + return simpleValue; + } + + public void setSimpleValue(String simpleValue) { + this.simpleValue = simpleValue; + } + + public TestBean getComponent() { + return component; + } + + public void setComponent(TestBean component) { + this.component = component; + } + + public Integer getIntValue() { + return intValue; + } + + public void setIntValue(Integer intValue) { + this.intValue = intValue; + } + + public Double getDoubleValue() { + return doubleValue; + } + + public void setDoubleValue(Double doubleValue) { + this.doubleValue = doubleValue; + } + + public Set getSetValue() { + return setValue; + } + + public void setSetValue(Set setValue) { + this.setValue = setValue; + } + + public Map getMapValue() { + return mapValue; + } + + public void setMapValue(Map mapValue) { + this.mapValue = mapValue; + } + + public Set getPositiveValues() { + return positiveValues; + } + + public void setPositiveValues(Set positiveValues) { + this.positiveValues = positiveValues; + } + + public Set getNegativeValues() { + return negativeValues; + } + + public void setNegativeValues(Set negativeValues) { + this.negativeValues = negativeValues; + } +} Added: trunk/interfaces/src/test/resources/org/dllearner/configuration/spring/configuration-based-property-override-configurer-configuration.xml =================================================================== --- trunk/interfaces/src/test/resources/org/dllearner/configuration/spring/configuration-based-property-override-configurer-configuration.xml (rev 0) +++ trunk/interfaces/src/test/resources/org/dllearner/configuration/spring/configuration-based-property-override-configurer-configuration.xml 2011-08-20 13:42:42 UTC (rev 3076) @@ -0,0 +1,12 @@ +<?xml version="1.0" encoding="UTF-8"?> +<beans xmlns="http://www.springframework.org/schema/beans" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> + + + <bean name="testBean" class="org.dllearner.configuration.spring.TestBean"/> + + <bean name="secondBean" class="org.dllearner.configuration.spring.TestBean"/> + + <bean name="thirdBean" class="org.dllearner.configuration.spring.TestBean" /> +</beans> \ No newline at end of file Copied: trunk/interfaces/src/test/resources/org/dllearner/configuration/spring/configurationBasedPropertyOverrideConfigurer.conf (from rev 3074, trunk/interfaces/src/test/resources/org/dllearner/confparser2/confParserConfigurationTest.conf) =================================================================== --- trunk/interfaces/src/test/resources/org/dllearner/configuration/spring/configurationBasedPropertyOverrideConfigurer.conf (rev 0) +++ trunk/interfaces/src/test/resources/org/dllearner/configuration/spring/configurationBasedPropertyOverrideConfigurer.conf 2011-08-20 13:42:42 UTC (rev 3076) @@ -0,0 +1,31 @@ +/** + * A multi-line comment, which is ignored. + */ + +// a single line comment, which is ignored +testBean.simpleValue="simple value example"; // simple value + +testBean.component=component:secondBean; // I wonder whether we even need the component keyword or could just write beanName.property=:test; + +testBean.intValue = 23; // an integer value + +testBean.doubleValue = 78.5; // a double value + +testBean.setValue={"a"}; // a set (list is not implemented, but can be done analogously) + +testBean.mapValue=[("a","b"),("c","d")]; // a map (we can use whatever syntax we like, this is the existing one) + +// Second Bean Definition - to show loading of a referenced bean +secondBean.simpleValue="second bean example"; // simple value +secondBean.component=component:thirdBean; //Another Bean +secondBean.intValue = 85; // an integer value +secondBean.doubleValue = 178.5; // a double value +secondBean.setValue={"e"}; // a set (list is not implemented, but can be done analogously) +secondBean.mapValue=[("f","g"),("c","d")]; // a map (we can use whatever syntax we like, this is the existing one) + +thirdBean.intValue=3; + +// you can also specify positive and negative examples +// (not sure if we really need that) ++"http://example.org/pos1/" +-"http://example.org/neg1/" \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lor...@us...> - 2011-08-22 07:28:21
|
Revision: 3082 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=3082&view=rev Author: lorenz_b Date: 2011-08-22 07:28:14 +0000 (Mon, 22 Aug 2011) Log Message: ----------- Continued build script. Modified Paths: -------------- trunk/interfaces/pom.xml trunk/interfaces/src/main/assemble/archive.xml Modified: trunk/interfaces/pom.xml =================================================================== --- trunk/interfaces/pom.xml 2011-08-22 07:23:50 UTC (rev 3081) +++ trunk/interfaces/pom.xml 2011-08-22 07:28:14 UTC (rev 3082) @@ -116,6 +116,13 @@ <groupId>org.codehaus.mojo</groupId> <artifactId>appassembler-maven-plugin</artifactId> <version>1.1.1</version> + <executions> + <execution> + <goals> + <goal>assemble</goal> + </goals> + </execution> + </executions> <configuration> <assembleDirectory>${project.build.directory}/dl-learner-dist</assembleDirectory> <repoPath>lib</repoPath> @@ -149,6 +156,41 @@ </programs> </configuration> </plugin> + <plugin> + <artifactId>maven-assembly-plugin</artifactId> + <executions> + <execution> + <phase>package</phase> + <goals> + <goal>attached</goal> + </goals> + </execution> + </executions> + <configuration> + <finalName>dl-learner-${maven.build.timestamp}</finalName> + <descriptors> + <descriptor>src/main/assemble/archive.xml</descriptor> + </descriptors> + </configuration> + </plugin> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>buildnumber-maven-plugin</artifactId> + <executions> + <execution> + <phase>initialize</phase> + <goals> + <goal>create</goal> + </goals> + </execution> + </executions> + <configuration> + <items> + <item>timestamp</item> + </items> + <timestampFormat>{0, date, yyyy-MM-dd}</timestampFormat> + </configuration> + </plugin> </plugins> </build> Modified: trunk/interfaces/src/main/assemble/archive.xml =================================================================== --- trunk/interfaces/src/main/assemble/archive.xml 2011-08-22 07:23:50 UTC (rev 3081) +++ trunk/interfaces/src/main/assemble/archive.xml 2011-08-22 07:28:14 UTC (rev 3082) @@ -1,12 +1,17 @@ <assembly> <id>archive</id> <formats> - <format>zip</format> + <format>tar.gz</format> </formats> + <fileSets> <fileSet> - <directory>${project.build.directory}/appassembler</directory> + <directory>${project.build.directory}/dl-learner-dist</directory> <outputDirectory>/</outputDirectory> </fileSet> + <fileSet> + <directory>../examples</directory> + <outputDirectory>examples</outputDirectory> + </fileSet> </fileSets> </assembly> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lor...@us...> - 2011-08-22 09:19:42
|
Revision: 3084 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=3084&view=rev Author: lorenz_b Date: 2011-08-22 09:19:36 +0000 (Mon, 22 Aug 2011) Log Message: ----------- Cleaned up pom.xml. Continued release script. Modified Paths: -------------- trunk/interfaces/pom.xml trunk/interfaces/src/main/assemble/archive.xml Modified: trunk/interfaces/pom.xml =================================================================== --- trunk/interfaces/pom.xml 2011-08-22 09:17:56 UTC (rev 3083) +++ trunk/interfaces/pom.xml 2011-08-22 09:19:36 UTC (rev 3084) @@ -13,6 +13,10 @@ <artifactId>dllearner-parent</artifactId> <version>1.0-SNAPSHOT</version> </parent> + + <properties> + <release.name>1.0-alpha-1</release.name> + </properties> <build> <finalName>interfaces</finalName> @@ -125,8 +129,8 @@ </executions> <configuration> <assembleDirectory>${project.build.directory}/dl-learner-dist</assembleDirectory> - <repoPath>lib</repoPath> - <repositoryName>lib</repositoryName> + <repoPath>dl-learner-${release.name}/lib</repoPath> + <repositoryName>dl-learner-${release.name}/lib</repositoryName> <extraJvmArguments>-Xms256m -Xmx1024m</extraJvmArguments> <platforms> <platform>windows</platform> @@ -134,14 +138,6 @@ </platforms> <programs> <program> - <mainClass>org.dllearner.cli.Start</mainClass> - <name>start</name> - </program> - <program> - <mainClass>org.dllearner.cli.QuickStart</mainClass> - <name>quickstart</name> - </program> - <program> <mainClass>org.dllearner.cli.CLI</mainClass> <name>cli</name> </program> @@ -149,10 +145,19 @@ <mainClass>org.dllearner.cli.Enrichment</mainClass> <name>enrichment</name> </program> + <!-- <program> <mainClass>org.dllearner.gui.StartGUI</mainClass> <name>gui</name> </program> + <program> + <mainClass>org.dllearner.cli.QuickStart</mainClass> + <name>quickstart</name> + </program> + <program> + <mainClass>org.dllearner.server.DLLearnerWS</mainClass> + <name>ws</name> + </program> --> </programs> </configuration> </plugin> @@ -167,7 +172,7 @@ </execution> </executions> <configuration> - <finalName>dl-learner-${maven.build.timestamp}</finalName> + <finalName>dl-learner-${release.name}</finalName> <descriptors> <descriptor>src/main/assemble/archive.xml</descriptor> </descriptors> @@ -198,7 +203,6 @@ <dependency> <groupId>org.dllearner</groupId> <artifactId>components-core</artifactId> - </dependency> <!-- Added the dependency of the core tests so that they will be accessible @@ -210,10 +214,7 @@ <scope>test</scope> </dependency> - <dependency> - <groupId>org.dllearner</groupId> - <artifactId>components-ext</artifactId> - </dependency> + <dependency> Modified: trunk/interfaces/src/main/assemble/archive.xml =================================================================== --- trunk/interfaces/src/main/assemble/archive.xml 2011-08-22 09:17:56 UTC (rev 3083) +++ trunk/interfaces/src/main/assemble/archive.xml 2011-08-22 09:19:36 UTC (rev 3084) @@ -1,17 +1,32 @@ <assembly> - <id>archive</id> - <formats> - <format>tar.gz</format> - </formats> - - <fileSets> - <fileSet> - <directory>${project.build.directory}/dl-learner-dist</directory> - <outputDirectory>/</outputDirectory> - </fileSet> - <fileSet> - <directory>../examples</directory> - <outputDirectory>examples</outputDirectory> - </fileSet> - </fileSets> + <id>archive</id> + <formats> + <format>tar.gz</format> + </formats> + + <fileSets> + <fileSet> + <directory>${project.build.directory}/dl-learner-dist/dl-learner-${release.name}/lib</directory> + <outputDirectory>lib</outputDirectory> + </fileSet> + <fileSet> + <directory>${project.build.directory}/dl-learner-dist/bin</directory> + <outputDirectory>/</outputDirectory> + <fileMode>0755</fileMode> + </fileSet> + <fileSet> + <directory>../examples</directory> + <outputDirectory>examples</outputDirectory> + </fileSet> + <fileSet> + <directory>doc</directory> + <outputDirectory>docs</outputDirectory> + <includes> + <include>configOptions.html</include> + <include>javadoc.html</include> + </includes> + </fileSet> + + </fileSets> + </assembly> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lor...@us...> - 2011-08-23 08:39:01
|
Revision: 3097 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=3097&view=rev Author: lorenz_b Date: 2011-08-23 08:38:55 +0000 (Tue, 23 Aug 2011) Log Message: ----------- Small changes in release creation. Modified Paths: -------------- trunk/interfaces/pom.xml trunk/interfaces/src/main/assemble/archive.xml Modified: trunk/interfaces/pom.xml =================================================================== --- trunk/interfaces/pom.xml 2011-08-23 06:43:13 UTC (rev 3096) +++ trunk/interfaces/pom.xml 2011-08-23 08:38:55 UTC (rev 3097) @@ -72,7 +72,8 @@ </execution> </executions> <configuration> - <finalName>dl-learner-${release.name}</finalName> + <finalName>dllearner-${release.name}</finalName> + <appendAssemblyId>false</appendAssemblyId> <descriptors> <descriptor>src/main/assemble/archive.xml</descriptor> </descriptors> Modified: trunk/interfaces/src/main/assemble/archive.xml =================================================================== --- trunk/interfaces/src/main/assemble/archive.xml 2011-08-23 06:43:13 UTC (rev 3096) +++ trunk/interfaces/src/main/assemble/archive.xml 2011-08-23 08:38:55 UTC (rev 3097) @@ -6,12 +6,27 @@ <fileSets> <fileSet> - <directory>${project.build.directory}/dl-learner-dist/dl-learner-${release.name}/lib</directory> + <directory>${project.build.directory}/dl-learner-dist/dl-learner-${release.name}/lib + </directory> <outputDirectory>lib</outputDirectory> </fileSet> <fileSet> <directory>${project.build.directory}/dl-learner-dist/bin</directory> <outputDirectory>/</outputDirectory> + <includes> + <include> + *.bat + </include> + </includes> + </fileSet> + <fileSet> + <directory>${project.build.directory}/dl-learner-dist/bin</directory> + <outputDirectory>/</outputDirectory> + <excludes> + <exclude> + *.bat + </exclude> + </excludes> <fileMode>0755</fileMode> </fileSet> <fileSet> @@ -26,6 +41,13 @@ <include>javadoc.html</include> </includes> </fileSet> + <fileSet> + <directory>${project.build.directory}/site</directory> + <outputDirectory>docs</outputDirectory> + <includes> + <include>manual.pdf</include> + </includes> + </fileSet> </fileSets> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2011-08-27 09:55:23
|
Revision: 3137 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=3137&view=rev Author: jenslehmann Date: 2011-08-27 09:55:16 +0000 (Sat, 27 Aug 2011) Log Message: ----------- added beanref-flag in ConfFileOption2; introduced special notation for empty bean set (probably very rarely needed) Modified Paths: -------------- trunk/interfaces/doc/manual/manual.tex trunk/interfaces/src/main/java/org/dllearner/cli/ConfFileOption2.java trunk/interfaces/src/main/java/org/dllearner/confparser3/ConfParser.java trunk/interfaces/src/main/java/org/dllearner/confparser3/ConfParserConstants.java trunk/interfaces/src/main/java/org/dllearner/confparser3/ConfParserTokenManager.java trunk/interfaces/src/main/java/org/dllearner/confparser3/conf3.jj trunk/interfaces/src/test/java/org/dllearner/confparser3/ParseTest.java Modified: trunk/interfaces/doc/manual/manual.tex =================================================================== --- trunk/interfaces/doc/manual/manual.tex 2011-08-26 20:22:41 UTC (rev 3136) +++ trunk/interfaces/doc/manual/manual.tex 2011-08-27 09:55:16 UTC (rev 3137) @@ -201,6 +201,10 @@ \section{DL-Learner Interfaces} +\subsection{Command Line Interface} + +\todo{Description of Conf File Syntax; special cases: empty set of beans is denoted by ``-''; the name of a bean must not be ``true'' or ``false'' or start with a number; config options must not have the name ``type''; these conentions are introduced in order to be a able to provide a very compact syntax} + One interface you have already used in Section \ref{sec:start} is the command line. There are two executables, which can be used for starting DL-Learner on the commandline: \verb|dl-learner| and \verb|quickstart|. The first one takes a conf file as argument, whereas the latter one lists all conf files in the examples folder and allows you to select one of those. \begin{figure} Modified: trunk/interfaces/src/main/java/org/dllearner/cli/ConfFileOption2.java =================================================================== --- trunk/interfaces/src/main/java/org/dllearner/cli/ConfFileOption2.java 2011-08-26 20:22:41 UTC (rev 3136) +++ trunk/interfaces/src/main/java/org/dllearner/cli/ConfFileOption2.java 2011-08-27 09:55:16 UTC (rev 3137) @@ -31,10 +31,8 @@ */ public class ConfFileOption2 { - // a boolean flag which indicates whether the value was in quotes - // TODO: alternatively, we could use a flag "isBeanReferrence" - bean references are (currently) - // those options which do not have quotes, but have type "String" or "Set" - private boolean inQuotes; + // a boolean flag which indicates whether it is a reference to a bean (or set/list of beans) + private boolean isBeanRef; private String beanName; @@ -54,14 +52,6 @@ } - public boolean isInQuotes() { - return inQuotes; - } - - public void setInQuotes(boolean inQuotes) { - this.inQuotes = inQuotes; - } - public String getBeanName() { return beanName; } @@ -103,5 +93,13 @@ public void setValueObject(Object valueObject) { this.valueObject = valueObject; } + + public boolean isBeanRef() { + return isBeanRef; + } + + public void setBeanRef(boolean isBeanRef) { + this.isBeanRef = isBeanRef; + } } Modified: trunk/interfaces/src/main/java/org/dllearner/confparser3/ConfParser.java =================================================================== --- trunk/interfaces/src/main/java/org/dllearner/confparser3/ConfParser.java 2011-08-26 20:22:41 UTC (rev 3136) +++ trunk/interfaces/src/main/java/org/dllearner/confparser3/ConfParser.java 2011-08-27 09:55:16 UTC (rev 3137) @@ -95,7 +95,7 @@ List<StringTuple> tuples = new LinkedList<StringTuple>(); ConfFileOption2 option = new ConfFileOption2(); - boolean inQuotes = false; + boolean isBeanRef = false; String beanName; String propertyName = ""; String propertyValue = ""; @@ -122,12 +122,12 @@ if(propertyValue.equals("true") || propertyValue.equals("false")) { val = Boolean.valueOf(propertyValue); propertyType = Boolean.class; } else { - val = propertyValue; propertyType = String.class; + val = propertyValue; propertyType = String.class; isBeanRef = true; } break; case STRING: propertyValue = String(); - val = propertyValue; inQuotes = true; propertyType = String.class; + val = propertyValue; propertyType = String.class; break; case NUMBER: val = Integer(); @@ -159,9 +159,13 @@ tmp = String(); values.add(tmp); propertyValue += "\u005c"" + tmp + "\u005c""; jj_consume_token(15); - propertyType = Set.class; propertyValue = "{"+ propertyValue + "}";; val = values; inQuotes = true; + propertyType = Set.class; propertyValue = "{"+ propertyValue + "}";; val = values; } else { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case 17: + jj_consume_token(17); + val = new HashSet(); propertyType = Set.class; propertyValue = "-"; isBeanRef = true; + break; case 14: jj_consume_token(14); label_3: @@ -178,18 +182,18 @@ tmp = Id(); values.add(tmp); propertyValue += tmp; jj_consume_token(15); - val = values; propertyType = Set.class; propertyValue = "{"+ propertyValue + "}"; + val = values; propertyType = Set.class; propertyValue = "{"+ propertyValue + "}"; isBeanRef = true; break; default: jj_la1[3] = jj_gen; if (jj_2_6(2147483647)) { - jj_consume_token(17); jj_consume_token(18); + jj_consume_token(19); val = new LinkedList(); propertyType = List.class; propertyValue = "[]"; } else { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case 17: - jj_consume_token(17); + case 18: + jj_consume_token(18); label_4: while (true) { if (jj_2_3(6)) { @@ -197,21 +201,21 @@ } else { break label_4; } - jj_consume_token(19); + jj_consume_token(20); tmp = String(); jj_consume_token(16); tmp2 = String(); - jj_consume_token(20); + jj_consume_token(21); tuples.add(new StringTuple(tmp,tmp2)); propertyValue += "(\u005c""+ tmp + "\u005c",\u005c"" + tmp2 + "\u005c"), "; jj_consume_token(16); } - jj_consume_token(19); + jj_consume_token(20); tmp = String(); jj_consume_token(16); tmp2 = String(); - jj_consume_token(20); + jj_consume_token(21); tuples.add(new StringTuple(tmp,tmp2)); propertyValue += "(\u005c""+ tmp + "\u005c",\u005c"" + tmp2 + "\u005c")"; - jj_consume_token(18); + jj_consume_token(19); val = tuples; propertyType = List.class; propertyValue = "["+ propertyValue + "]"; break; default: @@ -223,7 +227,7 @@ } } } - option.setInQuotes(inQuotes); + option.setBeanRef(isBeanRef); option.setBeanName(beanName); if(containsSubOption) { option.setPropertyName(propertyName); @@ -257,7 +261,7 @@ Token t1,t2; if (jj_2_7(2)) { t1 = jj_consume_token(ID); - jj_consume_token(21); + jj_consume_token(22); t2 = jj_consume_token(ID); {if (true) return t1.image + ":" + t2.image;} } else { @@ -375,32 +379,32 @@ } private boolean jj_3_6() { - if (jj_scan_token(17)) return true; if (jj_scan_token(18)) return true; + if (jj_scan_token(19)) return true; return false; } private boolean jj_3_7() { if (jj_scan_token(ID)) return true; - if (jj_scan_token(21)) return true; + if (jj_scan_token(22)) return true; return false; } - private boolean jj_3R_5() { - if (jj_scan_token(STRING)) return true; - return false; - } - private boolean jj_3_3() { - if (jj_scan_token(19)) return true; + if (jj_scan_token(20)) return true; if (jj_3R_5()) return true; if (jj_scan_token(16)) return true; if (jj_3R_5()) return true; - if (jj_scan_token(20)) return true; + if (jj_scan_token(21)) return true; if (jj_scan_token(16)) return true; return false; } + private boolean jj_3R_5() { + if (jj_scan_token(STRING)) return true; + return false; + } + private boolean jj_3_2() { if (jj_3R_6()) return true; if (jj_scan_token(16)) return true; @@ -435,7 +439,7 @@ jj_la1_init_0(); } private static void jj_la1_init_0() { - jj_la1_0 = new int[] {0x200,0x100,0x1e00,0x4000,0x20000,0x1200,0x200,}; + jj_la1_0 = new int[] {0x200,0x100,0x1e00,0x24000,0x40000,0x1200,0x200,}; } final private JJCalls[] jj_2_rtns = new JJCalls[7]; private boolean jj_rescan = false; @@ -621,7 +625,7 @@ /** Generate ParseException. */ public ParseException generateParseException() { jj_expentries.clear(); - boolean[] la1tokens = new boolean[22]; + boolean[] la1tokens = new boolean[23]; if (jj_kind >= 0) { la1tokens[jj_kind] = true; jj_kind = -1; @@ -635,7 +639,7 @@ } } } - for (int i = 0; i < 22; i++) { + for (int i = 0; i < 23; i++) { if (la1tokens[i]) { jj_expentry = new int[1]; jj_expentry[0] = i; Modified: trunk/interfaces/src/main/java/org/dllearner/confparser3/ConfParserConstants.java =================================================================== --- trunk/interfaces/src/main/java/org/dllearner/confparser3/ConfParserConstants.java 2011-08-26 20:22:41 UTC (rev 3136) +++ trunk/interfaces/src/main/java/org/dllearner/confparser3/ConfParserConstants.java 2011-08-27 09:55:16 UTC (rev 3137) @@ -49,6 +49,7 @@ "\"{\"", "\"}\"", "\",\"", + "\"-\"", "\"[\"", "\"]\"", "\"(\"", Modified: trunk/interfaces/src/main/java/org/dllearner/confparser3/ConfParserTokenManager.java =================================================================== --- trunk/interfaces/src/main/java/org/dllearner/confparser3/ConfParserTokenManager.java 2011-08-26 20:22:41 UTC (rev 3136) +++ trunk/interfaces/src/main/java/org/dllearner/confparser3/ConfParserTokenManager.java 2011-08-27 09:55:16 UTC (rev 3137) @@ -44,21 +44,23 @@ switch(curChar) { case 40: - return jjStopAtPos(0, 19); + return jjStopAtPos(0, 20); case 41: - return jjStopAtPos(0, 20); + return jjStopAtPos(0, 21); case 44: return jjStopAtPos(0, 16); + case 45: + return jjStopAtPos(0, 17); case 46: return jjStopAtPos(0, 8); case 58: - return jjStopAtPos(0, 21); + return jjStopAtPos(0, 22); case 61: return jjStopAtPos(0, 13); case 91: - return jjStopAtPos(0, 17); + return jjStopAtPos(0, 18); case 93: - return jjStopAtPos(0, 18); + return jjStopAtPos(0, 19); case 123: return jjStopAtPos(0, 14); case 125: @@ -349,14 +351,14 @@ /** Token literal values. */ public static final String[] jjstrLiteralImages = { "", null, null, null, null, null, null, null, "\56", null, null, null, null, -"\75", "\173", "\175", "\54", "\133", "\135", "\50", "\51", "\72", }; +"\75", "\173", "\175", "\54", "\55", "\133", "\135", "\50", "\51", "\72", }; /** Lexer state names. */ public static final String[] lexStateNames = { "DEFAULT", }; static final long[] jjtoToken = { - 0x3fff01L, + 0x7fff01L, }; static final long[] jjtoSkip = { 0xfeL, Modified: trunk/interfaces/src/main/java/org/dllearner/confparser3/conf3.jj =================================================================== --- trunk/interfaces/src/main/java/org/dllearner/confparser3/conf3.jj 2011-08-26 20:22:41 UTC (rev 3136) +++ trunk/interfaces/src/main/java/org/dllearner/confparser3/conf3.jj 2011-08-27 09:55:16 UTC (rev 3137) @@ -143,7 +143,7 @@ List<StringTuple> tuples = new LinkedList<StringTuple>(); ConfFileOption2 option = new ConfFileOption2(); - boolean inQuotes = false; + boolean isBeanRef = false; String beanName; String propertyName = ""; String propertyValue = ""; @@ -159,10 +159,10 @@ if(propertyValue.equals("true") || propertyValue.equals("false")) { val = Boolean.valueOf(propertyValue); propertyType = Boolean.class; } else { - val = propertyValue; propertyType = String.class; + val = propertyValue; propertyType = String.class; isBeanRef = true; } } // simple string enclosed in quotes - | propertyValue = String() { val = propertyValue; inQuotes = true; propertyType = String.class; } + | propertyValue = String() { val = propertyValue; propertyType = String.class; } | val = Integer() { propertyValue = val.toString(); propertyType = Integer.class;} | val = Double() { propertyValue = val.toString(); propertyType = Double.class; } // empty set @@ -170,11 +170,13 @@ // set with several elements which are quoted | LOOKAHEAD(4) "{" ( LOOKAHEAD(2) tmp=String() { values.add(tmp); propertyValue += "\"" + tmp + "\", ";} "," )* tmp=String() {values.add(tmp); propertyValue += "\"" + tmp + "\"";} "}" - { propertyType = Set.class; propertyValue = "{"+ propertyValue + "}";; val = values; inQuotes = true;} + { propertyType = Set.class; propertyValue = "{"+ propertyValue + "}";; val = values; } + // empty bean set + | "-" { val = new HashSet(); propertyType = Set.class; propertyValue = "-"; isBeanRef = true;} // set with several elements which are not quoted | "{" ( LOOKAHEAD(4) tmp=Id() { values.add(tmp); propertyValue += tmp + ", "; } "," )* ( tmp=Id()) {values.add(tmp); propertyValue += tmp;} "}" - { val = values; propertyType = Set.class; propertyValue = "{"+ propertyValue + "}"; } + { val = values; propertyType = Set.class; propertyValue = "{"+ propertyValue + "}"; isBeanRef = true;} // empty list | LOOKAHEAD("[" "]") "[" "]" { val = new LinkedList(); propertyType = List.class; propertyValue = "[]";} // a list with several elements, which tuples @@ -188,7 +190,7 @@ ) // <CONF_END> { - option.setInQuotes(inQuotes); + option.setBeanRef(isBeanRef); option.setBeanName(beanName); if(containsSubOption) { option.setPropertyName(propertyName); Modified: trunk/interfaces/src/test/java/org/dllearner/confparser3/ParseTest.java =================================================================== --- trunk/interfaces/src/test/java/org/dllearner/confparser3/ParseTest.java 2011-08-26 20:22:41 UTC (rev 3136) +++ trunk/interfaces/src/test/java/org/dllearner/confparser3/ParseTest.java 2011-08-27 09:55:16 UTC (rev 3137) @@ -1,3 +1,22 @@ +/** + * Copyright (C) 2007-2011, Jens Lehmann + * + * This file is part of DL-Learner. + * + * DL-Learner is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * DL-Learner is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ package org.dllearner.confparser3; import java.io.File; @@ -2,9 +21,12 @@ import java.io.FileNotFoundException; -import java.util.Set; import org.dllearner.cli.ConfFileOption2; -import org.dllearner.confparser3.ConfParser; -import org.dllearner.confparser3.ParseException; import org.junit.Test; +/** + * Conf parser tests. + * + * @author Jens Lehmann + * + */ public class ParseTest { @@ -16,7 +38,7 @@ ConfParser parser = ConfParser.parseFile(new File("../examples/family/father_new.conf")); for(ConfFileOption2 option : parser.getConfOptions()) { System.out.print(option.getBeanName() + "." + option.getPropertyName() + " = " + option.getPropertyValue()); - if((option.getPropertyType().equals(String.class) || option.getPropertyType().equals(Set.class)) && !option.isInQuotes()) { + if(option.isBeanRef()) { System.out.println(" (bean reference)"); } else { System.out.println(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sha...@us...> - 2011-09-01 04:22:18
|
Revision: 3203 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=3203&view=rev Author: shadowtm Date: 2011-09-01 04:22:12 +0000 (Thu, 01 Sep 2011) Log Message: ----------- Added Map support for the prefix post processing logic. Modified Paths: -------------- trunk/interfaces/pom.xml trunk/interfaces/src/main/java/org/dllearner/confparser3/PostProcessor.java trunk/interfaces/src/test/java/org/dllearner/configuration/spring/ConfigurationBasedPropertyOverrideConfigurerTest.java trunk/interfaces/src/test/resources/org/dllearner/configuration/spring/configurationBasedPropertyOverrideConfigurer.conf Modified: trunk/interfaces/pom.xml =================================================================== --- trunk/interfaces/pom.xml 2011-09-01 03:50:09 UTC (rev 3202) +++ trunk/interfaces/pom.xml 2011-09-01 04:22:12 UTC (rev 3203) @@ -187,7 +187,6 @@ <exclude>org/dllearner/test/SpringTest.java</exclude> <exclude>org/dllearner/test/junit/GeizhalsTest.java</exclude> <exclude>org/dllearner/cli/MoosiqueCLITest.java</exclude> - <exclude>org/dllearner/configuration/spring/ConfigurationBasedPropertyOverrideConfigurerTest.java</exclude> </excludes> </configuration> </plugin> Modified: trunk/interfaces/src/main/java/org/dllearner/confparser3/PostProcessor.java =================================================================== --- trunk/interfaces/src/main/java/org/dllearner/confparser3/PostProcessor.java 2011-09-01 03:50:09 UTC (rev 3202) +++ trunk/interfaces/src/main/java/org/dllearner/confparser3/PostProcessor.java 2011-09-01 04:22:12 UTC (rev 3203) @@ -63,7 +63,7 @@ } } else if(valueObject instanceof Map) { - throw new Error("Map post processing not implemented yet"); + valueObject = processStringMap(prefixes, (Map)valueObject); } else if(valueObject instanceof Collection){ processStringCollection(prefixes, (Collection<?>) valueObject); } else if(valueObject instanceof Boolean || valueObject instanceof Integer || valueObject instanceof Double) { @@ -74,10 +74,38 @@ option.setValueObject(valueObject); } - } - } + } + } - private void processStringCollection(Map<String,String> prefixes, Collection valueObject) { + + private Map processStringMap(Map<String, String> prefixes, Map inputMap) { + + Map newMap = new HashMap(); + + /** This does the values */ + for (Object keyObject : inputMap.keySet()) { + Object key = keyObject; + Object value = inputMap.get(key); + + if (keyObject instanceof String) { + String keyString = (String) keyObject; + if (value instanceof String) { + String valueString = (String) value; + for (String prefix : prefixes.keySet()) { + value = valueString.replaceAll(prefix + ":", prefixes.get(prefix)); + key = keyString.replaceAll(prefix + ":", prefixes.get(prefix)); + + } + } + } + newMap.put(key, value); + } + + return newMap; + + } + + private void processStringCollection(Map<String, String> prefixes, Collection valueObject) { Map<String, String> oldNewStringValues = new HashMap<String, String>(); Iterator itr = valueObject.iterator(); while (itr.hasNext()) { @@ -85,7 +113,7 @@ Object nextObject = itr.next(); if (nextObject instanceof String) { String oldValue = (String) nextObject; - String newValue = oldValue.replaceAll( prefix + ":", prefixes.get(prefix)); + String newValue = oldValue.replaceAll(prefix + ":", prefixes.get(prefix)); oldNewStringValues.put(oldValue, newValue); } } Modified: trunk/interfaces/src/test/java/org/dllearner/configuration/spring/ConfigurationBasedPropertyOverrideConfigurerTest.java =================================================================== --- trunk/interfaces/src/test/java/org/dllearner/configuration/spring/ConfigurationBasedPropertyOverrideConfigurerTest.java 2011-09-01 03:50:09 UTC (rev 3202) +++ trunk/interfaces/src/test/java/org/dllearner/configuration/spring/ConfigurationBasedPropertyOverrideConfigurerTest.java 2011-09-01 04:22:12 UTC (rev 3203) @@ -72,6 +72,7 @@ Assert.assertEquals(thirdBean.getIntValue(), (Integer) 3); TestBean fourthBean = thirdBean.getComponent(); validateFourthBean(fourthBean); + Assert.assertTrue(thirdBean.getMapValue().get("http://localhost/foo#f").equals("http://localhost/foo#g")); } private void validateFirstBean(TestBean testBean) { Modified: trunk/interfaces/src/test/resources/org/dllearner/configuration/spring/configurationBasedPropertyOverrideConfigurer.conf =================================================================== --- trunk/interfaces/src/test/resources/org/dllearner/configuration/spring/configurationBasedPropertyOverrideConfigurer.conf 2011-09-01 03:50:09 UTC (rev 3202) +++ trunk/interfaces/src/test/resources/org/dllearner/configuration/spring/configurationBasedPropertyOverrideConfigurer.conf 2011-09-01 04:22:12 UTC (rev 3203) @@ -28,8 +28,8 @@ thirdBean.intValue=3 thirdBean.component=fourthBean +thirdBean.mapValue=[("kb:f","kb:g")] - fourthBean.simpleValue="Fourth Bean - not specified in xml" fourthBean.type="org.dllearner.configuration.spring.TestBean" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lor...@us...> - 2011-09-02 13:41:22
|
Revision: 3236 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=3236&view=rev Author: lorenz_b Date: 2011-09-02 13:41:16 +0000 (Fri, 02 Sep 2011) Log Message: ----------- Changed scripts folder to bin, unfortunately needed now for release. Modified Paths: -------------- trunk/interfaces/pom.xml trunk/interfaces/src/main/assemble/archive.xml Modified: trunk/interfaces/pom.xml =================================================================== --- trunk/interfaces/pom.xml 2011-09-02 13:41:08 UTC (rev 3235) +++ trunk/interfaces/pom.xml 2011-09-02 13:41:16 UTC (rev 3236) @@ -37,10 +37,11 @@ </executions> <configuration> <assembleDirectory>${project.build.directory}/dl-learner-dist</assembleDirectory> - <repoPath>dl-learner-${release.name}/lib</repoPath> - <repositoryName>dl-learner-${release.name}/lib</repositoryName> + <repoPath>lib</repoPath> + <repositoryName>lib</repositoryName> <extraJvmArguments>-Xms256m -Xmx1024m</extraJvmArguments> <installArtifacts>false</installArtifacts> + <configurationDirectory>/</configurationDirectory> <platforms> <platform>windows</platform> <platform>unix</platform> Modified: trunk/interfaces/src/main/assemble/archive.xml =================================================================== --- trunk/interfaces/src/main/assemble/archive.xml 2011-09-02 13:41:08 UTC (rev 3235) +++ trunk/interfaces/src/main/assemble/archive.xml 2011-09-02 13:41:16 UTC (rev 3236) @@ -6,13 +6,13 @@ <fileSets> <fileSet> - <directory>${project.build.directory}/dl-learner-dist/dl-learner-${release.name}/lib + <directory>${project.build.directory}/dl-learner-dist/lib </directory> <outputDirectory>lib</outputDirectory> </fileSet> <fileSet> <directory>${project.build.directory}/dl-learner-dist/bin</directory> - <outputDirectory>/</outputDirectory> + <outputDirectory>/bin</outputDirectory> <includes> <include> *.bat @@ -21,7 +21,7 @@ </fileSet> <fileSet> <directory>${project.build.directory}/dl-learner-dist/bin</directory> - <outputDirectory>/</outputDirectory> + <outputDirectory>/bin</outputDirectory> <excludes> <exclude> *.bat This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lor...@us...> - 2011-09-15 10:08:13
|
Revision: 3270 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=3270&view=rev Author: lorenz_b Date: 2011-09-15 10:08:06 +0000 (Thu, 15 Sep 2011) Log Message: ----------- Increased release version number. Add zip packaging task. Modified Paths: -------------- trunk/interfaces/pom.xml trunk/interfaces/src/main/assemble/archive.xml Modified: trunk/interfaces/pom.xml =================================================================== --- trunk/interfaces/pom.xml 2011-09-15 09:24:46 UTC (rev 3269) +++ trunk/interfaces/pom.xml 2011-09-15 10:08:06 UTC (rev 3270) @@ -15,7 +15,7 @@ </parent> <properties> - <release.name>1.0-alpha-1</release.name> + <release.name>1.0-alpha-2</release.name> </properties> <profiles> Modified: trunk/interfaces/src/main/assemble/archive.xml =================================================================== --- trunk/interfaces/src/main/assemble/archive.xml 2011-09-15 09:24:46 UTC (rev 3269) +++ trunk/interfaces/src/main/assemble/archive.xml 2011-09-15 10:08:06 UTC (rev 3270) @@ -2,6 +2,7 @@ <id>archive</id> <formats> <format>tar.gz</format> + <format>zip</format> </formats> <fileSets> @@ -60,4 +61,4 @@ </fileSets> -</assembly> \ No newline at end of file +</assembly> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dc...@us...> - 2012-04-19 22:08:17
|
Revision: 3644 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=3644&view=rev Author: dcherix Date: 2012-04-19 22:08:10 +0000 (Thu, 19 Apr 2012) Log Message: ----------- files added for creating a debian package Modified Paths: -------------- trunk/interfaces/pom.xml Removed Paths: ------------- trunk/interfaces/src/deb/ Modified: trunk/interfaces/pom.xml =================================================================== --- trunk/interfaces/pom.xml 2012-04-19 20:39:59 UTC (rev 3643) +++ trunk/interfaces/pom.xml 2012-04-19 22:08:10 UTC (rev 3644) @@ -2,12 +2,13 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> - <groupId>org.dllearner</groupId> + <artifactId>interfaces</artifactId> <packaging>jar</packaging> <name>Interfaces: GUI, CLI, Web Service</name> <url>http://aksw.org/Projects/DLLearner</url> + <parent> <groupId>org.dllearner</groupId> <artifactId>dllearner-parent</artifactId> @@ -16,6 +17,8 @@ <properties> <release.name>1.0-beta-2</release.name> + <dist-dir>dl-learner-dist</dist-dir> + <install-dir>share/dl-learner</install-dir> </properties> <profiles> @@ -36,7 +39,7 @@ </execution> </executions> <configuration> - <repositoryLayout>flat</repositoryLayout> + <repositoryLayout>flat</repositoryLayout> <assembleDirectory>${project.build.directory}/dl-learner-dist</assembleDirectory> <repoPath>lib</repoPath> <repositoryName>lib</repositoryName> @@ -56,9 +59,9 @@ <mainClass>org.dllearner.cli.Enrichment</mainClass> <name>enrichment</name> </program> - <!-- <program> <mainClass>org.dllearner.gui.StartGUI</mainClass> - <name>gui</name> </program> <program> <mainClass>org.dllearner.cli.QuickStart</mainClass> - <name>quickstart</name> </program> <program> <mainClass>org.dllearner.server.DLLearnerWS</mainClass> + <!-- <program> <mainClass>org.dllearner.gui.StartGUI</mainClass> + <name>gui</name> </program> <program> <mainClass>org.dllearner.cli.QuickStart</mainClass> + <name>quickstart</name> </program> <program> <mainClass>org.dllearner.server.DLLearnerWS</mainClass> <name>ws</name> </program> --> </programs> </configuration> @@ -87,10 +90,10 @@ <version>1.1</version> <configuration> <settings> - <!-- all tex main documents in this folder (including subfolders) + <!-- all tex main documents in this folder (including subfolders) will be processed --> <texDirectory>${basedir}/doc/manual</texDirectory> - <!-- the generated artifacts will be copied to this folder relative + <!-- the generated artifacts will be copied to this folder relative to ${project.reporting.outputDirectory} --> <outputDirectory>.</outputDirectory> <!-- the working directory, for temporary files and LaTeX processing --> @@ -123,29 +126,201 @@ </plugins> </build> </profile> + <profile> + <id>debpackage</id> + <build> + <finalName>dl-learner</finalName> + <plugins> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>appassembler-maven-plugin</artifactId> + <version>1.1.1</version> + <executions> + <execution> + <goals> + <goal>assemble</goal> + </goals> + </execution> + </executions> + <configuration> + <repositoryLayout>flat</repositoryLayout> + <assembleDirectory>${project.build.directory}/${dist-dir}</assembleDirectory> + <repoPath>/usr/share/dl-learner/lib</repoPath> + <repositoryName>${install-dir}/lib</repositoryName> + <extraJvmArguments>-Xms256m -Xmx1024m</extraJvmArguments> + <installArtifacts>false</installArtifacts> + <configurationDirectory>/</configurationDirectory> + <platforms> + <platform>unix</platform> + </platforms> + <programs> + <program> + <mainClass>org.dllearner.cli.CLI</mainClass> + <name>dl-learner-cli</name> + </program> + <program> + <mainClass>org.dllearner.cli.Enrichment</mainClass> + <name>dl-learner-enrichment</name> + </program> + <!-- <program> <mainClass>org.dllearner.gui.StartGUI</mainClass> + <name>gui</name> </program> <program> <mainClass>org.dllearner.cli.QuickStart</mainClass> + <name>quickstart</name> </program> <program> <mainClass>org.dllearner.server.DLLearnerWS</mainClass> + <name>ws</name> </program> --> + </programs> + </configuration> + </plugin> + <plugin> + <groupId>de.akquinet.maven</groupId> + <artifactId>maven-latex-plugin</artifactId> + <version>1.1</version> + <configuration> + <settings> + <!-- all tex main documents in this folder (including subfolders) + will be processed --> + <texDirectory>${basedir}/doc/manual</texDirectory> + <!-- the generated artifacts will be copied to this folder relative + to ${project.reporting.outputDirectory} --> + <outputDirectory>.</outputDirectory> + <!-- the working directory, for temporary files and LaTeX processing --> + <tempDirectory>${project.build.directory}/m2latex</tempDirectory> + <!-- clean up the working directory in the end? May be used for debugging --> + <cleanUp>true</cleanUp> + <!-- path to the TeX scripts, if none, it must be on the system path --> + <texPath /> + <!-- the latex command --> + <texCommand>pdflatex</texCommand> + <!-- the bibtex command --> + <bibtexCommand>bibtex</bibtexCommand> + <!-- the arguments to use when calling latex --> + <texCommandArgs> + <texCommandArg>-interaction=nonstopmode</texCommandArg> + <texCommandArg>--src-specials</texCommandArg> + </texCommandArgs> + </settings> + </configuration> + <executions> + <!-- execute latex goal automatically during the site phase --> + <execution> + <phase>prepare-package</phase> + <goals> + <goal>latex</goal> + </goals> + </execution> + </executions> + </plugin> + <plugin> + <artifactId>jdeb</artifactId> + <groupId>org.vafer</groupId> + <version>0.9</version> + <executions> + <execution> + <phase>package</phase> + <goals> + <goal>jdeb</goal> + </goals> + <configuration> + <deb>${basedir}/target/dl-learner-${release.name}.deb</deb> + <version>${release.name}</version> + <controlDir>${basedir}/src/debian</controlDir> + <dataSet> + <data> + <src>${project.build.directory}/${dist-dir}/${install-dir}/lib</src> + <type>directory</type> + <mapper> + <type>perm</type> + <prefix>/usr/share/dl-learner/lib</prefix> + </mapper> + </data> + <data> + <src>${project.build.directory}/${dist-dir}/bin/dl-learner-cli</src> + <type>file</type> + + <mapper> + <type>perm</type> + <filemode>777</filemode> + <prefix>/usr/bin</prefix> + </mapper> + </data> + <data> + <src>${project.build.directory}/${dist-dir}/bin/dl-learner-enrichment</src> + <type>file</type> + + <mapper> + <type>perm</type> + <filemode>777</filemode> + <prefix>/usr/bin</prefix> + </mapper> + </data> + <data> + <src>${basedir}/log4j.properties</src> + <type>file</type> + <mapper> + <type>perm</type> + <filemode>777</filemode> + <prefix>/usr/share/dl-learner/lib</prefix> + </mapper> + </data> + <data> + <src>${basedir}/log/interfaces.log</src> + <type>file</type> + <mapper> + <type>perm</type> + <filemode>777</filemode> + <prefix>/var/log/dl-learner</prefix> + </mapper> + </data> + </dataSet> + <changesIn>${basedir}/CHANGES.txt</changesIn> + <changesOut>${basedir}/target/dl-learner-${release.name}.changes</changesOut> + </configuration> + </execution> + </executions> + </plugin> + </plugins> + </build> + </profile> </profiles> - <build> - <finalName>interfaces</finalName> + <finalName>dl-learner</finalName> <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-shade-plugin</artifactId> + <version>1.6</version> + <executions> + <execution> + <phase>package</phase> + <goals> + <goal>shade</goal> + </goals> + <configuration> + <transformers> + <transformer + implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"> + <mainClass>org.dllearner.cli.CLI</mainClass> + </transformer> + </transformers> + </configuration> + </execution> + </executions> + </plugin> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>xmlbeans-maven-plugin</artifactId> + <version>2.3.3</version> + <executions> + <execution> + <goals> + <goal>xmlbeans</goal> + </goals> + </execution> + </executions> + <inherited>true</inherited> + <configuration> + <schemaDirectory>src/main/xsd</schemaDirectory> + </configuration> + </plugin> - <plugin> - <groupId>org.codehaus.mojo</groupId> - <artifactId>xmlbeans-maven-plugin</artifactId> - <version>2.3.3</version> - <executions> - <execution> - <goals> - <goal>xmlbeans</goal> - </goals> - </execution> - </executions> - <inherited>true</inherited> - <configuration> - <schemaDirectory>src/main/xsd</schemaDirectory> - </configuration> - </plugin> - <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>tomcat-maven-plugin</artifactId> @@ -171,10 +346,10 @@ </requestLog> </configuration> <!--execution is used for testing --> - <!--executions> <execution> <id>start-jetty</id> <phase>pre-integration-test</phase> - <goals> <goal>run</goal> </goals> <configuration> <scanIntervalSeconds>0</scanIntervalSeconds> - <daemon>true</daemon> <stopKey>stopKey</stopKey> <stopPort>9999</stopPort> - </configuration> </execution> <execution> <id>stop-jetty</id> <phase>post-integration-test</phase> + <!--executions> <execution> <id>start-jetty</id> <phase>pre-integration-test</phase> + <goals> <goal>run</goal> </goals> <configuration> <scanIntervalSeconds>0</scanIntervalSeconds> + <daemon>true</daemon> <stopKey>stopKey</stopKey> <stopPort>9999</stopPort> + </configuration> </execution> <execution> <id>stop-jetty</id> <phase>post-integration-test</phase> <goals> <goal>stop</goal> </goals> </execution> </executions --> </plugin> @@ -185,10 +360,10 @@ <configuration> <excludes> <exclude>org/dllearner/test/junit/OWLlinkTest.java</exclude> - <exclude>org/dllearner/configuration/spring/TestBean.java</exclude> - <exclude>org/dllearner/test/SpringTest.java</exclude> - <exclude>org/dllearner/test/junit/GeizhalsTest.java</exclude> - <exclude>org/dllearner/cli/MoosiqueCLITest.java</exclude> + <exclude>org/dllearner/configuration/spring/TestBean.java</exclude> + <exclude>org/dllearner/test/SpringTest.java</exclude> + <exclude>org/dllearner/test/junit/GeizhalsTest.java</exclude> + <exclude>org/dllearner/cli/MoosiqueCLITest.java</exclude> </excludes> </configuration> </plugin> @@ -202,11 +377,9 @@ <groupId>org.dllearner</groupId> <artifactId>components-core</artifactId> </dependency> - <!--dependency> - <groupId>org.dllearner</groupId> - <artifactId>components-ext</artifactId> - </dependency--> - <!-- Added the dependency of the core tests so that they will be accessible + <!--dependency> <groupId>org.dllearner</groupId> <artifactId>components-ext</artifactId> + </dependency --> + <!-- Added the dependency of the core tests so that they will be accessible from the tests in this component --> <dependency> <groupId>org.dllearner</groupId> @@ -258,61 +431,64 @@ <groupId>org.springframework</groupId> <artifactId>spring-beans</artifactId> </dependency> - <dependency> - <groupId>org.apache.xmlbeans</groupId> - <artifactId>xmlbeans</artifactId> - </dependency> - <dependency> - <groupId>org.dllearner</groupId> - <artifactId>spring-xmlbeans-3.0</artifactId> - <version>1.0</version> - </dependency> + <dependency> + <groupId>org.apache.xmlbeans</groupId> + <artifactId>xmlbeans</artifactId> + </dependency> + <dependency> + <groupId>org.dllearner</groupId> + <artifactId>spring-xmlbeans-3.0</artifactId> + <version>1.0</version> + </dependency> - <dependency> - <groupId>net.sf.jopt-simple</groupId> - <artifactId>jopt-simple</artifactId> - </dependency> + <dependency> + <groupId>net.sf.jopt-simple</groupId> + <artifactId>jopt-simple</artifactId> + </dependency> - <dependency> - <groupId>org.json</groupId> - <artifactId>json</artifactId> - </dependency> - - <dependency> - <groupId>commons-lang</groupId> - <artifactId>commons-lang</artifactId> - <version>2.3</version> -</dependency> + <dependency> + <groupId>org.json</groupId> + <artifactId>json</artifactId> + </dependency> - <!--BEGIN Logging Dependencies--> + <dependency> + <groupId>commons-lang</groupId> + <artifactId>commons-lang</artifactId> + <version>2.3</version> + </dependency> - <!--This is the api jar, it's needed at compile time--> - <dependency> - <groupId>org.slf4j</groupId> - <artifactId>slf4j-api</artifactId> - </dependency> + <!--BEGIN Logging Dependencies --> - <!--This is the bridge that ties calls to the slf4j api to the log4j framework. This is a runtime dependency for programs which wish to use log4j as their implementation.--> - <dependency> - <groupId>org.slf4j</groupId> - <artifactId>slf4j-log4j12</artifactId> - <scope>runtime</scope> - </dependency> + <!--This is the api jar, it's needed at compile time --> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-api</artifactId> + </dependency> - <!--Log4J dependency needed for the runtime as well as some specific compile time calls--> - <dependency> - <groupId>log4j</groupId> - <artifactId>log4j</artifactId> - </dependency> + <!--This is the bridge that ties calls to the slf4j api to the log4j framework. + This is a runtime dependency for programs which wish to use log4j as their + implementation. --> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-log4j12</artifactId> + <scope>runtime</scope> + </dependency> - <dependency> - <groupId>org.slf4j</groupId> - <artifactId>jcl-over-slf4j</artifactId> - <scope>runtime</scope> - </dependency> - <!--END Logging Dependencies--> + <!--Log4J dependency needed for the runtime as well as some specific compile + time calls --> + <dependency> + <groupId>log4j</groupId> + <artifactId>log4j</artifactId> + </dependency> - + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>jcl-over-slf4j</artifactId> + <scope>runtime</scope> + </dependency> + <!--END Logging Dependencies --> + + </dependencies> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dc...@us...> - 2012-04-19 22:10:27
|
Revision: 3645 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=3645&view=rev Author: dcherix Date: 2012-04-19 22:10:21 +0000 (Thu, 19 Apr 2012) Log Message: ----------- files added for creating a debian package Added Paths: ----------- trunk/interfaces/CHANGES.txt trunk/interfaces/DebianPackageREADME.txt trunk/interfaces/log4j.properties trunk/interfaces/src/debian/ trunk/interfaces/src/debian/changelog trunk/interfaces/src/debian/control trunk/interfaces/src/debian/rules Added: trunk/interfaces/CHANGES.txt =================================================================== --- trunk/interfaces/CHANGES.txt (rev 0) +++ trunk/interfaces/CHANGES.txt 2012-04-19 22:10:21 UTC (rev 3645) @@ -0,0 +1,2 @@ +release date=20:13 13.10.2009,version=0.2,urgency=low,by=Jens Lehmann,distribution=staging + * Test application Added: trunk/interfaces/DebianPackageREADME.txt =================================================================== --- trunk/interfaces/DebianPackageREADME.txt (rev 0) +++ trunk/interfaces/DebianPackageREADME.txt 2012-04-19 22:10:21 UTC (rev 3645) @@ -0,0 +1,8 @@ +To create a debian package: + 1. use dch (apt-get install devscripts) to modify the changelog file in src/debian + 2. just copy the comments (only the comments) from the changelog file to CHANGES.txt + In CHANGES.txt the first line must be like release date=20:13 13.10.2009,version=0.2,urgency=low,by=Jens Lehmann,distribution=staging + paste the comments after this with one whitespace at begin of the line + 3. compile with mvn clean install -Pdebpackage + 4. the deb-package will be generate in target with a .changes file too + 5. sign the package and upload it to the stack \ No newline at end of file Added: trunk/interfaces/log4j.properties =================================================================== --- trunk/interfaces/log4j.properties (rev 0) +++ trunk/interfaces/log4j.properties 2012-04-19 22:10:21 UTC (rev 3645) @@ -0,0 +1,29 @@ +log4j.rootLogger=INFO, stdout, file + +log4j.appender.stdout=org.apache.log4j.ConsoleAppender +log4j.appender.stdout.layout=org.apache.log4j.PatternLayout + +log4j.appender.file=org.apache.log4j.FileAppender +log4j.appender.file.File=/var/log/dllearner/interfaces.log +log4j.appender.file.layout=org.apache.log4j.PatternLayout +log4j.appender.file.layout.ConversionPattern= %-4r [%t] %-5p %c %x - %m%n + +# DL-Learner Logs +log4j.logger.org.dllearner=INFO + +log4j.logger.org.dllearner.server.nke.LogicalRelationStrategy=DEBUG + +# Eliminate most of the Spring Context Loading noise +log4j.logger.org.springframework=WARN + +## log4j.logger.org.joseki.server.http.LocatorServletContext=ALL + +# Jena, including the Joseki client +#log4j.logger.com.hp.hpl.jena=WARN + +## log4j.logger.com.hp.hpl.jena.util.FileManager=ALL +## log4j.logger.com.hp.hpl.jena.util.LocatorURL=ALL +## log4j.logger.com.hp.hpl.jena.util.LocatorClassLoader=ALL +## log4j.logger.com.hp.hpl.jena.util.LocatorFile=ALL +## log4j.logger.com.hp.hpl.jena.util.LocationMapper=ALL + Property changes on: trunk/interfaces/log4j.properties ___________________________________________________________________ Added: svn:executable + * Added: trunk/interfaces/src/debian/changelog =================================================================== --- trunk/interfaces/src/debian/changelog (rev 0) +++ trunk/interfaces/src/debian/changelog 2012-04-19 22:10:21 UTC (rev 3645) @@ -0,0 +1 @@ + Added: trunk/interfaces/src/debian/control =================================================================== --- trunk/interfaces/src/debian/control (rev 0) +++ trunk/interfaces/src/debian/control 2012-04-19 22:10:21 UTC (rev 3645) @@ -0,0 +1,9 @@ +Package: [[name]] +Version: [[version]] +Section: misc +Priority: optional +Architecture: all +Depends: openjdk-6-jre | sun-java6-jre +Maintainer: Jens Lehmann <le...@in...> +Description: This is a package that contains the cli component of the dl-learner. +Distribution: development \ No newline at end of file Added: trunk/interfaces/src/debian/rules =================================================================== --- trunk/interfaces/src/debian/rules (rev 0) +++ trunk/interfaces/src/debian/rules 2012-04-19 22:10:21 UTC (rev 3645) @@ -0,0 +1,21 @@ +#!/usr/bin/make -f +# -*- makefile -*- +# Sample debian/rules that uses debhelper. +# This file was originally written by Joey Hess and Craig Small. +# As a special exception, when this file is copied by dh-make into a +# dh-make output file, you may use that output file without restriction. +# This special exception was added by Craig Small in version 0.37 of dh-make. + +# Uncomment this to turn on verbose mode. +#export DH_VERBOSE=1 + +install: + mkdir /usr/share/dllearner/ + mkdir /usr/share/dllearner/log + chmod -R 777 /usr/share/dllearner/log + cp -r tmp/${PACKAGE_NAME}-${VERSION}/lib /usr/share/dllearner + cp ../dllearner-cli /usr/bin/dllearner-cli + chmod +x /usr/bin/dllearner-cli + +%: + dh $@ \ No newline at end of file Property changes on: trunk/interfaces/src/debian/rules ___________________________________________________________________ Added: svn:executable + * This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lor...@us...> - 2012-07-30 13:54:20
|
Revision: 3810 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=3810&view=rev Author: lorenz_b Date: 2012-07-30 13:54:13 +0000 (Mon, 30 Jul 2012) Log Message: ----------- Added servlet class for enrichment. Modified Paths: -------------- trunk/interfaces/pom.xml trunk/interfaces/src/main/java/org/dllearner/cli/CLI.java trunk/interfaces/src/main/webapp/WEB-INF/web.xml trunk/interfaces/src/test/java/org/dllearner/test/junit/ExampleTests.java Added Paths: ----------- trunk/interfaces/.lastUsedExample trunk/interfaces/src/main/java/org/dllearner/server/EnrichmentServlet.java Added: trunk/interfaces/.lastUsedExample =================================================================== --- trunk/interfaces/.lastUsedExample (rev 0) +++ trunk/interfaces/.lastUsedExample 2012-07-30 13:54:13 UTC (rev 3810) @@ -0,0 +1 @@ +na \ No newline at end of file Modified: trunk/interfaces/pom.xml =================================================================== --- trunk/interfaces/pom.xml 2012-07-28 19:33:29 UTC (rev 3809) +++ trunk/interfaces/pom.xml 2012-07-30 13:54:13 UTC (rev 3810) @@ -344,6 +344,13 @@ <extended>true</extended> <logTimeZone>GMT</logTimeZone> </requestLog> + <connectors> + <connector implementation="org.mortbay.jetty.nio.SelectChannelConnector"> + <port>9099</port> + <maxIdleTime>60000</maxIdleTime> + </connector> + </connectors> + </configuration> <!--execution is used for testing --> <!--executions> <execution> <id>start-jetty</id> <phase>pre-integration-test</phase> Modified: trunk/interfaces/src/main/java/org/dllearner/cli/CLI.java =================================================================== --- trunk/interfaces/src/main/java/org/dllearner/cli/CLI.java 2012-07-28 19:33:29 UTC (rev 3809) +++ trunk/interfaces/src/main/java/org/dllearner/cli/CLI.java 2012-07-30 13:54:13 UTC (rev 3810) @@ -91,6 +91,8 @@ ApplicationContextBuilder builder = new DefaultApplicationContextBuilder(); context = builder.buildApplicationContext(configuration,springConfigResources); + + knowledgeSource = context.getBean(KnowledgeSource.class); } } Added: trunk/interfaces/src/main/java/org/dllearner/server/EnrichmentServlet.java =================================================================== --- trunk/interfaces/src/main/java/org/dllearner/server/EnrichmentServlet.java (rev 0) +++ trunk/interfaces/src/main/java/org/dllearner/server/EnrichmentServlet.java 2012-07-30 13:54:13 UTC (rev 3810) @@ -0,0 +1,405 @@ +package org.dllearner.server; + +import java.io.IOException; +import java.io.PrintWriter; +import java.net.SocketTimeoutException; +import java.net.URL; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.HashSet; +import java.util.LinkedList; +import java.util.List; +import java.util.concurrent.Callable; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.Future; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.commons.collections15.BidiMap; +import org.apache.commons.collections15.bidimap.DualHashBidiMap; +import org.dllearner.algorithms.DisjointClassesLearner; +import org.dllearner.algorithms.SimpleSubclassLearner; +import org.dllearner.algorithms.celoe.CELOE; +import org.dllearner.algorithms.properties.AsymmetricObjectPropertyAxiomLearner; +import org.dllearner.algorithms.properties.DataPropertyDomainAxiomLearner; +import org.dllearner.algorithms.properties.DataPropertyRangeAxiomLearner; +import org.dllearner.algorithms.properties.DisjointDataPropertyAxiomLearner; +import org.dllearner.algorithms.properties.DisjointObjectPropertyAxiomLearner; +import org.dllearner.algorithms.properties.EquivalentDataPropertyAxiomLearner; +import org.dllearner.algorithms.properties.EquivalentObjectPropertyAxiomLearner; +import org.dllearner.algorithms.properties.FunctionalDataPropertyAxiomLearner; +import org.dllearner.algorithms.properties.FunctionalObjectPropertyAxiomLearner; +import org.dllearner.algorithms.properties.InverseFunctionalObjectPropertyAxiomLearner; +import org.dllearner.algorithms.properties.IrreflexiveObjectPropertyAxiomLearner; +import org.dllearner.algorithms.properties.ObjectPropertyDomainAxiomLearner; +import org.dllearner.algorithms.properties.ObjectPropertyRangeAxiomLearner; +import org.dllearner.algorithms.properties.ReflexiveObjectPropertyAxiomLearner; +import org.dllearner.algorithms.properties.SubDataPropertyOfAxiomLearner; +import org.dllearner.algorithms.properties.SubObjectPropertyOfAxiomLearner; +import org.dllearner.algorithms.properties.SymmetricObjectPropertyAxiomLearner; +import org.dllearner.algorithms.properties.TransitiveObjectPropertyAxiomLearner; +import org.dllearner.core.AbstractAxiomLearningAlgorithm; +import org.dllearner.core.AnnComponentManager; +import org.dllearner.core.AxiomLearningAlgorithm; +import org.dllearner.core.ComponentInitException; +import org.dllearner.core.EvaluatedAxiom; +import org.dllearner.core.LearningAlgorithm; +import org.dllearner.core.config.ConfigHelper; +import org.dllearner.core.owl.DatatypeProperty; +import org.dllearner.core.owl.Entity; +import org.dllearner.core.owl.NamedClass; +import org.dllearner.core.owl.ObjectProperty; +import org.dllearner.kb.SparqlEndpointKS; +import org.dllearner.kb.sparql.ExtractionDBCache; +import org.dllearner.kb.sparql.SPARQLTasks; +import org.dllearner.kb.sparql.SparqlEndpoint; +import org.dllearner.reasoning.SPARQLReasoner; +import org.dllearner.utilities.owl.OWLAPIConverter; +import org.json.JSONArray; +import org.json.simple.JSONObject; +import org.semanticweb.owlapi.io.OWLObjectRenderer; +import org.semanticweb.owlapi.model.AxiomType; +import org.semanticweb.owlapi.util.DefaultPrefixManager; + +import uk.ac.manchester.cs.owl.owlapi.mansyntaxrenderer.ManchesterOWLSyntaxOWLObjectRendererImpl; +import uk.ac.manchester.cs.owl.owlapi.mansyntaxrenderer.ManchesterOWLSyntaxPrefixNameShortFormProvider; + +public class EnrichmentServlet extends HttpServlet { + + private static List<Class<? extends LearningAlgorithm>> objectPropertyAlgorithms; + private static List<Class<? extends LearningAlgorithm>> dataPropertyAlgorithms; + private static List<Class<? extends LearningAlgorithm>> classAlgorithms; + private static BidiMap<AxiomType, Class<? extends LearningAlgorithm>> axiomType2Class; + + private static final List<String> entityTypes = Arrays.asList(new String[]{"class", "objectproperty", "dataproperty"}); + + private static String validAxiomTypes = ""; + + static { + axiomType2Class = new DualHashBidiMap<AxiomType, Class<? extends LearningAlgorithm>>(); + axiomType2Class.put(AxiomType.SUBCLASS_OF, SimpleSubclassLearner.class); + axiomType2Class.put(AxiomType.EQUIVALENT_CLASSES, CELOE.class); + axiomType2Class.put(AxiomType.DISJOINT_CLASSES, DisjointClassesLearner.class); + axiomType2Class.put(AxiomType.SUB_OBJECT_PROPERTY, SubObjectPropertyOfAxiomLearner.class); + axiomType2Class.put(AxiomType.EQUIVALENT_OBJECT_PROPERTIES, EquivalentObjectPropertyAxiomLearner.class); + axiomType2Class.put(AxiomType.DISJOINT_OBJECT_PROPERTIES, DisjointObjectPropertyAxiomLearner.class); + axiomType2Class.put(AxiomType.OBJECT_PROPERTY_DOMAIN, ObjectPropertyDomainAxiomLearner.class); + axiomType2Class.put(AxiomType.OBJECT_PROPERTY_RANGE, ObjectPropertyRangeAxiomLearner.class); + axiomType2Class.put(AxiomType.FUNCTIONAL_OBJECT_PROPERTY, FunctionalObjectPropertyAxiomLearner.class); + axiomType2Class.put(AxiomType.INVERSE_FUNCTIONAL_OBJECT_PROPERTY, + InverseFunctionalObjectPropertyAxiomLearner.class); + axiomType2Class.put(AxiomType.REFLEXIVE_OBJECT_PROPERTY, ReflexiveObjectPropertyAxiomLearner.class); + axiomType2Class.put(AxiomType.IRREFLEXIVE_OBJECT_PROPERTY, IrreflexiveObjectPropertyAxiomLearner.class); + axiomType2Class.put(AxiomType.SYMMETRIC_OBJECT_PROPERTY, SymmetricObjectPropertyAxiomLearner.class); + axiomType2Class.put(AxiomType.ASYMMETRIC_OBJECT_PROPERTY, AsymmetricObjectPropertyAxiomLearner.class); + axiomType2Class.put(AxiomType.TRANSITIVE_OBJECT_PROPERTY, TransitiveObjectPropertyAxiomLearner.class); + axiomType2Class.put(AxiomType.SUB_DATA_PROPERTY, SubDataPropertyOfAxiomLearner.class); + axiomType2Class.put(AxiomType.EQUIVALENT_DATA_PROPERTIES, EquivalentDataPropertyAxiomLearner.class); + axiomType2Class.put(AxiomType.DISJOINT_DATA_PROPERTIES, DisjointDataPropertyAxiomLearner.class); + axiomType2Class.put(AxiomType.DATA_PROPERTY_DOMAIN, DataPropertyDomainAxiomLearner.class); + axiomType2Class.put(AxiomType.DATA_PROPERTY_RANGE, DataPropertyRangeAxiomLearner.class); + axiomType2Class.put(AxiomType.FUNCTIONAL_DATA_PROPERTY, FunctionalDataPropertyAxiomLearner.class); + + objectPropertyAlgorithms = new LinkedList<Class<? extends LearningAlgorithm>>(); + objectPropertyAlgorithms.add(DisjointObjectPropertyAxiomLearner.class); + objectPropertyAlgorithms.add(EquivalentObjectPropertyAxiomLearner.class); + objectPropertyAlgorithms.add(FunctionalObjectPropertyAxiomLearner.class); + objectPropertyAlgorithms.add(InverseFunctionalObjectPropertyAxiomLearner.class); + objectPropertyAlgorithms.add(ObjectPropertyDomainAxiomLearner.class); + objectPropertyAlgorithms.add(ObjectPropertyRangeAxiomLearner.class); + objectPropertyAlgorithms.add(SubObjectPropertyOfAxiomLearner.class); + objectPropertyAlgorithms.add(SymmetricObjectPropertyAxiomLearner.class); + objectPropertyAlgorithms.add(TransitiveObjectPropertyAxiomLearner.class); + + dataPropertyAlgorithms = new LinkedList<Class<? extends LearningAlgorithm>>(); + dataPropertyAlgorithms.add(DisjointDataPropertyAxiomLearner.class); + dataPropertyAlgorithms.add(EquivalentDataPropertyAxiomLearner.class); + dataPropertyAlgorithms.add(FunctionalDataPropertyAxiomLearner.class); + dataPropertyAlgorithms.add(DataPropertyDomainAxiomLearner.class); + dataPropertyAlgorithms.add(DataPropertyRangeAxiomLearner.class); + dataPropertyAlgorithms.add(SubDataPropertyOfAxiomLearner.class); + + classAlgorithms = new LinkedList<Class<? extends LearningAlgorithm>>(); + classAlgorithms.add(DisjointClassesLearner.class); + classAlgorithms.add(SimpleSubclassLearner.class); + classAlgorithms.add(CELOE.class); + + for (AxiomType type : AxiomType.AXIOM_TYPES) { + validAxiomTypes += type.getName() + ", "; + } + } + + private static final int DEFAULT_MAX_EXECUTION_TIME_IN_SECONDS = 10; + private static final int DEFAULT_MAX_NR_OF_RETURNED_AXIOMS = 10; + private static final double DEFAULT_THRESHOLD = 0.75; + + @Override + protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { + long timeStamp = System.currentTimeMillis(); + String endpointURL = req.getParameter("endpoint"); + if (endpointURL == null) { + throw new IllegalStateException("Missing parameter: endpoint"); + } + String graphURI = req.getParameter("graph"); + + SparqlEndpoint endpoint = new SparqlEndpoint(new URL(endpointURL), Collections.singletonList(graphURI), + Collections.<String> emptyList()); + + final boolean useInference = req.getParameter("useInference") == null ? false : Boolean.valueOf(req + .getParameter("useInference")); + + final int maxNrOfReturnedAxioms = req.getParameter("maxNrOfReturnedAxioms") == null ? DEFAULT_MAX_NR_OF_RETURNED_AXIOMS : Integer.parseInt(req.getParameter("maxNrOfReturnedAxioms")); + final int maxExecutionTimeInSeconds = req.getParameter("maxExecutionTimeInSeconds") == null ? DEFAULT_MAX_EXECUTION_TIME_IN_SECONDS : Integer.parseInt(req.getParameter("maxExecutionTimeInSeconds")); + final double threshold = req.getParameter("threshold") == null ? DEFAULT_THRESHOLD : Double.parseDouble(req.getParameter("threshold")); + + String resourceURI = req.getParameter("resource"); + if (resourceURI == null) { + throw new IllegalStateException("Missing parameter: resourceURI"); + } + + String axiomTypeStrings[] = req.getParameterValues("axiomTypes"); + if (axiomTypeStrings == null) { + throw new IllegalStateException("Missing parameter: axiomTypes"); + } + axiomTypeStrings = axiomTypeStrings[0].split(","); + + Collection<AxiomType> requestedAxiomTypes = new HashSet<AxiomType>(); + for (String typeStr : axiomTypeStrings) { + AxiomType type = AxiomType.getAxiomType(typeStr.trim()); + if (type == null) { + throw new IllegalStateException("Illegal axiom type: " + typeStr + ". Please use one of " + validAxiomTypes); + } else { + requestedAxiomTypes.add(type); + } + } + + SPARQLTasks st = new SPARQLTasks(endpoint); + String entityType = req.getParameter("entityType"); + final Entity entity; + if(entityType != null){ + if(oneOf(entityType, entityTypes)){ + entity = getEntity(resourceURI, entityType, endpoint); + } else { + throw new IllegalStateException("Illegal entity type: " + entityType + ". Please use one of " + entityTypes); + } + + } else { + entity = st.guessResourceType(resourceURI, true); + entityType = getEntityType(entity); + } + + Collection<AxiomType> executableAxiomTypes = new HashSet<AxiomType>(); + Collection<AxiomType> omittedAxiomTypes = new HashSet<AxiomType>(); + Collection<AxiomType> possibleAxiomTypes = getAxiomTypes(entityType); + for(AxiomType type : requestedAxiomTypes){ + if(possibleAxiomTypes.contains(type)){ + executableAxiomTypes.add(type); + } else { + omittedAxiomTypes.add(type); + } + } + + final SparqlEndpointKS ks = new SparqlEndpointKS(endpoint); + try { + ks.init(); + } catch (ComponentInitException e) { + e.printStackTrace(); + } + // check if endpoint supports SPARQL 1.1 + boolean supportsSPARQL_1_1 = st.supportsSPARQL_1_1(); + ks.setSupportsSPARQL_1_1(supportsSPARQL_1_1); + + final SPARQLReasoner reasoner = new SPARQLReasoner(new SparqlEndpointKS(endpoint)); + reasoner.setCache(new ExtractionDBCache("cache")); + if (useInference && !reasoner.isPrepared()) { + System.out.print("Precomputing subsumption hierarchy ... "); + long startTime = System.currentTimeMillis(); + reasoner.prepareSubsumptionHierarchy(); + System.out.println("done in " + (System.currentTimeMillis() - startTime) + " ms"); + } + + JSONArray result = new JSONArray(); + + ExecutorService executor = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors()); + List<Future<JSONObject>> list = new ArrayList<Future<JSONObject>>(); + + final OWLObjectRenderer renderer = new ManchesterOWLSyntaxOWLObjectRendererImpl(); + renderer.setShortFormProvider(new ManchesterOWLSyntaxPrefixNameShortFormProvider(new DefaultPrefixManager())); + + + for (final AxiomType axiomType : executableAxiomTypes) { + Callable<JSONObject> worker = new Callable<JSONObject>() { + + @Override + public JSONObject call() throws Exception { + JSONObject result = new JSONObject(); + JSONArray axiomArray = new JSONArray(); + List<EvaluatedAxiom> axioms = getEvaluatedAxioms(ks, reasoner, entity, axiomType, maxExecutionTimeInSeconds, threshold, maxNrOfReturnedAxioms, useInference); + for(EvaluatedAxiom ax : axioms){ + JSONObject axiomObject = new JSONObject(); + axiomObject.put("axiom", renderer.render(OWLAPIConverter.getOWLAPIAxiom(ax.getAxiom()))); + axiomObject.put("confidence", ax.getScore().getAccuracy()); + axiomArray.put(axiomObject); + } + result.put(axiomType, axiomArray); + return result; + } + + }; + Future<JSONObject> submit = executor.submit(worker); + list.add(submit); + } + + + for (Future<JSONObject> future : list) { + try { + JSONObject array = future.get(); + result.put(array); + } catch (InterruptedException e) { + e.printStackTrace(); + } catch (ExecutionException e) { + e.printStackTrace(); + } + } + + executor.shutdown(); + + + PrintWriter pw = resp.getWriter(); + JSONObject finalResult = new JSONObject(); + finalResult.put("result", result); + finalResult.put("timestamp", timeStamp); + finalResult.put("execution time", System.currentTimeMillis()-timeStamp); + finalResult.put("endpoint url", endpointURL); + finalResult.put("graph", graphURI); + finalResult.put("resource uri", resourceURI); + finalResult.put("entity type", entityType); + finalResult.put("omitted axiom types", omittedAxiomTypes); + pw.print(finalResult.toJSONString()); + pw.close(); + } + + private boolean oneOf(String value, String... possibleValues){ + for(String v : possibleValues){ + if(v.equals(value)){ + return true; + } + } + return false; + } + + private boolean oneOf(String value, Collection<String> possibleValues){ + for(String v : possibleValues){ + if(v.equals(value)){ + return true; + } + } + return false; + } + + private List<EvaluatedAxiom> getEvaluatedAxioms(SparqlEndpointKS endpoint, SPARQLReasoner reasoner, + Entity entity, AxiomType axiomType, int maxExecutionTimeInSeconds, + double threshold, int maxNrOfReturnedAxioms, boolean useInference) { + List<EvaluatedAxiom> learnedAxioms = new ArrayList<EvaluatedAxiom>(); + try { + learnedAxioms = applyLearningAlgorithm(axiomType2Class.get(axiomType), endpoint, reasoner, entity, maxExecutionTimeInSeconds, threshold, maxNrOfReturnedAxioms); + } catch (ComponentInitException e) { + e.printStackTrace(); + } + return learnedAxioms; + } + + private List<EvaluatedAxiom> applyLearningAlgorithm(Class<? extends LearningAlgorithm> algorithmClass, + SparqlEndpointKS ks, SPARQLReasoner reasoner, Entity entity, int maxExecutionTimeInSeconds, double threshold, int maxNrOfReturnedAxioms) + throws ComponentInitException { + AxiomLearningAlgorithm learner = null; + try { + learner = (AxiomLearningAlgorithm) algorithmClass.getConstructor(SparqlEndpointKS.class).newInstance(ks); + } catch (Exception e) { + e.printStackTrace(); + } + if (classAlgorithms.contains(algorithmClass)) { + ConfigHelper.configure(learner, "classToDescribe", entity); + } else { + ConfigHelper.configure(learner, "propertyToDescribe", entity); + } + ConfigHelper.configure(learner, "maxExecutionTimeInSeconds", maxExecutionTimeInSeconds); + // if(reasoner != null){ + ((AbstractAxiomLearningAlgorithm) learner).setReasoner(reasoner); + // } + learner.init(); + String algName = AnnComponentManager.getName(learner); + System.out.print("Applying " + algName + " on " + entity + " ... "); + long startTime = System.currentTimeMillis(); + try { + learner.start(); + } catch (Exception e) { + if (e.getCause() instanceof SocketTimeoutException) { + System.out.println("Query timed out (endpoint possibly too slow)."); + } else { + e.printStackTrace(); + } + } + long runtime = System.currentTimeMillis() - startTime; + System.out.println("done in " + runtime + " ms"); + List<EvaluatedAxiom> learnedAxioms = learner.getCurrentlyBestEvaluatedAxioms(maxNrOfReturnedAxioms, threshold); + return learnedAxioms; + } + + private Entity getEntity(String resourceURI, String entityType, SparqlEndpoint endpoint) { + Entity entity = null; + if (entityType.equals("class")) { + entity = new NamedClass(resourceURI); + } else if (entityType.equals("objectproperty")) { + entity = new ObjectProperty(resourceURI); + } else if (entityType.equals("dataproperty")) { + entity = new DatatypeProperty(resourceURI); + } else { + SPARQLTasks st = new SPARQLTasks(endpoint); + entity = st.guessResourceType(resourceURI, true); + } + return entity; + } + + private String getEntityType(Entity entity) { + String entityType = null; + if(entity instanceof NamedClass){ + entityType = "class"; + } else if(entity instanceof ObjectProperty){ + entityType = "objectproperty"; + } else if(entity instanceof ObjectProperty){ + entityType = "dataproperty"; + } + return entityType; + } + + public Collection<AxiomType> getAxiomTypes(String entityType){ + List<AxiomType> types = new ArrayList<AxiomType>(); + + List<Class<? extends LearningAlgorithm>> algorithms = null; + if(entityType.equals("class")){ + algorithms = classAlgorithms; + } else if(entityType.equals("objectproperty")){ + algorithms = objectPropertyAlgorithms; + } else if(entityType.equals("dataproperty")){ + algorithms = dataPropertyAlgorithms; + } + + if(algorithms != null){ + for(Class<? extends LearningAlgorithm> alg : algorithms){ + types.add(axiomType2Class.getKey(alg)); + } + } + + return types; + } + + +} Modified: trunk/interfaces/src/main/webapp/WEB-INF/web.xml =================================================================== --- trunk/interfaces/src/main/webapp/WEB-INF/web.xml 2012-07-28 19:33:29 UTC (rev 3809) +++ trunk/interfaces/src/main/webapp/WEB-INF/web.xml 2012-07-30 13:54:13 UTC (rev 3810) @@ -25,5 +25,14 @@ <servlet-name>NKEGeizhals</servlet-name> <url-pattern>/NKEGeizhals</url-pattern> </servlet-mapping> + + <servlet> + <servlet-name>Enrichment</servlet-name> + <servlet-class>org.dllearner.server.EnrichmentServlet</servlet-class> + </servlet> + <servlet-mapping> + <servlet-name>Enrichment</servlet-name> + <url-pattern>/Enrichment</url-pattern> + </servlet-mapping> </web-app> Modified: trunk/interfaces/src/test/java/org/dllearner/test/junit/ExampleTests.java =================================================================== --- trunk/interfaces/src/test/java/org/dllearner/test/junit/ExampleTests.java 2012-07-28 19:33:29 UTC (rev 3809) +++ trunk/interfaces/src/test/java/org/dllearner/test/junit/ExampleTests.java 2012-07-30 13:54:13 UTC (rev 3810) @@ -24,13 +24,11 @@ import java.util.ArrayList; import java.util.Collections; import java.util.Date; -import java.util.HashMap; import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Random; import java.util.Set; -import java.util.SortedMap; import java.util.TreeMap; import java.util.TreeSet; @@ -41,9 +39,7 @@ import org.dllearner.algorithms.gp.GP; import org.dllearner.cli.CLI; import org.dllearner.cli.QuickStart; -import org.dllearner.cli.Start; import org.dllearner.core.AbstractCELA; -import org.dllearner.core.ClassExpressionLearningAlgorithm; import org.dllearner.core.ComponentInitException; import org.dllearner.core.ComponentManager; import org.dllearner.core.LearningAlgorithm; @@ -153,6 +149,7 @@ break; } } + if(sparql == 2 && conf.contains("sparql")) ignored = true; if(ignored) { System.out.println("Skipping " + conf + " (is on ignore list)."); } else { @@ -163,6 +160,7 @@ // start example CLI start = new CLI(new File(conf)); start.init(); + // System.out.println("algorithm: " + start.getLearningAlgorithm()); boolean isSparql = start.getKnowledgeSource() instanceof SparqlKnowledgeSource; // boolean isSparql = false; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lor...@us...> - 2012-12-11 19:34:46
|
Revision: 3880 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=3880&view=rev Author: lorenz_b Date: 2012-12-11 19:34:37 +0000 (Tue, 11 Dec 2012) Log Message: ----------- Set default log level to INFO in log4j.properties file. Added config option logLevel(String value) for cli to set the log level via config file. Modified Paths: -------------- trunk/interfaces/pom.xml trunk/interfaces/src/main/java/org/dllearner/cli/CLI.java trunk/interfaces/src/main/java/org/dllearner/cli/GlobalEnrichment.java trunk/interfaces/src/main/resources/log4j.properties Modified: trunk/interfaces/pom.xml =================================================================== --- trunk/interfaces/pom.xml 2012-11-29 15:21:42 UTC (rev 3879) +++ trunk/interfaces/pom.xml 2012-12-11 19:34:37 UTC (rev 3880) @@ -383,6 +383,12 @@ <dependency> <groupId>org.dllearner</groupId> <artifactId>components-core</artifactId> + <exclusions> + <exclusion> + <artifactId>jena</artifactId> + <groupId>com.hp.hpl.jena</groupId> + </exclusion> + </exclusions> </dependency> <!--dependency> <groupId>org.dllearner</groupId> <artifactId>components-ext</artifactId> </dependency --> Modified: trunk/interfaces/src/main/java/org/dllearner/cli/CLI.java =================================================================== --- trunk/interfaces/src/main/java/org/dllearner/cli/CLI.java 2012-11-29 15:21:42 UTC (rev 3879) +++ trunk/interfaces/src/main/java/org/dllearner/cli/CLI.java 2012-12-11 19:34:37 UTC (rev 3880) @@ -29,6 +29,7 @@ import org.apache.commons.lang.exception.ExceptionUtils; +import org.apache.log4j.Level; import org.apache.xmlbeans.XmlObject; import org.dllearner.algorithms.ParCEL.ParCELPosNegLP; import org.dllearner.configuration.IConfiguration; @@ -70,6 +71,8 @@ private boolean performCrossValidation = false; private int nrOfFolds = 10; private int noOfRuns = 1; + + private String logLevel = "INFO"; public CLI() { @@ -97,6 +100,11 @@ } public void run() throws IOException { + try { + org.apache.log4j.Logger.getLogger("org.dllearner").setLevel(Level.toLevel(logLevel.toUpperCase())); + } catch (Exception e) { + logger.warn("Error setting log level to " + logLevel); + } if (writeSpringConfiguration) { SpringConfigurationXMLBeanConverter converter = new SpringConfigurationXMLBeanConverter(); @@ -272,6 +280,14 @@ this.nrOfFolds = nrOfFolds; } + public void setLogLevel(String logLevel) { + this.logLevel = logLevel; + } + + public String getLogLevel() { + return logLevel; + } + public LearningAlgorithm getLearningAlgorithm() { return algorithm; } Modified: trunk/interfaces/src/main/java/org/dllearner/cli/GlobalEnrichment.java =================================================================== --- trunk/interfaces/src/main/java/org/dllearner/cli/GlobalEnrichment.java 2012-11-29 15:21:42 UTC (rev 3879) +++ trunk/interfaces/src/main/java/org/dllearner/cli/GlobalEnrichment.java 2012-12-11 19:34:37 UTC (rev 3880) @@ -111,6 +111,8 @@ public static void main(String[] args) throws MalformedURLException, IllegalArgumentException, SecurityException, ComponentInitException, InstantiationException, IllegalAccessException, InvocationTargetException, NoSuchMethodException, LearningProblemUnsupportedException, FileNotFoundException { new File(baseDir).mkdirs(); + new File(baseDir).mkdirs(); + SimpleLayout layout = new SimpleLayout(); ConsoleAppender consoleAppender = new ConsoleAppender(layout); Logger.getRootLogger().setLevel(Level.WARN); Modified: trunk/interfaces/src/main/resources/log4j.properties =================================================================== --- trunk/interfaces/src/main/resources/log4j.properties 2012-11-29 15:21:42 UTC (rev 3879) +++ trunk/interfaces/src/main/resources/log4j.properties 2012-12-11 19:34:37 UTC (rev 3880) @@ -13,9 +13,9 @@ log4j.appender.file.Threshold=DEBUG # DL-Learner Logs -log4j.logger.org.dllearner=DEBUG +log4j.logger.org.dllearner=INFO # Turn this to Debug if you wish to dump stack traces to the appenders (console, file) -log4j.logger.org.dllearner.cli=DEBUG +log4j.logger.org.dllearner.cli=INFO log4j.logger.org.dllearner.server.nke.LogicalRelationStrategy=DEBUG log4j.category.org.dllearner.kb.simple=DEBUG This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lor...@us...> - 2013-06-13 13:36:51
|
Revision: 3996 http://sourceforge.net/p/dl-learner/code/3996 Author: lorenz_b Date: 2013-06-13 13:36:48 +0000 (Thu, 13 Jun 2013) Log Message: ----------- Improved enrichment. Modified Paths: -------------- trunk/interfaces/pom.xml trunk/interfaces/src/main/java/org/dllearner/cli/Enrichment.java Modified: trunk/interfaces/pom.xml =================================================================== --- trunk/interfaces/pom.xml 2013-06-13 13:34:00 UTC (rev 3995) +++ trunk/interfaces/pom.xml 2013-06-13 13:36:48 UTC (rev 3996) @@ -521,6 +521,10 @@ <!-- Exclude Project-D from Project-B --> <artifactId>slf4j-log4j12</artifactId> </exclusion> + <exclusion> + <groupId>net.sourceforge</groupId> + <artifactId>owlapi</artifactId> + </exclusion> </exclusions> </dependency> <dependency> Modified: trunk/interfaces/src/main/java/org/dllearner/cli/Enrichment.java =================================================================== --- trunk/interfaces/src/main/java/org/dllearner/cli/Enrichment.java 2013-06-13 13:34:00 UTC (rev 3995) +++ trunk/interfaces/src/main/java/org/dllearner/cli/Enrichment.java 2013-06-13 13:36:48 UTC (rev 3996) @@ -67,6 +67,7 @@ import org.aksw.commons.jena_owlapi.Conversion; import org.aksw.jena_sparql_api.core.QueryExecutionFactory; +import org.apache.jena.riot.Lang; import org.apache.jena.riot.checker.CheckerLiterals; import org.apache.jena.riot.system.ErrorHandlerFactory; import org.apache.log4j.ConsoleAppender; @@ -345,7 +346,7 @@ // loop over all entities and call appropriate algorithms Set<NamedClass> classes = reasoner.getTypes();//st.getAllClasses(); - filterByNamespaces(classes);//classes = Sets.newHashSet(new NamedClass("http://dbpedia.org/ontology/AdministrativeRegion")); + filterByNamespaces(classes);//classes = Sets.newHashSet(new NamedClass("http://dbpedia.org/ontology/Arachnid")); int entities = 0; for(NamedClass nc : classes) { try { @@ -856,16 +857,14 @@ model.write(fos, "TURTLE", null); OWLOntologyManager man = OWLManager.createOWLOntologyManager(); OWLOntology ontology = man.loadOntologyFromOntologyDocument(new ByteArrayInputStream(baos.toByteArray())); - try { - man.saveOntology(ontology, new TurtleOntologyFormat(), new FileOutputStream("error.owl")); - } catch (OWLOntologyStorageException e) { - e.printStackTrace(); - } catch (FileNotFoundException e) { - e.printStackTrace(); - } return ontology; } catch (OWLOntologyCreationException e) { e.printStackTrace(); + try { + model.write(new FileOutputStream("parse-error.ttl"), "TURTLE", null); + } catch (FileNotFoundException e1) { + e1.printStackTrace(); + } } return null; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dc...@us...> - 2013-11-14 09:06:44
|
Revision: 4148 http://sourceforge.net/p/dl-learner/code/4148 Author: dcherix Date: 2013-11-14 09:06:41 +0000 (Thu, 14 Nov 2013) Log Message: ----------- Changes for debian package Modified Paths: -------------- trunk/interfaces/pom.xml Added Paths: ----------- trunk/interfaces/src/debian/interfaces.log Modified: trunk/interfaces/pom.xml =================================================================== --- trunk/interfaces/pom.xml 2013-11-14 06:15:56 UTC (rev 4147) +++ trunk/interfaces/pom.xml 2013-11-14 09:06:41 UTC (rev 4148) @@ -334,7 +334,7 @@ </mapper> </data> <data> - <src>${basedir}/log/interfaces.log</src> + <src>${basedir}/src/debian/interfaces.log</src> <type>file</type> <mapper> <type>perm</type> Added: trunk/interfaces/src/debian/interfaces.log =================================================================== --- trunk/interfaces/src/debian/interfaces.log (rev 0) +++ trunk/interfaces/src/debian/interfaces.log 2013-11-14 09:06:41 UTC (rev 4148) @@ -0,0 +1,2 @@ + + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lor...@us...> - 2014-04-23 10:48:03
|
Revision: 4251 http://sourceforge.net/p/dl-learner/code/4251 Author: lorenz_b Date: 2014-04-23 10:47:59 +0000 (Wed, 23 Apr 2014) Log Message: ----------- Made config parser UTF-8 compatible. Modified Paths: -------------- trunk/interfaces/pom.xml trunk/interfaces/src/main/java/org/dllearner/cli/Enrichment.java trunk/interfaces/src/main/java/org/dllearner/confparser3/ConfParser.java trunk/interfaces/src/main/java/org/dllearner/confparser3/ConfParserTokenManager.java trunk/interfaces/src/main/java/org/dllearner/confparser3/ParseException.java trunk/interfaces/src/main/java/org/dllearner/confparser3/SimpleCharStream.java trunk/interfaces/src/main/java/org/dllearner/confparser3/Token.java trunk/interfaces/src/main/java/org/dllearner/confparser3/TokenMgrError.java trunk/interfaces/src/main/java/org/dllearner/confparser3/conf3.jj trunk/interfaces/src/test/java/org/dllearner/confparser3/ParseTest.java Modified: trunk/interfaces/pom.xml =================================================================== --- trunk/interfaces/pom.xml 2014-03-21 19:21:47 UTC (rev 4250) +++ trunk/interfaces/pom.xml 2014-04-23 10:47:59 UTC (rev 4251) @@ -402,6 +402,20 @@ <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-resources-plugin</artifactId> </plugin> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>javacc-maven-plugin</artifactId> + <version>2.6</version> + <executions> + <execution> + <id>javacc</id> + <goals> + <goal>javacc</goal> + </goals> + </execution> + </executions> + </plugin> + <plugin> <groupId>org.mortbay.jetty</groupId> @@ -612,5 +626,14 @@ </dependency> </dependencies> +<reporting> + <plugins> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>javacc-maven-plugin</artifactId> + <version>2.6</version> + </plugin> + </plugins> + </reporting> </project> Modified: trunk/interfaces/src/main/java/org/dllearner/cli/Enrichment.java =================================================================== --- trunk/interfaces/src/main/java/org/dllearner/cli/Enrichment.java 2014-03-21 19:21:47 UTC (rev 4250) +++ trunk/interfaces/src/main/java/org/dllearner/cli/Enrichment.java 2014-04-23 10:47:59 UTC (rev 4251) @@ -25,6 +25,7 @@ import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.File; +import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; @@ -116,6 +117,7 @@ import org.dllearner.core.owl.NamedClass; import org.dllearner.core.owl.ObjectProperty; import org.dllearner.core.owl.SubClassAxiom; +import org.dllearner.kb.LocalModelBasedSparqlEndpointKS; import org.dllearner.kb.OWLAPIOntology; import org.dllearner.kb.SparqlEndpointKS; import org.dllearner.kb.sparql.ConciseBoundedDescriptionGenerator; @@ -214,6 +216,7 @@ private SecureRandom random = new SecureRandom(); // enrichment parameters + private SparqlEndpointKS ks; private SparqlEndpoint se; private Entity resource; private boolean verbose; @@ -316,8 +319,76 @@ learnedOWLAxioms = new HashSet<OWLAxiom>(); learnedEvaluatedAxioms = new HashSet<EvaluatedAxiom>(); + + // instantiate SPARQL endpoint wrapper component + ks = new SparqlEndpointKS(se); + try { + ks.init(); + ks.setSupportsSPARQL_1_1(!iterativeMode); + } catch (ComponentInitException e) { + e.printStackTrace(); + } + } + public Enrichment(SparqlEndpointKS ks, Entity resource, double threshold, int nrOfAxiomsToLearn, + boolean useInference, boolean verbose, int chunksize, + int maxExecutionTimeInSeconds, boolean omitExistingAxioms) { + this.ks = ks; + this.resource = resource; + this.verbose = verbose; + this.threshold = threshold; + this.nrOfAxiomsToLearn = nrOfAxiomsToLearn; + this.useInference = useInference; + this.chunksize = chunksize; + this.maxExecutionTimeInSeconds = maxExecutionTimeInSeconds; + this.omitExistingAxioms = omitExistingAxioms; + + if(ks.isRemote()){ + try { + cacheDir = "cache" + File.separator + URLEncoder.encode(((SparqlEndpointKS)ks).getEndpoint().getURL().toString(), "UTF-8"); + } catch (UnsupportedEncodingException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + cache = new ExtractionDBCache(cacheDir); + } + + + objectPropertyAlgorithms = new LinkedList<Class<? extends AxiomLearningAlgorithm>>(); + objectPropertyAlgorithms.add(DisjointObjectPropertyAxiomLearner.class); + objectPropertyAlgorithms.add(EquivalentObjectPropertyAxiomLearner.class); + objectPropertyAlgorithms.add(FunctionalObjectPropertyAxiomLearner.class); + objectPropertyAlgorithms.add(InverseFunctionalObjectPropertyAxiomLearner.class); + objectPropertyAlgorithms.add(ObjectPropertyDomainAxiomLearner.class); + objectPropertyAlgorithms.add(ObjectPropertyRangeAxiomLearner.class); + objectPropertyAlgorithms.add(SubObjectPropertyOfAxiomLearner.class); + objectPropertyAlgorithms.add(SymmetricObjectPropertyAxiomLearner.class); + objectPropertyAlgorithms.add(AsymmetricObjectPropertyAxiomLearner.class); + objectPropertyAlgorithms.add(TransitiveObjectPropertyAxiomLearner.class); + objectPropertyAlgorithms.add(InverseObjectPropertyAxiomLearner.class); + objectPropertyAlgorithms.add(ReflexiveObjectPropertyAxiomLearner.class); + objectPropertyAlgorithms.add(IrreflexiveObjectPropertyAxiomLearner.class); + + dataPropertyAlgorithms = new LinkedList<Class<? extends AxiomLearningAlgorithm>>(); + dataPropertyAlgorithms.add(DisjointDataPropertyAxiomLearner.class); + dataPropertyAlgorithms.add(EquivalentDataPropertyAxiomLearner.class); + dataPropertyAlgorithms.add(FunctionalDataPropertyAxiomLearner.class); + dataPropertyAlgorithms.add(DataPropertyDomainAxiomLearner.class); + dataPropertyAlgorithms.add(DataPropertyRangeAxiomLearner.class); + dataPropertyAlgorithms.add(SubDataPropertyOfAxiomLearner.class); + + classAlgorithms = new LinkedList<Class<? extends LearningAlgorithm>>(); +// classAlgorithms.add(DisjointClassesLearner.class); +// classAlgorithms.add(SimpleSubclassLearner.class); + classAlgorithms.add(CELOE.class); + + algorithmRuns = new LinkedList<AlgorithmRun>(); + + learnedOWLAxioms = new HashSet<OWLAxiom>(); + learnedEvaluatedAxioms = new HashSet<EvaluatedAxiom>(); + } + public void setAllowedNamespaces(List<String> allowedNamespaces) { this.allowedNamespaces = allowedNamespaces; } @@ -331,11 +402,6 @@ public void start() throws ComponentInitException, IllegalArgumentException, SecurityException, InstantiationException, IllegalAccessException, InvocationTargetException, NoSuchMethodException, LearningProblemUnsupportedException, MalformedURLException { - // instantiate SPARQL endpoint wrapper component - SparqlEndpointKS ks = new SparqlEndpointKS(se); - ks.init(); - ks.setSupportsSPARQL_1_1(!iterativeMode); - // common helper objects SPARQLTasks st = new SPARQLTasks(se); @@ -344,7 +410,7 @@ // ks.setSupportsSPARQL_1_1(supportsSPARQL_1_1); if(useInference){ - reasoner = new SPARQLReasoner(ks, cache); + reasoner = new SPARQLReasoner(ks, cacheDir); System.out.print("Precomputing subsumption hierarchy ... "); long startTime = System.currentTimeMillis(); reasoner.prepareSubsumptionHierarchy(); @@ -459,6 +525,7 @@ } private void filterByNamespaces(Model model){ + List<Statement> toRemove = new ArrayList<>(); if(allowedNamespaces != null && !allowedNamespaces.isEmpty()){ for (StmtIterator iterator = model.listStatements(); iterator.hasNext();) { Statement st = iterator.next(); @@ -485,10 +552,11 @@ } } if(!startsWithAllowedNamespace){ - iterator.remove(); + toRemove.add(st); } } } + model.remove(toRemove); } @SuppressWarnings("unchecked") @@ -549,7 +617,13 @@ } else { System.out.print("extracting fragment ... ");//com.hp.hpl.jena.shared.impl.JenaParameters.enableEagerLiteralValidation = true; startTime = System.currentTimeMillis(); - Model model = getFragmentMultithreaded(ks, Sets.union(posExamples, negExamples)); + Model model; + if(ks.isRemote()){ + model = getFragmentMultithreaded(ks, Sets.union(posExamples, negExamples)); + } else { + model = ((LocalModelBasedSparqlEndpointKS)ks).getModel(); + } + filter(model); filterByNamespaces(model); OWLEntityTypeAdder.addEntityTypes(model); @@ -1136,6 +1210,7 @@ System.exit(0); } + SparqlEndpointKS ks = null; // create SPARQL endpoint object (check that indeed a URL was given) URL endpoint = null; try { @@ -1144,13 +1219,33 @@ System.out.println("The specified endpoint appears not be a proper URL."); System.exit(0); } - URI graph = null; + //check if the URL is a file and if exists load it into a JENA model try { - graph = (URI) options.valueOf("graph"); - } catch(OptionException e) { - System.out.println("The specified graph appears not be a proper URL."); - System.exit(0); + File file = new File(endpoint.toURI()); + if(file.exists()){ + Model kbModel = ModelFactory.createDefaultModel(); + kbModel.read(new FileInputStream(file), null); + ks = new LocalModelBasedSparqlEndpointKS(kbModel); + } else { + URI graph = null; + try { + graph = (URI) options.valueOf("graph"); + } catch(OptionException e) { + System.out.println("The specified graph appears not be a proper URL."); + System.exit(0); + } + + LinkedList<String> defaultGraphURIs = new LinkedList<String>(); + if(graph != null) { + defaultGraphURIs.add(graph.toString()); + } + SparqlEndpoint se = new SparqlEndpoint(endpoint, defaultGraphURIs, new LinkedList<String>()); + ks = new SparqlEndpointKS(se); + } + } catch (URISyntaxException e2) { + e2.printStackTrace(); } + URI resourceURI = null; try { resourceURI = (URI) options.valueOf("resource"); @@ -1170,30 +1265,25 @@ }); } - - LinkedList<String> defaultGraphURIs = new LinkedList<String>(); - if(graph != null) { - defaultGraphURIs.add(graph.toString()); - } - SparqlEndpoint se = new SparqlEndpoint(endpoint, defaultGraphURIs, new LinkedList<String>()); - - // sanity check that endpoint/graph returns at least one triple - String query = "SELECT * WHERE {?s ?p ?o} LIMIT 1"; - SparqlQuery sq = new SparqlQuery(query, se); - try { - ResultSet q = sq.send(); - while (q.hasNext()) { - q.next(); + if(ks.isRemote()){ + // sanity check that endpoint/graph returns at least one triple + String query = "SELECT * WHERE {?s ?p ?o} LIMIT 1"; + SparqlQuery sq = new SparqlQuery(query, ks.getEndpoint()); + try { + ResultSet q = sq.send(); + while (q.hasNext()) { + q.next(); + } + } catch(QueryExceptionHTTP e) { + System.out.println("Endpoint not reachable (check spelling)."); + System.exit(0); } - } catch(QueryExceptionHTTP e) { - System.out.println("Endpoint not reachable (check spelling)."); - System.exit(0); } // map resource to correct type Entity resource = null; if(options.valueOf("resource") != null) { - resource = new SPARQLTasks(se).guessResourceType(resourceURI.toString(), true); + resource = new SPARQLTasks(((SparqlEndpointKS)ks).getEndpoint()).guessResourceType(resourceURI.toString(), true); if(resource == null) { throw new IllegalArgumentException("Could not determine the type (class, object property or data property) of input resource " + options.valueOf("resource")); } @@ -1229,7 +1319,7 @@ boolean processDataProperties = (Boolean) options.valueOf("dp"); boolean processClasses = (Boolean) options.valueOf("cls"); - Enrichment e = new Enrichment(se, resource, threshold, maxNrOfResults, useInference, false, chunksize, maxExecutionTimeInSeconds, omitExistingAxioms); + Enrichment e = new Enrichment(ks, resource, threshold, maxNrOfResults, useInference, false, chunksize, maxExecutionTimeInSeconds, omitExistingAxioms); e.setAllowedNamespaces(allowedNamespaces); e.setIterativeMode(iterativeMode); e.setProcessObjectProperties(processObjectProperties); @@ -1237,8 +1327,6 @@ e.setProcessClasses(processClasses); e.start(); - SparqlEndpointKS ks = new SparqlEndpointKS(se); - // print output in correct format if(options.has("f")) { List<AlgorithmRun> runs = e.getAlgorithmRuns(); Modified: trunk/interfaces/src/main/java/org/dllearner/confparser3/ConfParser.java =================================================================== --- trunk/interfaces/src/main/java/org/dllearner/confparser3/ConfParser.java 2014-03-21 19:21:47 UTC (rev 4250) +++ trunk/interfaces/src/main/java/org/dllearner/confparser3/ConfParser.java 2014-04-23 10:47:59 UTC (rev 4251) @@ -1,3 +1,4 @@ +/* ConfParser.java */ /* Generated By:JavaCC: Do not edit this line. ConfParser.java */ package org.dllearner.confparser3; @@ -4,6 +5,8 @@ import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; +import java.io.InputStreamReader; +import java.io.UnsupportedEncodingException; import java.util.HashMap; import java.util.HashSet; import java.util.LinkedList; @@ -13,7 +16,6 @@ import org.dllearner.cli.ConfFileOption2; import org.dllearner.parser.KBParser; -import org.dllearner.utilities.datastructures.StringTuple; public class ConfParser implements ConfParserConstants { @@ -58,38 +60,37 @@ return confOptionsByBean.get(beanName); } - public static ConfParser parseFile(File filename) throws FileNotFoundException, ParseException { - ConfParser parser = new ConfParser(new FileInputStream(filename)); + public static ConfParser parseFile(File filename) throws FileNotFoundException, ParseException, UnsupportedEncodingException { + ConfParser parser = new ConfParser(new InputStreamReader(new FileInputStream(filename),"UTF-8")); parser.Start(); return parser; } - final public void Start() throws ParseException { - ConfFileOption2 confOption; + final public void Start() throws ParseException {ConfFileOption2 confOption; label_1: while (true) { - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case ID: + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case ID:{ ; break; + } default: jj_la1[0] = jj_gen; break label_1; } confOption = ConfOption(); - if(confOption.getPropertyName() == null) { +if(confOption.getPropertyName() == null) { specialOptions.put(confOption.getBeanName(),confOption); } else { addConfOption(confOption); } } jj_consume_token(0); - PostProcessor pp = new PostProcessor(confOptions, specialOptions); +PostProcessor pp = new PostProcessor(confOptions, specialOptions); pp.applyAll(); } - final public ConfFileOption2 ConfOption() throws ParseException { - boolean containsSubOption=false; + final public ConfFileOption2 ConfOption() throws ParseException {boolean containsSubOption=false; String value="", value1="", value2="", tmp="", tmp2=""; Set<String> values = new HashSet<String>(); Map<String,String> tuples = new HashMap<String,String>(); @@ -105,47 +106,52 @@ Object val = null; Double d; beanName = Id(); - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case COMMAND_END: + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case COMMAND_END:{ jj_consume_token(COMMAND_END); propertyName = Id(); - containsSubOption=true; +containsSubOption=true; break; + } default: jj_la1[1] = jj_gen; ; } jj_consume_token(13); - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case ID: + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case ID:{ // two strings separated by a double colon // LOOKAHEAD(2) value1=Id() ":" value2=Id() { useColon = true; } // simple string propertyValue = Id(); - if(propertyValue.equals("true") || propertyValue.equals("false")) { +if(propertyValue.equals("true") || propertyValue.equals("false")) { val = Boolean.valueOf(propertyValue); propertyType = Boolean.class; } else { val = propertyValue; propertyType = String.class; isBeanRef = true; } break; - case STRING: + } + case STRING:{ propertyValue = String(); - val = propertyValue; propertyType = String.class; +val = propertyValue; propertyType = String.class; break; - case NUMBER: + } + case NUMBER:{ val = Integer(); - propertyValue = val.toString(); propertyType = Integer.class; +propertyValue = val.toString(); propertyType = Integer.class; break; - case DOUBLE: + } + case DOUBLE:{ val = Double(); - propertyValue = val.toString(); propertyType = Double.class; +propertyValue = val.toString(); propertyType = Double.class; break; + } default: jj_la1[2] = jj_gen; if (jj_2_5(2147483647)) { jj_consume_token(14); jj_consume_token(15); - val = new HashSet(); propertyType = Set.class; propertyValue = "{}"; +val = new HashSet(); propertyType = Set.class; propertyValue = "{}"; } else if (jj_2_6(4)) { jj_consume_token(14); label_2: @@ -156,20 +162,21 @@ break label_2; } tmp = String(); - values.add(tmp); propertyValue += "\u005c"" + tmp + "\u005c", "; +values.add(tmp); propertyValue += "\u005c"" + tmp + "\u005c", "; jj_consume_token(16); } tmp = String(); - values.add(tmp); propertyValue += "\u005c"" + tmp + "\u005c""; +values.add(tmp); propertyValue += "\u005c"" + tmp + "\u005c""; jj_consume_token(15); - propertyType = Set.class; propertyValue = "{"+ propertyValue + "}";; val = values; +propertyType = Set.class; propertyValue = "{"+ propertyValue + "}";; val = values; } else { - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case 17: + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case 17:{ jj_consume_token(17); - val = new HashSet(); propertyType = Set.class; propertyValue = "-"; isBeanCollection = true; +val = new HashSet(); propertyType = Set.class; propertyValue = "-"; isBeanCollection = true; break; - case 14: + } + case 14:{ jj_consume_token(14); label_3: while (true) { @@ -179,20 +186,21 @@ break label_3; } tmp = Id(); - values.add(tmp); propertyValue += tmp + ", "; +values.add(tmp); propertyValue += tmp + ", "; jj_consume_token(16); } tmp = Id(); - values.add(tmp); propertyValue += tmp; +values.add(tmp); propertyValue += tmp; jj_consume_token(15); - val = values; propertyType = Set.class; propertyValue = "{"+ propertyValue + "}"; isBeanCollection = true; +val = values; propertyType = Set.class; propertyValue = "{"+ propertyValue + "}"; isBeanCollection = true; break; + } default: jj_la1[3] = jj_gen; if (jj_2_7(2147483647)) { jj_consume_token(18); jj_consume_token(19); - val = new LinkedList(); propertyType = List.class; propertyValue = "[]"; +val = new LinkedList(); propertyType = List.class; propertyValue = "[]"; } else if (jj_2_8(2147483647)) { jj_consume_token(18); label_4: @@ -207,7 +215,7 @@ jj_consume_token(16); tmp2 = String(); jj_consume_token(21); - tuples.put(tmp,tmp2); propertyValue += "(\u005c""+ tmp + "\u005c",\u005c"" + tmp2 + "\u005c"), "; +tuples.put(tmp,tmp2); propertyValue += "(\u005c""+ tmp + "\u005c",\u005c"" + tmp2 + "\u005c"), "; jj_consume_token(16); } jj_consume_token(20); @@ -215,12 +223,12 @@ jj_consume_token(16); tmp2 = String(); jj_consume_token(21); - tuples.put(tmp,tmp2); propertyValue += "(\u005c""+ tmp + "\u005c",\u005c"" + tmp2 + "\u005c")"; +tuples.put(tmp,tmp2); propertyValue += "(\u005c""+ tmp + "\u005c",\u005c"" + tmp2 + "\u005c")"; jj_consume_token(19); - val = tuples; propertyType = List.class; propertyValue = "["+ propertyValue + "]"; +val = tuples; propertyType = List.class; propertyValue = "["+ propertyValue + "]"; } else { - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case 18: + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case 18:{ jj_consume_token(18); label_5: while (true) { @@ -234,7 +242,7 @@ jj_consume_token(16); d = Double(); jj_consume_token(21); - tuplesD.put(tmp,d); propertyValue += "(\u005c""+ tmp + "\u005c",\u005c"" + d.toString() + "\u005c"), "; +tuplesD.put(tmp,d); propertyValue += "(\u005c""+ tmp + "\u005c",\u005c"" + d.toString() + "\u005c"), "; jj_consume_token(16); } jj_consume_token(20); @@ -242,10 +250,11 @@ jj_consume_token(16); d = Double(); jj_consume_token(21); - tuplesD.put(tmp,d); propertyValue += "(\u005c""+ tmp + "\u005c",\u005c"" + d.toString() + "\u005c")"; +tuplesD.put(tmp,d); propertyValue += "(\u005c""+ tmp + "\u005c",\u005c"" + d.toString() + "\u005c")"; jj_consume_token(19); - val = tuplesD; propertyType = List.class; propertyValue = "["+ propertyValue + "]"; +val = tuplesD; propertyType = List.class; propertyValue = "["+ propertyValue + "]"; break; + } default: jj_la1[4] = jj_gen; jj_consume_token(-1); @@ -255,7 +264,7 @@ } } } - option.setBeanRef(isBeanRef); +option.setBeanRef(isBeanRef); option.setBeanReferenceCollection(isBeanCollection); option.setBeanName(beanName); if(containsSubOption) { @@ -264,41 +273,42 @@ option.setPropertyType(propertyType); option.setPropertyValue(propertyValue); option.setValueObject(val); - {if (true) return option;} + {if ("" != null) return option;} throw new Error("Missing return statement in function"); } - final public String Individual() throws ParseException { - String name; - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case ID: + final public String Individual() throws ParseException {String name; + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case ID:{ name = Id(); break; - case STRING: + } + case STRING:{ name = String(); break; + } default: jj_la1[5] = jj_gen; jj_consume_token(-1); throw new ParseException(); } - {if (true) return KBParser.getInternalURI(name);} +{if ("" != null) return KBParser.getInternalURI(name);} throw new Error("Missing return statement in function"); } - final public String ComplexId() throws ParseException { - Token t1,t2; + final public String ComplexId() throws ParseException {Token t1,t2; if (jj_2_9(2)) { t1 = jj_consume_token(ID); jj_consume_token(22); t2 = jj_consume_token(ID); - {if (true) return t1.image + ":" + t2.image;} +{if ("" != null) return t1.image + ":" + t2.image;} } else { - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case ID: + switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { + case ID:{ t1 = jj_consume_token(ID); - {if (true) return t1.image;} +{if ("" != null) return t1.image;} break; + } default: jj_la1[6] = jj_gen; jj_consume_token(-1); @@ -308,102 +318,108 @@ throw new Error("Missing return statement in function"); } - final public String Id() throws ParseException { - Token t; + final public String Id() throws ParseException {Token t; t = jj_consume_token(ID); - {if (true) return t.image;} +{if ("" != null) return t.image;} throw new Error("Missing return statement in function"); } - final public Double Double() throws ParseException { - Token t; + final public Double Double() throws ParseException {Token t; t = jj_consume_token(DOUBLE); - {if (true) return new Double(t.image);} +{if ("" != null) return new Double(t.image);} throw new Error("Missing return statement in function"); } - final public Integer Integer() throws ParseException { - Token t; + final public Integer Integer() throws ParseException {Token t; t = jj_consume_token(NUMBER); - {if (true) return new Integer(t.image);} +{if ("" != null) return new Integer(t.image);} throw new Error("Missing return statement in function"); } - final public String String() throws ParseException { - Token t; + final public String String() throws ParseException {Token t; String s; t = jj_consume_token(STRING); - // enclosing "" are removed +// enclosing "" are removed s = t.image; s = s.substring(1, s.length() - 1); - {if (true) return s;} + {if ("" != null) return s;} throw new Error("Missing return statement in function"); } - private boolean jj_2_1(int xla) { + private boolean jj_2_1(int xla) + { jj_la = xla; jj_lastpos = jj_scanpos = token; try { return !jj_3_1(); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(0, xla); } } - private boolean jj_2_2(int xla) { + private boolean jj_2_2(int xla) + { jj_la = xla; jj_lastpos = jj_scanpos = token; try { return !jj_3_2(); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(1, xla); } } - private boolean jj_2_3(int xla) { + private boolean jj_2_3(int xla) + { jj_la = xla; jj_lastpos = jj_scanpos = token; try { return !jj_3_3(); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(2, xla); } } - private boolean jj_2_4(int xla) { + private boolean jj_2_4(int xla) + { jj_la = xla; jj_lastpos = jj_scanpos = token; try { return !jj_3_4(); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(3, xla); } } - private boolean jj_2_5(int xla) { + private boolean jj_2_5(int xla) + { jj_la = xla; jj_lastpos = jj_scanpos = token; try { return !jj_3_5(); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(4, xla); } } - private boolean jj_2_6(int xla) { + private boolean jj_2_6(int xla) + { jj_la = xla; jj_lastpos = jj_scanpos = token; try { return !jj_3_6(); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(5, xla); } } - private boolean jj_2_7(int xla) { + private boolean jj_2_7(int xla) + { jj_la = xla; jj_lastpos = jj_scanpos = token; try { return !jj_3_7(); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(6, xla); } } - private boolean jj_2_8(int xla) { + private boolean jj_2_8(int xla) + { jj_la = xla; jj_lastpos = jj_scanpos = token; try { return !jj_3_8(); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(7, xla); } } - private boolean jj_2_9(int xla) { + private boolean jj_2_9(int xla) + { jj_la = xla; jj_lastpos = jj_scanpos = token; try { return !jj_3_9(); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(8, xla); } } - private boolean jj_3_3() { + private boolean jj_3_3() + { if (jj_scan_token(20)) return true; if (jj_3R_6()) return true; if (jj_scan_token(16)) return true; @@ -413,40 +429,47 @@ return false; } - private boolean jj_3R_7() { + private boolean jj_3R_7() + { if (jj_scan_token(ID)) return true; return false; } - private boolean jj_3_2() { + private boolean jj_3_2() + { if (jj_3R_7()) return true; if (jj_scan_token(16)) return true; return false; } - private boolean jj_3_5() { + private boolean jj_3_5() + { if (jj_scan_token(14)) return true; if (jj_scan_token(15)) return true; return false; } - private boolean jj_3_9() { + private boolean jj_3_9() + { if (jj_scan_token(ID)) return true; if (jj_scan_token(22)) return true; return false; } - private boolean jj_3R_8() { + private boolean jj_3R_8() + { if (jj_scan_token(DOUBLE)) return true; return false; } - private boolean jj_3R_6() { + private boolean jj_3R_6() + { if (jj_scan_token(STRING)) return true; return false; } - private boolean jj_3_4() { + private boolean jj_3_4() + { if (jj_scan_token(20)) return true; if (jj_3R_6()) return true; if (jj_scan_token(16)) return true; @@ -456,7 +479,8 @@ return false; } - private boolean jj_3_8() { + private boolean jj_3_8() + { if (jj_scan_token(18)) return true; if (jj_scan_token(20)) return true; if (jj_3R_6()) return true; @@ -465,7 +489,8 @@ return false; } - private boolean jj_3_6() { + private boolean jj_3_6() + { if (jj_scan_token(14)) return true; Token xsp; while (true) { @@ -477,13 +502,15 @@ return false; } - private boolean jj_3_1() { + private boolean jj_3_1() + { if (jj_3R_6()) return true; if (jj_scan_token(16)) return true; return false; } - private boolean jj_3_7() { + private boolean jj_3_7() + { if (jj_scan_token(18)) return true; if (jj_scan_token(19)) return true; return false; @@ -608,6 +635,7 @@ throw generateParseException(); } + @SuppressWarnings("serial") static private final class LookaheadSuccess extends java.lang.Error { } final private LookaheadSuccess jj_ls = new LookaheadSuccess(); private boolean jj_scan_token(int kind) { @@ -651,7 +679,7 @@ return t; } - private int jj_ntk() { + private int jj_ntk_f() { if ((jj_nt=token.next) == null) return (jj_ntk = (token.next=token_source.getNextToken()).kind); else Modified: trunk/interfaces/src/main/java/org/dllearner/confparser3/ConfParserTokenManager.java =================================================================== --- trunk/interfaces/src/main/java/org/dllearner/confparser3/ConfParserTokenManager.java 2014-03-21 19:21:47 UTC (rev 4250) +++ trunk/interfaces/src/main/java/org/dllearner/confparser3/ConfParserTokenManager.java 2014-04-23 10:47:59 UTC (rev 4251) @@ -1,3 +1,4 @@ +/* ConfParserTokenManager.java */ /* Generated By:JavaCC: Do not edit this line. ConfParserTokenManager.java */ package org.dllearner.confparser3; import java.io.File; @@ -14,23 +15,20 @@ import org.dllearner.utilities.datastructures.StringTuple; /** Token Manager. */ -public class ConfParserTokenManager implements ConfParserConstants -{ +@SuppressWarnings("unused")public class ConfParserTokenManager implements ConfParserConstants { /** Debug output. */ public java.io.PrintStream debugStream = System.out; /** Set debug output. */ public void setDebugStream(java.io.PrintStream ds) { debugStream = ds; } -private final int jjStopStringLiteralDfa_0(int pos, long active0) -{ +private final int jjStopStringLiteralDfa_0(int pos, long active0){ switch (pos) { default : return -1; } } -private final int jjStartNfa_0(int pos, long active0) -{ +private final int jjStartNfa_0(int pos, long active0){ return jjMoveNfa_0(jjStopStringLiteralDfa_0(pos, active0), pos + 1); } private int jjStopAtPos(int pos, int kind) @@ -39,8 +37,7 @@ jjmatchedPos = pos; return pos + 1; } -private int jjMoveStringLiteralDfa0_0() -{ +private int jjMoveStringLiteralDfa0_0(){ switch(curChar) { case 40: @@ -70,6 +67,9 @@ } } static final long[] jjbitVec0 = { + 0xfffffffffffffffeL, 0xffffffffffffffffL, 0xffffffffffffffffL, 0xffffffffffffffffL +}; +static final long[] jjbitVec2 = { 0x0L, 0x0L, 0xffffffffffffffffL, 0xffffffffffffffffL }; private int jjMoveNfa_0(int startState, int curPos) @@ -95,18 +95,18 @@ { if (kind > 10) kind = 10; - jjCheckNAddStates(0, 2); + { jjCheckNAddStates(0, 2); } } else if (curChar == 48) { if (kind > 10) kind = 10; - jjCheckNAdd(27); + { jjCheckNAdd(27); } } else if (curChar == 47) - jjAddStates(3, 5); + { jjAddStates(3, 5); } else if (curChar == 34) - jjCheckNAddTwoStates(3, 4); + { jjCheckNAddTwoStates(3, 4); } break; case 1: if ((0x3ff000000000000L & l) == 0L) @@ -117,11 +117,11 @@ break; case 2: if (curChar == 34) - jjCheckNAddTwoStates(3, 4); + { jjCheckNAddTwoStates(3, 4); } break; case 3: if ((0xfffffffbffffffffL & l) != 0L) - jjCheckNAddTwoStates(3, 4); + { jjCheckNAddTwoStates(3, 4); } break; case 4: if (curChar == 34 && kind > 12) @@ -129,15 +129,15 @@ break; case 5: if (curChar == 47) - jjAddStates(3, 5); + { jjAddStates(3, 5); } break; case 6: if (curChar == 47) - jjCheckNAddStates(6, 8); + { jjCheckNAddStates(6, 8); } break; case 7: if ((0xffffffffffffdbffL & l) != 0L) - jjCheckNAddStates(6, 8); + { jjCheckNAddStates(6, 8); } break; case 8: if ((0x2400L & l) != 0L && kind > 5) @@ -153,23 +153,23 @@ break; case 11: if (curChar == 42) - jjCheckNAddTwoStates(12, 13); + { jjCheckNAddTwoStates(12, 13); } break; case 12: if ((0xfffffbffffffffffL & l) != 0L) - jjCheckNAddTwoStates(12, 13); + { jjCheckNAddTwoStates(12, 13); } break; case 13: if (curChar == 42) - jjCheckNAddStates(9, 11); + { jjCheckNAddStates(9, 11); } break; case 14: if ((0xffff7bffffffffffL & l) != 0L) - jjCheckNAddTwoStates(15, 13); + { jjCheckNAddTwoStates(15, 13); } break; case 15: if ((0xfffffbffffffffffL & l) != 0L) - jjCheckNAddTwoStates(15, 13); + { jjCheckNAddTwoStates(15, 13); } break; case 16: if (curChar == 47 && kind > 6) @@ -181,23 +181,23 @@ break; case 18: if (curChar == 42) - jjCheckNAddTwoStates(19, 20); + { jjCheckNAddTwoStates(19, 20); } break; case 19: if ((0xfffffbffffffffffL & l) != 0L) - jjCheckNAddTwoStates(19, 20); + { jjCheckNAddTwoStates(19, 20); } break; case 20: if (curChar == 42) - jjCheckNAddStates(12, 14); + { jjCheckNAddStates(12, 14); } break; case 21: if ((0xffff7bffffffffffL & l) != 0L) - jjCheckNAddTwoStates(22, 20); + { jjCheckNAddTwoStates(22, 20); } break; case 22: if ((0xfffffbffffffffffL & l) != 0L) - jjCheckNAddTwoStates(22, 20); + { jjCheckNAddTwoStates(22, 20); } break; case 23: if (curChar == 47 && kind > 7) @@ -208,39 +208,39 @@ break; if (kind > 10) kind = 10; - jjCheckNAddStates(0, 2); + { jjCheckNAddStates(0, 2); } break; case 25: if ((0x3ff000000000000L & l) == 0L) break; if (kind > 10) kind = 10; - jjCheckNAdd(25); + { jjCheckNAdd(25); } break; case 26: if ((0x3ff000000000000L & l) != 0L) - jjCheckNAddTwoStates(26, 27); + { jjCheckNAddTwoStates(26, 27); } break; case 27: if (curChar != 46) break; if (kind > 11) kind = 11; - jjCheckNAdd(28); + { jjCheckNAdd(28); } break; case 28: if ((0x3ff000000000000L & l) == 0L) break; if (kind > 11) kind = 11; - jjCheckNAdd(28); + { jjCheckNAdd(28); } break; case 29: if (curChar != 48) break; if (kind > 10) kind = 10; - jjCheckNAdd(27); + { jjCheckNAdd(27); } break; default : break; } @@ -258,35 +258,35 @@ break; if (kind > 9) kind = 9; - jjCheckNAdd(1); + { jjCheckNAdd(1); } break; case 1: if ((0x7fffffe87fffffeL & l) == 0L) break; if (kind > 9) kind = 9; - jjCheckNAdd(1); + { jjCheckNAdd(1); } break; case 3: if ((0xffffffffefffffffL & l) != 0L) - jjAddStates(15, 16); + { jjAddStates(15, 16); } break; case 7: - jjAddStates(6, 8); + { jjAddStates(6, 8); } break; case 12: - jjCheckNAddTwoStates(12, 13); + { jjCheckNAddTwoStates(12, 13); } break; case 14: case 15: - jjCheckNAddTwoStates(15, 13); + { jjCheckNAddTwoStates(15, 13); } break; case 19: - jjCheckNAddTwoStates(19, 20); + { jjCheckNAddTwoStates(19, 20); } break; case 21: case 22: - jjCheckNAddTwoStates(22, 20); + { jjCheckNAddTwoStates(22, 20); } break; default : break; } @@ -294,6 +294,9 @@ } else { + int hiByte = (curChar >> 8); + int i1 = hiByte >> 6; + long l1 = 1L << (hiByte & 077); int i2 = (curChar & 0xff) >> 6; long l2 = 1L << (curChar & 077); do @@ -301,32 +304,32 @@ switch(jjstateSet[--i]) { case 3: - if ((jjbitVec0[i2] & l2) != 0L) - jjAddStates(15, 16); + if (jjCanMove_0(hiByte, i1, i2, l1, l2)) + { jjAddStates(15, 16); } break; case 7: - if ((jjbitVec0[i2] & l2) != 0L) - jjAddStates(6, 8); + if (jjCanMove_0(hiByte, i1, i2, l1, l2)) + { jjAddStates(6, 8); } break; case 12: - if ((jjbitVec0[i2] & l2) != 0L) - jjCheckNAddTwoStates(12, 13); + if (jjCanMove_0(hiByte, i1, i2, l1, l2)) + { jjCheckNAddTwoStates(12, 13); } break; case 14: case 15: - if ((jjbitVec0[i2] & l2) != 0L) - jjCheckNAddTwoStates(15, 13); + if (jjCanMove_0(hiByte, i1, i2, l1, l2)) + { jjCheckNAddTwoStates(15, 13); } break; case 19: - if ((jjbitVec0[i2] & l2) != 0L) - jjCheckNAddTwoStates(19, 20); + if (jjCanMove_0(hiByte, i1, i2, l1, l2)) + { jjCheckNAddTwoStates(19, 20); } break; case 21: case 22: - if ((jjbitVec0[i2] & l2) != 0L) - jjCheckNAddTwoStates(22, 20); + if (jjCanMove_0(hiByte, i1, i2, l1, l2)) + { jjCheckNAddTwoStates(22, 20); } break; - default : break; + default : if (i1 == 0 || l1 == 0 || i2 == 0 || l2 == 0) break; else break; } } while(i != startsAt); } @@ -347,71 +350,23 @@ 25, 26, 27, 6, 17, 18, 7, 8, 10, 13, 14, 16, 20, 21, 23, 3, 4, }; +private static final boolean jjCanMove_0(int hiByte, int i1, int i2, long l1, long l2) +{ + switch(hiByte) + { + case 0: + return ((jjbitVec2[i2] & l2) != 0L); + default : + if ((jjbitVec0[i1] & l1) != 0L) + return true; + return false; + } +} /** Token literal values. */ public static final String[] jjstrLiteralImages = { "", null, null, null, null, null, null, null, "\56", null, null, null, null, "\75", "\173", "\175", "\54", "\55", "\133", "\135", "\50", "\51", "\72", }; - -/** Lexer state names. */ -public static final String[] lexStateNames = { - "DEFAULT", -}; -static final long[] jjtoToken = { - 0x7fff01L, -}; -static final long[] jjtoSkip = { - 0xfeL, -}; -protected SimpleCharStream input_stream; -private final int[] jjrounds = new int[30]; -private final int[] jjstateSet = new int[60]; -protected char curChar; -/** Constructor. */ -public ConfParserTokenManager(SimpleCharStream stream){ - if (SimpleCharStream.staticFlag) - throw new Error("ERROR: Cannot use a static CharStream class with a non-static lexical analyzer."); - input_stream = stream; -} - -/** Constructor. */ -public ConfParserTokenManager(SimpleCharStream stream, int lexState){ - this(stream); - SwitchTo(lexState); -} - -/** Reinitialise parser. */ -public void ReInit(SimpleCharStream stream) -{ - jjmatchedPos = jjnewStateCnt = 0; - curLexState = defaultLexState; - input_stream = stream; - ReInitRounds(); -} -private void ReInitRounds() -{ - int i; - jjround = 0x80000001; - for (i = 30; i-- > 0;) - jjrounds[i] = 0x80000000; -} - -/** Reinitialise parser. */ -public void ReInit(SimpleCharStream stream, int lexState) -{ - ReInit(stream); - SwitchTo(lexState); -} - -/** Switch to specified lex state. */ -public void SwitchTo(int lexState) -{ - if (lexState >= 1 || lexState < 0) - throw new TokenMgrError("Error: Ignoring invalid lexical state : " + lexState + ". State unchanged.", TokenMgrError.INVALID_LEXICAL_STATE); - else - curLexState = lexState; -} - protected Token jjFillToken() { final Token t; @@ -459,6 +414,7 @@ catch(java.io.IOException e) { jjmatchedKind = 0; + jjmatchedPos = -1; matchedToken = jjFillToken(); return matchedToken; } @@ -535,4 +491,69 @@ } while (start++ != end); } + /** Constructor. */ + public ConfParserTokenManager(SimpleCharStream stream){ + + if (SimpleCharStream.staticFlag) + throw new Error("ERROR: Cannot use a static CharStream class with a non-static lexical analyzer."); + + input_stream = stream; + } + + /** Constructor. */ + public ConfParserTokenManager (SimpleCharStream stream, int lexState){ + ReInit(stream); + SwitchTo(lexState); + } + + /** Reinitialise parser. */ + public void ReInit(SimpleCharStream stream) + { + jjmatchedPos = jjnewStateCnt = 0; + curLexState = defaultLexState; + input_stream = stream; + ReInitRounds(); + } + + private void ReInitRounds() + { + int i; + jjround = 0x80000001; + for (i = 30; i-- > 0;) + jjrounds[i] = 0x80000000; + } + + /** Reinitialise parser. */ + public void ReInit(SimpleCharStream stream, int lexState) + { + ReInit(stream); + SwitchTo(lexState); + } + + /** Switch to specified lex state. */ + public void SwitchTo(int lexState) + { + if (lexState >= 1 || lexState < 0) + throw new TokenMgrError("Error: Ignoring invalid lexical state : " + lexState + ". State unchanged.", TokenMgrError.INVALID_LEXICAL_STATE); + else + curLexState = lexState; + } + +/** Lexer state names. */ +public static final String[] lexStateNames = { + "DEFAULT", +}; +static final long[] jjtoToken = { + 0x7fff01L, +}; +static final long[] jjtoSkip = { + 0xfeL, +}; + protected SimpleCharStream input_stream; + + private final int[] jjrounds = new int[30]; + private final int[] jjstateSet = new int[2 * 30]; + + + protected char curChar; } Modified: trunk/interfaces/src/main/java/org/dllearner/confparser3/ParseException.java =================================================================== --- trunk/interfaces/src/main/java/org/dllearner/confparser3/ParseException.java 2014-03-21 19:21:47 UTC (rev 4250) +++ trunk/interfaces/src/main/java/org/dllearner/confparser3/ParseException.java 2014-04-23 10:47:59 UTC (rev 4251) @@ -1,4 +1,4 @@ -/* Generated By:JavaCC: Do not edit this line. ParseException.java Version 5.0 */ +/* Generated By:JavaCC: Do not edit this line. ParseException.java Version 6.0 */ /* JavaCCOptions:KEEP_LINE_COL=null */ package org.dllearner.confparser3; @@ -184,4 +184,4 @@ } } -/* JavaCC - OriginalChecksum=44a252ba2c41282348d0b2fcf86420df (do not edit this line) */ +/* JavaCC - OriginalChecksum=72d8badf88dbc09bae77f8c82b715143 (do not edit this line) */ Modified: trunk/interfaces/src/main/java/org/dllearner/confparser3/SimpleCharStream.java =================================================================== --- trunk/interfaces/src/main/java/org/dllearner/confparser3/SimpleCharStream.java 2014-03-21 19:21:47 UTC (rev 4250) +++ trunk/interfaces/src/main/java/org/dllearner/confparser3/SimpleCharStream.java 2014-04-23 10:47:59 UTC (rev 4251) @@ -1,4 +1,4 @@ -/* Generated By:JavaCC: Do not edit this line. SimpleCharStream.java Version 5.0 */ +/* Generated By:JavaCC: Do not edit this line. SimpleCharStream.java Version 6.0 */ /* JavaCCOptions:STATIC=false,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ package org.dllearner.confparser3; @@ -31,9 +31,10 @@ protected int maxNextCharInd = 0; protected int inBuf = 0; protected int tabSize = 8; + protected boolean trackLineColumn = true; - protected void setTabSize(int i) { tabSize = i; } - protected int getTabSize(int i) { return tabSize; } + public void setTabSize(int i) { tabSize = i; } + public int getTabSize() { return tabSize; } protected void ExpandBuff(boolean wrapAround) @@ -467,5 +468,7 @@ column = bufcolumn[j]; } + boolean getTrackLineColumn() { return trackLineColumn; } + void setTrackLineColumn(boolean tlc) { trackLineColumn = tlc; } } -/* JavaCC - OriginalChecksum=9533267d690297b19b8deefd4143bb73 (do not edit this line) */ +/* JavaCC - OriginalChecksum=e6b5e4f4223db89b882e22f7e6893bd9 (do not edit this line) */ Modified: trunk/interfaces/src/main/java/org/dllearner/confparser3/Token.java =================================================================== --- trunk/interfaces/src/main/java/org/dllearner/confparser3/Token.java 2014-03-21 19:21:47 UTC (rev 4250) +++ trunk/interfaces/src/main/java/org/dllearner/confparser3/Token.java 2014-04-23 10:47:59 UTC (rev 4251) @@ -1,4 +1,4 @@ -/* Generated By:JavaCC: Do not edit this line. Token.java Version 5.0 */ +/* Generated By:JavaCC: Do not edit this line. Token.java Version 6.0 */ /* JavaCCOptions:TOKEN_EXTENDS=,KEEP_LINE_COL=null,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */ package org.dllearner.confparser3; @@ -128,4 +128,4 @@ } } -/* JavaCC - OriginalChecksum=f5f1c260daaacf6ad7943faea399abd0 (do not edit this line) */ +/* JavaCC - OriginalChecksum=b46f40b47c1ab727d843a023759aeb18 (do not edit this line) */ Modified: trunk/interfaces/src/main/java/org/dllearner/confparser3/TokenMgrError.java =================================================================== --- trunk/interfaces/src/main/java/org/dllearner/confparser3/TokenMgrError.java 2014-03-21 19:21:47 UTC (rev 4250) +++ trunk/interfaces/src/main/java/org/dllearner/confparser3/TokenMgrError.java 2014-04-23 10:47:59 UTC (rev 4251) @@ -1,4 +1,4 @@ -/* Generated By:JavaCC: Do not edit this line. TokenMgrError.java Version 5.0 */ +/* Generated By:JavaCC: Do not edit this line. TokenMgrError.java Version 6.0 */ /* JavaCCOptions: */ package org.dllearner.confparser3; @@ -144,4 +144,4 @@ this(LexicalError(EOFSeen, lexState, errorLine, errorColumn, errorAfter, curChar), reason); } } -/* JavaCC - OriginalChecksum=cfdfdc87d92964d81aa3da705fa4b09a (do not edit this line) */ +/* JavaCC - OriginalChecksum=52462882bed940bf33866ca9696c8f85 (do not edit this line) */ Modified: trunk/interfaces/src/main/java/org/dllearner/confparser3/conf3.jj =================================================================== --- trunk/interfaces/src/main/java/org/dllearner/confparser3/conf3.jj 2014-03-21 19:21:47 UTC (rev 4250) +++ trunk/interfaces/src/main/java/org/dllearner/confparser3/conf3.jj 2014-04-23 10:47:59 UTC (rev 4251) @@ -26,6 +26,7 @@ options { JDK_VERSION = "1.6"; STATIC = false; + UNICODE_INPUT=true; } PARSER_BEGIN(ConfParser) @@ -33,7 +34,9 @@ import java.io.File; import java.io.FileInputStream; +import java.io.InputStreamReader; import java.io.FileNotFoundException; +import java.io.UnsupportedEncodingException; import java.util.HashMap; import java.util.HashSet; import java.util.LinkedList; @@ -88,8 +91,8 @@ return confOptionsByBean.get(beanName); } - public static ConfParser parseFile(File filename) throws FileNotFoundException, ParseException { - ConfParser parser = new ConfParser(new FileInputStream(filename)); + public static ConfParser parseFile(File filename) throws FileNotFoundException, ParseException, UnsupportedEncodingException { + ConfParser parser = new ConfParser(new InputStreamReader(new FileInputStream(filename),"UTF-8")); parser.Start(); return parser; } Modified: trunk/interfaces/src/test/java/org/dllearner/confparser3/ParseTest.java =================================================================== --- trunk/interfaces/src/test/java/org/dllearner/confparser3/ParseTest.java 2014-03-21 19:21:47 UTC (rev 4250) +++ trunk/interfaces/src/test/java/org/dllearner/confparser3/ParseTest.java 2014-04-23 10:47:59 UTC (rev 4251) @@ -21,6 +21,7 @@ import java.io.File; import java.io.FileNotFoundException; +import java.io.UnsupportedEncodingException; import org.dllearner.cli.ConfFileOption2; import org.junit.Test; @@ -34,7 +35,7 @@ public class ParseTest { @Test - public void test() throws FileNotFoundException, ParseException { + public void test() throws FileNotFoundException, ParseException, UnsupportedEncodingException { ConfParser parser = ConfParser.parseFile(new File("../examples/family/father.conf")); for(ConfFileOption2 option : parser.getConfOptions()) { System.out.print(option.getBeanName() + "." + option.getPropertyName() + " = " + option.getValue().toString()); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |