Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running example problem #10

Open
jupiterhyun opened this issue Mar 26, 2017 · 2 comments
Open

Running example problem #10

jupiterhyun opened this issue Mar 26, 2017 · 2 comments

Comments

@jupiterhyun
Copy link

jupiterhyun commented Mar 26, 2017

Hi, when I play with the example. Basically I have three schemes need to run the match algorithm, I use one match manager to do the job, however, I have received this error message:
Exception in thread "main" java.lang.IllegalArgumentException: the value should be from 0 to 4, found instead: 5
at it.unitn.disi.smatch.async.AsyncTask.setProgress(AsyncTask.java:289)
at it.unitn.disi.smatch.async.AsyncTask.progress(AsyncTask.java:590)
at it.unitn.disi.smatch.async.AsyncTask.progress(AsyncTask.java:574)
at it.unitn.disi.smatch.matchers.element.RunnableElementMatcher.elementLevelMatching(RunnableElementMatcher.java:218)
at it.unitn.disi.smatch.MatchManager.elementLevelMatching(MatchManager.java:189)
at it.unitn.disi.smatch.MatchManager.online(MatchManager.java:220)
at it.unitn.disi.smatch.MatchManager.match(MatchManager.java:232)
at it.unitn.disi.smatch.examples.SMatchAPIDemo.example(SMatchAPIDemo.java:78)
at it.unitn.disi.smatch.examples.SMatchAPIDemo.main(SMatchAPIDemo.java:21)

Could you please help on how to solve this? Thank you very much,

The source code is here:

    System.out.println("Starting example...");
    System.out.println("Creating MatchManager...");
    IMatchManager mm = MatchManager.getInstanceFromResource("/it/unitn/disi/smatch/examples/conf/s-match-spsm.xml");

    System.out.println("Creating source context...");
    IContext s = mm.createContext();
    INode sroot = s.createRoot("university one");
    sroot.createChild("student");

    System.out.println("Creating target context...");
    IContext t = mm.createContext();
    INode root = t.createRoot("student.xml");
    root.createChild("student name");
    root.createChild("date of birth");
    root.createChild("cell number");
    root.createChild("email");
    root.createChild("student id");
    root.createChild("major");

    IContext s2 = mm.createContext();
    INode sroot2 = s2.createRoot("student two");
    sroot2.createChild("student");
    
    IContextMapping<INode> result = mm.match(s, s2);
    
    System.out.println("Processing results...");
    System.out.println("Printing matches:");
    for (IMappingElement<INode> e : result) {
        System.out.println(e.getSource().nodeData().getName() + "\t" + e.getRelation() + "\t" + e.getTarget().nodeData().getName());
    }
    
    result = mm.match(s, t);
    
    System.out.println("Processing results...");
    System.out.println("Printing matches:");
    for (IMappingElement<INode> e : result) {
        System.out.println(e.getSource().nodeData().getName() + "\t" + e.getRelation() + "\t" + e.getTarget().nodeData().getName());
    }
    
    System.out.println("Done");
@DavidLeoni
Copy link
Member

Thanks for reporting the bug, I was able to reproduce it. Seems related to #4

I don't have much time to properly investigate the issue. As a workaround that works, you can create a synchronous version of the s-match-spsm.xml. For example, I just copied that file, renamed it to s-match-spsm-sync.xml and in it changed

<import resource="s-match.xml"/>
into
<import resource="s-match-synchronous.xml"/>

For reference, here is the file:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.1.xs

    <import resource="s-match-synchronous.xml"/>
.
    <bean id="treeMatcher" class="it.unitn.disi.smatch.matchers.structure.tree.spsm.SPSMTreeMatcher">
        <constructor-arg name="nodeMatcher" ref="nodeMatcher"/>
        <constructor-arg name="mappingFactory" ref="mappingFactory"/>
        <constructor-arg name="spsmFilter" ref="spsmFilter"/>
    </bean>
    <bean id="spsmFilter" class="it.unitn.disi.smatch.filters.SPSMMappingFilter">
        <constructor-arg name="mappingFactory" ref="mappingFactory"/>
    </bean>

