From: <ku...@us...> - 2011-06-16 08:49:30
|
Revision: 2891 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=2891&view=rev Author: kurzum Date: 2011-06-16 08:49:23 +0000 (Thu, 16 Jun 2011) Log Message: ----------- finished initial version of geizhals server Modified Paths: -------------- trunk/components-core/src/main/java/org/dllearner/core/ComponentManager.java 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 trunk/interfaces/src/main/java/org/dllearner/server/nke/Learner.java Added Paths: ----------- trunk/interfaces/log/ Modified: trunk/components-core/src/main/java/org/dllearner/core/ComponentManager.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/core/ComponentManager.java 2011-06-16 08:07:18 UTC (rev 2890) +++ trunk/components-core/src/main/java/org/dllearner/core/ComponentManager.java 2011-06-16 08:49:23 UTC (rev 2891) @@ -495,7 +495,7 @@ * Frees all references to components created by <code>ComponentManager</code>. * @see #freeComponent(Component) */ - public void freeAllComponents() { + public synchronized void freeAllComponents() { pool.clearComponents(); } Modified: trunk/interfaces/pom.xml =================================================================== --- trunk/interfaces/pom.xml 2011-06-16 08:07:18 UTC (rev 2890) +++ trunk/interfaces/pom.xml 2011-06-16 08:49:23 UTC (rev 2891) @@ -1,204 +1,204 @@ <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> - <finalName>interfaces</finalName> - <plugins> - <plugin> - <groupId>org.codehaus.mojo</groupId> - <artifactId>tomcat-maven-plugin</artifactId> - </plugin> + <build> + <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> + <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> - <artifactId>maven-surefire-plugin</artifactId> - <configuration> - <excludes> - <exclude>org/dllearner/test/junit/OWLlinkTest.java</exclude> - </excludes> - </configuration> - </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> <!--does not seem to work properly, please test more--> - <!--plugin> - <groupId>de.tarent.maven.plugins</groupId> - <artifactId>maven-pkg-plugin</artifactId> - <version>2.1.0</version> - <configuration> + <!--plugin> + <groupId>de.tarent.maven.plugins</groupId> + <artifactId>maven-pkg-plugin</artifactId> + <version>2.1.0</version> + <configuration> - <defaultTarget>all</defaultTarget> + <defaultTarget>all</defaultTarget> - <defaultDistro>ubuntu_intrepid</defaultDistro> - <shortDescription>My Short Project Description...</shortDescription> + <defaultDistro>ubuntu_intrepid</defaultDistro> + <shortDescription>My Short Project Description...</shortDescription> - <defaults> - <section>misc</section> - <mainClass>org.dllearner.cli.Start</mainClass> - <architecture>all</architecture> - <srcAuxFilesDir>src/main/pkg</srcAuxFilesDir> - <maintainer>Jens Lehmann</maintainer> - </defaults> + <defaults> + <section>misc</section> + <mainClass>org.dllearner.cli.Start</mainClass> + <architecture>all</architecture> + <srcAuxFilesDir>src/main/pkg</srcAuxFilesDir> + <maintainer>Jens Lehmann</maintainer> + </defaults> - <targetConfigurations> + <targetConfigurations> - <targetConfiguration> - <target>i386</target> + <targetConfiguration> + <target>i386</target> - <architecture>i386</architecture> - <srcJNIFilesDir>src/main/native/i386</srcJNIFilesDir> + <architecture>i386</architecture> + <srcJNIFilesDir>src/main/native/i386</srcJNIFilesDir> - </targetConfiguration> + </targetConfiguration> - <targetConfiguration> - <target>armel</target> + <targetConfiguration> + <target>armel</target> - <architecture>armel</architecture> - <srcJNIFilesDir>src/main/native/armel</srcJNIFilesDir> + <architecture>armel</architecture> + <srcJNIFilesDir>src/main/native/armel</srcJNIFilesDir> - </targetConfiguration> + </targetConfiguration> - </targetConfigurations> + </targetConfigurations> - <distroConfigurations> - <distroConfiguration> + <distroConfigurations> + <distroConfiguration> - <distros> - <distro>ubuntu_intrepid</distro> - <distro>ubuntu_karmic</distro> - </distros> + <distros> + <distro>ubuntu_intrepid</distro> + <distro>ubuntu_karmic</distro> + </distros> - </distroConfiguration> - </distroConfigurations> - </configuration> - </plugin--> - </plugins> - </build> + </distroConfiguration> + </distroConfigurations> + </configuration> + </plugin--> + </plugins> + </build> - <dependencies> - <dependency> - <groupId>org.dllearner</groupId> - <artifactId>components-core</artifactId> - <exclusions> - <exclusion> - <groupId>org.slf4j</groupId> - <!-- Exclude Project-D from Project-B --> - <artifactId>slf4j-log4j12</artifactId> - </exclusion> - </exclusions> - </dependency> + <dependencies> + <dependency> + <groupId>org.dllearner</groupId> + <artifactId>components-core</artifactId> + <exclusions> + <exclusion> + <groupId>org.slf4j</groupId> + <!-- Exclude Project-D from Project-B --> + <artifactId>slf4j-log4j12</artifactId> + </exclusion> + </exclusions> + </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>org.dllearner</groupId> + <artifactId>components-ext</artifactId> + </dependency> - <dependency> - <groupId>com.jamonapi</groupId> - <artifactId>jamon</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> - <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> + <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> - <dependency> - <groupId>org.aksw.commons</groupId> - <artifactId>model</artifactId> - <exclusions> - <exclusion> - <groupId>org.slf4j</groupId> - <!-- Exclude Project-D from Project-B --> - <artifactId>slf4j-log4j12</artifactId> - </exclusion> - </exclusions> - </dependency> - <dependency> - <groupId>com.googlecode.json-simple</groupId> - <artifactId>json-simple</artifactId> - </dependency> + <dependency> + <groupId>org.aksw.commons</groupId> + <artifactId>model</artifactId> + <exclusions> + <exclusion> + <groupId>org.slf4j</groupId> + <!-- Exclude Project-D from Project-B --> + <artifactId>slf4j-log4j12</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>com.googlecode.json-simple</groupId> + <artifactId>json-simple</artifactId> + </dependency> - </dependencies> + </dependencies> </project> Modified: trunk/interfaces/src/main/java/org/dllearner/server/NKEGeizhals.java =================================================================== --- trunk/interfaces/src/main/java/org/dllearner/server/NKEGeizhals.java 2011-06-16 08:07:18 UTC (rev 2890) +++ trunk/interfaces/src/main/java/org/dllearner/server/NKEGeizhals.java 2011-06-16 08:49:23 UTC (rev 2891) @@ -3,6 +3,7 @@ import com.hp.hpl.jena.ontology.OntClass; import com.jamonapi.Monitor; import com.jamonapi.MonitorFactory; +import org.dllearner.core.ComponentManager; import org.dllearner.core.owl.Description; import org.dllearner.core.owl.NamedClass; import org.dllearner.learningproblems.EvaluatedDescriptionPosNeg; @@ -21,7 +22,6 @@ import java.io.PrintWriter; import java.net.URLEncoder; import java.security.InvalidParameterException; -import java.util.Arrays; import java.util.HashSet; import java.util.Set; @@ -50,6 +50,8 @@ * @throws java.io.IOException */ 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 { @@ -68,16 +70,23 @@ if (action.equals("learn")) { String json = ""; if (isSet(httpServletRequest, "data")) { + 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 j = new JSONObject(); j.put("learned", concept); - j.put("up", JSONArray.toJSONString(Arrays.asList(new String[]{concept.toJSONString(), concept.toJSONString()}))); - j.put("down", JSONArray.toJSONString(Arrays.asList(new String[]{concept.toJSONString(), concept.toJSONString()}))); + JSONArray up = new JSONArray(); + up.add(concept); + up.add(concept); + j.put("up", up); + j.put("down", up); + String time = logMonitor(mon.stop()); + j.put("time", time); + PrintWriter pw = httpServletResponse.getWriter(); - log.debug("Request handled: " + logMonitor(mon.stop())); + log.debug("Request handled: " + time); pw.print(j.toJSONString()); pw.close(); return; 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 08:07:18 UTC (rev 2890) +++ trunk/interfaces/src/main/java/org/dllearner/server/nke/Geizhals2OWL.java 2011-06-16 08:49:23 UTC (rev 2891) @@ -24,8 +24,8 @@ public static final Geizhals2OWL geizhals2OWL = new Geizhals2OWL(); public static Map<String, String> ramMap = new HashMap<String, String>(); - public static Map<String, String> hdMap = new HashMap<String, String>(); - public static Map<String, String> discMap = 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 String prefix = "http://nke.aksw.org/geizhals/_"; //public static final String prefix = "http://geizhals.at/?cat=nb15w&xf="; @@ -43,25 +43,26 @@ ramMap.put("8192MB", "12_8192"); ramMap.put("unbekannt", "12_unbekannt"); - hdMap.put("32GB", "11_32"); - hdMap.put("80GB", "11_80"); - hdMap.put("120GB", "11_120"); - hdMap.put("128GB", "11_128"); - hdMap.put("160GB", "11_160"); - hdMap.put("250GB", "11_250"); - hdMap.put("256GB", "11_256"); - hdMap.put("320GB", "11_320"); - hdMap.put("500GB", "11_500"); - hdMap.put("640GB", "11_640"); - hdMap.put("1000GB", "11_1000"); - hdMap.put("sonstige", "11_sonstige"); - hdMap.put("unbekannt", "11_unbekannt"); + harddriveMap.put("32GB", "11_32"); + harddriveMap.put("80GB", "11_80"); + harddriveMap.put("120GB", "11_120"); + harddriveMap.put("128GB", "11_128"); + harddriveMap.put("160GB", "11_160"); + harddriveMap.put("250GB", "11_250"); + harddriveMap.put("256GB", "11_256"); + harddriveMap.put("320GB", "11_320"); + harddriveMap.put("500GB", "11_500"); + harddriveMap.put("640GB", "11_640"); + harddriveMap.put("1000GB", "11_1000"); + harddriveMap.put("sonstige", "11_sonstige"); + harddriveMap.put("unbekannt", "11_unbekannt"); - discMap.put("kein optisches Laufwerk", "84_ohne"); - discMap.put("DVD/CD-RW Combo", "84_DVD%2FCD-RW+Combo"); - discMap.put("DVD+/-RW DL", "84_DVD%2B%2F-RW"); - discMap.put("DVD+/-RW", "84_DVD%2B%2F-RW"); - discMap.put("Blu-ray (BD-ROM) und DVD+/-RW DL", "84_Blu-ray+(BD-ROM)"); + optischesLaufwerkMap.put("kein optisches Laufwerk", "84_ohne"); + optischesLaufwerkMap.put("DVD/CD-RW Combo", "84_DVD%2FCD-RW+Combo"); + optischesLaufwerkMap.put("DVD+/-RW DL", "84_DVD%2B%2F-RW"); + optischesLaufwerkMap.put("DVD /-RW DL", "84_DVD%2B%2F-RW"); + optischesLaufwerkMap.put("DVD+/-RW", "84_DVD%2B%2F-RW"); + optischesLaufwerkMap.put("Blu-ray (BD-ROM) und DVD+/-RW DL", "84_Blu-ray+(BD-ROM)"); //$subs[] = array("84_Blu-ray+(BD-R%2FRE)","84_Blu-ray+(BD-R%2FRE%2FRW)","84_Blu-ray+(BD-ROM)","84_DVD%2B%2F-RW","84_DVD-ROM","84_DVD%2FCD-RW+Combo","84_ohne","84_unbekannt",""); } @@ -96,12 +97,12 @@ classes.add(prefix + "82_HDD"); } hd = hd.substring(0, hd.indexOf("GB") + 2); - add(classes, hdMap, hd); + add(classes, harddriveMap, hd); } catch (Exception e) { log.warn("Handling hd failed: " + features[2].trim()); } String disc = features[3].trim(); - add(classes, discMap, disc); + add(classes, optischesLaufwerkMap, disc); //4 =Intel GMA X4500HD (IGP) max.384MB shared memory //5 =3x USB 2.0/FireWire/Modem/Gb LAN/WLAN 802.11agn/Bluetooth @@ -138,7 +139,7 @@ public static void add(List<String> classes, Map<String, String> map, String key) { String val = null; if ((val = map.get(key)) == null) { - log.warn("No value found for: " + key); + log.warn("No value found for: |" + key+"|"); return; } else { //log.info("Adding " + val); 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 08:07:18 UTC (rev 2890) +++ trunk/interfaces/src/main/java/org/dllearner/server/nke/Learner.java 2011-06-16 08:49:23 UTC (rev 2891) @@ -33,6 +33,7 @@ public EvaluatedDescriptionPosNeg learn(Set<String> pos, Set<String> neg, OntModel model, int maxTime) throws IOException, ComponentInitException, LearningProblemUnsupportedException { ComponentManager cm = ComponentManager.getInstance(); + try { model.createIndividual("http://nke.aksw.org/", model.createClass(OWL.Ontology.getURI())); ModelUtils.write(model, new File("test.owl")); @@ -80,6 +81,7 @@ lp.init(); ELLearningAlgorithm la = cm.learningAlgorithm(ELLearningAlgorithm.class, lp, rc); + la.getConfigurator().setInstanceBasedDisjoints(false); // CELOE la = cm.learningAlgorithm(CELOE.class, lp, rc); la.init(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |