From: <sha...@us...> - 2011-08-27 20:37:46
|
Revision: 3142 http://dl-learner.svn.sourceforge.net/dl-learner/?rev=3142&view=rev Author: shadowtm Date: 2011-08-27 20:37:40 +0000 (Sat, 27 Aug 2011) Log Message: ----------- Cleaned up the IConfiguration interface and added a father_autowired.conf example. Modified Paths: -------------- trunk/components-core/src/main/java/org/dllearner/configuration/IConfiguration.java trunk/interfaces/pom.xml trunk/interfaces/src/main/java/org/dllearner/configuration/spring/ConfigurationBasedBeanDefinitionRegistryPostProcessor.java trunk/interfaces/src/main/java/org/dllearner/confparser3/ConfParserConfiguration.java trunk/interfaces/src/test/java/org/dllearner/cli/FatherCLITest.java Added Paths: ----------- trunk/examples/family/father_autowired.conf Modified: trunk/components-core/src/main/java/org/dllearner/configuration/IConfiguration.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/configuration/IConfiguration.java 2011-08-27 20:28:40 UTC (rev 3141) +++ trunk/components-core/src/main/java/org/dllearner/configuration/IConfiguration.java 2011-08-27 20:37:40 UTC (rev 3142) @@ -20,8 +20,6 @@ package org.dllearner.configuration; import java.util.Collection; -import java.util.Properties; -import java.util.Set; /** * Created by IntelliJ IDEA. @@ -35,25 +33,6 @@ public interface IConfiguration { /** - * Get the object for the given key. - * - * @param key The key of the object to retrieve. - * @return The Object representation of the value keyed by key. - */ - public Object getObjectValue(String key); - - /** - * Get a Properties object describing all of the properties which this configuration object - * knows about. - * - * As Properties are basically Map<String,String> objects, you can use getObjectValue(String key). To - * get the Object. - * - * @return A Properties Object. - */ - public Properties getProperties(); - - /** * Get a collection of all the bean names defined in the configuration. * * @return a collection of all the bean names defined in the configuration. @@ -69,32 +48,17 @@ public Class getClass(String beanName); /** - * Get the set of positive examples associated with this configuration. - * - * Never returns null, only an empty set if there are no positive examples. - * - * @return The set of positive examples associated with this configuration. - */ - public Set<String> getPositiveExamples(); - - /** - * Get the set of negative examples associated with this configuration. - * - * Never returns null, only an empty set if there are no negative examples. - * - * @return The set of negative examples associated with this configuration. - */ - public Set<String> getNegativeExamples(); - - /** * Get the Base Directory where this configuration should be running out of. * * @return The Base Directory where this configuration should be running out of. */ public String getBaseDir(); - - public Collection<IConfigurationProperty> getConfigurationOptions(String beanName); - - + /** + * Get the configuration properties for the specified bean. + * + * @param beanName The bean to get properties for. + * @return A collection of properties + */ + public Collection<IConfigurationProperty> getConfigurationProperties(String beanName); } Copied: trunk/examples/family/father_autowired.conf (from rev 3141, trunk/examples/family/father.conf) =================================================================== --- trunk/examples/family/father_autowired.conf (rev 0) +++ trunk/examples/family/father_autowired.conf 2011-08-27 20:37:40 UTC (rev 3142) @@ -0,0 +1,49 @@ +/** + * Father Example + * + * possible solution: + * male AND EXISTS hasChild.TOP + * + * Copyright (C) 2007, Jens Lehmann + */ + +// declare some prefixes to use as abbreviations +prefixes = [ ("kb","http://localhost/foo#") ] + +// knowledge source definition +ks.type = "KB file" +ks.url = "father.kb" +// ks.baseDir = "examples/family"; //Assuming running from parent directory of examples. + +// reasoner +reasoner.type = "fast instance checker" +reasoner.reasonerComponent = embeddedReasoner + +embeddedReasoner.type = "OWL API Reasoner" +embeddedReasoner.sources = { ks } + +// learning problem +lp.type = "posNegStandard" +lp.positiveExamples = {"kb:stefan","kb:markus","kb:bernd"} +lp.negativeExamples = {"kb:heinz","kb:anna","kb:gabi","kb:michelle"} + +// plug a reasoner into the learning problem +lp.reasoner = reasoner +//lp.reasoner = reasoner - try to remove the component:part in the parser + +// create a refinement operator and configure it +op.type = "rho" +op.useCardinalityRestrictions = true +op.reasoner = reasoner + +// create a heuristic and configure it +h.type = "multiheuristic" +h.expansionPenaltyFactor = 0.2 + +// create learning algorithm to run +alg.type = "ocel" +alg.reasoner = reasoner +alg.operator = op +alg.learningProblem = lp +alg.heuristic = h +alg.maxExecutionTimeInSeconds = 15 \ No newline at end of file Modified: trunk/interfaces/pom.xml =================================================================== --- trunk/interfaces/pom.xml 2011-08-27 20:28:40 UTC (rev 3141) +++ trunk/interfaces/pom.xml 2011-08-27 20:37:40 UTC (rev 3142) @@ -168,7 +168,6 @@ <exclude>org/dllearner/configuration/spring/TestBean.java</exclude> <exclude>org/dllearner/test/SpringTest.java</exclude> <exclude>org/dllearner/test/junit/GeizhalsTest.java</exclude> - <exclude>org/dllearner/cli/FatherCLITest.java</exclude> </excludes> </configuration> </plugin> Modified: trunk/interfaces/src/main/java/org/dllearner/configuration/spring/ConfigurationBasedBeanDefinitionRegistryPostProcessor.java =================================================================== --- trunk/interfaces/src/main/java/org/dllearner/configuration/spring/ConfigurationBasedBeanDefinitionRegistryPostProcessor.java 2011-08-27 20:28:40 UTC (rev 3141) +++ trunk/interfaces/src/main/java/org/dllearner/configuration/spring/ConfigurationBasedBeanDefinitionRegistryPostProcessor.java 2011-08-27 20:37:40 UTC (rev 3142) @@ -66,7 +66,7 @@ BeanDefinition beanDefinition = beanFactory.getBeanDefinition(beanName); - Collection<IConfigurationProperty> properties = configuration.getConfigurationOptions(beanName); + Collection<IConfigurationProperty> properties = configuration.getConfigurationProperties(beanName); for (IConfigurationProperty property : properties) { Modified: trunk/interfaces/src/main/java/org/dllearner/confparser3/ConfParserConfiguration.java =================================================================== --- trunk/interfaces/src/main/java/org/dllearner/confparser3/ConfParserConfiguration.java 2011-08-27 20:28:40 UTC (rev 3141) +++ trunk/interfaces/src/main/java/org/dllearner/confparser3/ConfParserConfiguration.java 2011-08-27 20:37:40 UTC (rev 3142) @@ -38,16 +38,6 @@ } @Override - public Object getObjectValue(String key) { - return null; //To change body of implemented methods use File | Settings | File Templates. - } - - @Override - public Properties getProperties() { - return null; //To change body of implemented methods use File | Settings | File Templates. - } - - @Override public Collection<String> getBeanNames() { Set<String> result = new HashSet<String>(); Map<String,List<ConfFileOption2>> beans = parser.getConfOptionsByBean(); @@ -95,22 +85,12 @@ } @Override - public Set<String> getPositiveExamples() { - return null; //To change body of implemented methods use File | Settings | File Templates. - } - - @Override - public Set<String> getNegativeExamples() { - return null; //To change body of implemented methods use File | Settings | File Templates. - } - - @Override public String getBaseDir() { return baseDir; } @Override - public Collection<IConfigurationProperty> getConfigurationOptions(String beanName) { + public Collection<IConfigurationProperty> getConfigurationProperties(String beanName) { List<ConfFileOption2> confFileOptions = parser.getConfOptionsByBean(beanName); Collection<IConfigurationProperty> result = new ArrayList<IConfigurationProperty>(); Modified: trunk/interfaces/src/test/java/org/dllearner/cli/FatherCLITest.java =================================================================== --- trunk/interfaces/src/test/java/org/dllearner/cli/FatherCLITest.java 2011-08-27 20:28:40 UTC (rev 3141) +++ trunk/interfaces/src/test/java/org/dllearner/cli/FatherCLITest.java 2011-08-27 20:37:40 UTC (rev 3142) @@ -22,52 +22,53 @@ * User: Chris * Date: 8/23/11 * Time: 5:21 AM - * + * <p/> * Test for the CLI Class */ public class FatherCLITest { - private static ApplicationContext context; - @BeforeClass - public static void setUp() throws IOException{ - + public ApplicationContext createApplicationContext(Resource confFile) throws IOException { ApplicationContextBuilder builder = new DefaultApplicationContextBuilder(); - /** The DL-Learner Config File */ - Resource confFile = new FileSystemResource("../examples/family/father.conf"); - -// confFile.getAbsoluteFile().getParent( - //Component Key Prefixes List<String> componentKeyPrefixes = new ArrayList<String>(); componentKeyPrefixes.add("component:"); componentKeyPrefixes.add(":"); //Spring Config Files List<Resource> springConfigResources = new ArrayList<Resource>(); -// springConfigResources.add(new ClassPathResource("/org/dllearner/configuration/spring/configuration-based-property-override-configurer-configuration.xml")); //DL-Learner Configuration Object IConfiguration configuration = new ConfParserConfiguration(confFile); //Build The Application Context - context = builder.buildApplicationContext(configuration, componentKeyPrefixes,springConfigResources); + ApplicationContext context = builder.buildApplicationContext(configuration, componentKeyPrefixes, springConfigResources); + return context; } @Test - public void testFatherConf(){ + public void testFatherConf() throws Exception { + Resource confFile = new FileSystemResource("../examples/family/father.conf"); + ApplicationContext context = createApplicationContext(confFile); + validateContext(context); + } + @Test + public void testFatherAutoWiredConf() throws Exception { + Resource confFile = new FileSystemResource("../examples/family/father_autowired.conf"); + ApplicationContext context = createApplicationContext(confFile); + validateContext(context); + } + + private void validateContext(ApplicationContext context) { PosNegLPStandard lp = context.getBean("lp", PosNegLPStandard.class); Assert.assertTrue(lp.getPositiveExamples().size() == 3); Assert.assertTrue(lp.getNegativeExamples().size() == 4); Assert.assertNotNull(lp.getReasoner()); - OCEL algorithm = context.getBean("alg",OCEL.class); + OCEL algorithm = context.getBean("alg", OCEL.class); Assert.assertNotNull(algorithm); algorithm.start(); - - - } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |