Examples of OntoSpreadState


Examples of org.ontospread.state.OntoSpreadState

      }
    }
   
  }
  public void createPlayer(ScoredConceptTO[] initialConcepts) throws ConceptNotFoundException {
    OntoSpreadState ontoSpreadState = new OntoSpreadState();   
    ontoSpreadState.setInitialConcepts(initialConcepts);   
    this.player = new SpreadDebugPlayer(ontoSpreadProcess,ontoSpreadState);
  }
View Full Code Here

Examples of org.ontospread.state.OntoSpreadState

    assertNotNull(process);
   
  }
  public void testCreateExecProcess(){
    OntoSpreadProcess process = (OntoSpreadProcess) ApplicationContextLocator.getApplicationContext().getBean("process");
    OntoSpreadState state = (OntoSpreadState) ApplicationContextLocator.getApplicationContext().getBean("ontoSpreadState");
    assertNotNull(process);   
    assertNotNull(state);
    assertEquals(2, state.getInitialConcepts().length);
  }
View Full Code Here

Examples of org.ontospread.state.OntoSpreadState

    ontoSpreadXMLState.setCurrentScore(ontoSpreadState.getCurrentScore());
    return ontoSpreadXMLState;
  }
 
  public static OntoSpreadState asState(OntoSpreadXMLState ontoSpreadXMLState){
    OntoSpreadState ontoSpreadState = new OntoSpreadState();
    ScoredConceptTO []initialConcepts = new ScoredConceptTO[ontoSpreadXMLState.getScoredConcepts().getScoredConceptTOs().size()];
    int k = 0;
    for (ScoredConceptTOType scoredXML : ontoSpreadXMLState.getScoredConcepts().getScoredConceptTOs()) {
      ScoredConceptTO scoredConceptTO = new ScoredConceptTO();
      scoredConceptTO.setConceptUri(scoredXML.getConceptUri());
      scoredConceptTO.setScore(scoredXML.getScore())
      initialConcepts[k++] = scoredConceptTO; 
    }
    ontoSpreadState.setInitialConcepts(initialConcepts);
    ontoSpreadState.setSpreadTime(ontoSpreadXMLState.getSpreadTime());
   
    Set<String> spreadedConcepts = new HashSet<String>();
    for (String uri : ontoSpreadXMLState.getSpreadedConcepts().getSpreadedConcepts()) {
      spreadedConcepts.add(uri);
    }
    ontoSpreadState.setSpreadedConcepts(spreadedConcepts );
   
   
   
    Map<String, PathTO[]> spreadPathTable = new HashMap<String, PathTO[]>();
    for (EntryPathTableType entry : ontoSpreadXMLState.getSpreadPathTable().getSpreadTableTOs()) {
      String key = entry.getUri();
      PathTOTypeList pathTOs = entry.getPathTOs();
      PathTO []path = new PathTO[pathTOs==null?0:pathTOs.getPathTOs().size()];
      if(pathTOs != null){
        int i = 0;
        for (PathTOType pathTo : pathTOs.getPathTOs()) {
          path[i++] = new PathTO(pathTo.getUri(),pathTo.getRelations().getRelations().toArray(new String[pathTo.getRelations().getRelations().size()]));
       
      }     
      spreadPathTable.put(key, path);     
    }
    ontoSpreadState.setSpreadPathTable(spreadPathTable);
   
    SpreadedConceptTO[] result = new SpreadedConceptTO[ontoSpreadXMLState.getFinalSpreadedConcepts().getSpreadedConceptTOs().size()];
    int i = 0;
    for (SpreadedConceptTOType spreadedXML : ontoSpreadXMLState.getFinalSpreadedConcepts().getSpreadedConceptTOs()){
      PathTOTypeList pathTOs = spreadedXML.getPathTOs();
      PathTO []path = new PathTO[pathTOs==null?0:pathTOs.getPathTOs().size()];
      if(pathTOs != null){
        int j = 0;
        for (PathTOType pathTo : pathTOs.getPathTOs()) {
          path[j++] = new PathTO(pathTo.getUri(),
              pathTo.getRelations().getRelations().toArray(new String[pathTo.getRelations().getRelations().size()]));
       
      }     
      double score = spreadedXML.getScore();
      result[i++] = new SpreadedConceptTO(new ConceptTO(spreadedXML.getConceptUri()),path,score );
     
    }
    ontoSpreadState.setFinalSpreadedConcepts(result);
   
    List<UriDepthPair> sortedList = new LinkedList<UriDepthPair>();
    for (UriDepthPairType uriXMLPair : ontoSpreadXMLState.getUriDepthPair().getUriDepthPairs()) {
      sortedList.add(new UriDepthPair(uriXMLPair.getConceptUri(),uriXMLPair.getDepth()));
    }
    ontoSpreadState.setSortedList(sortedList);

    Map<String, Double> concepts = new HashMap<String, Double>();
    for (EntryConceptsType entryXML : ontoSpreadXMLState.getConcepts().getEntryConceptTOs()) {
      concepts.put(entryXML.getUri(), entryXML.getValue());
    }
    ontoSpreadState.setConcepts(concepts );
   
    HashMap<PathTO, Integer> prizeTable = ontoSpreadState.getConceptsToPrize().getPrizeTable();   
    for (EntryPrizeTableTOType entry : ontoSpreadXMLState.getPrizeTable().getEntryPrizeTableTOs()) {
      int value = entry.getHits();
      PathTO pathTO = new PathTO(entry.getPathTO().getUri(),entry.getPathTO().getRelations().getRelations().toArray(new String[entry.getPathTO().getRelations().getRelations().size()]));
      prizeTable.put(pathTO , value);
    }
    ontoSpreadState.setConceptToSpread(new ConceptTO(ontoSpreadXMLState.getConceptTOSpread()));
    ontoSpreadState.setHasIteration(ontoSpreadXMLState.isHasIteration());
    ontoSpreadState.setCurrentScore(ontoSpreadXMLState.getCurrentScore());
   
    return ontoSpreadState;
  }
View Full Code Here

Examples of org.ontospread.state.OntoSpreadState

   
  }

  public void testVisitOntoSpreadSimpleRestriction() {
    OntoSpreadRestriction restriction = new OntoSpreadRestrictionMinConcepts(2);
    OntoSpreadState state = new OntoSpreadState();
    OntoSpreadBooleanRestrictionVisitor visitor = new OntoSpreadBooleanRestrictionVisitor();
    visitor.setOntoSpreadState(state);
    Object stop = visitor.visit(restriction);
    assertEquals(stop.getClass(),Boolean.class);
    assertTrue(((Boolean)stop).booleanValue());
    for(int i = 0; i<10;i++){
      state.getSpreadedConcepts().add(String.valueOf(i));
    }
    stop = visitor.visit(restriction);
    assertFalse(((Boolean)stop).booleanValue());   
  }
View Full Code Here

Examples of org.ontospread.state.OntoSpreadState

  public static void main(String []args) throws Exception{
    String []conceptUris = new String[]{
        "http://websemantica.fundacionctic.org/ontologias/bopa/empleado.owl#Vacaciones",
         "http://websemantica.fundacionctic.org/ontologias/bopa/ensamble.owl#EmpleadoDeFincas"};
    OntoSpreadState ontoSpreadState = new OntoSpreadState();
    ontoSpreadState.setInitialConcepts(OntoSpreadTestUtils.createScoredConcepts(conceptUris,1.0));
    SpreadPlayer player = new SpreadSimplePlayer(OntoSpreadTestUtils.createDefaultOntoSpreadProcess(3, 5, 0.3),
        ontoSpreadState);   
    while(player.hasNext()){
      ontoSpreadState = player.next();     
    }
   
    SpreadedConceptTO spreadedConcepts[] = ontoSpreadState.getFinalSpreadedConcepts();
    for (int i = 0; i < spreadedConcepts.length; i++) {
      System.out.println(spreadedConcepts[i]);
    }
   
  }
View Full Code Here

Examples of org.ontospread.state.OntoSpreadState

    double minActivation = 0;
    String context = "";
    int retries = 0;
    long time = 0;   
    double defaultValue = 1.0;   
    OntoSpreadState ontoSpreadState = new OntoSpreadState()
    String [] initialUris = new String[]{
        "http://dbpedia.org/resource/Berlin",
        "http://dbpedia.org/resource/Quini",
        "http://dbpedia.org/resource/Oviedo"
    };   
    ScoredConceptTO[] initialConcepts = new ScoredConceptTO[initialUris.length];
    for (int i = 0; i < initialUris.length; i++) {
      initialConcepts[i] = new ScoredConceptTO(initialUris[i],1.0)
    }   
    ontoSpreadState.setInitialConcepts(initialConcepts);   
    String relationsFile = "src/test/resources/dbpedia/dbpedia-weights.rdf";
    String[] resources = new String[0];
    SpreadSimplePlayer player = new SpreadSimplePlayer(OntoSpreadDemoUtils.createDefaultOntoSpreadProcess(resources, relationsFile,
        min,
        max,
        minActivation,
        context,       
        retries, time, defaultValue),  ontoSpreadState);   
    ontoSpreadState = player.next();
    while(player.hasNext()){
      ontoSpreadState = player.next();
    }
   
    System.out.println("::::::::::::::Time "+ontoSpreadState.getSpreadTime()+"ms :::::::::::::::::::");
    SpreadedConceptTO[] finalSpreadedConcepts = ontoSpreadState.getFinalSpreadedConcepts();
    Arrays.sort(finalSpreadedConcepts, new WebOntologyDAOImplTest.CompareFinaSpreadConcepts());
    for (int i = 0; i < finalSpreadedConcepts.length && i<10; i++) {
      System.out.println(finalSpreadedConcepts[i]);     
    }
    //System.out.println(ToStringHelper.arrayToString(finalSpreadedConcepts,"\n"));   
View Full Code Here

Examples of org.ontospread.state.OntoSpreadState

    }
    */
  }
  private StateDAOPairTO execute(Test test, RestrictionManagerHelper manager) throws ConceptNotFoundException {
    logger.info("Execute");
    OntoSpreadState state = new OntoSpreadState();
    ScoredConceptTO[] initialConcepts = OntoSpreadTestUtils.createScoredConcepts(test.getOntoSpreadConfig().getInitialConcepts());
    state.setInitialConcepts(initialConcepts);
    OntoSpreadRelationWeight relationWeight = OntoSpreadTestUtils.createRelationWeight(test.getOntoSpreadConfig().getRelations().getLocations());
    OntologyDAO ontologyDAO = OntoSpreadTestUtils.createOntologyDAO(test.getResources().getLocations());
    OntoSpreadProcess process = new OntoSpreadProcess(
        ontologyDAO,
        OntoSpreadTestUtils.createDefaultPreAdjustment(test.getOntoSpreadConfig().getInitialConcepts().getValue()),
View Full Code Here

Examples of org.ontospread.state.OntoSpreadState

  public OntoSpreadState last() throws ConceptNotFoundException {
     throw new UnsupportedOperationException();
  }

  public OntoSpreadState next() throws ConceptNotFoundException {
    OntoSpreadState ontoSpreadState =
      getOntoSpreadProcess().iterate(ontoCurrentSpreadState);
    if(!hasNext()){
      this.ontoSpreadProces.postAdjustment(ontoSpreadState);
    }
    ontoCurrentSpreadState = ontoSpreadState;
View Full Code Here

Examples of org.ontospread.state.OntoSpreadState

public class OntoSpreadRestrictionMaxConceptsTest extends TestCase {

  public void testEval() {
    OntoSpreadRestriction maxRestriction = new OntoSpreadRestrictionMaxConcepts(10);
    OntoSpreadState ontoSpreadState = new OntoSpreadState();
    Set<String> spreadedConcepts= new HashSet<String>();
    ontoSpreadState.setSpreadedConcepts(spreadedConcepts);
    assertTrue(maxRestriction.eval(ontoSpreadState));
    for(int i = 0; i<=10;i++){
      ontoSpreadState.getSpreadedConcepts().add(String.valueOf(i));
    }
    assertFalse(maxRestriction.eval(ontoSpreadState));
  }
View Full Code Here

Examples of org.ontospread.state.OntoSpreadState

public class OntoSpreadRestrictionMinConceptsTest extends TestCase {

  public void testEval() {
    OntoSpreadRestriction minRestriction = new OntoSpreadRestrictionMinConcepts(10);
    OntoSpreadState ontoSpreadState = new OntoSpreadState();
    Set<String> spreadedConcepts= new HashSet<String>();
    ontoSpreadState.setSpreadedConcepts(spreadedConcepts);
    assertTrue(minRestriction.eval(ontoSpreadState));
    for(int i = 0; i<=10;i++){
      ontoSpreadState.getSpreadedConcepts().add(String.valueOf(i));
    }
    assertFalse(minRestriction.eval(ontoSpreadState));
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.