</beans>

@jupiterhyun
Copy link
Author

Hi,

Thanks for response this. I have followed what you said, but I have new error messages said spring framework detected cyclic loading of class path resource,

source code of the main:
//others are the same:
IMatchManager mm = MatchManager.getInstanceFromResource("/it/unitn/disi/smatch/examples/conf/s-match-spsm-sync.xml");

source code of s-match-spsm-sync.xml is the same as yours.
source code of s-match-spsm-synchronous.xml

<!-- enable ${name} properties resolution -->
<context:property-placeholder properties-ref="properties"/>
<util:properties id="properties"/>

<bean id="matchManager" class="it.unitn.disi.smatch.MatchManager">
    <constructor-arg name="contextLoader" ref="contextLoader"/>
    <constructor-arg name="contextRenderer" ref="contextRenderer"/>
    <constructor-arg name="mappingLoader" ref="mappingLoader"/>
    <constructor-arg name="mappingRenderer" ref="mappingRenderer"/>
    <constructor-arg name="mappingFilter"><null /></constructor-arg>
    <constructor-arg name="mappingFactory" ref="mappingFactory"/>
    <constructor-arg name="contextPreprocessor" ref="contextPreprocessor"/>
    <constructor-arg name="contextClassifier" ref="contextClassifier"/>
    <constructor-arg name="elementMatcher" ref="elementMatcher"/>
    <constructor-arg name="treeMatcher" ref="treeMatcher"/>
</bean>

<bean id="contextLoader" class="it.unitn.disi.smatch.loaders.context.SimpleXMLContextLoader">
    <constructor-arg name="linguisticOracle" ref="linguisticOracle"/>
</bean>

<bean id="contextRenderer" class="it.unitn.disi.smatch.renderers.context.SimpleXMLContextRenderer"/>

<bean id="mappingLoader" class="it.unitn.disi.smatch.loaders.mapping.PlainMappingLoader">
    <constructor-arg name="mappingFactory" ref="mappingFactory"/>
</bean>

<bean id="mappingRenderer" class="it.unitn.disi.smatch.renderers.mapping.PlainMappingRenderer"/>

<bean id="mappingFactory" class="it.unitn.disi.smatch.data.mappings.HashMapping"/>

<bean id="contextPreprocessor" class="it.unitn.disi.smatch.preprocessors.DefaultContextPreprocessor">
    <constructor-arg name="senseMatcher" ref="senseMatcher"/>
    <constructor-arg name="linguisticOracle" ref="linguisticOracle"/>
</bean>

<bean id="contextClassifier" class="it.unitn.disi.smatch.classifiers.CNFContextClassifier"/>

<bean id="elementMatcher" class="it.unitn.disi.smatch.matchers.element.ElementMatcher">
    <constructor-arg name="mappingFactory" ref="mappingFactory"/>
    <constructor-arg name="senseMatcher" ref="senseMatcher"/>
    <constructor-arg name="useWeakSemanticsElementLevelMatchersLibrary" value="true"/>
    <constructor-arg name="stringMatchers">
        <util:list>
            <bean class="it.unitn.disi.smatch.matchers.element.string.Synonym"/>
            <bean class="it.unitn.disi.smatch.matchers.element.string.Prefix"/>
            <bean class="it.unitn.disi.smatch.matchers.element.string.Suffix"/>
            <bean class="it.unitn.disi.smatch.matchers.element.string.NGram"/>
            <bean class="it.unitn.disi.smatch.matchers.element.string.EditDistanceOptimized"/>
        </util:list>
    </constructor-arg>
    <constructor-arg name="senseGlossMatchers"><null /></constructor-arg>
</bean>

<bean id="satSolver" class="it.unitn.disi.smatch.deciders.CachingSolver">
    <constructor-arg name="satSolver">
        <bean class="it.unitn.disi.smatch.deciders.SAT4J"/>
    </constructor-arg>
</bean>

<bean id="nodeMatcher" class="it.unitn.disi.smatch.matchers.structure.node.DefaultNodeMatcher">
    <constructor-arg name="satSolver" ref="satSolver"/>
</bean>

<bean id="treeMatcher" class="it.unitn.disi.smatch.matchers.structure.tree.def.DefaultTreeMatcher">
    <constructor-arg name="nodeMatcher" ref="nodeMatcher"/>
    <constructor-arg name="mappingFactory" ref="mappingFactory"/>
</bean>


<bean id="linguisticOracle" class="it.unitn.disi.smatch.oracles.wordnet.WordNet">
    <!--default config tokenizes too much, so we have to use our own config -->
    <constructor-arg name="jwnlPropertiesPath" value="../conf/wn31resource.xml"/>
</bean>
<alias name="linguisticOracle" alias="senseMatcher"/>

These are error messages I copied:

Exception in thread "main" org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Failed to import bean definitions from relative location [s-match-synchronous.xml]
Offending resource: class path resource [it/unitn/disi/smatch/examples/conf/s-match-spsm-sync.xml]; nested exception is org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Failed to import bean definitions from relative location [s-match-synchronous.xml]
Offending resource: class path resource [it/unitn/disi/smatch/examples/conf/s-match-synchronous.xml]; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: Detected cyclic loading of class path resource [it/unitn/disi/smatch/examples/conf/s-match-synchronous.xml] - check your import definitions!
at org.springframework.beans.factory.parsing.FailFastProblemReporter.error(FailFastProblemReporter.java:70)
at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:85)
at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:76)
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.importBeanDefinitionResource(DefaultBeanDefinitionDocumentReader.java:261)
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseDefaultElement(DefaultBeanDefinitionDocumentReader.java:186)
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:171)
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.doRegisterBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:144)
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:100)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:510)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:392)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:336)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:304)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:181)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:217)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:188)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:252)
at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:127)
at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:93)
at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:129)
at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:537)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:452)
at org.springframework.context.support.ClassPathXmlApplicationContext.(ClassPathXmlApplicationContext.java:139)
at org.springframework.context.support.ClassPathXmlApplicationContext.(ClassPathXmlApplicationContext.java:93)
at it.unitn.disi.smatch.MatchManager.getInstanceFromResource(MatchManager.java:60)
at it.unitn.disi.smatch.examples.SMatchAPIDemo.example(SMatchAPIDemo.java:35)
at it.unitn.disi.smatch.examples.SMatchAPIDemo.main(SMatchAPIDemo.java:21)
Caused by: org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Failed to import bean definitions from relative location [s-match-synchronous.xml]
Offending resource: class path resource [it/unitn/disi/smatch/examples/conf/s-match-synchronous.xml]; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: Detected cyclic loading of class path resource [it/unitn/disi/smatch/examples/conf/s-match-synchronous.xml] - check your import definitions!
at org.springframework.beans.factory.parsing.FailFastProblemReporter.error(FailFastProblemReporter.java:70)
at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:85)
at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:76)
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.importBeanDefinitionResource(DefaultBeanDefinitionDocumentReader.java:261)
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseDefaultElement(DefaultBeanDefinitionDocumentReader.java:186)
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:171)
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.doRegisterBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:144)
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:100)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:510)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:392)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:336)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:304)
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.importBeanDefinitionResource(DefaultBeanDefinitionDocumentReader.java:245)
... 22 more
Caused by: org.springframework.beans.factory.BeanDefinitionStoreException: Detected cyclic loading of class path resource [it/unitn/disi/smatch/examples/conf/s-match-synchronous.xml] - check your import definitions!
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:326)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:304)
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.importBeanDefinitionResource(DefaultBeanDefinitionDocumentReader.java:245)
... 31 more

Please have a look and help me, thank you very much,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants