Package org.ontospread.state

Examples of org.ontospread.state.UriDepthPair


    }
    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()) {
View Full Code Here


            OntoSpreadCommonUtils.registerSpreadPath(ontoSpreadState,initialConcept, null, new PathTO[0]);               
            //Initialitate the list with the uri concept that will spreaded
            OntoSpreadCommonUtils.addToConceptStack(ontoSpreadState,initialConcept, INIT_DEPTH);        
            OntoSpreadCommonUtils.addScore(ontoSpreadState,initialConcepts[i].getScore(), initialConcept);
            initialScore = Math.max(initialScore, initialConcepts[i].getScore());
        sortedList.add(new UriDepthPair(initialConcepts[i].getConceptUri(),INIT_DEPTH));
           }       
        ontoSpreadState.setSortedList(sortedList);
        return initialScore;
    }
View Full Code Here

public class OntoSpreadStackConstraintTest extends TestCase {

  public void testNotEmpty(){
    OntoSpreadState ontoSpreadState = new OntoSpreadState();
    ontoSpreadState.getSortedList().add(new UriDepthPair("http://one.uri", 0));
    assertTrue(OntoSpreadStackConstraint.checkNotEmptyStack(ontoSpreadState));
  }
View Full Code Here

                      new OntoSpreadRelationWeightImpl());
    OntoSpreadState ontoSpreadState = new OntoSpreadState();
    ontoSpreadState.setInitialConcepts(OntoSpreadTestUtils.createScoredConcepts(conceptUris,1.0));
    List<UriDepthPair> sortedList = new LinkedList<UriDepthPair>();
    for(int i = 0; i<conceptUris.length;i++){
      sortedList.add(new UriDepthPair(conceptUris[i],1));
    }
    ontoSpreadState.setSortedList(sortedList);
    while(runOntoSpread.hasIteration(ontoSpreadState)){
      runOntoSpread.applyIteration(ontoSpreadState)
    }
View Full Code Here

                      new OntoSpreadRelationWeightImpl());
    OntoSpreadState ontoSpreadState = new OntoSpreadState();
    ontoSpreadState.setInitialConcepts(OntoSpreadTestUtils.createScoredConcepts(conceptUris,1.0));
    List<UriDepthPair> sortedList = new LinkedList<UriDepthPair>();
    for(int i = 0; i<conceptUris.length;i++){
      sortedList.add(new UriDepthPair(conceptUris[i],1));
    }
    ontoSpreadState.setCurrentScore(2.0);
    ontoSpreadState.setSortedList(sortedList);
    assertTrue(runOntoSpread.hasIteration(ontoSpreadState));
    assertEquals(0, ontoSpreadState.getSpreadedConcepts().size());
View Full Code Here

    OntoSpreadState ontoSpreadState = new OntoSpreadState();
    ontoSpreadState.setInitialConcepts(OntoSpreadTestUtils.createScoredConcepts(conceptUris,1.0));
    setupInitialConcepts(ontoSpreadState, 1.0);   
    List<UriDepthPair> sortedList = new LinkedList<UriDepthPair>();
    for(int i = 0; i<conceptUris.length;i++){
      sortedList.add(new UriDepthPair(conceptUris[i],1));
    }
    ontoSpreadState.setCurrentScore(2.0);
    ontoSpreadState.setSortedList(sortedList);
    while(runOntoSpread.hasIteration(ontoSpreadState)){
      runOntoSpread.applyIteration(ontoSpreadState)
View Full Code Here

            OntoSpreadCommonUtils.registerSpreadPath(ontoSpreadState,initialConcept, null, new PathTO[0]);               
            //Initialitate the list with the uri concept that will spreaded
            OntoSpreadCommonUtils.addToConceptStack(ontoSpreadState,initialConcept, 1);        
            OntoSpreadCommonUtils.addScore(ontoSpreadState,initialConcepts[i].getScore(), initialConcept);
            initialScore = Math.max(initialScore, initialConcepts[i].getScore());
        sortedList.add(new UriDepthPair(initialConcepts[i].getConceptUri(),1));
           }       
        ontoSpreadState.setSortedList(sortedList);
        return initialScore;
    }
View Full Code Here

  }
 
 
  public void spreadConcept(ConceptTO conceptTO, OntoSpreadState ontoSpreadState) throws ConceptNotFoundException{
       //Begin the algorithm with each concept
      final UriDepthPair uriDepth = extractFromConceptStack(ontoSpreadState);     
    final String currentUri = uriDepth.getUri();
    ontoSpreadState.setConceptToSpread(new ConceptTO(uriDepth.getUri()));//FIXME
        final PathTO[] currentSpreadPath = getSpreadPath(ontoSpreadState.getSpreadPathTable(),currentUri);       
        final double currentScore = getScore(ontoSpreadState, currentUri);
        ontoSpreadState.setCurrentScore(currentScore);//FIXME
        final int depth = uriDepth.getDepth();
        final double []parameters = new double[]{depth};
        double degradation = 1.0;
    Concept concept = getOntologyDAO().getConcept(currentUri, null);
    ConceptOperations conceptOperations = new ConceptOperations(concept);
        //We take all the concepts (and the relation wich join with the  // ''concept'' variable)
        //Iterate over them, and score its spread value
    //System.out.println("Spreading "+uriDepth);
    logger.debug("SPREADING "+uriDepth.getUri()+" DEPTH "+uriDepth.getDepth()+" SCORE "+currentScore);
    timer.start();
    for (ConceptRelationPair conceptRelation : conceptOperations.getRelatedConcepts()) {
        final String qualRelationUri = conceptRelation.getOnproperty();
            final String relatedUri =conceptRelation.getConceptUri();
            logger.debug("Activation for "+relatedUri+" from "+uriDepth.getUri()+" on "+qualRelationUri);           
            if (conceptOperations.isSon(conceptRelation.getConceptUri()))
                degradation = getDegradationFunction().applyDegradation(parameters, ontoSpreadState);           
            /**
            * Concept activation
            */
          if(managerBeforeConceptActivationStrategy!= null) {
            managerBeforeConceptActivationStrategy.applyStrategy(ontoSpreadState);
          }
   
            //FIXME:USE as key relatedUri and qualRelationUri
      registerSpreadPath(ontoSpreadState, relatedUri, uriDepth.getUri(), qualRelationUri,currentSpreadPath);         
            /*
             * The puntuation of the concept of this iteration, is
             * related with the score of the one it's been spreaded, the
             * weight of the relation (a "gobernadoPor" should has "more
             * weight" than a "itDoesn'tMatter" one) and the degradation
             * score (if this concept is a really abstract one, the
             * degradation should be really big
             */
            final double newScore = currentScore * getWeight(qualRelationUri) * degradation;
            addScore(ontoSpreadState, newScore, relatedUri);
            int newDepth = 0;
            //The new node increments its depth if it's a parent
            if(conceptOperations.isSon(conceptRelation.getConceptUri())){
              newDepth = depth;
            }else{
              newDepth = depth + 1;
            }
            //If the uri in spreading is the related Uri no
           
            addToConceptStack(ontoSpreadState,relatedUri, uriDepth.getUri(), newDepth);
            logger.debug("Adding to stack "+relatedUri);
          if(managerAfterConceptActivationStrategy != null){
            managerAfterConceptActivationStrategy.applyStrategy(ontoSpreadState);
          }
         
View Full Code Here

      ontoSpreadState.getSpreadedConcepts().add(currentUri);
  }

  public void addToConceptStack(OntoSpreadState ontoSpreadState, String relatedUri, String fromUri, int depth) {   
    if(!ontoSpreadState.getSpreadedConcepts().contains(relatedUri) && !relatedUri.equals(fromUri)){
      UriDepthPair uriDepthPair = new UriDepthPair(relatedUri, depth);
      //FIXME: Linealizar conceptos con relaciones
      if(!ontoSpreadState.getSortedList().contains(uriDepthPair))
        ontoSpreadState.getSortedList().add(uriDepthPair);
    }
         
View Full Code Here

   
  public UriDepthPair extractFromConceptStack(OntoSpreadState ontoSpreadState) {
        Comparator<UriDepthPair> scoreComparator = new ScoreComparator(ontoSpreadState);
      Collections.sort(ontoSpreadState.getSortedList(), scoreComparator);
          //We take the first element of the list (the one with the best // score)
      UriDepthPair toReturn = (UriDepthPair) ontoSpreadState.getSortedList().remove(0);
      return toReturn;//FIXME
  }
View Full Code Here

TOP

Related Classes of org.ontospread.state.UriDepthPair

Copyright © 2018 www.massapicom. 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.