You can subscribe to this list here.
2007 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(120) |
Sep
(36) |
Oct
(116) |
Nov
(17) |
Dec
(44) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2008 |
Jan
(143) |
Feb
(192) |
Mar
(74) |
Apr
(84) |
May
(105) |
Jun
(64) |
Jul
(49) |
Aug
(120) |
Sep
(159) |
Oct
(156) |
Nov
(51) |
Dec
(28) |
2009 |
Jan
(17) |
Feb
(55) |
Mar
(33) |
Apr
(57) |
May
(54) |
Jun
(28) |
Jul
(6) |
Aug
(16) |
Sep
(38) |
Oct
(30) |
Nov
(26) |
Dec
(52) |
2010 |
Jan
(7) |
Feb
(91) |
Mar
(65) |
Apr
(2) |
May
(14) |
Jun
(25) |
Jul
(38) |
Aug
(48) |
Sep
(80) |
Oct
(70) |
Nov
(75) |
Dec
(77) |
2011 |
Jan
(68) |
Feb
(53) |
Mar
(51) |
Apr
(35) |
May
(65) |
Jun
(101) |
Jul
(29) |
Aug
(230) |
Sep
(95) |
Oct
(49) |
Nov
(110) |
Dec
(63) |
2012 |
Jan
(41) |
Feb
(42) |
Mar
(25) |
Apr
(46) |
May
(51) |
Jun
(44) |
Jul
(45) |
Aug
(29) |
Sep
(12) |
Oct
(9) |
Nov
(17) |
Dec
(2) |
2013 |
Jan
(12) |
Feb
(14) |
Mar
(7) |
Apr
(16) |
May
(54) |
Jun
(27) |
Jul
(11) |
Aug
(5) |
Sep
(85) |
Oct
(27) |
Nov
(37) |
Dec
(32) |
2014 |
Jan
(8) |
Feb
(29) |
Mar
(5) |
Apr
(3) |
May
(22) |
Jun
(3) |
Jul
(4) |
Aug
(3) |
Sep
|
Oct
|
Nov
|
Dec
|
From: <sk...@us...> - 2008-01-29 13:28:58
|
Revision: 452 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=452&view=rev Author: sknappe Date: 2008-01-29 05:28:48 -0800 (Tue, 29 Jan 2008) Log Message: ----------- fixed a bug with json Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/kb/sparql/query/SparqlQuery.java Modified: trunk/src/dl-learner/org/dllearner/kb/sparql/query/SparqlQuery.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/sparql/query/SparqlQuery.java 2008-01-29 12:03:11 UTC (rev 451) +++ trunk/src/dl-learner/org/dllearner/kb/sparql/query/SparqlQuery.java 2008-01-29 13:28:48 UTC (rev 452) @@ -238,6 +238,7 @@ if (rs==null) this.send(); ByteArrayOutputStream baos=new ByteArrayOutputStream(); ResultSetFormatter.outputAsJSON(baos, rs); + rs=JSONtoResultSet(baos.toString()); return baos.toString(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sk...@us...> - 2008-01-29 12:03:29
|
Revision: 451 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=451&view=rev Author: sknappe Date: 2008-01-29 04:03:11 -0800 (Tue, 29 Jan 2008) Log Message: ----------- Caching of Sparql-Queries is now working Modified Paths: -------------- trunk/src/dbpedia-navigator/DLLearnerConnection.php trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlKnowledgeSource.java trunk/src/dl-learner/org/dllearner/kb/sparql/query/SparqlQuery.java trunk/src/dl-learner/org/dllearner/server/DLLearnerWS.java Added Paths: ----------- trunk/src/dl-learner/org/dllearner/kb/sparql/query/CachedSparqlQueryTest.java Modified: trunk/src/dbpedia-navigator/DLLearnerConnection.php =================================================================== --- trunk/src/dbpedia-navigator/DLLearnerConnection.php 2008-01-29 10:11:45 UTC (rev 450) +++ trunk/src/dbpedia-navigator/DLLearnerConnection.php 2008-01-29 12:03:11 UTC (rev 451) @@ -112,6 +112,7 @@ function getSparqlResult($query) { $this->client->applyConfigEntryStringArray($this->id, $this->ksID, "defaultGraphURIs", array("http://dbpedia.org")); + $this->client->applyConfigEntryBoolean($this->id, $this->ksID, "cached", true); $queryID=$this->client->sparqlQueryThreaded($this->id,$this->ksID,$query); $running=true; $i = 1; Modified: trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlKnowledgeSource.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlKnowledgeSource.java 2008-01-29 10:11:45 UTC (rev 450) +++ trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlKnowledgeSource.java 2008-01-29 12:03:11 UTC (rev 451) @@ -46,6 +46,8 @@ import org.dllearner.core.dl.KB; import org.dllearner.kb.sparql.configuration.SparqlEndpoint; import org.dllearner.kb.sparql.configuration.SparqlQueryType; +import org.dllearner.kb.sparql.query.Cache; +import org.dllearner.kb.sparql.query.CachedSparqlQueryTest; import org.dllearner.kb.sparql.query.SparqlQuery; import org.dllearner.parser.KBParser; import org.dllearner.reasoning.DIGConverter; @@ -101,6 +103,8 @@ // received ontology as KB, the internal format private KB kb; + + private boolean cached=true; public static String getName() { return "SPARQL Endpoint"; @@ -158,7 +162,8 @@ "role to learn Domain/Range from")); options.add(new StringConfigOption("blankNodeIdentifier", "used to identify blanknodes in Tripels")); - + options.add(new BooleanConfigOption("cached", + "use Cache")); options.add(new StringTupleListConfigOption("example", "example")); options.add(new StringTupleListConfigOption("replacePredicate", "rule for replacing predicates")); @@ -217,6 +222,8 @@ dumpToFile = (Boolean) entry.getValue(); } else if (option.equals("useLits")) { useLits = (Boolean) entry.getValue(); + } else if (option.equals("cached")) { + cached = (Boolean) entry.getValue(); } else if (option.equals("getAllSuperClasses")) { getAllSuperClasses = (Boolean) entry.getValue(); /* @@ -391,7 +398,8 @@ public SparqlQuery sparqlQuery(String query) { this.endpoint = new SparqlEndpoint(url, defaultGraphURIs, namedGraphURIs); - return new SparqlQuery(query, endpoint); + if (cached) return new CachedSparqlQueryTest(endpoint, new Cache("cache"),""+query.hashCode(),query); + else return new SparqlQuery(query, endpoint); } /*public static void main(String[] args) throws MalformedURLException { Added: trunk/src/dl-learner/org/dllearner/kb/sparql/query/CachedSparqlQueryTest.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/sparql/query/CachedSparqlQueryTest.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/kb/sparql/query/CachedSparqlQueryTest.java 2008-01-29 12:03:11 UTC (rev 451) @@ -0,0 +1,30 @@ +package org.dllearner.kb.sparql.query; + +import org.dllearner.kb.sparql.configuration.SparqlEndpoint; + +public class CachedSparqlQueryTest extends SparqlQuery { + + private Cache cache; + private String key; + + public CachedSparqlQueryTest(SparqlEndpoint endpoint, Cache cache, String key, + String queryString) { + super(queryString,endpoint); + this.cache = cache; + this.key = key; + } + + public void send() + { + String FromCache = cache.get(key, queryString); + + // if not in cache get it from EndPoint + if (FromCache == null) { + super.send(); + this.cache.put(key, queryString, getAsJSON()); + } else { + this.rs=SparqlQuery.JSONtoResultSet(FromCache); + System.out.println("FROM CACHE"); + } + } +} Modified: trunk/src/dl-learner/org/dllearner/kb/sparql/query/SparqlQuery.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/sparql/query/SparqlQuery.java 2008-01-29 10:11:45 UTC (rev 450) +++ trunk/src/dl-learner/org/dllearner/kb/sparql/query/SparqlQuery.java 2008-01-29 12:03:11 UTC (rev 451) @@ -30,7 +30,6 @@ import org.dllearner.kb.sparql.configuration.SparqlEndpoint; import org.dllearner.utilities.StringTuple; -import com.hp.hpl.jena.query.QueryExecution; import com.hp.hpl.jena.query.ResultSet; import com.hp.hpl.jena.query.ResultSetFactory; import com.hp.hpl.jena.query.ResultSetFormatter; @@ -47,11 +46,11 @@ public class SparqlQuery { private boolean print_flag = false; - private boolean isRunning = false; - private String queryString; - private QueryExecution queryExecution; - SparqlEndpoint endpoint; - private ResultSet rs=null; + protected boolean isRunning = false; + protected String queryString; + protected QueryEngineHTTP queryExecution; + protected SparqlEndpoint endpoint; + protected ResultSet rs=null; /** * simplest contructor, works only with some endpoints, @@ -74,19 +73,21 @@ this.endpoint = endpoint; } + public void setIsRunning(boolean running){ + this.isRunning=running; + } /** * method used for sending over Jena * @return jena ResultSet */ public void send() { - this.isRunning=true; p(queryString); String service = endpoint.getURL().toString(); p(endpoint.getURL().toString()); // Jena access to SPARQL endpoint - QueryEngineHTTP queryExecution=new QueryEngineHTTP(service,queryString); + queryExecution=new QueryEngineHTTP(service,queryString); for (String dgu : endpoint.getDefaultGraphURIs()){ queryExecution.addDefaultGraph(dgu); } @@ -99,7 +100,6 @@ rs = queryExecution.execSelect(); p(rs.getResultVars().toString()); //p(ResultSetFormatter.asXMLString(rs)); - this.isRunning=false; } public void stop() { Modified: trunk/src/dl-learner/org/dllearner/server/DLLearnerWS.java =================================================================== --- trunk/src/dl-learner/org/dllearner/server/DLLearnerWS.java 2008-01-29 10:11:45 UTC (rev 450) +++ trunk/src/dl-learner/org/dllearner/server/DLLearnerWS.java 2008-01-29 12:03:11 UTC (rev 451) @@ -47,6 +47,7 @@ import org.dllearner.core.dl.Individual; import org.dllearner.kb.OWLFile; import org.dllearner.kb.sparql.SparqlKnowledgeSource; +import org.dllearner.kb.sparql.query.SparqlQuery; import org.dllearner.learningproblems.PosNegDefinitionLP; import org.dllearner.learningproblems.PosNegInclusionLP; import org.dllearner.learningproblems.PosOnlyDefinitionLP; @@ -517,7 +518,10 @@ Thread sparqlThread = new Thread() { @Override public void run() { - state.getQuery(id).send(); + SparqlQuery query=state.getQuery(id); + query.setIsRunning(true); + query.send(); + query.setIsRunning(false); } }; sparqlThread.start(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sk...@us...> - 2008-01-29 10:11:52
|
Revision: 450 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=450&view=rev Author: sknappe Date: 2008-01-29 02:11:45 -0800 (Tue, 29 Jan 2008) Log Message: ----------- Deleted some unnecessary fields Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlKnowledgeSource.java Modified: trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlKnowledgeSource.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlKnowledgeSource.java 2008-01-29 08:49:28 UTC (rev 449) +++ trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlKnowledgeSource.java 2008-01-29 10:11:45 UTC (rev 450) @@ -293,7 +293,7 @@ // like default-graph uri endpoint = new SparqlEndpoint(url); } - + // get Options for Filters if (predefinedFilter >= 1) { @@ -308,6 +308,7 @@ // give everything to the manager m.useConfiguration(sparqlQueryType, endpoint, manipulator, recursionDepth, getAllSuperClasses, closeAfterRecursion); + try { String ont = ""; // the actual extraction is started here @@ -393,7 +394,7 @@ return new SparqlQuery(query, endpoint); } - public static void main(String[] args) throws MalformedURLException { + /*public static void main(String[] args) throws MalformedURLException { String query = "SELECT ?pred ?obj\n" + "WHERE {<http://dbpedia.org/resource/Leipzig> ?pred ?obj}"; URL url = new URL("http://dbpedia.openlinksw.com:8890/sparql"); @@ -405,5 +406,5 @@ System.out.print(array[i][j] + " "); System.out.println(); } - } + }*/ } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sk...@us...> - 2008-01-29 08:49:30
|
Revision: 449 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=449&view=rev Author: sknappe Date: 2008-01-29 00:49:28 -0800 (Tue, 29 Jan 2008) Log Message: ----------- now works with new SparqlQuery Modified Paths: -------------- trunk/src/dbpedia-navigator/DLLearnerConnection.php Modified: trunk/src/dbpedia-navigator/DLLearnerConnection.php =================================================================== --- trunk/src/dbpedia-navigator/DLLearnerConnection.php 2008-01-29 05:51:30 UTC (rev 448) +++ trunk/src/dbpedia-navigator/DLLearnerConnection.php 2008-01-29 08:49:28 UTC (rev 449) @@ -42,7 +42,7 @@ function getConceptFromExamples($posExamples,$negExamples) { - $this->client->applyConfigEntryInt($this->id, $this->ksID, "recursionDepth",2); + $this->client->applyConfigEntryInt($this->id, $this->ksID, "recursionDepth",1); $this->client->applyConfigEntryStringArray($this->id, $this->ksID, "instances", array_merge($posExamples,$negExamples)); // $this->client->applyConfigEntryStringArray($this->id, $this->ksID, "predList", array()); // $this->client->applyConfigEntryStringArray($this->id, $this->ksID, "objList", array()); @@ -122,16 +122,16 @@ sleep($sleeptime); - $running=$this->client->isSparqlQueryRunning($this->id,$this->ksID,$queryID); + $running=$this->client->isSparqlQueryRunning($this->id,$queryID); if (!$running){ - $result=$this->client->sparqlQuery($this->id,$this->ksID,$queryID); + $result=$this->client->getAsStringArray($this->id,$queryID); return $result; } $seconds = $i * $sleeptime; $i++; } while($seconds<$this->ttl); - $this->client->stopSparqlQuery($id,$ksID,$queryID); + $this->client->stopSparqlQuery($id,$queryID); } function getSubjects($label) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ton...@us...> - 2008-01-29 05:51:33
|
Revision: 448 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=448&view=rev Author: tonytacker Date: 2008-01-28 21:51:30 -0800 (Mon, 28 Jan 2008) Log Message: ----------- changed colors on errors Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/gui/WidgetPanelBoolean.java trunk/src/dl-learner/org/dllearner/gui/WidgetPanelInteger.java Modified: trunk/src/dl-learner/org/dllearner/gui/WidgetPanelBoolean.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/WidgetPanelBoolean.java 2008-01-29 05:12:31 UTC (rev 447) +++ trunk/src/dl-learner/org/dllearner/gui/WidgetPanelBoolean.java 2008-01-29 05:51:30 UTC (rev 448) @@ -117,8 +117,8 @@ } } else { // configOption == NULL JLabel noConfigOptionLabel = new JLabel( - "no init at moment (Boolean)"); - noConfigOptionLabel.setForeground(Color.RED); + "no init (Boolean)"); + noConfigOptionLabel.setForeground(Color.MAGENTA); widgetPanel.add(noConfigOptionLabel); } } Modified: trunk/src/dl-learner/org/dllearner/gui/WidgetPanelInteger.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/WidgetPanelInteger.java 2008-01-29 05:12:31 UTC (rev 447) +++ trunk/src/dl-learner/org/dllearner/gui/WidgetPanelInteger.java 2008-01-29 05:51:30 UTC (rev 448) @@ -112,8 +112,8 @@ widgetPanel.add(notImplementedLabel); } } else { // configOption == NULL - JLabel noConfigOptionLabel = new JLabel("no init at moment (Integer)"); - noConfigOptionLabel.setForeground(Color.RED); + JLabel noConfigOptionLabel = new JLabel("no init (Integer)"); + noConfigOptionLabel.setForeground(Color.MAGENTA); widgetPanel.add(noConfigOptionLabel); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ton...@us...> - 2008-01-29 05:12:34
|
Revision: 447 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=447&view=rev Author: tonytacker Date: 2008-01-28 21:12:31 -0800 (Mon, 28 Jan 2008) Log Message: ----------- implemented all configOptions in all 4 classes Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java trunk/src/dl-learner/org/dllearner/gui/LearningProblemPanel.java trunk/src/dl-learner/org/dllearner/gui/OptionPanel.java trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java trunk/src/dl-learner/org/dllearner/gui/WidgetPanelBoolean.java trunk/src/dl-learner/org/dllearner/gui/WidgetPanelInteger.java Modified: trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java 2008-01-29 03:12:04 UTC (rev 446) +++ trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java 2008-01-29 05:12:31 UTC (rev 447) @@ -54,6 +54,7 @@ private int choosenClassIndex; private List<Class<? extends KnowledgeSource>> sources; private JLabel infoLabel = new JLabel("choose local file or type URL"); + private OptionPanel optionPanel; KnowledgeSourcePanel(final Config config) { super(new BorderLayout()); @@ -122,9 +123,17 @@ gridbag.setConstraints(openButton, constraints); centerPanel.add(openButton); + buildConstraints(constraints, 0, 2, 2, 1, 100, 100); + gridbag.setConstraints(initPanel, constraints); + centerPanel.add(initPanel); + + optionPanel = new OptionPanel(config, config.getKnowledgeSource(), + sources.get(choosenClassIndex)); + updateOptionPanel(); + add(choosePanel, BorderLayout.PAGE_START); add(centerPanel, BorderLayout.CENTER); - add(initPanel, BorderLayout.PAGE_END); + add(optionPanel, BorderLayout.PAGE_END); choosenClassIndex = cb.getSelectedIndex(); } @@ -132,6 +141,7 @@ public void actionPerformed(ActionEvent e) { // read selected KnowledgeSourceClass choosenClassIndex = cb.getSelectedIndex(); + updateOptionPanel(); checkIfSparql(); // open File @@ -157,6 +167,7 @@ System.out.println("init KnowledgeSource with \n" + sources.get(choosenClassIndex) + " and \n" + config.getURI() + "\n"); + updateOptionPanel(); } } @@ -183,4 +194,9 @@ } } + public void updateOptionPanel() { + // update OptionPanel + optionPanel.setComponent(config.getKnowledgeSource()); + optionPanel.setComponentOption(sources.get(choosenClassIndex)); + } } Modified: trunk/src/dl-learner/org/dllearner/gui/LearningProblemPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/LearningProblemPanel.java 2008-01-29 03:12:04 UTC (rev 446) +++ trunk/src/dl-learner/org/dllearner/gui/LearningProblemPanel.java 2008-01-29 05:12:31 UTC (rev 447) @@ -60,6 +60,7 @@ private List<Individual> individuals; private JList posList = new JList(); private JList negList = new JList(); + private OptionPanel optionPanel; private Config config; @@ -71,15 +72,12 @@ initButton = new JButton("Init LearningProblem"); initButton.addActionListener(this); - readListButton = new JButton("Read List"); + readListButton = new JButton("Get Instances"); readListButton.addActionListener(this); choosePanel.add(cb); choosePanel.add(readListButton); lpPanel.add(initButton); - add(choosePanel, BorderLayout.PAGE_START); - add(centerPanel, BorderLayout.CENTER); - add(lpPanel, BorderLayout.PAGE_END); problems = config.getComponentManager().getLearningProblems(); @@ -129,6 +127,10 @@ buildConstraints(constraints, 1, 1, 1, 1, 100, 100); gridbag.setConstraints(negListScroller, constraints); centerPanel.add(negListScroller); + + buildConstraints(constraints, 0, 2, 2, 1, 100, 100); + gridbag.setConstraints(lpPanel, constraints); + centerPanel.add(lpPanel); add(centerPanel, BorderLayout.CENTER); @@ -159,11 +161,23 @@ config.setNegExampleSet(negExampleSet); } }); + + optionPanel = new OptionPanel(config, config.getLearningProblem(), + problems.get(choosenClassIndex)); + updateOptionPanel(); + + cb.addActionListener(this); + + add(choosePanel, BorderLayout.PAGE_START); + add(centerPanel, BorderLayout.CENTER); + add(optionPanel, BorderLayout.PAGE_END); + } public void actionPerformed(ActionEvent e) { // read selected LearningProblemClass choosenClassIndex = cb.getSelectedIndex(); + updateOptionPanel(); // get list after reasoner init if (e.getSource() == readListButton @@ -196,6 +210,7 @@ config.getNegExampleSet()); config.getLearningProblem().init(); System.out.println("init LearningProblem"); + updateOptionPanel(); } } @@ -213,4 +228,9 @@ gbc.weighty = wy; } + public void updateOptionPanel() { + // update OptionPanel + optionPanel.setComponent(config.getLearningProblem()); + optionPanel.setComponentOption(problems.get(choosenClassIndex)); + } } Modified: trunk/src/dl-learner/org/dllearner/gui/OptionPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/OptionPanel.java 2008-01-29 03:12:04 UTC (rev 446) +++ trunk/src/dl-learner/org/dllearner/gui/OptionPanel.java 2008-01-29 05:12:31 UTC (rev 447) @@ -74,9 +74,6 @@ showWidgets(); - System.out.println("AAA: " - + ComponentManager.getConfigOptions(componentOption)); - } public void setComponent(Component component) { Modified: trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java 2008-01-29 03:12:04 UTC (rev 446) +++ trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java 2008-01-29 05:12:31 UTC (rev 447) @@ -42,6 +42,7 @@ private List<Class<? extends ReasonerComponent>> reasoners; private JPanel choosePanel = new JPanel(); private JPanel initPanel = new JPanel(); + private OptionPanel optionPanel; private JButton initButton; private Config config; private String[] cbItems = {}; @@ -59,9 +60,6 @@ choosePanel.add(cb); - add(choosePanel, BorderLayout.PAGE_START); - add(initPanel, BorderLayout.PAGE_END); - // add into comboBox reasoners = config.getComponentManager().getReasonerComponents(); for (int i = 0; i < reasoners.size(); i++) { @@ -70,11 +68,22 @@ reasoners.get(i))); } + optionPanel = new OptionPanel(config, config.getReasoner(), reasoners + .get(choosenClassIndex)); + updateOptionPanel(); + + cb.addActionListener(this); + + add(choosePanel, BorderLayout.PAGE_START); + add(initPanel, BorderLayout.CENTER); + add(optionPanel, BorderLayout.PAGE_END); + } public void actionPerformed(ActionEvent e) { // read selected Class choosenClassIndex = cb.getSelectedIndex(); + updateOptionPanel(); if (e.getSource() == initButton && config.getKnowledgeSource() != null) { // set reasoner @@ -86,8 +95,15 @@ // set ReasoningService config.setReasoningService(config.getComponentManager() .reasoningService(config.getReasoner())); - + System.out.println("init Reasoner"); + updateOptionPanel(); } } + + public void updateOptionPanel() { + // update OptionPanel + optionPanel.setComponent(config.getReasoner()); + optionPanel.setComponentOption(reasoners.get(choosenClassIndex)); + } } Modified: trunk/src/dl-learner/org/dllearner/gui/WidgetPanelBoolean.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/WidgetPanelBoolean.java 2008-01-29 03:12:04 UTC (rev 446) +++ trunk/src/dl-learner/org/dllearner/gui/WidgetPanelBoolean.java 2008-01-29 05:12:31 UTC (rev 447) @@ -30,8 +30,7 @@ import javax.swing.JPanel; import javax.swing.JButton; -import org.dllearner.core.Component; // import -// org.dllearner.core.ComponentManager; +import org.dllearner.core.Component; import org.dllearner.core.config.ConfigEntry; import org.dllearner.core.config.ConfigOption; import org.dllearner.core.config.BooleanConfigOption; @@ -117,7 +116,8 @@ widgetPanel.add(notImplementedLabel); } } else { // configOption == NULL - JLabel noConfigOptionLabel = new JLabel("no init at moment (Boolean)"); + JLabel noConfigOptionLabel = new JLabel( + "no init at moment (Boolean)"); noConfigOptionLabel.setForeground(Color.RED); widgetPanel.add(noConfigOptionLabel); } Modified: trunk/src/dl-learner/org/dllearner/gui/WidgetPanelInteger.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/WidgetPanelInteger.java 2008-01-29 03:12:04 UTC (rev 446) +++ trunk/src/dl-learner/org/dllearner/gui/WidgetPanelInteger.java 2008-01-29 05:12:31 UTC (rev 447) @@ -30,8 +30,7 @@ import javax.swing.JPanel; import javax.swing.JButton; -import org.dllearner.core.Component; // import -// org.dllearner.core.ComponentManager; +import org.dllearner.core.Component; import org.dllearner.core.config.ConfigEntry; import org.dllearner.core.config.ConfigOption; import org.dllearner.core.config.IntegerConfigOption; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ton...@us...> - 2008-01-29 03:12:07
|
Revision: 446 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=446&view=rev Author: tonytacker Date: 2008-01-28 19:12:04 -0800 (Mon, 28 Jan 2008) Log Message: ----------- add AbstractWidgetPanel for all WidgetPanels to set options, add tooltip on each widgetlabel, add WidgetPanelBoolean, removed a small bug Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.java trunk/src/dl-learner/org/dllearner/gui/OptionPanel.java trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java trunk/src/dl-learner/org/dllearner/gui/WidgetPanelDefault.java trunk/src/dl-learner/org/dllearner/gui/WidgetPanelInteger.java Added Paths: ----------- trunk/src/dl-learner/org/dllearner/gui/AbstractWidgetPanel.java trunk/src/dl-learner/org/dllearner/gui/WidgetPanelBoolean.java Removed Paths: ------------- trunk/src/dl-learner/org/dllearner/gui/Startgui$1.class trunk/src/dl-learner/org/dllearner/gui/Startgui.class Added: trunk/src/dl-learner/org/dllearner/gui/AbstractWidgetPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/AbstractWidgetPanel.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/gui/AbstractWidgetPanel.java 2008-01-29 03:12:04 UTC (rev 446) @@ -0,0 +1,49 @@ +package org.dllearner.gui; + +/** + * Copyright (C) 2007-2008, 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/>. + * + */ + +import javax.swing.JPanel; + +/** + * AbstractWidgetPanel + * + * @author Tilo Hielscher + * + */ +public abstract class AbstractWidgetPanel extends JPanel { + + + /* + * show label and tooltip + */ + protected abstract void showLabel(); + + /* + * show textfield, setbutton and so on + */ + protected abstract void showThingToChange(); + + /* + * set entry you got from showThingToChange() + */ + protected abstract void setEntry(); + +} Modified: trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.java 2008-01-28 23:32:48 UTC (rev 445) +++ trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.java 2008-01-29 03:12:04 UTC (rev 446) @@ -81,9 +81,7 @@ public void actionPerformed(ActionEvent e) { // read selected Class choosenClassIndex = cb.getSelectedIndex(); - updateOptionPanel(); - // init if (e.getSource() == initButton && config.getLearningProblem() != null) { config.setLearningAlgorithm(config.getComponentManager() @@ -91,6 +89,7 @@ config.getLearningProblem(), config.getReasoningService())); updateOptionPanel(); + System.out.println("init LearningAlgorithm"); config.getLearningAlgorithm().init(); } } Modified: trunk/src/dl-learner/org/dllearner/gui/OptionPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/OptionPanel.java 2008-01-28 23:32:48 UTC (rev 445) +++ trunk/src/dl-learner/org/dllearner/gui/OptionPanel.java 2008-01-29 03:12:04 UTC (rev 446) @@ -42,85 +42,95 @@ */ public class OptionPanel extends JPanel { - private static final long serialVersionUID = -3053205578443575240L; - private Config config; - private Class<? extends Component> componentOption; - private List<ConfigOption<?>> optionList; - private JPanel centerPanel = new JPanel(); - private Component component; - private GridBagLayout gridBagLayout = new GridBagLayout(); - private GridBagConstraints constraints = new GridBagConstraints(); + private static final long serialVersionUID = -3053205578443575240L; + private Config config; + private Class<? extends Component> componentOption; + private List<ConfigOption<?>> optionList; + private JPanel centerPanel = new JPanel(); + private Component component; + private GridBagLayout gridBagLayout = new GridBagLayout(); + private GridBagConstraints constraints = new GridBagConstraints(); - public OptionPanel(Config config, Component component, Class<? extends Component> componentOption) { - super(new BorderLayout()); - - this.config = config; - this.component = component; - this.componentOption = componentOption; - - optionList = ComponentManager.getConfigOptions(componentOption); - - // define GridBagLayout - centerPanel.setLayout(gridBagLayout); - constraints.anchor = GridBagConstraints.NORTHWEST; + public OptionPanel(Config config, Component component, + Class<? extends Component> componentOption) { + super(new BorderLayout()); - // add scrollPane - JScrollPane centerScroller = new JScrollPane(centerPanel); - centerScroller.setPreferredSize(new Dimension(400, 200)); - - // add Panels - add(centerScroller, BorderLayout.CENTER); - - showWidgets(); + this.config = config; + this.component = component; + this.componentOption = componentOption; - System.out.println("AAA: " + ComponentManager.getConfigOptions(componentOption)); + optionList = ComponentManager.getConfigOptions(componentOption); + // define GridBagLayout + centerPanel.setLayout(gridBagLayout); + constraints.anchor = GridBagConstraints.NORTHWEST; + + // add scrollPane + JScrollPane centerScroller = new JScrollPane(centerPanel); + centerScroller.setPreferredSize(new Dimension(400, 200)); + + // add Panels + add(centerScroller, BorderLayout.CENTER); + + showWidgets(); + + System.out.println("AAA: " + + ComponentManager.getConfigOptions(componentOption)); + + } + + public void setComponent(Component component) { + this.component = component; + showWidgets(); + } + + public void setComponentOption(Class<? extends Component> componentOption) { + this.componentOption = componentOption; + showWidgets(); + } + + /* + * define here what core.config.class is what type of widget + * WidgetPanelDefault is for none defined classes + */ + private void showWidgets() { + JPanel widgetPanel; + optionList = ComponentManager.getConfigOptions(componentOption); // get + // class + // for + // options + centerPanel.removeAll(); // clear panel + for (int i = 0; i < optionList.size(); i++) { + buildConstraints(constraints, 0, i, 1, 1, 0, 0); + if (optionList.get(i).getClass().toString().contains( + "IntegerConfigOption")) { + widgetPanel = new WidgetPanelInteger(config, component, + componentOption, optionList.get(i)); + } else if (optionList.get(i).getClass().toString().contains( + "BooleanConfigOption")) { + widgetPanel = new WidgetPanelBoolean(config, component, + componentOption, optionList.get(i)); + } else { + widgetPanel = new WidgetPanelDefault(config, component, + componentOption, optionList.get(i)); + } + gridBagLayout.setConstraints(widgetPanel, constraints); + centerPanel.add(widgetPanel); } - - public void setComponent (Component component) { - this.component = component; - showWidgets(); - } - - public void setComponentOption (Class<? extends Component> componentOption) { - this.componentOption = componentOption; - showWidgets(); - } - - /* - * define here what core.config.class is what type of widget - * WidgetPanelDefault is for none defined classes - */ - private void showWidgets() { - JPanel widgetPanel; - optionList = ComponentManager.getConfigOptions(componentOption); // get class for options - centerPanel.removeAll(); // clear panel - for (int i=0; i<optionList.size(); i++) { - buildConstraints(constraints, 0, i, 1, 1, 0, 0); - if (optionList.get(i).getClass().toString().contains("IntegerConfigOption")) { - widgetPanel = new WidgetPanelInteger(config, component, componentOption, optionList.get(i)); - } - else if (false) { - } - else { - widgetPanel = new WidgetPanelDefault(config, component, componentOption, optionList.get(i)); - } - gridBagLayout.setConstraints(widgetPanel, constraints); - centerPanel.add(widgetPanel); - } - centerPanel.updateUI(); // update graphic - } - - /* - * Define GridBagConstraints - */ - private void buildConstraints(GridBagConstraints gbc, int gx, int gy, int gw, int gh, int wx, int wy) { - gbc.gridx = gx; - gbc.gridy = gy; - gbc.gridwidth = gw; - gbc.gridheight = gh; - gbc.weightx = wx; - gbc.weighty = wy; - } - + centerPanel.updateUI(); // update graphic + } + + /* + * Define GridBagConstraints + */ + private void buildConstraints(GridBagConstraints gbc, int gx, int gy, + int gw, int gh, int wx, int wy) { + gbc.gridx = gx; + gbc.gridy = gy; + gbc.gridwidth = gw; + gbc.gridheight = gh; + gbc.weightx = wx; + gbc.weighty = wy; + } + } Modified: trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java 2008-01-28 23:32:48 UTC (rev 445) +++ trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java 2008-01-29 03:12:04 UTC (rev 446) @@ -86,6 +86,8 @@ // set ReasoningService config.setReasoningService(config.getComponentManager() .reasoningService(config.getReasoner())); + + System.out.println("init Reasoner"); } } } Deleted: trunk/src/dl-learner/org/dllearner/gui/Startgui$1.class =================================================================== (Binary files differ) Deleted: trunk/src/dl-learner/org/dllearner/gui/Startgui.class =================================================================== (Binary files differ) Added: trunk/src/dl-learner/org/dllearner/gui/WidgetPanelBoolean.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/WidgetPanelBoolean.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/gui/WidgetPanelBoolean.java 2008-01-29 03:12:04 UTC (rev 446) @@ -0,0 +1,145 @@ +package org.dllearner.gui; + +/** + * Copyright (C) 2007-2008, 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/>. + * + */ + +import java.awt.BorderLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.Color; + +import javax.swing.JComboBox; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JButton; + +import org.dllearner.core.Component; // import +// org.dllearner.core.ComponentManager; +import org.dllearner.core.config.ConfigEntry; +import org.dllearner.core.config.ConfigOption; +import org.dllearner.core.config.BooleanConfigOption; +import org.dllearner.core.config.InvalidConfigOptionValueException; + +/** + * WidgetPanelInteger + * + * @author Tilo Hielscher + * + */ +public class WidgetPanelBoolean extends AbstractWidgetPanel implements + ActionListener { + + private static final long serialVersionUID = -4800583253223939928L; + private Config config; + private ConfigOption<?> configOption; + private JLabel nameLabel; + private JPanel widgetPanel = new JPanel(); + private JButton setButton = new JButton("Set"); + private Component component; + private Class<? extends Component> componentOption; + + private Boolean value; + private String[] kbBoxItems = { "true", "false" }; + private JComboBox cb = new JComboBox(kbBoxItems); + + public WidgetPanelBoolean(Config config, Component component, + Class<? extends Component> componentOption, + ConfigOption<?> configOption) { + this.config = config; + this.configOption = configOption; + this.component = component; + this.componentOption = componentOption; + + showLabel(); // name of option and tooltip + showThingToChange(); // textfield, setbutton + add(widgetPanel, BorderLayout.CENTER); + } + + public JPanel getPanel() { + return this; + } + + public void actionPerformed(ActionEvent e) { + if (e.getSource() == setButton) { + setEntry(); + } + } + + protected void showLabel() { + nameLabel = new JLabel(configOption.getName()); + nameLabel.setToolTipText(configOption.getDescription()); + widgetPanel.add(nameLabel); + } + + protected void showThingToChange() { + if (component != null) { + // IntegerConfigOption + if (configOption.getClass().toString().contains( + "BooleanConfigOption")) { + // default value + if (configOption.getDefaultValue() != null) { + value = (Boolean) configOption.getDefaultValue(); + } + // then false + else { + value = false; + } + // cb.setText(value.toString()); + if (value == false) + cb.setSelectedIndex(0); + else + cb.setSelectedIndex(1); + setButton.addActionListener(this); + widgetPanel.add(cb); + widgetPanel.add(setButton); + } + // UNKNOWN + else { + JLabel notImplementedLabel = new JLabel("not a boolean"); + notImplementedLabel.setForeground(Color.RED); + widgetPanel.add(notImplementedLabel); + } + } else { // configOption == NULL + JLabel noConfigOptionLabel = new JLabel("no init at moment (Boolean)"); + noConfigOptionLabel.setForeground(Color.RED); + widgetPanel.add(noConfigOptionLabel); + } + } + + protected void setEntry() { + BooleanConfigOption specialOption; + if (cb.getSelectedIndex() == 0) + value = true; + else + value = false; + specialOption = (BooleanConfigOption) config.getComponentManager() + .getConfigOption(componentOption, configOption.getName()); + try { + ConfigEntry<Boolean> specialEntry = new ConfigEntry<Boolean>( + specialOption, value); + config.getComponentManager().applyConfigEntry(component, + specialEntry); + System.out.println("set Boolean: " + configOption.getName() + " = " + + value); + } catch (InvalidConfigOptionValueException s) { + s.printStackTrace(); + } + } +} Modified: trunk/src/dl-learner/org/dllearner/gui/WidgetPanelDefault.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/WidgetPanelDefault.java 2008-01-28 23:32:48 UTC (rev 445) +++ trunk/src/dl-learner/org/dllearner/gui/WidgetPanelDefault.java 2008-01-29 03:12:04 UTC (rev 446) @@ -29,33 +29,47 @@ import org.dllearner.core.Component; import org.dllearner.core.config.ConfigOption; - /** * WidgetPanelDefault * * @author Tilo Hielscher * */ -public class WidgetPanelDefault extends JPanel { +public class WidgetPanelDefault extends AbstractWidgetPanel { - private static final long serialVersionUID = 4059515858894036769L; - private JLabel nameLabel; - private JPanel centerPanel = new JPanel(); - - public WidgetPanelDefault(Config config, Component component, Class<? extends Component> componentOption, ConfigOption<?> configOption) { - - // default - nameLabel = new JLabel(configOption.getName()); + private static final long serialVersionUID = 4059515858894036769L; - // text - nameLabel = new JLabel(configOption.getName()); - JLabel notImplementedLabel = new JLabel(configOption.getClass().getSimpleName() + " not implemented"); - notImplementedLabel.setForeground(Color.RED); - centerPanel.add(nameLabel); - centerPanel.add(notImplementedLabel); - - // default - add(centerPanel, BorderLayout.CENTER); - } - + private ConfigOption<?> configOption; + private JLabel nameLabel; + private JPanel widgetPanel = new JPanel(); + + public WidgetPanelDefault(Config config, Component component, + Class<? extends Component> componentOption, + ConfigOption<?> configOption) { + + this.configOption = configOption; + + showLabel(); + showThingToChange(); + add(widgetPanel, BorderLayout.CENTER); + } + + protected void showLabel() { + nameLabel = new JLabel(configOption.getName()); + nameLabel.setToolTipText(configOption.getDescription()); + widgetPanel.add(nameLabel); + } + + protected void showThingToChange() { + JLabel notImplementedLabel = new JLabel(configOption.getClass() + .getSimpleName() + + " not implemented"); + notImplementedLabel.setForeground(Color.RED); + + widgetPanel.add(notImplementedLabel); + } + + protected void setEntry() { + } + } Modified: trunk/src/dl-learner/org/dllearner/gui/WidgetPanelInteger.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/WidgetPanelInteger.java 2008-01-28 23:32:48 UTC (rev 445) +++ trunk/src/dl-learner/org/dllearner/gui/WidgetPanelInteger.java 2008-01-29 03:12:04 UTC (rev 446) @@ -30,126 +30,109 @@ import javax.swing.JPanel; import javax.swing.JButton; -import org.dllearner.core.Component; -//import org.dllearner.core.ComponentManager; +import org.dllearner.core.Component; // import +// org.dllearner.core.ComponentManager; import org.dllearner.core.config.ConfigEntry; import org.dllearner.core.config.ConfigOption; import org.dllearner.core.config.IntegerConfigOption; import org.dllearner.core.config.InvalidConfigOptionValueException; - /** * WidgetPanelInteger * * @author Tilo Hielscher * */ -public class WidgetPanelInteger extends JPanel implements ActionListener { +public class WidgetPanelInteger extends AbstractWidgetPanel implements + ActionListener { - private static final long serialVersionUID = -1802111225835164644L; + private static final long serialVersionUID = -1802111225835164644L; - private Config config; - private ConfigOption<?> configOption; - private JLabel nameLabel; - private JPanel centerPanel = new JPanel(); - private JButton setButton = new JButton("Set"); - private Component component; - private Class<? extends Component> componentOption; - - private Integer value; - private JTextField integerField = new JTextField(3); + private Config config; + private ConfigOption<?> configOption; + private JLabel nameLabel; + private JPanel widgetPanel = new JPanel(); + private JButton setButton = new JButton("Set"); + private Component component; + private Class<? extends Component> componentOption; - - public WidgetPanelInteger(Config config, Component component, Class<? extends Component> componentOption, ConfigOption<?> configOption) { - this.config = config; - this.configOption = configOption; - this.component = component; - this.componentOption = componentOption; - - showLabel(); // name of option and tooltip - showThingToChange(); // textfield, setbutton - add(centerPanel, BorderLayout.CENTER); + private Integer value; + private JTextField integerField = new JTextField(3); + + public WidgetPanelInteger(Config config, Component component, + Class<? extends Component> componentOption, + ConfigOption<?> configOption) { + this.config = config; + this.configOption = configOption; + this.component = component; + this.componentOption = componentOption; + + showLabel(); // name of option and tooltip + showThingToChange(); // textfield, setbutton + add(widgetPanel, BorderLayout.CENTER); + } + + public JPanel getPanel() { + return this; + } + + public void actionPerformed(ActionEvent e) { + if (e.getSource() == setButton) { + setEntry(); } - - public JPanel getPanel() { - return this; - } - - public void actionPerformed(ActionEvent e) { - if (e.getSource() == setButton) { - setEntry(); - } - } - - private void showLabel() { - nameLabel = new JLabel(configOption.getName()); - centerPanel.add(nameLabel); - } - - - private void showThingToChange () { - if (component != null) { - System.out.println("show set Integer config.getComponentManager().getConfigOptionValue(component, name): " + config.getComponentManager().getConfigOptionValue(component, configOption.getName())); + } - // IntegerConfigOption - if (configOption.getClass().toString().contains("IntegerConfigOption")) { - // seted value - if (config.getComponentManager().getConfigOptionValue(component, configOption.getName()) != null) { - value = (Integer) config.getComponentManager().getConfigOptionValue(component, configOption.getName()); - System.out.println("value readed: " + value); - } - // default value - else if (configOption.getDefaultValue() != null) { - System.out.println("default value null"); - value = (Integer) configOption.getDefaultValue(); - } - // then 0 - else { - value = 0; - System.out.println("default value not null"); - } - System.out.println("value: " + value); - integerField.setText(value.toString()); - System.out.println("configOption.getDefaultValue(): " + configOption.getDefaultValue()); - setButton.addActionListener(this); - centerPanel.add(integerField); - centerPanel.add(setButton); - } - // UNKNOWN - else { - nameLabel = new JLabel(configOption.getName()); - JLabel notImplementedLabel = new JLabel("not an integer"); - notImplementedLabel.setForeground(Color.RED); - centerPanel.add(nameLabel); - centerPanel.add(notImplementedLabel); - } + protected void showLabel() { + nameLabel = new JLabel(configOption.getName()); + nameLabel.setToolTipText(configOption.getDescription()); + widgetPanel.add(nameLabel); + } + + protected void showThingToChange() { + if (component != null) { + // IntegerConfigOption + if (configOption.getClass().toString().contains( + "IntegerConfigOption")) { + // default value + if (configOption.getDefaultValue() != null) { + value = (Integer) configOption.getDefaultValue(); } - else { // configOption == NULL - JLabel noConfigOptionLabel = new JLabel("no init at moment"); - noConfigOptionLabel.setForeground(Color.RED); - centerPanel.add(noConfigOptionLabel); + // then 0 + else { + value = 0; } + integerField.setText(value.toString()); + setButton.addActionListener(this); + widgetPanel.add(integerField); + widgetPanel.add(setButton); + } + // UNKNOWN + else { + JLabel notImplementedLabel = new JLabel("not an integer"); + notImplementedLabel.setForeground(Color.RED); + widgetPanel.add(notImplementedLabel); + } + } else { // configOption == NULL + JLabel noConfigOptionLabel = new JLabel("no init at moment (Integer)"); + noConfigOptionLabel.setForeground(Color.RED); + widgetPanel.add(noConfigOptionLabel); } - - private void setEntry() { - // INTEGER - IntegerConfigOption specialOption; - value = Integer.parseInt(integerField.getText()); - System.out.println("set Integer: " + configOption.getName() + " = " + value); - specialOption = (IntegerConfigOption) config.getComponentManager().getConfigOption(componentOption, configOption.getName()); - try { - ConfigEntry<Integer> specialEntry = new ConfigEntry<Integer>(specialOption, value); - //System.out.println("set Integer specialEntry: " + specialEntry); - System.out.println("set Integer component: " + component); - //System.out.println("set Integer componentOption: " + componentOption); - //System.out.println("set Integer config.getComponentManager().getConfigOptionValue(component, name): " + config.getComponentManager().getConfigOptionValue(component, name)); - config.getComponentManager().applyConfigEntry(component, specialEntry); - // update this - System.out.println("set Integer config.getComponentManager().getConfigOptionValue(component, name): " + config.getComponentManager().getConfigOptionValue(component, configOption.getName())); - System.out.println("seted value: " + this.value); - } - catch (InvalidConfigOptionValueException s) { - s.printStackTrace(); - } + } + + protected void setEntry() { + IntegerConfigOption specialOption; + value = Integer.parseInt(integerField.getText()); // get from input + specialOption = (IntegerConfigOption) config.getComponentManager() + .getConfigOption(componentOption, configOption.getName()); + try { + ConfigEntry<Integer> specialEntry = new ConfigEntry<Integer>( + specialOption, value); + config.getComponentManager().applyConfigEntry(component, + specialEntry); + System.out.println("set Integer: " + configOption.getName() + " = " + + value); + } catch (InvalidConfigOptionValueException s) { + s.printStackTrace(); } + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ton...@us...> - 2008-01-28 23:32:53
|
Revision: 445 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=445&view=rev Author: tonytacker Date: 2008-01-28 15:32:48 -0800 (Mon, 28 Jan 2008) Log Message: ----------- renamed OutputPanel to RunPanel, formated code, removed variable status Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/gui/Config.java trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.java trunk/src/dl-learner/org/dllearner/gui/LearningProblemPanel.java trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java trunk/src/dl-learner/org/dllearner/gui/StartGUI.java Added Paths: ----------- trunk/src/dl-learner/org/dllearner/gui/RunPanel.java Removed Paths: ------------- trunk/src/dl-learner/org/dllearner/gui/OutputPanel.java Modified: trunk/src/dl-learner/org/dllearner/gui/Config.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/Config.java 2008-01-28 22:16:24 UTC (rev 444) +++ trunk/src/dl-learner/org/dllearner/gui/Config.java 2008-01-28 23:32:48 UTC (rev 445) @@ -21,7 +21,6 @@ */ import java.util.HashSet; -import java.util.List; import java.util.Set; import org.dllearner.core.ComponentManager; @@ -30,9 +29,7 @@ import org.dllearner.core.LearningProblem; import org.dllearner.core.ReasonerComponent; import org.dllearner.core.ReasoningService; -import org.dllearner.core.config.ConfigOption; - /** * config * @@ -43,117 +40,86 @@ */ public class Config { - private ComponentManager cm = ComponentManager.getInstance(); - private KnowledgeSource source; - private String uri; - private ReasonerComponent reasoner; - private ReasoningService rs; - private Set<String> posExampleSet = new HashSet<String>(); - private Set<String> negExampleSet = new HashSet<String>(); - private LearningProblem lp; - private LearningAlgorithm la; - - private List<ConfigOption<?>> optionLearningAlgorithm ; - - /** - * status should show witch variables are set - * status[0] ... cm - * status[1] ... KnowledgeSource - * status[2] ... URI - * status[3] ... Resoner - * status[4] ... ReasoningService - * status[5] ... ExampleSet - * status[6] ... LearningProblem - */ - protected static boolean[] status = new boolean[8]; - - protected boolean getStatus(int position) { - if (status[position]) - return true; - else - return false; - } + private ComponentManager cm = ComponentManager.getInstance(); + private KnowledgeSource source; + private String uri; + private ReasonerComponent reasoner; + private ReasoningService rs; + private Set<String> posExampleSet = new HashSet<String>(); + private Set<String> negExampleSet = new HashSet<String>(); + private LearningProblem lp; + private LearningAlgorithm la; - protected ComponentManager getComponentManager() { - return cm; - } - - protected void setComponentManager (ComponentManager input) { - cm = input; - } + protected ComponentManager getComponentManager() { + return cm; + } - protected String getURI () { - return uri; - } - - protected void setURI (String input) { - status[2] = true; - uri = input; - } - - protected ReasonerComponent getReasoner () { - return reasoner; - } + protected void setComponentManager(ComponentManager input) { + cm = input; + } - protected void setReasoner (ReasonerComponent input) { - status[3] = true; - reasoner = input; - } - - - protected ReasoningService getReasoningService () { - return rs; - } - - protected void setReasoningService (ReasoningService input) { - status[4] = true; - rs = input; - } - - protected KnowledgeSource getKnowledgeSource() { - return source; - } + protected String getURI() { + return uri; + } - protected void setKnowledgeSource(KnowledgeSource input) { - status[1] = true; - source = input; - } + protected void setURI(String input) { + uri = input; + } - protected void setPosExampleSet(Set<String> posExampleSet) { - status[5] = true; - this.posExampleSet = posExampleSet; - } - - protected Set<String> getPosExampleSet () { - return this.posExampleSet; - } - - protected void setNegExampleSet(Set<String> negExampleSet) { - status[5] = true; - this.negExampleSet = negExampleSet; - } - - protected Set<String> getNegExampleSet () { - return this.negExampleSet; - } + protected ReasonerComponent getReasoner() { + return reasoner; + } - protected void setLearningProblem (LearningProblem input) { - status[6] = true; - lp = input; - } - - protected LearningProblem getLearningProblem () { - return lp; - } - - protected void setLearningAlgorithm (LearningAlgorithm input) { - status[6] = true; - la = input; - } - - protected LearningAlgorithm getLearningAlgorithm () { - return la; - } + protected void setReasoner(ReasonerComponent input) { + reasoner = input; + } - + protected ReasoningService getReasoningService() { + return rs; + } + + protected void setReasoningService(ReasoningService input) { + rs = input; + } + + protected KnowledgeSource getKnowledgeSource() { + return source; + } + + protected void setKnowledgeSource(KnowledgeSource input) { + source = input; + } + + protected void setPosExampleSet(Set<String> posExampleSet) { + this.posExampleSet = posExampleSet; + } + + protected Set<String> getPosExampleSet() { + return this.posExampleSet; + } + + protected void setNegExampleSet(Set<String> negExampleSet) { + this.negExampleSet = negExampleSet; + } + + protected Set<String> getNegExampleSet() { + return this.negExampleSet; + } + + protected void setLearningProblem(LearningProblem input) { + lp = input; + } + + protected LearningProblem getLearningProblem() { + return lp; + } + + protected void setLearningAlgorithm(LearningAlgorithm input) { + la = input; + } + + protected LearningAlgorithm getLearningAlgorithm() { + return la; + } + } Modified: trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java 2008-01-28 22:16:24 UTC (rev 444) +++ trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java 2008-01-28 23:32:48 UTC (rev 445) @@ -34,7 +34,6 @@ import org.dllearner.core.KnowledgeSource; - /** * KnowledgeSourcePanel * @@ -42,138 +41,146 @@ * */ public class KnowledgeSourcePanel extends JPanel implements ActionListener { - - private static final long serialVersionUID = -7678275020058043937L; - - private JFileChooser fc; - private JButton openButton, initButton; - private JTextField fileDisplay; + + private static final long serialVersionUID = -7678275020058043937L; + + private JFileChooser fc; + private JButton openButton, initButton; + private JTextField fileDisplay; private String[] kbBoxItems = {}; - private JComboBox cb = new JComboBox(kbBoxItems); - private JPanel centerPanel, choosePanel, initPanel; - private Config config; - private int choosenClassIndex; - private List<Class<? extends KnowledgeSource>> sources; - private JLabel infoLabel = new JLabel("choose local file or type URL"); - - KnowledgeSourcePanel(final Config config) { - super(new BorderLayout()); - - this.config = config; - sources = config.getComponentManager().getKnowledgeSources(); - - fc = new JFileChooser(new File("examples/")); - openButton = new JButton("choose local file"); - openButton.addActionListener(this); - - initButton = new JButton("Init KnowledgeSource"); - initButton.addActionListener(this); - - fileDisplay = new JTextField(35); - fileDisplay.setEditable(true); - - // update config if textfield fileDisplay changed - fileDisplay.getDocument().addDocumentListener(new DocumentListener() { - public void insertUpdate(DocumentEvent e) { - config.setURI(fileDisplay.getText()); - } - public void removeUpdate(DocumentEvent e) { - config.setURI(fileDisplay.getText()); - } - public void changedUpdate(DocumentEvent e) { - config.setURI(fileDisplay.getText()); - } - }); - - // add to comboBox - for (int i=0; i<sources.size(); i++) { - // cb.addItem(sources.get(i).getSimpleName()); - cb.addItem(config.getComponentManager().getComponentName(sources.get(i))); - } - - cb.addActionListener(this); - - choosePanel = new JPanel(); - choosePanel.add(cb); + private JComboBox cb = new JComboBox(kbBoxItems); + private JPanel centerPanel, choosePanel, initPanel; + private Config config; + private int choosenClassIndex; + private List<Class<? extends KnowledgeSource>> sources; + private JLabel infoLabel = new JLabel("choose local file or type URL"); - initPanel = new JPanel(); - initPanel.add(initButton); + KnowledgeSourcePanel(final Config config) { + super(new BorderLayout()); - centerPanel = new JPanel(); - - // define GridBag - GridBagLayout gridbag = new GridBagLayout(); - centerPanel.setLayout(gridbag); - GridBagConstraints constraints = new GridBagConstraints(); - constraints.fill = GridBagConstraints.BOTH; - constraints.anchor = GridBagConstraints.CENTER; + this.config = config; + sources = config.getComponentManager().getKnowledgeSources(); - buildConstraints(constraints, 0, 0, 1, 1, 100, 100); - gridbag.setConstraints(infoLabel, constraints); - centerPanel.add(infoLabel); + fc = new JFileChooser(new File("examples/")); + openButton = new JButton("choose local file"); + openButton.addActionListener(this); - buildConstraints(constraints, 0, 1, 1, 1, 100, 100); - gridbag.setConstraints(fileDisplay, constraints); - centerPanel.add(fileDisplay); - - buildConstraints(constraints, 1, 1, 1, 1, 100, 100); - gridbag.setConstraints(openButton, constraints); - centerPanel.add(openButton); - - add(choosePanel, BorderLayout.PAGE_START); - add(centerPanel, BorderLayout.CENTER); - add(initPanel, BorderLayout.PAGE_END); - - choosenClassIndex = cb.getSelectedIndex(); + initButton = new JButton("Init KnowledgeSource"); + initButton.addActionListener(this); + + fileDisplay = new JTextField(35); + fileDisplay.setEditable(true); + + // update config if textfield fileDisplay changed + fileDisplay.getDocument().addDocumentListener(new DocumentListener() { + public void insertUpdate(DocumentEvent e) { + config.setURI(fileDisplay.getText()); + } + + public void removeUpdate(DocumentEvent e) { + config.setURI(fileDisplay.getText()); + } + + public void changedUpdate(DocumentEvent e) { + config.setURI(fileDisplay.getText()); + } + }); + + // add to comboBox + for (int i = 0; i < sources.size(); i++) { + // cb.addItem(sources.get(i).getSimpleName()); + cb.addItem(config.getComponentManager().getComponentName( + sources.get(i))); } - - public void actionPerformed(ActionEvent e) { - // read selected KnowledgeSourceClass - choosenClassIndex = cb.getSelectedIndex(); - checkIfSparql(); - - // open File - if (e.getSource() == openButton) { - int returnVal = fc.showOpenDialog(KnowledgeSourcePanel.this); - if (returnVal == JFileChooser.APPROVE_OPTION) { - String URI = "file://"; - URI = URI.concat(fc.getSelectedFile().toString()); // make "file://" before local URI - config.setURI(URI); //save variable - fileDisplay.setText(URI); - } - return; + + cb.addActionListener(this); + + choosePanel = new JPanel(); + choosePanel.add(cb); + + initPanel = new JPanel(); + initPanel.add(initButton); + + centerPanel = new JPanel(); + + // define GridBag + GridBagLayout gridbag = new GridBagLayout(); + centerPanel.setLayout(gridbag); + GridBagConstraints constraints = new GridBagConstraints(); + constraints.fill = GridBagConstraints.BOTH; + constraints.anchor = GridBagConstraints.CENTER; + + buildConstraints(constraints, 0, 0, 1, 1, 100, 100); + gridbag.setConstraints(infoLabel, constraints); + centerPanel.add(infoLabel); + + buildConstraints(constraints, 0, 1, 1, 1, 100, 100); + gridbag.setConstraints(fileDisplay, constraints); + centerPanel.add(fileDisplay); + + buildConstraints(constraints, 1, 1, 1, 1, 100, 100); + gridbag.setConstraints(openButton, constraints); + centerPanel.add(openButton); + + add(choosePanel, BorderLayout.PAGE_START); + add(centerPanel, BorderLayout.CENTER); + add(initPanel, BorderLayout.PAGE_END); + + choosenClassIndex = cb.getSelectedIndex(); + } + + public void actionPerformed(ActionEvent e) { + // read selected KnowledgeSourceClass + choosenClassIndex = cb.getSelectedIndex(); + checkIfSparql(); + + // open File + if (e.getSource() == openButton) { + int returnVal = fc.showOpenDialog(KnowledgeSourcePanel.this); + if (returnVal == JFileChooser.APPROVE_OPTION) { + String URI = "file://"; + // make "file://" before local URI + URI = URI.concat(fc.getSelectedFile().toString()); + config.setURI(URI); // save variable + fileDisplay.setText(URI); } - - // init - if (e.getSource() == initButton && config.getStatus(2)) { - config.setKnowledgeSource(config.getComponentManager().knowledgeSource(sources.get(choosenClassIndex))); - config.getComponentManager().applyConfigEntry(config.getKnowledgeSource(), "url", config.getURI()); - config.getKnowledgeSource().init(); - System.out.println("init KnowledgeSource with \n" + sources.get(choosenClassIndex) + " and \n" + config.getURI() + "\n"); - } + return; } - - /* - * Define GridBagConstraints - */ - private void buildConstraints(GridBagConstraints gbc, int gx, int gy, int gw, int gh, int wx, int wy) { - gbc.gridx = gx; - gbc.gridy = gy; - gbc.gridwidth = gw; - gbc.gridheight = gh; - gbc.weightx = wx; - gbc.weighty = wy; + + // init + if (e.getSource() == initButton && config.getURI() != null) { + config.setKnowledgeSource(config.getComponentManager() + .knowledgeSource(sources.get(choosenClassIndex))); + config.getComponentManager().applyConfigEntry( + config.getKnowledgeSource(), "url", config.getURI()); + config.getKnowledgeSource().init(); + System.out.println("init KnowledgeSource with \n" + + sources.get(choosenClassIndex) + " and \n" + + config.getURI() + "\n"); } - - private void checkIfSparql() { - if (sources.get(choosenClassIndex).toString().contains("Sparql")) { - openButton.setEnabled(false); - infoLabel.setText("type URL"); - } - else { - openButton.setEnabled(true); - infoLabel.setText("choose local file or type URL"); - } + } + + /* + * Define GridBagConstraints + */ + private void buildConstraints(GridBagConstraints gbc, int gx, int gy, + int gw, int gh, int wx, int wy) { + gbc.gridx = gx; + gbc.gridy = gy; + gbc.gridwidth = gw; + gbc.gridheight = gh; + gbc.weightx = wx; + gbc.weighty = wy; + } + + private void checkIfSparql() { + if (sources.get(choosenClassIndex).toString().contains("Sparql")) { + openButton.setEnabled(false); + infoLabel.setText("type URL"); + } else { + openButton.setEnabled(true); + infoLabel.setText("choose local file or type URL"); } - + } + } Modified: trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.java 2008-01-28 22:16:24 UTC (rev 444) +++ trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.java 2008-01-28 23:32:48 UTC (rev 445) @@ -35,72 +35,69 @@ * */ public class LearningAlgorithmPanel extends JPanel implements ActionListener { - - private static final long serialVersionUID = 8721490771860452959L; + + private static final long serialVersionUID = 8721490771860452959L; private Config config; private List<Class<? extends LearningAlgorithm>> learners; - private JPanel choosePanel = new JPanel(); - private OptionPanel optionPanel; - private JPanel initPanel = new JPanel(); + private JPanel choosePanel = new JPanel(); + private OptionPanel optionPanel; + private JPanel initPanel = new JPanel(); private JButton initButton; private String[] cbItems = {}; - private JComboBox cb = new JComboBox(cbItems); - private int choosenClassIndex; + private JComboBox cb = new JComboBox(cbItems); + private int choosenClassIndex; - - LearningAlgorithmPanel(Config config) { - super(new BorderLayout()); + LearningAlgorithmPanel(Config config) { + super(new BorderLayout()); - this.config = config; - - initButton = new JButton("Init LearingAlgorithm"); - initButton.addActionListener(this); - - initPanel.add(initButton); + this.config = config; - choosePanel.add(cb); - - // add into comboBox - learners = config.getComponentManager().getLearningAlgorithms(); - for (int i=0; i<learners.size(); i++) { - cb.addItem(config.getComponentManager().getComponentName(learners.get(i))); - } - - cb.addActionListener(this); - - optionPanel = new OptionPanel(config, config.getLearningAlgorithm(), learners.get(choosenClassIndex)); - updateOptionPanel(); + initButton = new JButton("Init LearingAlgorithm"); + initButton.addActionListener(this); - - add(choosePanel, BorderLayout.PAGE_START); - add(initPanel, BorderLayout.CENTER); - add(optionPanel, BorderLayout.PAGE_END); - - } - + initPanel.add(initButton); - public void actionPerformed(ActionEvent e) { - // read selected Class - choosenClassIndex = cb.getSelectedIndex(); + choosePanel.add(cb); - updateOptionPanel(); - - // init - if (e.getSource() == initButton) { - if (config.getStatus(6)) { - config.setLearningAlgorithm(config.getComponentManager().learningAlgorithm(learners.get(choosenClassIndex), config.getLearningProblem(), config.getReasoningService())); - updateOptionPanel(); - config.getLearningAlgorithm().init(); - } - if (config.getStatus(5)) { // examples are set - System.out.println("LearningAlgorithm: " + config.getLearningAlgorithm() + "\n"); - } - } + // add into comboBox + learners = config.getComponentManager().getLearningAlgorithms(); + for (int i = 0; i < learners.size(); i++) { + cb.addItem(config.getComponentManager().getComponentName( + learners.get(i))); } - public void updateOptionPanel() { - // update OptionPanel - optionPanel.setComponent(config.getLearningAlgorithm()); - optionPanel.setComponentOption(learners.get(choosenClassIndex)); + cb.addActionListener(this); + + optionPanel = new OptionPanel(config, config.getLearningAlgorithm(), + learners.get(choosenClassIndex)); + updateOptionPanel(); + + add(choosePanel, BorderLayout.PAGE_START); + add(initPanel, BorderLayout.CENTER); + add(optionPanel, BorderLayout.PAGE_END); + + } + + public void actionPerformed(ActionEvent e) { + // read selected Class + choosenClassIndex = cb.getSelectedIndex(); + + updateOptionPanel(); + + // init + if (e.getSource() == initButton && config.getLearningProblem() != null) { + config.setLearningAlgorithm(config.getComponentManager() + .learningAlgorithm(learners.get(choosenClassIndex), + config.getLearningProblem(), + config.getReasoningService())); + updateOptionPanel(); + config.getLearningAlgorithm().init(); } + } + + public void updateOptionPanel() { + // update OptionPanel + optionPanel.setComponent(config.getLearningAlgorithm()); + optionPanel.setComponentOption(learners.get(choosenClassIndex)); + } } Modified: trunk/src/dl-learner/org/dllearner/gui/LearningProblemPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/LearningProblemPanel.java 2008-01-28 22:16:24 UTC (rev 444) +++ trunk/src/dl-learner/org/dllearner/gui/LearningProblemPanel.java 2008-01-28 23:32:48 UTC (rev 445) @@ -42,170 +42,175 @@ * LearningProblemPanel * * @author Tilo Hielscher - * */ - public class LearningProblemPanel extends JPanel implements ActionListener { - - private static final long serialVersionUID = -3819627680918930203L; - private List<Class<? extends LearningProblem>> problems; + private static final long serialVersionUID = -3819627680918930203L; + + private List<Class<? extends LearningProblem>> problems; private String[] lpBoxItems = {}; - private JComboBox cb = new JComboBox(lpBoxItems); - private JPanel choosePanel = new JPanel(); - private JPanel centerPanel = new JPanel(); - private JPanel lpPanel = new JPanel(); - private JLabel posLabel = new JLabel("positive Examples"); - private JLabel negLabel = new JLabel("negative Examples"); + private JComboBox cb = new JComboBox(lpBoxItems); + private JPanel choosePanel = new JPanel(); + private JPanel centerPanel = new JPanel(); + private JPanel lpPanel = new JPanel(); + private JLabel posLabel = new JLabel("positive Examples"); + private JLabel negLabel = new JLabel("negative Examples"); private JButton initButton, readListButton; - private int choosenClassIndex; + private int choosenClassIndex; private List<Individual> individuals; private JList posList = new JList(); private JList negList = new JList(); - + private Config config; - - LearningProblemPanel(final Config config) { - super(new BorderLayout()); - this.config = config; - - initButton = new JButton("Init LearningProblem"); - initButton.addActionListener(this); - - readListButton = new JButton("Read List"); - readListButton.addActionListener(this); - - choosePanel.add(cb); - choosePanel.add(readListButton); - lpPanel.add(initButton); - add(choosePanel, BorderLayout.PAGE_START); - add(centerPanel, BorderLayout.CENTER); - add(lpPanel, BorderLayout.PAGE_END); - - problems = config.getComponentManager().getLearningProblems(); - - // add into comboBox - for (int i=0; i<problems.size(); i++) { - //cb.addItem(problems.get(i).getSimpleName()); - cb.addItem(config.getComponentManager().getComponentName(problems.get(i))); - } - - // read choosen LearningProblem - choosenClassIndex = cb.getSelectedIndex(); - - // create a scrollable list of positive examples - posList = new JList(); - posList.setLayoutOrientation(JList.VERTICAL); - posList.setVisibleRowCount(-1); - JScrollPane posListScroller = new JScrollPane(posList); - posListScroller.setPreferredSize(new Dimension(300, 200)); - - // create a scrollable list of negative examples - negList = new JList(); - negList.setLayoutOrientation(JList.VERTICAL); - negList.setVisibleRowCount(-1); - JScrollPane negListScroller = new JScrollPane(negList); - negListScroller.setPreferredSize(new Dimension(300, 200)); - - // define GridBag - GridBagLayout gridbag = new GridBagLayout(); - centerPanel.setLayout(gridbag); - GridBagConstraints constraints = new GridBagConstraints(); - constraints.fill = GridBagConstraints.BOTH; - constraints.anchor = GridBagConstraints.CENTER; + LearningProblemPanel(final Config config) { + super(new BorderLayout()); - buildConstraints(constraints, 0, 0, 1, 1, 100, 100); - gridbag.setConstraints(posLabel, constraints); - centerPanel.add(posLabel); + this.config = config; - buildConstraints(constraints, 1, 0, 1, 1, 100, 100); - gridbag.setConstraints(negLabel, constraints); - centerPanel.add(negLabel); + initButton = new JButton("Init LearningProblem"); + initButton.addActionListener(this); - buildConstraints(constraints, 0, 1, 1, 1, 100, 100); - gridbag.setConstraints(posListScroller, constraints); - centerPanel.add(posListScroller); - - buildConstraints(constraints, 1, 1, 1, 1, 100, 100); - gridbag.setConstraints(negListScroller, constraints); - centerPanel.add(negListScroller); + readListButton = new JButton("Read List"); + readListButton.addActionListener(this); - add(centerPanel, BorderLayout.CENTER); - - // listener for posList - posList.addListSelectionListener(new ListSelectionListener() { - public void valueChanged(ListSelectionEvent evt) { - if (evt.getValueIsAdjusting()) - return; - // detect witch examples have been selected - Set<String> posExampleSet = new HashSet<String>(); - int[] selectedIndices = posList.getSelectedIndices(); - for(int i : selectedIndices) - posExampleSet.add(individuals.get(i).toString()); - config.setPosExampleSet(posExampleSet); - System.out.println("posList: " + config.getPosExampleSet() ); - } - }); - - // listener for negList - negList.addListSelectionListener(new ListSelectionListener() { - public void valueChanged(ListSelectionEvent evt) { - if (evt.getValueIsAdjusting()) - return; - // detect witch examples have been selected - Set<String> negExampleSet = new HashSet<String>(); - int[] selectedIndices = negList.getSelectedIndices(); - for(int i : selectedIndices) - negExampleSet.add(individuals.get(i).toString()); - config.setNegExampleSet(negExampleSet); - System.out.println("negList: " + config.getNegExampleSet() ); - } - }); + choosePanel.add(cb); + choosePanel.add(readListButton); + lpPanel.add(initButton); + add(choosePanel, BorderLayout.PAGE_START); + add(centerPanel, BorderLayout.CENTER); + add(lpPanel, BorderLayout.PAGE_END); + + problems = config.getComponentManager().getLearningProblems(); + + // add into comboBox + for (int i = 0; i < problems.size(); i++) { + // cb.addItem(problems.get(i).getSimpleName()); + cb.addItem(config.getComponentManager().getComponentName( + problems.get(i))); } - - public void actionPerformed(ActionEvent e) { - // read selected LearningProblemClass - choosenClassIndex = cb.getSelectedIndex(); - - // get list after reasoner init - if (e.getSource() == readListButton) { - // fill lists - if (config.getStatus(4)) { // only with a reasoner - Set<Individual> individualsSet = config.getReasoningService().getIndividuals(); - individuals = new LinkedList<Individual>(individualsSet); - DefaultListModel listModel = new DefaultListModel(); - for(Individual ind : individuals) { - listModel.addElement(ind); - } - posList.setModel(listModel); - negList.setModel(listModel); - } - } - - //init - if (e.getSource() == initButton) { - if (config.getStatus(5)) { - config.setLearningProblem(config.getComponentManager().learningProblem(problems.get(choosenClassIndex), config.getReasoningService())); - config.getComponentManager().applyConfigEntry(config.getLearningProblem(), "positiveExamples", config.getPosExampleSet()); - config.getComponentManager().applyConfigEntry(config.getLearningProblem(), "negativeExamples", config.getNegExampleSet()); - config.getLearningProblem().init(); - System.out.println("init LearningProblem with \n" + problems.get(choosenClassIndex) + "\nand " + "\nposExample: " - + config.getPosExampleSet() + "\nand negExample: " + config.getNegExampleSet()); - } - } + + // read choosen LearningProblem + choosenClassIndex = cb.getSelectedIndex(); + + // create a scrollable list of positive examples + posList = new JList(); + posList.setLayoutOrientation(JList.VERTICAL); + posList.setVisibleRowCount(-1); + JScrollPane posListScroller = new JScrollPane(posList); + posListScroller.setPreferredSize(new Dimension(300, 200)); + + // create a scrollable list of negative examples + negList = new JList(); + negList.setLayoutOrientation(JList.VERTICAL); + negList.setVisibleRowCount(-1); + JScrollPane negListScroller = new JScrollPane(negList); + negListScroller.setPreferredSize(new Dimension(300, 200)); + + // define GridBag + GridBagLayout gridbag = new GridBagLayout(); + centerPanel.setLayout(gridbag); + GridBagConstraints constraints = new GridBagConstraints(); + constraints.fill = GridBagConstraints.BOTH; + constraints.anchor = GridBagConstraints.CENTER; + + buildConstraints(constraints, 0, 0, 1, 1, 100, 100); + gridbag.setConstraints(posLabel, constraints); + centerPanel.add(posLabel); + + buildConstraints(constraints, 1, 0, 1, 1, 100, 100); + gridbag.setConstraints(negLabel, constraints); + centerPanel.add(negLabel); + + buildConstraints(constraints, 0, 1, 1, 1, 100, 100); + gridbag.setConstraints(posListScroller, constraints); + centerPanel.add(posListScroller); + + buildConstraints(constraints, 1, 1, 1, 1, 100, 100); + gridbag.setConstraints(negListScroller, constraints); + centerPanel.add(negListScroller); + + add(centerPanel, BorderLayout.CENTER); + + // listener for posList + posList.addListSelectionListener(new ListSelectionListener() { + public void valueChanged(ListSelectionEvent evt) { + if (evt.getValueIsAdjusting()) + return; + // detect witch examples have been selected + Set<String> posExampleSet = new HashSet<String>(); + int[] selectedIndices = posList.getSelectedIndices(); + for (int i : selectedIndices) + posExampleSet.add(individuals.get(i).toString()); + config.setPosExampleSet(posExampleSet); + } + }); + + // listener for negList + negList.addListSelectionListener(new ListSelectionListener() { + public void valueChanged(ListSelectionEvent evt) { + if (evt.getValueIsAdjusting()) + return; + // detect witch examples have been selected + Set<String> negExampleSet = new HashSet<String>(); + int[] selectedIndices = negList.getSelectedIndices(); + for (int i : selectedIndices) + negExampleSet.add(individuals.get(i).toString()); + config.setNegExampleSet(negExampleSet); + } + }); + } + + public void actionPerformed(ActionEvent e) { + // read selected LearningProblemClass + choosenClassIndex = cb.getSelectedIndex(); + + // get list after reasoner init + if (e.getSource() == readListButton + && config.getReasoningService() != null) { + // fill lists + Set<Individual> individualsSet = config.getReasoningService() + .getIndividuals(); + individuals = new LinkedList<Individual>(individualsSet); + DefaultListModel listModel = new DefaultListModel(); + for (Individual ind : individuals) { + listModel.addElement(ind); + } + posList.setModel(listModel); + negList.setModel(listModel); } - - /* - * Define GridBagConstraints - */ - private void buildConstraints(GridBagConstraints gbc, int gx, int gy, int gw, int gh, int wx, int wy) { - gbc.gridx = gx; - gbc.gridy = gy; - gbc.gridwidth = gw; - gbc.gridheight = gh; - gbc.weightx = wx; - gbc.weighty = wy; + + // init + if (e.getSource() == initButton + && config.getReasoningService() != null + && (config.getPosExampleSet().size() > 0 || config + .getNegExampleSet().size() > 0)) { + config.setLearningProblem(config.getComponentManager() + .learningProblem(problems.get(choosenClassIndex), + config.getReasoningService())); + config.getComponentManager().applyConfigEntry( + config.getLearningProblem(), "positiveExamples", + config.getPosExampleSet()); + config.getComponentManager().applyConfigEntry( + config.getLearningProblem(), "negativeExamples", + config.getNegExampleSet()); + config.getLearningProblem().init(); + System.out.println("init LearningProblem"); } - + + } + + /* + * Define GridBagConstraints + */ + private void buildConstraints(GridBagConstraints gbc, int gx, int gy, + int gw, int gh, int wx, int wy) { + gbc.gridx = gx; + gbc.gridy = gy; + gbc.gridwidth = gw; + gbc.gridheight = gh; + gbc.weightx = wx; + gbc.weighty = wy; + } + } Deleted: trunk/src/dl-learner/org/dllearner/gui/OutputPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/OutputPanel.java 2008-01-28 22:16:24 UTC (rev 444) +++ trunk/src/dl-learner/org/dllearner/gui/OutputPanel.java 2008-01-28 23:32:48 UTC (rev 445) @@ -1,100 +0,0 @@ -package org.dllearner.gui; - -/** - * Copyright (C) 2007-2008, 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/>. - * - */ - -import java.awt.BorderLayout; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; - -import javax.swing.*; - -import org.dllearner.core.dl.Concept; - -/** - * OutputPanel - * - * @author Tilo Hielscher - * - */ -public class OutputPanel extends JPanel implements ActionListener { - - private static final long serialVersionUID = 1643304576470046636L; - - private JButton showButton; - private JButton runButton; - private JTextArea infoArea; - private Config config; - - OutputPanel(Config config) { - super(new BorderLayout()); - - this.config = config; - - showButton = new JButton("Show Variables"); - showButton.addActionListener(this); - - runButton = new JButton("Run"); - runButton.addActionListener(this); - - infoArea = new JTextArea(20, 50); - JScrollPane infoScroll = new JScrollPane(infoArea); - - JPanel showPanel = new JPanel(); - showPanel.add(showButton); - showPanel.add(runButton); - JPanel infoPanel = new JPanel(); - infoPanel.add(infoScroll); - - add(showPanel, BorderLayout.PAGE_START); - add(infoPanel, BorderLayout.CENTER); - } - - public void actionPerformed(ActionEvent e) { - if (e.getSource() == showButton) { - infoArea.setText(""); - if (config.getStatus(1)) { // kb is set - infoArea.append("SourceClass: " + config.getKnowledgeSource().toString() + "\n"); - } - if (config.getStatus(2)) { // file is set - infoArea.append("URI: " + config.getURI() + "\n"); - } - if (config.getStatus(3)) { // Reasoner is set - infoArea.append("Reasoner: " + config.getReasoner() + "\n"); - } - if (config.getStatus(4)) { // ReasoningServic is set - infoArea.append("ReasoningService: " + config.getReasoningService() + "\n"); - } - if (false) { - for (int i = 0; i<8; i++) { // show status-vars - infoArea.append("i: " + config.getStatus(i) + "\n"); - } - } - } - - if (e.getSource() == runButton) { - if (config.getStatus(6)) { - config.getLearningAlgorithm().start(); - Concept solution = config.getLearningAlgorithm().getBestSolution(); - infoArea.setText(solution.toString()); - } - } - } -} Modified: trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java 2008-01-28 22:16:24 UTC (rev 444) +++ trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java 2008-01-28 23:32:48 UTC (rev 445) @@ -29,7 +29,6 @@ import org.dllearner.core.ReasonerComponent; - /** * ReasonerPanel * @@ -37,60 +36,56 @@ * */ public class ReasonerPanel extends JPanel implements ActionListener { - - private static final long serialVersionUID = -7678275020058043937L; - private List<Class<? extends ReasonerComponent>> reasoners; - private JPanel choosePanel = new JPanel(); - private JPanel initPanel = new JPanel(); + private static final long serialVersionUID = -7678275020058043937L; + + private List<Class<? extends ReasonerComponent>> reasoners; + private JPanel choosePanel = new JPanel(); + private JPanel initPanel = new JPanel(); private JButton initButton; private Config config; private String[] cbItems = {}; - private JComboBox cb = new JComboBox(cbItems); - private int choosenClassIndex; - - ReasonerPanel(final Config config) { - super(new BorderLayout()); - - this.config = config; - - initButton = new JButton("Init Reasoner"); - initButton.addActionListener(this); - initPanel.add(initButton); - - choosePanel.add(cb); - - add(choosePanel, BorderLayout.PAGE_START); - add(initPanel, BorderLayout.PAGE_END); - - // add into comboBox - reasoners = config.getComponentManager().getReasonerComponents(); - for (int i=0; i<reasoners.size(); i++) { - //cb.addItem(reasoners.get(i).getSimpleName()); - cb.addItem(config.getComponentManager().getComponentName(reasoners.get(i))); - } + private JComboBox cb = new JComboBox(cbItems); + private int choosenClassIndex; + ReasonerPanel(final Config config) { + super(new BorderLayout()); + + this.config = config; + + initButton = new JButton("Init Reasoner"); + initButton.addActionListener(this); + initPanel.add(initButton); + + choosePanel.add(cb); + + add(choosePanel, BorderLayout.PAGE_START); + add(initPanel, BorderLayout.PAGE_END); + + // add into comboBox + reasoners = config.getComponentManager().getReasonerComponents(); + for (int i = 0; i < reasoners.size(); i++) { + // cb.addItem(reasoners.get(i).getSimpleName()); + cb.addItem(config.getComponentManager().getComponentName( + reasoners.get(i))); } - - public void actionPerformed(ActionEvent e) { - // read selected Class - choosenClassIndex = cb.getSelectedIndex(); - - if (e.getSource() == initButton) { - if (config.getStatus(2)) { // no check if button initKnowledgeSource was pressed - // set reasoner - config.setReasoner(config.getComponentManager().reasoner(reasoners.get(choosenClassIndex), config.getKnowledgeSource())); - config.getReasoner().init(); - - // set ReasoningService - config.setReasoningService(config.getComponentManager().reasoningService(config.getReasoner())); - } - if (config.getStatus(3)) { // Reasoner is set - System.out.println("Reasoner: " + config.getReasoner()); - } - if (config.getStatus(4)) { // ReasoningServic is set - System.out.println("ReasoningService: " + config.getReasoningService()); - } - } + + } + + public void actionPerformed(ActionEvent e) { + // read selected Class + choosenClassIndex = cb.getSelectedIndex(); + + if (e.getSource() == initButton && config.getKnowledgeSource() != null) { + // set reasoner + config.setReasoner(config.getComponentManager().reasoner( + reasoners.get(choosenClassIndex), + config.getKnowledgeSource())); + config.getReasoner().init(); + + // set ReasoningService + config.setReasoningService(config.getComponentManager() + .reasoningService(config.getReasoner())); } + } } Added: trunk/src/dl-learner/org/dllearner/gui/RunPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/RunPanel.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/gui/RunPanel.java 2008-01-28 23:32:48 UTC (rev 445) @@ -0,0 +1,72 @@ +package org.dllearner.gui; + +/** + * Copyright (C) 2007-2008, 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/>. + * + */ + +import java.awt.BorderLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +import javax.swing.*; + +import org.dllearner.core.dl.Concept; + +/** + * OutputPanel + * + * @author Tilo Hielscher + * + */ +public class RunPanel extends JPanel implements ActionListener { + + private static final long serialVersionUID = 1643304576470046636L; + + private JButton runButton; + private JTextArea infoArea; + private Config config; + + RunPanel(Config config) { + super(new BorderLayout()); + + this.config = config; + + runButton = new JButton("Run"); + runButton.addActionListener(this); + + infoArea = new JTextArea(20, 50); + JScrollPane infoScroll = new JScrollPane(infoArea); + + JPanel showPanel = new JPanel(); + showPanel.add(runButton); + JPanel infoPanel = new JPanel(); + infoPanel.add(infoScroll); + + add(showPanel, BorderLayout.PAGE_START); + add(infoPanel, BorderLayout.CENTER); + } + + public void actionPerformed(ActionEvent e) { + if (e.getSource() == runButton && config.getLearningAlgorithm() != null) { + config.getLearningAlgorithm().start(); + Concept solution = config.getLearningAlgorithm().getBestSolution(); + infoArea.setText(solution.toString()); + } + } +} Modified: trunk/src/dl-learner/org/dllearner/gui/StartGUI.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/StartGUI.java 2008-01-28 22:16:24 UTC (rev 444) +++ trunk/src/dl-learner/org/dllearner/gui/StartGUI.java 2008-01-28 23:32:48 UTC (rev 445) @@ -35,52 +35,51 @@ */ public class StartGUI extends JFrame { - - private static final long serialVersionUID = -739265982906533775L; - - public JTabbedPane tabPane = new JTabbedPane(); - - private JPanel tab1 = new JPanel(); - private JPanel tab2 = new JPanel(); - private JPanel tab3 = new JPanel(); - private JPanel tab4 = new JPanel(); - private JPanel tab5 = new JPanel(); - public StartGUI() { - Config config = new Config(); - this.setTitle("DL-Learner GUI"); - this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); - this.setLocationByPlatform(true); - this.setSize(800, 600); - tab1.add(new KnowledgeSourcePanel(config)); - tab2.add(new ReasonerPanel(config)); - tab3.add(new LearningProblemPanel(config)); - tab4.add(new LearningAlgorithmPanel(config)); - tab5.add(new OutputPanel(config)); - tabPane.addTab("Knowledge Source", tab1); - tabPane.addTab("Reasoner", tab2); - tabPane.addTab("Learning Problem", tab3); - tabPane.addTab("Learning Algorithm", tab4); - tabPane.addTab("Output", tab5); - this.add(tabPane); - this.setVisible(true); - } - - public static void main(String[] args) { - // create GUI logger - SimpleLayout layout = new SimpleLayout(); - ConsoleAppender consoleAppender = new ConsoleAppender(layout); - Logger logger = Logger.getRootLogger(); - logger.removeAllAppenders(); - logger.addAppender(consoleAppender); - logger.setLevel(Level.INFO); - - new StartGUI(); - } - - protected void renew() { - tabPane.repaint(); - } + private static final long serialVersionUID = -739265982906533775L; + public JTabbedPane tabPane = new JTabbedPane(); + private JPanel tab1 = new JPanel(); + private JPanel tab2 = new JPanel(); + private JPanel tab3 = new JPanel(); + private JPanel tab4 = new JPanel(); + private JPanel tab5 = new JPanel(); + + public StartGUI() { + Config config = new Config(); + this.setTitle("DL-Learner GUI"); + this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + this.setLocationByPlatform(true); + this.setSize(800, 600); + tab1.add(new KnowledgeSourcePanel(config)); + tab2.add(new ReasonerPanel(config)); + tab3.add(new LearningProblemPanel(config)); + tab4.add(new LearningAlgorithmPanel(config)); + tab5.add(new RunPanel(config)); + tabPane.addTab("Knowledge Source", tab1); + tabPane.addTab("Reasoner", tab2); + tabPane.addTab("Learning Problem", tab3); + tabPane.addTab("Learning Algorithm", tab4); + tabPane.addTab("Run", tab5); + this.add(tabPane); + this.setVisible(true); + } + + public static void main(String[] args) { + // create GUI logger + SimpleLayout layout = new SimpleLayout(); + ConsoleAppender consoleAppender = new ConsoleAppender(layout); + Logger logger = Logger.getRootLogger(); + logger.removeAllAppenders(); + logger.addAppender(consoleAppender); + logger.setLevel(Level.INFO); + + new StartGUI(); + } + + protected void renew() { + tabPane.repaint(); + } + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ton...@us...> - 2008-01-28 22:16:28
|
Revision: 444 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=444&view=rev Author: tonytacker Date: 2008-01-28 14:16:24 -0800 (Mon, 28 Jan 2008) Log Message: ----------- changed copyright, add check for init in KnowledgeSourcePanel, switched option and init-button in LearningAlgorithmPanel Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/gui/Config.java trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.java trunk/src/dl-learner/org/dllearner/gui/LearningProblemPanel.java trunk/src/dl-learner/org/dllearner/gui/MiniGUI.java trunk/src/dl-learner/org/dllearner/gui/OptionPanel.java trunk/src/dl-learner/org/dllearner/gui/OutputPanel.java trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java trunk/src/dl-learner/org/dllearner/gui/StartGUI.java trunk/src/dl-learner/org/dllearner/gui/WidgetPanelDefault.java trunk/src/dl-learner/org/dllearner/gui/WidgetPanelInteger.java Removed Paths: ------------- trunk/src/dl-learner/org/dllearner/gui/ComponentRetrievalTest.java Deleted: trunk/src/dl-learner/org/dllearner/gui/ComponentRetrievalTest.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/ComponentRetrievalTest.java 2008-01-28 19:15:03 UTC (rev 443) +++ trunk/src/dl-learner/org/dllearner/gui/ComponentRetrievalTest.java 2008-01-28 22:16:24 UTC (rev 444) @@ -1,60 +0,0 @@ -/** - * Copyright (C) 2007, 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.gui; - -import java.util.List; - -import org.dllearner.core.ComponentManager; -import org.dllearner.core.KnowledgeSource; -import org.dllearner.core.config.ConfigEntry; -import org.dllearner.core.config.InvalidConfigOptionValueException; -import org.dllearner.core.config.StringConfigOption; -import org.dllearner.kb.OWLFile; - -/** - * @author Jens Lehmann - * - */ -public class ComponentRetrievalTest { - - /** - * @param args - */ - public static void main(String[] args) { - // example 1: getting all components of a given type - ComponentManager cm = ComponentManager.getInstance(); - List<Class<? extends KnowledgeSource>> sources = cm.getKnowledgeSources(); - cm.knowledgeSource(sources.get(0)); - System.out.println(sources.get(1).toString()); - - // example 2: setting a config value using a ConfigEntry object - KnowledgeSource owlFile = cm.knowledgeSource(OWLFile.class); - StringConfigOption urlOption = (StringConfigOption) cm.getConfigOption(OWLFile.class, "url"); - ConfigEntry<String> urlEntry; - try { - urlEntry = new ConfigEntry<String>(urlOption, "http://example.com"); - cm.applyConfigEntry(owlFile, urlEntry); - } catch (InvalidConfigOptionValueException e) { - e.printStackTrace(); - } - - } - -} Modified: trunk/src/dl-learner/org/dllearner/gui/Config.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/Config.java 2008-01-28 19:15:03 UTC (rev 443) +++ trunk/src/dl-learner/org/dllearner/gui/Config.java 2008-01-28 22:16:24 UTC (rev 444) @@ -1,7 +1,7 @@ package org.dllearner.gui; /** - * Copyright (C) 2007, Jens Lehmann + * Copyright (C) 2007-2008, Jens Lehmann * * This file is part of DL-Learner. * @@ -21,8 +21,8 @@ */ import java.util.HashSet; +import java.util.List; import java.util.Set; -//import java.io.File; import org.dllearner.core.ComponentManager; import org.dllearner.core.KnowledgeSource; @@ -30,7 +30,9 @@ import org.dllearner.core.LearningProblem; import org.dllearner.core.ReasonerComponent; import org.dllearner.core.ReasoningService; +import org.dllearner.core.config.ConfigOption; + /** * config * @@ -51,6 +53,8 @@ private LearningProblem lp; private LearningAlgorithm la; + private List<ConfigOption<?>> optionLearningAlgorithm ; + /** * status should show witch variables are set * status[0] ... cm Modified: trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java 2008-01-28 19:15:03 UTC (rev 443) +++ trunk/src/dl-learner/org/dllearner/gui/KnowledgeSourcePanel.java 2008-01-28 22:16:24 UTC (rev 444) @@ -1,7 +1,7 @@ package org.dllearner.gui; /** - * Copyright (C) 2007, Jens Lehmann + * Copyright (C) 2007-2008, Jens Lehmann * * This file is part of DL-Learner. * @@ -41,7 +41,6 @@ * @author Tilo Hielscher * */ - public class KnowledgeSourcePanel extends JPanel implements ActionListener { private static final long serialVersionUID = -7678275020058043937L; @@ -129,24 +128,24 @@ } public void actionPerformed(ActionEvent e) { - // read selected KnowledgeSourceClass - choosenClassIndex = cb.getSelectedIndex(); - checkIfSparql(); + // read selected KnowledgeSourceClass + choosenClassIndex = cb.getSelectedIndex(); + checkIfSparql(); - // open File - if (e.getSource() == openButton) { - int returnVal = fc.showOpenDialog(KnowledgeSourcePanel.this); - if (returnVal == JFileChooser.APPROVE_OPTION) { - String URI = "file://"; - URI = URI.concat(fc.getSelectedFile().toString()); // make "file://" before local URI - config.setURI(URI); //save variable - fileDisplay.setText(URI); - } - return; + // open File + if (e.getSource() == openButton) { + int returnVal = fc.showOpenDialog(KnowledgeSourcePanel.this); + if (returnVal == JFileChooser.APPROVE_OPTION) { + String URI = "file://"; + URI = URI.concat(fc.getSelectedFile().toString()); // make "file://" before local URI + config.setURI(URI); //save variable + fileDisplay.setText(URI); } + return; + } // init - if (e.getSource() == initButton) { + if (e.getSource() == initButton && config.getStatus(2)) { config.setKnowledgeSource(config.getComponentManager().knowledgeSource(sources.get(choosenClassIndex))); config.getComponentManager().applyConfigEntry(config.getKnowledgeSource(), "url", config.getURI()); config.getKnowledgeSource().init(); Modified: trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.java 2008-01-28 19:15:03 UTC (rev 443) +++ trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.java 2008-01-28 22:16:24 UTC (rev 444) @@ -1,7 +1,7 @@ package org.dllearner.gui; /** - * Copyright (C) 2007, Jens Lehmann + * Copyright (C) 2007-2008, Jens Lehmann * * This file is part of DL-Learner. * @@ -19,7 +19,6 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. * */ - import javax.swing.*; import java.awt.BorderLayout; @@ -29,15 +28,12 @@ import org.dllearner.core.LearningAlgorithm; - - /** * LearningAlgorithmPanel * * @author Tilo Hielscher * */ - public class LearningAlgorithmPanel extends JPanel implements ActionListener { private static final long serialVersionUID = 8721490771860452959L; @@ -50,9 +46,8 @@ private String[] cbItems = {}; private JComboBox cb = new JComboBox(cbItems); private int choosenClassIndex; + - - LearningAlgorithmPanel(Config config) { super(new BorderLayout()); @@ -68,8 +63,6 @@ // add into comboBox learners = config.getComponentManager().getLearningAlgorithms(); for (int i=0; i<learners.size(); i++) { - //cb.addItem(learners.get(i).getSimpleName()); - //System.out.println(learners.get(i).getSimpleName()); cb.addItem(config.getComponentManager().getComponentName(learners.get(i))); } @@ -80,8 +73,9 @@ add(choosePanel, BorderLayout.PAGE_START); - add(optionPanel, BorderLayout.CENTER); - add(initPanel, BorderLayout.PAGE_END); + add(initPanel, BorderLayout.CENTER); + add(optionPanel, BorderLayout.PAGE_END); + } Modified: trunk/src/dl-learner/org/dllearner/gui/LearningProblemPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/LearningProblemPanel.java 2008-01-28 19:15:03 UTC (rev 443) +++ trunk/src/dl-learner/org/dllearner/gui/LearningProblemPanel.java 2008-01-28 22:16:24 UTC (rev 444) @@ -1,7 +1,7 @@ package org.dllearner.gui; /** - * Copyright (C) 2007, Jens Lehmann + * Copyright (C) 2007-2008, Jens Lehmann * * This file is part of DL-Learner. * Modified: trunk/src/dl-learner/org/dllearner/gui/MiniGUI.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/MiniGUI.java 2008-01-28 19:15:03 UTC (rev 443) +++ trunk/src/dl-learner/org/dllearner/gui/MiniGUI.java 2008-01-28 22:16:24 UTC (rev 444) @@ -1,5 +1,5 @@ /** - * Copyright (C) 2007, Jens Lehmann + * Copyright (C) 2007-2008, Jens Lehmann * * This file is part of DL-Learner. * Modified: trunk/src/dl-learner/org/dllearner/gui/OptionPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/OptionPanel.java 2008-01-28 19:15:03 UTC (rev 443) +++ trunk/src/dl-learner/org/dllearner/gui/OptionPanel.java 2008-01-28 22:16:24 UTC (rev 444) @@ -1,7 +1,7 @@ package org.dllearner.gui; /** - * Copyright (C) 2007, Jens Lehmann + * Copyright (C) 2007-2008, Jens Lehmann * * This file is part of DL-Learner. * @@ -72,6 +72,9 @@ add(centerScroller, BorderLayout.CENTER); showWidgets(); + + System.out.println("AAA: " + ComponentManager.getConfigOptions(componentOption)); + } public void setComponent (Component component) { Modified: trunk/src/dl-learner/org/dllearner/gui/OutputPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/OutputPanel.java 2008-01-28 19:15:03 UTC (rev 443) +++ trunk/src/dl-learner/org/dllearner/gui/OutputPanel.java 2008-01-28 22:16:24 UTC (rev 444) @@ -1,7 +1,7 @@ package org.dllearner.gui; /** - * Copyright (C) 2007, Jens Lehmann + * Copyright (C) 2007-2008, Jens Lehmann * * This file is part of DL-Learner. * @@ -34,7 +34,6 @@ * @author Tilo Hielscher * */ - public class OutputPanel extends JPanel implements ActionListener { private static final long serialVersionUID = 1643304576470046636L; Modified: trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java 2008-01-28 19:15:03 UTC (rev 443) +++ trunk/src/dl-learner/org/dllearner/gui/ReasonerPanel.java 2008-01-28 22:16:24 UTC (rev 444) @@ -1,7 +1,7 @@ package org.dllearner.gui; /** - * Copyright (C) 2007, Jens Lehmann + * Copyright (C) 2007-2008, Jens Lehmann * * This file is part of DL-Learner. * Modified: trunk/src/dl-learner/org/dllearner/gui/StartGUI.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/StartGUI.java 2008-01-28 19:15:03 UTC (rev 443) +++ trunk/src/dl-learner/org/dllearner/gui/StartGUI.java 2008-01-28 22:16:24 UTC (rev 444) @@ -1,7 +1,7 @@ package org.dllearner.gui; /** - * Copyright (C) 2007, Jens Lehmann + * Copyright (C) 2007-2008, Jens Lehmann * * This file is part of DL-Learner. * Modified: trunk/src/dl-learner/org/dllearner/gui/WidgetPanelDefault.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/WidgetPanelDefault.java 2008-01-28 19:15:03 UTC (rev 443) +++ trunk/src/dl-learner/org/dllearner/gui/WidgetPanelDefault.java 2008-01-28 22:16:24 UTC (rev 444) @@ -1,7 +1,7 @@ package org.dllearner.gui; /** - * Copyright (C) 2007, Jens Lehmann + * Copyright (C) 2007-2008, Jens Lehmann * * This file is part of DL-Learner. * Modified: trunk/src/dl-learner/org/dllearner/gui/WidgetPanelInteger.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/WidgetPanelInteger.java 2008-01-28 19:15:03 UTC (rev 443) +++ trunk/src/dl-learner/org/dllearner/gui/WidgetPanelInteger.java 2008-01-28 22:16:24 UTC (rev 444) @@ -1,7 +1,7 @@ package org.dllearner.gui; /** - * Copyright (C) 2007, Jens Lehmann + * Copyright (C) 2007-2008, Jens Lehmann * * This file is part of DL-Learner. * @@ -140,7 +140,7 @@ try { ConfigEntry<Integer> specialEntry = new ConfigEntry<Integer>(specialOption, value); //System.out.println("set Integer specialEntry: " + specialEntry); - //System.out.println("set Integer component: " + component); + System.out.println("set Integer component: " + component); //System.out.println("set Integer componentOption: " + componentOption); //System.out.println("set Integer config.getComponentManager().getConfigOptionValue(component, name): " + config.getComponentManager().getConfigOptionValue(component, name)); config.getComponentManager().applyConfigEntry(component, specialEntry); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2008-01-28 19:15:11
|
Revision: 443 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=443&view=rev Author: jenslehmann Date: 2008-01-28 11:15:03 -0800 (Mon, 28 Jan 2008) Log Message: ----------- - fixed useRetrievalForClassification option - fixed warnings Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/cli/Start.java trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlKnowledgeSource.java trunk/src/dl-learner/org/dllearner/learningproblems/PosNegDefinitionLP.java trunk/src/dl-learner/org/dllearner/learningproblems/PosNegLP.java Modified: trunk/src/dl-learner/org/dllearner/cli/Start.java =================================================================== --- trunk/src/dl-learner/org/dllearner/cli/Start.java 2008-01-28 18:28:59 UTC (rev 442) +++ trunk/src/dl-learner/org/dllearner/cli/Start.java 2008-01-28 19:15:03 UTC (rev 443) @@ -92,6 +92,8 @@ */ public class Start { + private static Logger logger = Logger.getRootLogger(); + /** * Entry point for CLI interface. * @@ -109,7 +111,6 @@ // its messages to the console) SimpleLayout layout = new SimpleLayout(); ConsoleAppender consoleAppender = new ConsoleAppender(layout); - Logger logger = Logger.getRootLogger(); logger.removeAllAppenders(); logger.addAppender(consoleAppender); logger.setLevel(Level.INFO); @@ -287,7 +288,7 @@ // the name of the option is suboption-part (the first part refers // to its component) String optionName = option.getSubOption(); - + ConfigOption<?> configOption = cm.getConfigOption(component.getClass(), optionName); // check whether such an option exists if (configOption != null) { @@ -522,8 +523,8 @@ } private static void initComponent(ComponentManager cm, Component component) { - System.out.print("initialising component \"" + cm.getComponentName(component.getClass()) - + "\" ... "); + String startMessage = "initialising component \"" + cm.getComponentName(component.getClass()) + + "\" ... "; long initStartTime = System.nanoTime(); component.init(); // standard messsage is just "OK" but can be more detailed for certain @@ -538,7 +539,7 @@ } long initTime = System.nanoTime() - initStartTime; - System.out.println(message + " (" + Helper.prettyPrintNanoSeconds(initTime, false, false) + logger.info(startMessage + message + " (" + Helper.prettyPrintNanoSeconds(initTime, false, false) + ")"); } Modified: trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlKnowledgeSource.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlKnowledgeSource.java 2008-01-28 18:28:59 UTC (rev 442) +++ trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlKnowledgeSource.java 2008-01-28 19:15:03 UTC (rev 443) @@ -25,12 +25,9 @@ import java.net.URI; import java.net.URL; import java.util.Collection; -import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.LinkedList; -import java.util.Map; -import java.util.Random; import java.util.Set; import org.apache.log4j.Logger; @@ -64,7 +61,6 @@ */ public class SparqlKnowledgeSource extends KnowledgeSource { - private Map<Integer, String[][]> queryResult = new HashMap<Integer, String[][]>(); // ConfigOptions public URL url; // String host; Modified: trunk/src/dl-learner/org/dllearner/learningproblems/PosNegDefinitionLP.java =================================================================== --- trunk/src/dl-learner/org/dllearner/learningproblems/PosNegDefinitionLP.java 2008-01-28 18:28:59 UTC (rev 442) +++ trunk/src/dl-learner/org/dllearner/learningproblems/PosNegDefinitionLP.java 2008-01-28 19:15:03 UTC (rev 443) @@ -19,12 +19,14 @@ */ package org.dllearner.learningproblems; +import java.util.Collection; import java.util.Set; import java.util.SortedSet; import java.util.TreeSet; import org.dllearner.core.ReasoningService; import org.dllearner.core.Score; +import org.dllearner.core.config.ConfigOption; import org.dllearner.core.dl.Concept; import org.dllearner.core.dl.Individual; import org.dllearner.utilities.Helper; @@ -63,6 +65,10 @@ return "two valued definition learning problem"; } + public static Collection<ConfigOption<?>> createConfigOptions() { + return PosNegLP.createConfigOptions(); + } + /** * This method computes (using the reasoner) whether a concept is too weak. * If it is not weak, it returns the number of covered negative example. It Modified: trunk/src/dl-learner/org/dllearner/learningproblems/PosNegLP.java =================================================================== --- trunk/src/dl-learner/org/dllearner/learningproblems/PosNegLP.java 2008-01-28 18:28:59 UTC (rev 442) +++ trunk/src/dl-learner/org/dllearner/learningproblems/PosNegLP.java 2008-01-28 19:15:03 UTC (rev 443) @@ -112,9 +112,9 @@ else if (name.equals("negativeExamples")) negativeExamples = CommonConfigMappings .getIndividualSet((Set<String>) entry.getValue()); - else if (name.equals("useRetrievalForClassification")) + else if (name.equals("useRetrievalForClassficiation")) { useRetrievalForClassification = (Boolean) entry.getValue(); - else if (name.equals("percentPerLengthUnit")) + } else if (name.equals("percentPerLengthUnit")) percentPerLengthUnit = (Double) entry.getValue(); else if (name.equals("useMultiInstanceChecks")) { String value = (String) entry.getValue(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2008-01-28 18:29:03
|
Revision: 442 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=442&view=rev Author: jenslehmann Date: 2008-01-28 10:28:59 -0800 (Mon, 28 Jan 2008) Log Message: ----------- - resurrected and extented the fast retrieval reasoner algorithm; extremely fast reasoning, reasonably correct instance checks, often incorrect subsumption checks - add reasoner = fastRetrieval in the conf files to use it Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/cli/Start.java trunk/src/dl-learner/org/dllearner/reasoning/FastRetrieval.java trunk/src/dl-learner/org/dllearner/reasoning/FastRetrievalReasoner.java Modified: trunk/src/dl-learner/org/dllearner/cli/Start.java =================================================================== --- trunk/src/dl-learner/org/dllearner/cli/Start.java 2008-01-28 17:10:02 UTC (rev 441) +++ trunk/src/dl-learner/org/dllearner/cli/Start.java 2008-01-28 18:28:59 UTC (rev 442) @@ -76,6 +76,7 @@ import org.dllearner.parser.ParseException; import org.dllearner.parser.TokenMgrError; import org.dllearner.reasoning.DIGReasoner; +import org.dllearner.reasoning.FastRetrievalReasoner; import org.dllearner.reasoning.OWLAPIReasoner; import org.dllearner.utilities.ConceptComparator; import org.dllearner.utilities.Datastructures; @@ -150,9 +151,11 @@ reasonerClass = DIGReasoner.class; else if(reasonerOption.getStringValue().equals("owlAPI")) reasonerClass = OWLAPIReasoner.class; + else if(reasonerOption.getStringValue().equals("fastRetrieval")) + reasonerClass = FastRetrievalReasoner.class; else { handleError("Unknown value " + reasonerOption.getStringValue() - + "for option \"reasoner\"."); + + " for option \"reasoner\"."); } ReasonerComponent reasoner = cm.reasoner(reasonerClass, sources); configureComponent(cm, reasoner, componentPrefixMapping, parser); Modified: trunk/src/dl-learner/org/dllearner/reasoning/FastRetrieval.java =================================================================== --- trunk/src/dl-learner/org/dllearner/reasoning/FastRetrieval.java 2008-01-28 17:10:02 UTC (rev 441) +++ trunk/src/dl-learner/org/dllearner/reasoning/FastRetrieval.java 2008-01-28 18:28:59 UTC (rev 442) @@ -12,6 +12,8 @@ import org.dllearner.core.dl.Disjunction; import org.dllearner.core.dl.Exists; import org.dllearner.core.dl.FlatABox; +import org.dllearner.core.dl.MultiConjunction; +import org.dllearner.core.dl.MultiDisjunction; import org.dllearner.core.dl.Negation; import org.dllearner.core.dl.Top; import org.dllearner.utilities.Helper; @@ -46,6 +48,20 @@ return calculateConjunctionSets(calculateSetsADC(concept.getChild(0),adcSet),calculateSetsADC(concept.getChild(1),adcSet)); } else if(concept instanceof Disjunction) { return calculateDisjunctionSets(calculateSetsADC(concept.getChild(0),adcSet),calculateSetsADC(concept.getChild(1),adcSet)); + } else if(concept instanceof MultiConjunction) { + SortedSetTuple<String> res = + calculateConjunctionSets(calculateSetsADC(concept.getChild(0),adcSet),calculateSetsADC(concept.getChild(1),adcSet)); + for(int i=2; i < concept.getChildren().size(); i++) { + res = calculateConjunctionSets(res,calculateSetsADC(concept.getChild(i),adcSet)); + } + return res; + } else if(concept instanceof MultiDisjunction) { + SortedSetTuple<String> res = + calculateDisjunctionSets(calculateSetsADC(concept.getChild(0),adcSet),calculateSetsADC(concept.getChild(1),adcSet)); + for(int i=2; i < concept.getChildren().size(); i++) { + res = calculateDisjunctionSets(res,calculateSetsADC(concept.getChild(i),adcSet)); + } + return res; } else if(concept instanceof All) { return calculateAllSet(abox,((All)concept).getRole().getName(),calculateSetsADC(concept.getChild(0),adcSet)); } else if(concept instanceof Exists) { Modified: trunk/src/dl-learner/org/dllearner/reasoning/FastRetrievalReasoner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/reasoning/FastRetrievalReasoner.java 2008-01-28 17:10:02 UTC (rev 441) +++ trunk/src/dl-learner/org/dllearner/reasoning/FastRetrievalReasoner.java 2008-01-28 18:28:59 UTC (rev 442) @@ -5,14 +5,21 @@ import java.util.SortedSet; import java.util.TreeSet; +import org.dllearner.core.KnowledgeSource; import org.dllearner.core.ReasonerComponent; +import org.dllearner.core.ReasoningMethodUnsupportedException; +import org.dllearner.core.ReasoningService; import org.dllearner.core.config.ConfigEntry; import org.dllearner.core.config.InvalidConfigOptionValueException; import org.dllearner.core.dl.AtomicConcept; import org.dllearner.core.dl.AtomicRole; import org.dllearner.core.dl.Concept; +import org.dllearner.core.dl.Conjunction; import org.dllearner.core.dl.FlatABox; import org.dllearner.core.dl.Individual; +import org.dllearner.core.dl.Negation; +import org.dllearner.core.dl.RoleHierarchy; +import org.dllearner.core.dl.SubsumptionHierarchy; import org.dllearner.utilities.Helper; import org.dllearner.utilities.SortedSetTuple; @@ -24,6 +31,25 @@ Set<AtomicRole> atomicRoles; SortedSet<Individual> individuals; + ReasoningService rs; + ReasonerComponent rc; + + public FastRetrievalReasoner(Set<KnowledgeSource> sources) { + rc = new DIGReasoner(sources); + rc.init(); + atomicConcepts = rc.getAtomicConcepts(); + atomicRoles = rc.getAtomicRoles(); + individuals = rc.getIndividuals(); + rs = new ReasoningService(rc); + try { + abox = Helper.createFlatABox(rs); + } catch (ReasoningMethodUnsupportedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + fastRetrieval = new FastRetrieval(abox); + } + public FastRetrievalReasoner(FlatABox abox) { this.abox = abox; fastRetrieval = new FastRetrieval(abox); @@ -79,10 +105,43 @@ return abox; } + // C \sqsubseteq D is rewritten to a retrieval for \not C \sqcap D + @Override + public boolean subsumes(Concept superConcept, Concept subConcept) { + Negation neg = new Negation(subConcept); + Conjunction c = new Conjunction(neg,superConcept); + return fastRetrieval.calculateSets(c).getPosSet().isEmpty(); + } + + @Override + public void prepareRoleHierarchy(Set<AtomicRole> allowedRoles) { + rs.prepareRoleHierarchy(allowedRoles); + } + + @Override + public RoleHierarchy getRoleHierarchy() { + return rs.getRoleHierarchy(); + } + public void prepareSubsumptionHierarchy(Set<AtomicConcept> allowedConcepts) { - // hier muss nichts getan werden + rs.prepareSubsumptionHierarchy(allowedConcepts); } + @Override + public SubsumptionHierarchy getSubsumptionHierarchy() { + return rs.getSubsumptionHierarchy(); + } + + @Override + public boolean isSatisfiable() { + return rs.isSatisfiable(); + } + + @Override + public boolean instanceCheck(Concept concept, Individual individual) { + return fastRetrieval.calculateSets(concept).getPosSet().contains(individual.getName()); + } + public static String getName() { return "fast retrieval reasoner"; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sk...@us...> - 2008-01-28 17:10:14
|
Revision: 441 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=441&view=rev Author: sknappe Date: 2008-01-28 09:10:02 -0800 (Mon, 28 Jan 2008) Log Message: ----------- changed the SparqlQuery mechanism Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlKnowledgeSource.java trunk/src/dl-learner/org/dllearner/kb/sparql/query/CachedSparqlQuery.java trunk/src/dl-learner/org/dllearner/kb/sparql/query/SparqlQuery.java trunk/src/dl-learner/org/dllearner/server/ClientState.java trunk/src/dl-learner/org/dllearner/server/DLLearnerWS.java Modified: trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlKnowledgeSource.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlKnowledgeSource.java 2008-01-28 16:05:10 UTC (rev 440) +++ trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlKnowledgeSource.java 2008-01-28 17:10:02 UTC (rev 441) @@ -64,7 +64,6 @@ */ public class SparqlKnowledgeSource extends KnowledgeSource { - private Map<Integer, SparqlQuery> queryIDs = new HashMap<Integer, SparqlQuery>(); private Map<Integer, String[][]> queryResult = new HashMap<Integer, String[][]>(); // ConfigOptions public URL url; @@ -392,34 +391,12 @@ return ontArray; } - public int sparqlQuery(String query) { + public SparqlQuery sparqlQuery(String query) { this.endpoint = new SparqlEndpoint(url, defaultGraphURIs, namedGraphURIs); - return this.generateQueryID(new SparqlQuery(query, endpoint)); + return new SparqlQuery(query, endpoint); } - public void startSparqlQuery(int queryID) { - queryResult.put(queryID, queryIDs.get(queryID).getAsStringArray()); - } - - public SparqlQuery getSparqlQuery(int queryID) { - return queryIDs.get(queryID); - } - - public String[][] getSparqlResult(int queryID) { - return queryResult.get(queryID); - } - - private int generateQueryID(SparqlQuery query) { - int id; - Random rand = new Random(); - do { - id = rand.nextInt(); - } while (queryIDs.keySet().contains(id)); - queryIDs.put(id, query); - return id; - } - public static void main(String[] args) throws MalformedURLException { String query = "SELECT ?pred ?obj\n" + "WHERE {<http://dbpedia.org/resource/Leipzig> ?pred ?obj}"; Modified: trunk/src/dl-learner/org/dllearner/kb/sparql/query/CachedSparqlQuery.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/sparql/query/CachedSparqlQuery.java 2008-01-28 16:05:10 UTC (rev 440) +++ trunk/src/dl-learner/org/dllearner/kb/sparql/query/CachedSparqlQuery.java 2008-01-28 17:10:02 UTC (rev 441) @@ -77,10 +77,6 @@ return SparqlQuery.JSONtoResultSet(getAsJSON()); } - public ResultSet getAsResultSet2(){ - return this.sparqlQuery.send(); - } - /** * sends a query and returns JSON using cache * Modified: trunk/src/dl-learner/org/dllearner/kb/sparql/query/SparqlQuery.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/sparql/query/SparqlQuery.java 2008-01-28 16:05:10 UTC (rev 440) +++ trunk/src/dl-learner/org/dllearner/kb/sparql/query/SparqlQuery.java 2008-01-28 17:10:02 UTC (rev 441) @@ -51,11 +51,8 @@ private String queryString; private QueryExecution queryExecution; SparqlEndpoint endpoint; + private ResultSet rs=null; - public void setQueryExecutionRunning(boolean isRunning){ - this.isRunning=isRunning; - } - /** * simplest contructor, works only with some endpoints, * not with DBpedia @@ -82,7 +79,8 @@ * method used for sending over Jena * @return jena ResultSet */ - protected ResultSet send() { + public void send() { + this.isRunning=true; p(queryString); String service = endpoint.getURL().toString(); @@ -98,10 +96,10 @@ p("query SPARQL server"); - ResultSet rs = queryExecution.execSelect(); + rs = queryExecution.execSelect(); p(rs.getResultVars().toString()); //p(ResultSetFormatter.asXMLString(rs)); - return rs; + this.isRunning=false; } public void stop() { @@ -119,8 +117,8 @@ */ @SuppressWarnings({"unchecked"}) public String[][] getAsStringArray(){ + if (rs==null) this.send(); System.out.println("Starting Query"); - ResultSet rs=send(); List<ResultBinding> l = ResultSetFormatter.toList(rs); List<String> resultVars=rs.getResultVars(); String[][] array=new String[l.size()][resultVars.size()]; @@ -147,7 +145,7 @@ * @return String xml */ public String getAsXMLString() { - ResultSet rs = send(); + if (rs==null) this.send(); return ResultSetFormatter.asXMLString(rs); } @@ -159,7 +157,7 @@ */ @SuppressWarnings({"unchecked"}) public List<ResultBinding> getAsList() { - ResultSet rs = send(); + if (rs==null) this.send(); return ResultSetFormatter.toList(rs); } @@ -174,7 +172,6 @@ @SuppressWarnings({"unchecked"}) @Deprecated public Vector<String> getAsVector(String varName) { - ResultSet rs = send(); Vector<String> vret = new Vector<String>(); List<ResultBinding> l = ResultSetFormatter.toList(rs); for (ResultBinding resultBinding : l) { @@ -196,8 +193,6 @@ @Deprecated public Vector<StringTuple> getAsVectorOfTupels(String varName1, String varName2) { - ResultSet rs = send(); - Vector<StringTuple> vret = new Vector<StringTuple>(); List<ResultBinding> l = ResultSetFormatter.toList(rs); //System.out.println(l); @@ -240,7 +235,7 @@ * @return a String representation of the Resultset as JSON */ public String getAsJSON(){ - ResultSet rs=send(); + if (rs==null) this.send(); ByteArrayOutputStream baos=new ByteArrayOutputStream(); ResultSetFormatter.outputAsJSON(baos, rs); return baos.toString(); Modified: trunk/src/dl-learner/org/dllearner/server/ClientState.java =================================================================== --- trunk/src/dl-learner/org/dllearner/server/ClientState.java 2008-01-28 16:05:10 UTC (rev 440) +++ trunk/src/dl-learner/org/dllearner/server/ClientState.java 2008-01-28 17:10:02 UTC (rev 441) @@ -34,6 +34,7 @@ import org.dllearner.core.ReasoningService; import org.dllearner.kb.OWLFile; import org.dllearner.kb.sparql.SparqlKnowledgeSource; +import org.dllearner.kb.sparql.query.SparqlQuery; /** * Stores the state of a DL-Learner client session. @@ -50,6 +51,8 @@ private Set<KnowledgeSource> knowledgeSources = new HashSet<KnowledgeSource>(); + private Map<Integer, SparqlQuery> queryIDs = new HashMap<Integer, SparqlQuery>(); + private LearningProblem learningProblem; private ReasonerComponent reasonerComponent; @@ -70,6 +73,24 @@ return id; } + private int generateQueryID(SparqlQuery query) { + int id; + Random rand = new Random(); + do { + id = rand.nextInt(); + } while (queryIDs.keySet().contains(id)); + queryIDs.put(id, query); + return id; + } + + public int addQuery(SparqlQuery query){ + return this.generateQueryID(query); + } + + public SparqlQuery getQuery(int id){ + return queryIDs.get(id); + } + /** * @return the isAlgorithmRunning */ Modified: trunk/src/dl-learner/org/dllearner/server/DLLearnerWS.java =================================================================== --- trunk/src/dl-learner/org/dllearner/server/DLLearnerWS.java 2008-01-28 16:05:10 UTC (rev 440) +++ trunk/src/dl-learner/org/dllearner/server/DLLearnerWS.java 2008-01-28 17:10:02 UTC (rev 441) @@ -488,45 +488,55 @@ //////////////////////////////////////// @WebMethod - public String[][] sparqlQuery(int sessionID, int componentID, int queryID) throws ClientNotKnownException + public String[][] getAsStringArray(int sessionID, int queryID) throws ClientNotKnownException { ClientState state = getState(sessionID); - Component component = state.getComponent(componentID); - return ((SparqlKnowledgeSource)component).getSparqlResult(queryID); + return state.getQuery(queryID).getAsStringArray(); } @WebMethod + public String getAsJSON(int sessionID, int queryID) throws ClientNotKnownException + { + ClientState state = getState(sessionID); + return state.getQuery(queryID).getAsJSON(); + } + + @WebMethod + public String getAsXMLString(int sessionID, int queryID) throws ClientNotKnownException + { + ClientState state = getState(sessionID); + return state.getQuery(queryID).getAsXMLString(); + } + + @WebMethod public int sparqlQueryThreaded(int sessionID, int componentID, final String query) throws ClientNotKnownException { final ClientState state = getState(sessionID); final Component component = state.getComponent(componentID); - final int ID=((SparqlKnowledgeSource)component).sparqlQuery(query); + final int id=state.addQuery(((SparqlKnowledgeSource)component).sparqlQuery(query)); Thread sparqlThread = new Thread() { @Override public void run() { - ((SparqlKnowledgeSource)component).getSparqlQuery(ID).setQueryExecutionRunning(true); - ((SparqlKnowledgeSource)component).startSparqlQuery(ID); - ((SparqlKnowledgeSource)component).getSparqlQuery(ID).setQueryExecutionRunning(false); + state.getQuery(id).send(); } }; sparqlThread.start(); - return ID; + return id; } @WebMethod - public boolean isSparqlQueryRunning(int sessionID, int componentID, int queryID) throws ClientNotKnownException + public boolean isSparqlQueryRunning(int sessionID, int queryID) throws ClientNotKnownException { ClientState state = getState(sessionID); - Component component = state.getComponent(componentID); - return ((SparqlKnowledgeSource)component).getSparqlQuery(queryID).isRunning(); + return state.getQuery(queryID).isRunning(); } @WebMethod - public void stopSparqlThread(int sessionID, int componentID, int queryID) throws ClientNotKnownException + public void stopSparqlThread(int sessionID, int queryID) throws ClientNotKnownException { ClientState state = getState(sessionID); - Component component = state.getComponent(componentID); - ((SparqlKnowledgeSource)component).getSparqlQuery(queryID).stop(); + + state.getQuery(queryID).stop(); } @WebMethod This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sk...@us...> - 2008-01-28 16:05:20
|
Revision: 440 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=440&view=rev Author: sknappe Date: 2008-01-28 08:05:10 -0800 (Mon, 28 Jan 2008) Log Message: ----------- added functionality for testing Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/kb/sparql/query/CachedSparqlQuery.java trunk/src/dl-learner/org/dllearner/kb/sparql/query/SparqlQuery.java Modified: trunk/src/dl-learner/org/dllearner/kb/sparql/query/CachedSparqlQuery.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/sparql/query/CachedSparqlQuery.java 2008-01-28 16:03:17 UTC (rev 439) +++ trunk/src/dl-learner/org/dllearner/kb/sparql/query/CachedSparqlQuery.java 2008-01-28 16:05:10 UTC (rev 440) @@ -73,11 +73,11 @@ * TODO can further be optimized * @return a jena ResultSet */ - public ResultSet getAsResultSet2(){ + public ResultSet getAsResultSet(){ return SparqlQuery.JSONtoResultSet(getAsJSON()); } - public ResultSet getAsResultSet(){ + public ResultSet getAsResultSet2(){ return this.sparqlQuery.send(); } @@ -97,6 +97,7 @@ if (FromCache == null) { // configuration.increaseNumberOfuncachedSparqlQueries(); JSON = this.sparqlQuery.getAsJSON(); + System.out.println(JSON); // sendAndReceiveSPARQL(sparql); // p(sparql); // System.out.println(xml); Modified: trunk/src/dl-learner/org/dllearner/kb/sparql/query/SparqlQuery.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/sparql/query/SparqlQuery.java 2008-01-28 16:03:17 UTC (rev 439) +++ trunk/src/dl-learner/org/dllearner/kb/sparql/query/SparqlQuery.java 2008-01-28 16:05:10 UTC (rev 440) @@ -260,6 +260,10 @@ return rs; } + + public String getQueryString() { + return queryString; + } public void p(String str) { if (print_flag) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sk...@us...> - 2008-01-28 16:03:50
|
Revision: 439 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=439&view=rev Author: sknappe Date: 2008-01-28 08:03:17 -0800 (Mon, 28 Jan 2008) Log Message: ----------- fixed bug with interests Modified Paths: -------------- trunk/src/dbpedia-navigator/ajaxfunctions.php Modified: trunk/src/dbpedia-navigator/ajaxfunctions.php =================================================================== --- trunk/src/dbpedia-navigator/ajaxfunctions.php 2008-01-28 15:59:22 UTC (rev 438) +++ trunk/src/dbpedia-navigator/ajaxfunctions.php 2008-01-28 16:03:17 UTC (rev 439) @@ -126,7 +126,7 @@ //Add Positives to Session if (!isset($_SESSION['positive'])){ - $array=array("http://dbpedia.org/resource/".str_replace(" ","_",$subject)) => "http://dbpedia.org/resource/".str_replace(" ","_",$subject)); + $array=array("http://dbpedia.org/resource/".str_replace(" ","_",$subject) => "http://dbpedia.org/resource/".str_replace(" ","_",$subject)); $_SESSION['positive']=$array; } else{ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sk...@us...> - 2008-01-28 15:59:42
|
Revision: 438 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=438&view=rev Author: sknappe Date: 2008-01-28 07:59:22 -0800 (Mon, 28 Jan 2008) Log Message: ----------- fixed bug with interests Modified Paths: -------------- trunk/src/dbpedia-navigator/ajaxfunctions.php Modified: trunk/src/dbpedia-navigator/ajaxfunctions.php =================================================================== --- trunk/src/dbpedia-navigator/ajaxfunctions.php 2008-01-28 15:35:28 UTC (rev 437) +++ trunk/src/dbpedia-navigator/ajaxfunctions.php 2008-01-28 15:59:22 UTC (rev 438) @@ -126,12 +126,12 @@ //Add Positives to Session if (!isset($_SESSION['positive'])){ - $array=array($subject => "http://dbpedia.org/resource/".str_replace(" ","_",$subject)); + $array=array("http://dbpedia.org/resource/".str_replace(" ","_",$subject)) => "http://dbpedia.org/resource/".str_replace(" ","_",$subject)); $_SESSION['positive']=$array; } else{ $array=$_SESSION['positive']; - $array[$subject]="http://dbpedia.org/resource/".str_replace(" ","_",$subject); + $array["http://dbpedia.org/resource/".str_replace(" ","_",$subject)]="http://dbpedia.org/resource/".str_replace(" ","_",$subject); $_SESSION['positive']=$array; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sk...@us...> - 2008-01-28 15:35:42
|
Revision: 437 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=437&view=rev Author: sknappe Date: 2008-01-28 07:35:28 -0800 (Mon, 28 Jan 2008) Log Message: ----------- the correct URI's are now send to Web-Service Modified Paths: -------------- trunk/src/dbpedia-navigator/DLLearnerConnection.php trunk/src/dbpedia-navigator/ajaxfunctions.php Modified: trunk/src/dbpedia-navigator/DLLearnerConnection.php =================================================================== --- trunk/src/dbpedia-navigator/DLLearnerConnection.php 2008-01-28 15:30:34 UTC (rev 436) +++ trunk/src/dbpedia-navigator/DLLearnerConnection.php 2008-01-28 15:35:28 UTC (rev 437) @@ -42,7 +42,7 @@ function getConceptFromExamples($posExamples,$negExamples) { - $this->client->applyConfigEntryInt($this->id, $this->ksID, "recursionDepth",1); + $this->client->applyConfigEntryInt($this->id, $this->ksID, "recursionDepth",2); $this->client->applyConfigEntryStringArray($this->id, $this->ksID, "instances", array_merge($posExamples,$negExamples)); // $this->client->applyConfigEntryStringArray($this->id, $this->ksID, "predList", array()); // $this->client->applyConfigEntryStringArray($this->id, $this->ksID, "objList", array()); Modified: trunk/src/dbpedia-navigator/ajaxfunctions.php =================================================================== --- trunk/src/dbpedia-navigator/ajaxfunctions.php 2008-01-28 15:30:34 UTC (rev 436) +++ trunk/src/dbpedia-navigator/ajaxfunctions.php 2008-01-28 15:35:28 UTC (rev 437) @@ -126,12 +126,12 @@ //Add Positives to Session if (!isset($_SESSION['positive'])){ - $array=array($subject => $subject); + $array=array($subject => "http://dbpedia.org/resource/".str_replace(" ","_",$subject)); $_SESSION['positive']=$array; } else{ $array=$_SESSION['positive']; - $array[$subject]=$subject; + $array[$subject]="http://dbpedia.org/resource/".str_replace(" ","_",$subject); $_SESSION['positive']=$array; } @@ -249,11 +249,11 @@ //add Positives and Negatives to Interests $posInterests=""; if (isset($_SESSION['positive'])) foreach($_SESSION['positive'] as $pos){ - $posInterests=$posInterests.$pos." <a href=\"\" onclick=\"xajax_toNegative('".$pos."');return false;\"><img src=\"images/minus.jpg\" alt=\"Minus\"/></a> <a href=\"\" onclick=\"xajax_removePosInterest('".$pos."');return false;\"><img src=\"images/remove.png\" alt=\"Minus\"/></a><br/>"; + $posInterests=$posInterests.substr (strrchr ($pos, "/"), 1)." <a href=\"\" onclick=\"xajax_toNegative('".$pos."');return false;\"><img src=\"images/minus.jpg\" alt=\"Minus\"/></a> <a href=\"\" onclick=\"xajax_removePosInterest('".$pos."');return false;\"><img src=\"images/remove.png\" alt=\"Minus\"/></a><br/>"; } $negInterests=""; if (isset($_SESSION['negative'])) foreach($_SESSION['negative'] as $neg){ - $negInterests=$negInterests.$neg." <a href=\"\" onclick=\"xajax_toPositive('".$neg."');return false;\"><img src=\"images/plus.jpg\" alt=\"Plus\"/></a> <a href=\"\" onclick=\"xajax_removeNegInterest('".$neg."');return false;\"><img src=\"images/remove.png\" alt=\"Minus\"/></a><br/>"; + $negInterests=$negInterests.substr (strrchr ($neg, "/"), 1)." <a href=\"\" onclick=\"xajax_toPositive('".$neg."');return false;\"><img src=\"images/plus.jpg\" alt=\"Plus\"/></a> <a href=\"\" onclick=\"xajax_removeNegInterest('".$neg."');return false;\"><img src=\"images/remove.png\" alt=\"Minus\"/></a><br/>"; } $objResponse=new xajaxResponse(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sk...@us...> - 2008-01-28 15:30:58
|
Revision: 436 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=436&view=rev Author: sknappe Date: 2008-01-28 07:30:34 -0800 (Mon, 28 Jan 2008) Log Message: ----------- updated the sparql modul web methods Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/server/DLLearnerWS.java Modified: trunk/src/dl-learner/org/dllearner/server/DLLearnerWS.java =================================================================== --- trunk/src/dl-learner/org/dllearner/server/DLLearnerWS.java 2008-01-28 15:27:29 UTC (rev 435) +++ trunk/src/dl-learner/org/dllearner/server/DLLearnerWS.java 2008-01-28 15:30:34 UTC (rev 436) @@ -486,95 +486,8 @@ //////////////////////////////////////// // SPARQL component methods // //////////////////////////////////////// - /* - @WebMethod - public void startThread(int id, int componentID, String[] options) throws ClientNotKnownException - { - final ClientState state = getState(id); - final Component component = state.getComponent(componentID); - String method=options[0]; - Thread thread=null; - if (method.equals("subjects")){ - final String label=options[1]; - final int limit=Integer.parseInt(options[2]); - thread = new Thread() { - @Override - public void run() { - ((SparqlKnowledgeSource)component).setSubjectThread(this); - ((SparqlKnowledgeSource)component).setSubjectThreadRunning(true); - ((SparqlKnowledgeSource)component).calculateSubjects(label,limit); - ((SparqlKnowledgeSource)component).setSubjectThreadRunning(false); - } - }; - } else if (method.equals("triples")){ - final String subject=options[1]; - thread = new Thread() { - @Override - public void run() { - ((SparqlKnowledgeSource)component).setTriplesThread(this); - ((SparqlKnowledgeSource)component).setTriplesThreadRunning(true); - ((SparqlKnowledgeSource)component).calculateTriples(subject); - ((SparqlKnowledgeSource)component).setTriplesThreadRunning(false); - } - }; - } else if (method.equals("conceptSubjects")){ - final String concept=options[1]; - thread = new Thread() { - @Override - public void run() { - ((SparqlKnowledgeSource)component).setConceptThread(this); - ((SparqlKnowledgeSource)component).setConceptThreadRunning(true); - ((SparqlKnowledgeSource)component).calculateConceptSubjects(concept); - ((SparqlKnowledgeSource)component).setConceptThreadRunning(false); - } - }; - } - thread.start(); - } @WebMethod - public boolean isThreadRunning(int id, int componentID, String option) throws ClientNotKnownException - { - ClientState state = getState(id); - Component component = state.getComponent(componentID); - if (option.equals("subjects")) - return ((SparqlKnowledgeSource)component).subjectThreadIsRunning(); - else if (option.equals("triples")) - return ((SparqlKnowledgeSource)component).triplesThreadIsRunning(); - else if (option.equals("conceptSubjects")) - return ((SparqlKnowledgeSource)component).conceptThreadIsRunning(); - return true; - } - - @WebMethod - public void stopSparqlThread(int id, int componentID, String option) throws ClientNotKnownException - { - ClientState state = getState(id); - Component component = state.getComponent(componentID); - if (option.equals("subjects")) - ((SparqlKnowledgeSource)component).getSubjectThread().stop(); - else if (option.equals("triples")) - ((SparqlKnowledgeSource)component).getTriplesThread().stop(); - else if (option.equals("conceptSubjects")) - ((SparqlKnowledgeSource)component).getConceptThread().stop(); - } - - @WebMethod - public String[] getFromSparql(int id, int componentID, String option) throws ClientNotKnownException - { - ClientState state = getState(id); - Component component = state.getComponent(componentID); - if (option.equals("subjects")) - return ((SparqlKnowledgeSource)component).getSubjects(); - else if (option.equals("triples")) - return ((SparqlKnowledgeSource)component).getTriples(); - else if (option.equals("conceptSubjects")) - return ((SparqlKnowledgeSource)component).getConceptSubjects(); - return new String[0]; - } - */ - - @WebMethod public String[][] sparqlQuery(int sessionID, int componentID, int queryID) throws ClientNotKnownException { ClientState state = getState(sessionID); @@ -617,8 +530,8 @@ } @WebMethod - public String debug(String deb) + public void debug(String deb) { - return "Test"; + System.out.println(deb); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sk...@us...> - 2008-01-28 15:27:59
|
Revision: 435 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=435&view=rev Author: sknappe Date: 2008-01-28 07:27:29 -0800 (Mon, 28 Jan 2008) Log Message: ----------- deleted static test class, because static methods where deleted Removed Paths: ------------- trunk/src/dl-learner/org/dllearner/kb/sparql/test/TestStaticQueries.java Deleted: trunk/src/dl-learner/org/dllearner/kb/sparql/test/TestStaticQueries.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/sparql/test/TestStaticQueries.java 2008-01-28 15:23:51 UTC (rev 434) +++ trunk/src/dl-learner/org/dllearner/kb/sparql/test/TestStaticQueries.java 2008-01-28 15:27:29 UTC (rev 435) @@ -1,72 +0,0 @@ -/** - * Copyright (C) 2007-2008, 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.kb.sparql.test; - -import org.dllearner.kb.sparql.configuration.SparqlEndpoint; -import org.dllearner.kb.sparql.query.SparqlQuery; - -public class TestStaticQueries { - - // tests makeArticleQuery - // - // - public static void main(String[] args) { - String test1="http://dbpedia.org/resource/Angela_Merkel"; - String test2="http://dbpedia.org/resource/Leipzig"; - String test3="http://dbpedia.org/class/yago/Woman110787470"; - boolean one=false; - boolean two=true; - boolean three=false; - try { - if(one){ - //System.out.println(SparqlQuery.makeArticleQuery(test1, - // SparqlEndpoint.getEndpointByNumber(1)).getAsXMLString()); - //System.out.println(SparqlQuery.makeArticleQuery(test1, - // SparqlEndpoint.getEndpointByNumber(1)).getAsList()); - System.out.println(SparqlQuery.makeArticleQuery(test1, - SparqlEndpoint.getEndpointByNumber(1)).getAsVectorOfTupels("predicate", "object")); - } - - if(two){ - System.out.println(SparqlQuery.makeLabelQuery(test2,10, - SparqlEndpoint.getEndpointByNumber(1)).getAsXMLString()); - System.out.println(SparqlQuery.makeLabelQuery(test2,10, - SparqlEndpoint.getEndpointByNumber(1)).getAsList()); - System.out.println(SparqlQuery.makeLabelQuery(test2,10, - SparqlEndpoint.getEndpointByNumber(1)).getAsVector("subject")); - } - if(three){ - System.out.println(SparqlQuery.makeConceptQuery(test3, - SparqlEndpoint.getEndpointByNumber(1)).getAsXMLString()); - System.out.println(SparqlQuery.makeConceptQuery(test3, - SparqlEndpoint.getEndpointByNumber(1)).getAsList()); - System.out.println(SparqlQuery.makeConceptQuery(test3, - SparqlEndpoint.getEndpointByNumber(1)).getAsVector("subject")); - } - - - - } catch (Exception e) { - e.printStackTrace(); - } - - } - -} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sk...@us...> - 2008-01-28 15:23:57
|
Revision: 434 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=434&view=rev Author: sknappe Date: 2008-01-28 07:23:51 -0800 (Mon, 28 Jan 2008) Log Message: ----------- changed to non dbpedia-specific queries Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/kb/sparql/query/SparqlQuery.java Modified: trunk/src/dl-learner/org/dllearner/kb/sparql/query/SparqlQuery.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/sparql/query/SparqlQuery.java 2008-01-28 14:27:16 UTC (rev 433) +++ trunk/src/dl-learner/org/dllearner/kb/sparql/query/SparqlQuery.java 2008-01-28 15:23:51 UTC (rev 434) @@ -95,7 +95,6 @@ for (String ngu : endpoint.getNamedGraphURIs()){ queryExecution.addNamedGraph(ngu); } - queryExecution.addDefaultGraph("http://dbpedia.org"); p("query SPARQL server"); @@ -261,51 +260,6 @@ return rs; } - - - - - /** - * creates a query for subjects with the specified label - * @param label a phrase that is part of the label of a subject - * @param limit this limits the amount of results - * @param endpoint a SparqlEndpoint - * @return SparqlQuery - */ - public static SparqlQuery makeLabelQuery(String label,int limit,SparqlEndpoint endpoint){ - //TODO maybe use http://xmlns:com/foaf/0.1/page - String queryString= - "SELECT DISTINCT ?subject\n"+ - "WHERE { ?subject <http://www.w3.org/2000/01/rdf-schema#label> ?object. ?object bif:contains '\""+label+"\"'@en}\n"+ - "LIMIT "+limit; - return new SparqlQuery( queryString,endpoint); - } - - /** - * creates a query for all subjects that are of the type concept - * @param concept the type that subjects are searched for - * @param endpoint a SparqlEndpoint - * @return SparqlQuery - */ - public static SparqlQuery makeConceptQuery(String concept, SparqlEndpoint endpoint){ - String queryString = - "SELECT DISTINCT ?subject\n"+ - "WHERE { ?subject a <"+concept+">}\n"; - return new SparqlQuery( queryString,endpoint); - } - - /** - * @param subject - * @param endpoint a SparqlEndpoint - * @return SparqlQuery - */ - public static SparqlQuery makeArticleQuery(String subject,SparqlEndpoint endpoint){ - String queryString = - "SELECT ?predicate ?object\n"+ - "WHERE { <"+subject+"> ?predicate ?object}\n"; - return new SparqlQuery( queryString,endpoint); - } - public void p(String str) { if (print_flag) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sk...@us...> - 2008-01-28 14:27:24
|
Revision: 433 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=433&view=rev Author: sknappe Date: 2008-01-28 06:27:16 -0800 (Mon, 28 Jan 2008) Log Message: ----------- fixed some bugs Modified Paths: -------------- trunk/src/dbpedia-navigator/DLLearnerConnection.php trunk/src/dbpedia-navigator/ajaxfunctions.php trunk/src/dbpedia-navigator/index.php Modified: trunk/src/dbpedia-navigator/DLLearnerConnection.php =================================================================== --- trunk/src/dbpedia-navigator/DLLearnerConnection.php 2008-01-28 14:26:54 UTC (rev 432) +++ trunk/src/dbpedia-navigator/DLLearnerConnection.php 2008-01-28 14:27:16 UTC (rev 433) @@ -40,7 +40,7 @@ return array(0 => $id, 1 => $ksID); } - function getConceptFromExamples($ttl,$posExamples,$negExamples) + function getConceptFromExamples($posExamples,$negExamples) { $this->client->applyConfigEntryInt($this->id, $this->ksID, "recursionDepth",1); $this->client->applyConfigEntryStringArray($this->id, $this->ksID, "instances", array_merge($posExamples,$negExamples)); @@ -88,7 +88,7 @@ $seconds = $i * $sleeptime; $i++; - } while($seconds<$ttl&&$running); + } while($seconds<$this->ttl&&$running); $this->client->stop($this->id); } Modified: trunk/src/dbpedia-navigator/ajaxfunctions.php =================================================================== --- trunk/src/dbpedia-navigator/ajaxfunctions.php 2008-01-28 14:26:54 UTC (rev 432) +++ trunk/src/dbpedia-navigator/ajaxfunctions.php 2008-01-28 14:27:16 UTC (rev 433) @@ -292,21 +292,20 @@ foreach ($_SESSION['negative'] as $neg) $negArray[]=$neg; - require_once("Settings.php"); require_once("DLLearnerConnection.php"); - $settings=new Settings(); - $sc=new DLLearnerConnection($settings->dbpediauri,$settings->wsdluri,$_SESSION['id'],$_SESSION['ksID']); + $sc=new DLLearnerConnection($_SESSION['id'],$_SESSION['ksID']); - $concept=$sc->getConceptFromExamples($settings->sparqlttl,$posArray,$negArray); + $concept=$sc->getConceptFromExamples($posArray,$negArray); $_SESSION['lastLearnedConcept']=$concept; - if (strlen(substr (strrchr ($concept, "/"), 1))>0) $concept=urldecode(substr (strrchr ($concept, "/"), 1)); + if (strlen(substr (strrchr ($concept, "/"), 1))>0) $concept="<a href=\"\" onclick=\"xajax_getSubjectsFromConcept();return false;\" />".urldecode(substr (strrchr ($concept, "/"), 1))."</a>"; + else $concept="<a href=\"\" onclick=\"xajax_getSubjectsFromConcept();return false;\" />".$concept."</a>"; } else $concept="You must choose at least one<br/> positive example."; $objResponse = new xajaxResponse(); - $objResponse->assign("conceptcontent", "innerHTML", $concept); + $objResponse->assign("conceptlink", "innerHTML", $concept); return $objResponse; } Modified: trunk/src/dbpedia-navigator/index.php =================================================================== --- trunk/src/dbpedia-navigator/index.php 2008-01-28 14:26:54 UTC (rev 432) +++ trunk/src/dbpedia-navigator/index.php 2008-01-28 14:27:16 UTC (rev 433) @@ -68,7 +68,7 @@ <body> <!-- <h1>DBpedia Navigator</h1> --> -<img src="images/dbpedia_navigator.png" alt="DBpedia Navigator" style="padding:5px" /> +<img src="images/dbpedia_navigator.png" alt="DBpedia Navigator" style="padding:5px" /> <span id="conceptlink"></span> <div id="layer" style="display:none"> <div id="layerContent" style="display:none"></div> </div> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sk...@us...> - 2008-01-28 14:26:55
|
Revision: 432 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=432&view=rev Author: sknappe Date: 2008-01-28 06:26:54 -0800 (Mon, 28 Jan 2008) Log Message: ----------- fixed some bugs Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlKnowledgeSource.java trunk/src/dl-learner/org/dllearner/kb/sparql/query/CachedSparqlQuery.java trunk/src/dl-learner/org/dllearner/kb/sparql/query/SparqlQuery.java Modified: trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlKnowledgeSource.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlKnowledgeSource.java 2008-01-28 03:09:12 UTC (rev 431) +++ trunk/src/dl-learner/org/dllearner/kb/sparql/SparqlKnowledgeSource.java 2008-01-28 14:26:54 UTC (rev 432) @@ -32,7 +32,6 @@ import java.util.Map; import java.util.Random; import java.util.Set; -import java.util.Vector; import org.apache.log4j.Logger; import org.dllearner.core.KnowledgeSource; @@ -98,39 +97,6 @@ SparqlEndpoint endpoint = null; - /** - * Holds the results of the calculateSubjects method - */ - private String[] subjects; - - /** - * Holds the results of the calculateTriples method - */ - private String[] triples; - - /** - * Holds the results of the calculateConceptSubjects method - */ - private String[] conceptSubjects; - - /** - * if a method is running this becomes true - */ - private boolean subjectThreadRunning = false; - - private boolean triplesThreadRunning = false; - - private boolean conceptThreadRunning = false; - - /** - * the Thread that is running a method - */ - private Thread subjectThread; - - private Thread triplesThread; - - private Thread conceptThread; - private LinkedList<String> defaultGraphURIs = new LinkedList<String>(); private LinkedList<String> namedGraphURIs = new LinkedList<String>(); @@ -426,136 +392,6 @@ return ontArray; } - /** - * - * @param label - * @param limit - */ - public void calculateSubjects(String label, int limit) { - logger.info("SparqlModul: Collecting Subjects"); - // oldSparqlOntologyCollector oc = new oldSparqlOntologyCollector(url); - // try { - Vector<String> v = (SparqlQuery.makeLabelQuery(label, limit, endpoint) - .getAsVector("subject")); - subjects = (String[]) v.toArray(new String[v.size()]); - // subjects = oc.getSubjectsFromLabel(label, limit); - // } catch (IOException e) { - // TODO I removed IOException, please check - // subjects = new String[1]; - // subjects[0] = "[Error]Sparql Endpoint could not be reached."; - // } - logger.info("SparqlModul: ****Finished"); - } - - /** - * TODO SparqlOntologyCollector needs to be removed - * - * @param subject - */ - public void calculateTriples(String subject) { - logger.info("SparqlModul: Collecting Triples"); - Vector<StringTuple> v = (SparqlQuery - .makeArticleQuery(subject, endpoint).getAsVectorOfTupels( - "predicate", "objcet")); - // String[] subjects = (String[]) v.toArray(new String[v.size()]); - String[] tmp = new String[v.size()]; - int i = 0; - for (StringTuple stringTuple : v) { - tmp[i++] = stringTuple.a + "<" + stringTuple.b; - } - triples = tmp; - // oldSparqlOntologyCollector oc = new oldSparqlOntologyCollector(url); - // try { - // triples = oc.collectTriples(subject); - // } catch (IOException e) { - // triples = new String[1]; - // triples[0] = "[Error]Sparql Endpoint could not be reached."; - // } - logger.info("SparqlModul: ****Finished"); - } - - /** - * - * - * @param concept - */ - public void calculateConceptSubjects(String concept) { - logger.info("SparqlModul: Collecting Subjects"); - Vector<String> v = (SparqlQuery.makeConceptQuery(concept, endpoint) - .getAsVector("subject")); - conceptSubjects = (String[]) v.toArray(new String[v.size()]); - - // oldSparqlOntologyCollector oc = new oldSparqlOntologyCollector(url); - // try { - // conceptSubjects = oc.getSubjectsFromConcept(concept); - // } catch (IOException e) { - // TODO I removed IOException, please check - // conceptSubjects = new String[1]; - // conceptSubjects[0] = "[Error]Sparql Endpoint could not be reached."; - // } - logger.info("SparqlModul: ****Finished"); - } - - public boolean subjectThreadIsRunning() { - return subjectThreadRunning; - } - - public void setSubjectThreadRunning(boolean bool) { - subjectThreadRunning = bool; - } - - public boolean triplesThreadIsRunning() { - return triplesThreadRunning; - } - - public void setTriplesThreadRunning(boolean bool) { - triplesThreadRunning = bool; - } - - public boolean conceptThreadIsRunning() { - return conceptThreadRunning; - } - - public void setConceptThreadRunning(boolean bool) { - conceptThreadRunning = bool; - } - - public String[] getSubjects() { - return subjects; - } - - public Thread getSubjectThread() { - return subjectThread; - } - - public void setSubjectThread(Thread subjectThread) { - this.subjectThread = subjectThread; - } - - public Thread getTriplesThread() { - return triplesThread; - } - - public void setTriplesThread(Thread triplesThread) { - this.triplesThread = triplesThread; - } - - public Thread getConceptThread() { - return conceptThread; - } - - public void setConceptThread(Thread conceptThread) { - this.conceptThread = conceptThread; - } - - public String[] getTriples() { - return triples; - } - - public String[] getConceptSubjects() { - return conceptSubjects; - } - public int sparqlQuery(String query) { this.endpoint = new SparqlEndpoint(url, defaultGraphURIs, namedGraphURIs); Modified: trunk/src/dl-learner/org/dllearner/kb/sparql/query/CachedSparqlQuery.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/sparql/query/CachedSparqlQuery.java 2008-01-28 03:09:12 UTC (rev 431) +++ trunk/src/dl-learner/org/dllearner/kb/sparql/query/CachedSparqlQuery.java 2008-01-28 14:26:54 UTC (rev 432) @@ -73,10 +73,14 @@ * TODO can further be optimized * @return a jena ResultSet */ - public ResultSet getAsResultSet(){ + public ResultSet getAsResultSet2(){ return SparqlQuery.JSONtoResultSet(getAsJSON()); } + public ResultSet getAsResultSet(){ + return this.sparqlQuery.send(); + } + /** * sends a query and returns JSON using cache * Modified: trunk/src/dl-learner/org/dllearner/kb/sparql/query/SparqlQuery.java =================================================================== --- trunk/src/dl-learner/org/dllearner/kb/sparql/query/SparqlQuery.java 2008-01-28 03:09:12 UTC (rev 431) +++ trunk/src/dl-learner/org/dllearner/kb/sparql/query/SparqlQuery.java 2008-01-28 14:26:54 UTC (rev 432) @@ -30,10 +30,7 @@ import org.dllearner.kb.sparql.configuration.SparqlEndpoint; import org.dllearner.utilities.StringTuple; -import com.hp.hpl.jena.query.Query; import com.hp.hpl.jena.query.QueryExecution; -import com.hp.hpl.jena.query.QueryExecutionFactory; -import com.hp.hpl.jena.query.QueryFactory; import com.hp.hpl.jena.query.ResultSet; import com.hp.hpl.jena.query.ResultSetFactory; import com.hp.hpl.jena.query.ResultSetFormatter; @@ -125,7 +122,6 @@ public String[][] getAsStringArray(){ System.out.println("Starting Query"); ResultSet rs=send(); - System.out.println("getResults"); List<ResultBinding> l = ResultSetFormatter.toList(rs); List<String> resultVars=rs.getResultVars(); String[][] array=new String[l.size()][resultVars.size()]; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ton...@us...> - 2008-01-28 03:09:13
|
Revision: 431 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=431&view=rev Author: tonytacker Date: 2008-01-27 19:09:12 -0800 (Sun, 27 Jan 2008) Log Message: ----------- without the twice-clicking bug - but I saw, options will not work after press on init - I have to change it next time and will hold these possible options at org.dllearner.gui.Config.java Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.java Modified: trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.java 2008-01-28 02:38:38 UTC (rev 430) +++ trunk/src/dl-learner/org/dllearner/gui/LearningAlgorithmPanel.java 2008-01-28 03:09:12 UTC (rev 431) @@ -21,7 +21,6 @@ */ import javax.swing.*; -//import javax.swing.table.DefaultTableModel; import java.awt.BorderLayout; import java.awt.event.ActionEvent; @@ -29,8 +28,6 @@ import java.util.List; import org.dllearner.core.LearningAlgorithm; -//import org.dllearner.core.config.ConfigOption; -//import org.dllearner.core.ComponentManager; @@ -97,8 +94,8 @@ // init if (e.getSource() == initButton) { if (config.getStatus(6)) { - updateOptionPanel(); config.setLearningAlgorithm(config.getComponentManager().learningAlgorithm(learners.get(choosenClassIndex), config.getLearningProblem(), config.getReasoningService())); + updateOptionPanel(); config.getLearningAlgorithm().init(); } if (config.getStatus(5)) { // examples are set This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ton...@us...> - 2008-01-28 02:38:42
|
Revision: 430 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=430&view=rev Author: tonytacker Date: 2008-01-27 18:38:38 -0800 (Sun, 27 Jan 2008) Log Message: ----------- WidgetPanelInteger works, but you have init it twice (its a small bug), after you can then set integers Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/gui/OptionPanel.java trunk/src/dl-learner/org/dllearner/gui/WidgetPanelInteger.java Added Paths: ----------- trunk/src/dl-learner/org/dllearner/gui/WidgetPanelDefault.java Modified: trunk/src/dl-learner/org/dllearner/gui/OptionPanel.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/OptionPanel.java 2008-01-26 19:25:33 UTC (rev 429) +++ trunk/src/dl-learner/org/dllearner/gui/OptionPanel.java 2008-01-28 02:38:38 UTC (rev 430) @@ -21,14 +21,14 @@ */ import java.awt.BorderLayout; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; +import java.awt.Dimension; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; + import java.util.List; -import javax.swing.JButton; import javax.swing.JPanel; -import javax.swing.JTable; -import javax.swing.table.DefaultTableModel; +import javax.swing.JScrollPane; import org.dllearner.core.Component; import org.dllearner.core.ComponentManager; @@ -40,20 +40,16 @@ * @author Tilo Hielscher * */ -public class OptionPanel extends JPanel implements ActionListener { +public class OptionPanel extends JPanel { private static final long serialVersionUID = -3053205578443575240L; private Config config; private Class<? extends Component> componentOption; private List<ConfigOption<?>> optionList; - private JButton tableButton; - private JButton normalButton; - private JButton readOptionsButton; - private DefaultTableModel optionModel = new DefaultTableModel(); - private JTable optionTable = new JTable(optionModel); - private JPanel startPanel = new JPanel(); private JPanel centerPanel = new JPanel(); private Component component; + private GridBagLayout gridBagLayout = new GridBagLayout(); + private GridBagConstraints constraints = new GridBagConstraints(); public OptionPanel(Config config, Component component, Class<? extends Component> componentOption) { super(new BorderLayout()); @@ -62,83 +58,66 @@ this.component = component; this.componentOption = componentOption; - tableButton = new JButton("show options as table"); - tableButton.addActionListener(this); - - normalButton = new JButton("show normal"); - normalButton.addActionListener(this); - - readOptionsButton = new JButton("read set option"); - readOptionsButton.addActionListener(this); - optionList = ComponentManager.getConfigOptions(componentOption); - startPanel.add(tableButton); - startPanel.add(normalButton); - startPanel.add(readOptionsButton); - - add(startPanel, BorderLayout.PAGE_START); - add(centerPanel, BorderLayout.CENTER); + // define GridBagLayout + centerPanel.setLayout(gridBagLayout); + constraints.anchor = GridBagConstraints.NORTHWEST; - // set JTable - optionModel.addColumn("name"); - optionModel.addColumn("default"); - optionModel.addColumn("class"); - optionModel.addRow(new Object[] {"name","default","class"}); // header - optionTable.setSize(400, 400); - optionTable.updateUI(); + // add scrollPane + JScrollPane centerScroller = new JScrollPane(centerPanel); + centerScroller.setPreferredSize(new Dimension(400, 200)); + // add Panels + add(centerScroller, BorderLayout.CENTER); + + showWidgets(); } - public void actionPerformed(ActionEvent e) { - // show as table - if (e.getSource() == tableButton) { - optionList = ComponentManager.getConfigOptions(componentOption); - - // clear - centerPanel.removeAll(); - - // clear JTable - for (int i=optionModel.getRowCount()-1; i>0; i--) { // from last to first - optionModel.removeRow(i); - } - // new JTable - for (int i=0; i<optionList.size(); i++) { - optionModel.addRow(new Object[] {optionList.get(i).getName(), optionList.get(i).getDefaultValue(), - optionList.get(i).getClass().getSimpleName()}); - } - // update graphic - centerPanel.add(optionTable); - centerPanel.updateUI(); - } - // show normal - if (e.getSource() == normalButton) { - optionList = ComponentManager.getConfigOptions(componentOption); // get class for options - - // clear - centerPanel.removeAll(); - - //get a WidgetPanel Example - // optionList is the list of possible options for componentOption - // each option can be type of IntegerConfigOption, StringConfigOption and so on - WidgetPanelInteger firstPanel = new WidgetPanelInteger(config, component, componentOption, optionList.get(0)); - centerPanel.add(firstPanel); - - // update graphic - centerPanel.updateUI(); - } - // read set options - if (e.getSource() == readOptionsButton) { - System.out.println("setOptions: " + config.getComponentManager().getConfigOption(componentOption, optionList.get(0).getName())); - } - } - public void setComponent (Component component) { this.component = component; + showWidgets(); } public void setComponentOption (Class<? extends Component> componentOption) { this.componentOption = componentOption; + showWidgets(); } + /* + * define here what core.config.class is what type of widget + * WidgetPanelDefault is for none defined classes + */ + private void showWidgets() { + JPanel widgetPanel; + optionList = ComponentManager.getConfigOptions(componentOption); // get class for options + centerPanel.removeAll(); // clear panel + for (int i=0; i<optionList.size(); i++) { + buildConstraints(constraints, 0, i, 1, 1, 0, 0); + if (optionList.get(i).getClass().toString().contains("IntegerConfigOption")) { + widgetPanel = new WidgetPanelInteger(config, component, componentOption, optionList.get(i)); + } + else if (false) { + } + else { + widgetPanel = new WidgetPanelDefault(config, component, componentOption, optionList.get(i)); + } + gridBagLayout.setConstraints(widgetPanel, constraints); + centerPanel.add(widgetPanel); + } + centerPanel.updateUI(); // update graphic + } + + /* + * Define GridBagConstraints + */ + private void buildConstraints(GridBagConstraints gbc, int gx, int gy, int gw, int gh, int wx, int wy) { + gbc.gridx = gx; + gbc.gridy = gy; + gbc.gridwidth = gw; + gbc.gridheight = gh; + gbc.weightx = wx; + gbc.weighty = wy; + } + } Added: trunk/src/dl-learner/org/dllearner/gui/WidgetPanelDefault.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/WidgetPanelDefault.java (rev 0) +++ trunk/src/dl-learner/org/dllearner/gui/WidgetPanelDefault.java 2008-01-28 02:38:38 UTC (rev 430) @@ -0,0 +1,61 @@ +package org.dllearner.gui; + +/** + * Copyright (C) 2007, 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/>. + * + */ + +import java.awt.BorderLayout; +import java.awt.Color; + +import javax.swing.JLabel; +import javax.swing.JPanel; + +import org.dllearner.core.Component; +import org.dllearner.core.config.ConfigOption; + + +/** + * WidgetPanelDefault + * + * @author Tilo Hielscher + * + */ +public class WidgetPanelDefault extends JPanel { + + private static final long serialVersionUID = 4059515858894036769L; + private JLabel nameLabel; + private JPanel centerPanel = new JPanel(); + + public WidgetPanelDefault(Config config, Component component, Class<? extends Component> componentOption, ConfigOption<?> configOption) { + + // default + nameLabel = new JLabel(configOption.getName()); + + // text + nameLabel = new JLabel(configOption.getName()); + JLabel notImplementedLabel = new JLabel(configOption.getClass().getSimpleName() + " not implemented"); + notImplementedLabel.setForeground(Color.RED); + centerPanel.add(nameLabel); + centerPanel.add(notImplementedLabel); + + // default + add(centerPanel, BorderLayout.CENTER); + } + +} Modified: trunk/src/dl-learner/org/dllearner/gui/WidgetPanelInteger.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/WidgetPanelInteger.java 2008-01-26 19:25:33 UTC (rev 429) +++ trunk/src/dl-learner/org/dllearner/gui/WidgetPanelInteger.java 2008-01-28 02:38:38 UTC (rev 430) @@ -39,7 +39,7 @@ /** - * WidgetPanel + * WidgetPanelInteger * * @author Tilo Hielscher * @@ -55,38 +55,19 @@ private JButton setButton = new JButton("Set"); private Component component; private Class<? extends Component> componentOption; - + + private Integer value; + private JTextField integerField = new JTextField(3); + + public WidgetPanelInteger(Config config, Component component, Class<? extends Component> componentOption, ConfigOption<?> configOption) { this.config = config; this.configOption = configOption; this.component = component; this.componentOption = componentOption; - System.out.println("1st: " + component); - - // default - nameLabel = new JLabel(configOption.getName()); - setButton.addActionListener(this); - - // IntegerConfigOption - if (configOption.toString().contains("IntegerConfigOption")) { - JTextField integerField = new JTextField(3); - integerField.setText("100"); - System.out.println(configOption.getDefaultValue()); - centerPanel.add(nameLabel); - centerPanel.add(integerField); - centerPanel.add(setButton); - } - // UNKNOWN - else { - nameLabel = new JLabel(configOption.getName()); - JLabel notImplementedLabel = new JLabel("not an integer"); - notImplementedLabel.setForeground(Color.RED); - centerPanel.add(nameLabel); - centerPanel.add(notImplementedLabel); - } - - // default + showLabel(); // name of option and tooltip + showThingToChange(); // textfield, setbutton add(centerPanel, BorderLayout.CENTER); } @@ -96,30 +77,79 @@ public void actionPerformed(ActionEvent e) { if (e.getSource() == setButton) { - // INTEGER - Integer value = 10; - IntegerConfigOption specialOption; - String name = configOption.getName(); - //Component component = config.getLearningAlgorithm(); - System.out.println("name: " + name + " & value: " + value); - specialOption = (IntegerConfigOption) config.getComponentManager().getConfigOption(componentOption, name); - try { - ConfigEntry<Integer> specialEntry = new ConfigEntry<Integer>(specialOption, value); - System.out.println("TEST specialEntry: " + specialEntry); - System.out.println("TEST component: " + component); - config.getComponentManager().applyConfigEntry(component, specialEntry); + setEntry(); + } + } + + private void showLabel() { + nameLabel = new JLabel(configOption.getName()); + centerPanel.add(nameLabel); + } + + + private void showThingToChange () { + if (component != null) { + System.out.println("show set Integer config.getComponentManager().getConfigOptionValue(component, name): " + config.getComponentManager().getConfigOptionValue(component, configOption.getName())); + + // IntegerConfigOption + if (configOption.getClass().toString().contains("IntegerConfigOption")) { + // seted value + if (config.getComponentManager().getConfigOptionValue(component, configOption.getName()) != null) { + value = (Integer) config.getComponentManager().getConfigOptionValue(component, configOption.getName()); + System.out.println("value readed: " + value); + } + // default value + else if (configOption.getDefaultValue() != null) { + System.out.println("default value null"); + value = (Integer) configOption.getDefaultValue(); + } + // then 0 + else { + value = 0; + System.out.println("default value not null"); + } + System.out.println("value: " + value); + integerField.setText(value.toString()); + System.out.println("configOption.getDefaultValue(): " + configOption.getDefaultValue()); + setButton.addActionListener(this); + centerPanel.add(integerField); + centerPanel.add(setButton); } - catch (InvalidConfigOptionValueException s) { - s.printStackTrace(); + // UNKNOWN + else { + nameLabel = new JLabel(configOption.getName()); + JLabel notImplementedLabel = new JLabel("not an integer"); + notImplementedLabel.setForeground(Color.RED); + centerPanel.add(nameLabel); + centerPanel.add(notImplementedLabel); } } + else { // configOption == NULL + JLabel noConfigOptionLabel = new JLabel("no init at moment"); + noConfigOptionLabel.setForeground(Color.RED); + centerPanel.add(noConfigOptionLabel); + } } - public void setComponent (Component component) { - this.component = component; + private void setEntry() { + // INTEGER + IntegerConfigOption specialOption; + value = Integer.parseInt(integerField.getText()); + System.out.println("set Integer: " + configOption.getName() + " = " + value); + specialOption = (IntegerConfigOption) config.getComponentManager().getConfigOption(componentOption, configOption.getName()); + try { + ConfigEntry<Integer> specialEntry = new ConfigEntry<Integer>(specialOption, value); + //System.out.println("set Integer specialEntry: " + specialEntry); + //System.out.println("set Integer component: " + component); + //System.out.println("set Integer componentOption: " + componentOption); + //System.out.println("set Integer config.getComponentManager().getConfigOptionValue(component, name): " + config.getComponentManager().getConfigOptionValue(component, name)); + config.getComponentManager().applyConfigEntry(component, specialEntry); + // update this + System.out.println("set Integer config.getComponentManager().getConfigOptionValue(component, name): " + config.getComponentManager().getConfigOptionValue(component, configOption.getName())); + System.out.println("seted value: " + this.value); + } + catch (InvalidConfigOptionValueException s) { + s.printStackTrace(); + } } - - public void setComponentOption (Class<? extends Component> componentOption) { - this.componentOption = componentOption; - } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jen...@us...> - 2008-01-26 19:25:36
|
Revision: 429 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=429&view=rev Author: jenslehmann Date: 2008-01-26 11:25:33 -0800 (Sat, 26 Jan 2008) Log Message: ----------- algorithm fixes and beautification Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLComponent.java trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java Modified: trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLComponent.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLComponent.java 2008-01-26 01:51:11 UTC (rev 428) +++ trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLComponent.java 2008-01-26 19:25:33 UTC (rev 429) @@ -287,6 +287,7 @@ // options to it algorithm = new ExampleBasedROLearner( learningProblem, + rs, operator, algHeuristic, // usedConcepts, @@ -305,7 +306,7 @@ } public static String getName() { - return "example driven refinement operator based learning algorithm [not working]"; + return "example driven refinement operator based learning algorithm"; } @Override Modified: trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java =================================================================== --- trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java 2008-01-26 01:51:11 UTC (rev 428) +++ trunk/src/dl-learner/org/dllearner/algorithms/refexamples/ExampleBasedROLearner.java 2008-01-26 19:25:33 UTC (rev 429) @@ -148,6 +148,7 @@ public ExampleBasedROLearner( LearningProblem learningProblem, + ReasoningService rs, RefinementOperator operator, ExampleBasedHeuristic heuristic, // Set<AtomicConcept> allowedConcepts, @@ -167,27 +168,29 @@ this.posOnlyLearningProblem = (PosOnlyDefinitionLP) learningProblem; posOnly = true; } - - // this.heuristic = heuristic; - // candidate sets entsprechend der gewählten Heuristik initialisieren + this.rs = rs; + this.operator = (RhoDown) operator; + // initialise candidate set with heuristic as ordering candidates = new TreeSet<ExampleBasedNode>(heuristic); - // newCandidates = new TreeSet<Node>(nodeComparator); + // this.noisePercentage ... + this.writeSearchTree = writeSearchTree; + this.replaceSearchTree = replaceSearchTree; + this.searchTreeFile = searchTreeFile; + this.useTooWeakList = useTooWeakList; + this.useOverlyGeneralList = useOverlyGeneralList; + this.useShortConceptConstruction = useShortConceptConstruction; } public void start() { - // Suche wird mit Top-Konzept gestartet + // start search with most general concept Top top = new Top(); ExampleBasedNode topNode = new ExampleBasedNode(top); - // int coveredNegativeExamples = learningProblem.coveredNegativeExamplesOrTooWeak(top); - // aus Top folgen immer alle negativen Beispiele, d.h. es ist nur eine Lösung, wenn - // es keine negativen Beispiele gibt + // top covers all negatives int coveredNegativeExamples = getNumberOfNegatives(); topNode.setCoveredNegativeExamples(coveredNegativeExamples); - // topNode.setHorizontalExpansion(1); // die 0 ist eigentlich richtig, da keine Refinements - // der Länge 1 untersucht wurden candidates.add(topNode); candidatesStable.add(topNode); - // Abbruchvariable => beachten, dass bereits TOP eine Lösung sein kann + // note that TOP may already be a solution solutionFound = (coveredNegativeExamples == 0); solutions = new LinkedList<Concept>(); if(solutionFound) @@ -690,7 +693,7 @@ } public void stop() { - + stop = true; } public Concept getBestSolution() { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ton...@us...> - 2008-01-26 01:51:14
|
Revision: 428 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=428&view=rev Author: tonytacker Date: 2008-01-25 17:51:11 -0800 (Fri, 25 Jan 2008) Log Message: ----------- fixed a warning Modified Paths: -------------- trunk/src/dl-learner/org/dllearner/gui/WidgetPanelInteger.java Modified: trunk/src/dl-learner/org/dllearner/gui/WidgetPanelInteger.java =================================================================== --- trunk/src/dl-learner/org/dllearner/gui/WidgetPanelInteger.java 2008-01-26 01:40:55 UTC (rev 427) +++ trunk/src/dl-learner/org/dllearner/gui/WidgetPanelInteger.java 2008-01-26 01:51:11 UTC (rev 428) @@ -31,7 +31,7 @@ import javax.swing.JButton; import org.dllearner.core.Component; -import org.dllearner.core.ComponentManager; +//import org.dllearner.core.ComponentManager; import org.dllearner.core.config.ConfigEntry; import org.dllearner.core.config.ConfigOption; import org.dllearner.core.config.IntegerConfigOption; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |