Package com.hp.hpl.jena.query

Examples of com.hp.hpl.jena.query.QuerySolution


    if(varNames.size()>2){
      scoreVar = varNames.get(2);
    }
    List<SearchResultItem> results = new ArrayList<SearchResultItem>();
    while(resultSet.hasNext()){
      QuerySolution sol = resultSet.next();
      Literal nameLiteral = sol.getLiteral(labelVar);
      String name = nameLiteral==null?"":nameLiteral.getString();
      String id = sol.getResource(idVar).getURI();
      double score = 0;
      if(scoreVar!=null){
        score = sol.getLiteral(scoreVar).getDouble();
      }
     
      results.add(new SearchResultItem(id, name, score));
    }
    return ImmutableList.copyOf(results);
View Full Code Here


      scoreVar = varNames.get(2);
    }
    List<SearchResultItem> results = new ArrayList<SearchResultItem>();
    Set<String> seen = new HashSet<String>();
    while(resultSet.hasNext()){
      QuerySolution sol = resultSet.next();
      String id = sol.getResource(idVar).getURI();
      if(seen.contains(id)){
        continue;
      }
      seen.add(id);
      Literal nameLiteral = sol.getLiteral(labelVar);
      String name = nameLiteral==null?"":nameLiteral.getString();
      double score = 0;
      if(scoreVar!=null){
        score = sol.getLiteral(scoreVar).getDouble();
      }
     
      results.add(new SearchResultItem(id, name, score));
      if(results.size()==limit){
        //got enough
View Full Code Here

      throw new RuntimeException("resultSetToMultimap only accepts a resultset with exactly two variables in the solution");
    }
    String keyVar = varNames.get(0);
    String valVar = varNames.get(1);
    while(resultSet.hasNext()){
      QuerySolution sol = resultSet.next();
     
      String key = sol.getResource(keyVar).getURI();
      RDFNode valNode = sol.get(valVar);
      String val = valNode.canAs(Resource.class)?valNode.as(Resource.class).getURI():valNode.asLiteral().getString();
      /*if(map.keySet().size()==limit && !map.keySet().contains(key)){
        break;
      }*/
      map.put(key, val);
View Full Code Here

  }
 
  public static List<String> resultSetToList(ResultSet resultset, String varName){
    List<String> result = new ArrayList<String>();
    while(resultset.hasNext()){
      QuerySolution sol = resultset.next();
      String uri = sol.getResource(varName).getURI();
      result.add(uri);
    }
    return result;
  }
View Full Code Here

    List<String> varNames = resultset.getResultVars();
    String var1 = varNames.get(0);
    String var2 = varNames.get(1);
    List<String[]> result = new ArrayList<String[]>();
    while(resultset.hasNext()){
      QuerySolution sol = resultset.next();
      String s = sol.getResource(var1).getURI();
      RDFNode object = sol.get(var2);
      /*String o;
      if(object.canAs(Resource.class)){
        o = object.asResource().getURI();
      }else{
        o = object.asLiteral().getString();
View Full Code Here

    List<ReconciliationCandidate> candidates = new ArrayList<ReconciliationCandidate>();
    boolean match = false;
    boolean moreThanOneMatch = false;
    Set<String> seen = new HashSet<String>();
    while(resultSet.hasNext()){
      QuerySolution solution = resultSet.nextSolution();
      Resource entity = solution.getResource("entity");
      String entityUri = entity.getURI();
      if(seen.contains(entityUri)){
        //already seen
        continue;
      }
View Full Code Here

  @Override
  public ImmutableList<SearchResultItem> wrapTypeSuggestResultSet(ResultSet resultSet, String prefix, int limit) {
    List<SearchResultItem> items = new ArrayList<SearchResultItem>();
    while(resultSet.hasNext()){
      QuerySolution solution = resultSet.nextSolution();
      String type = solution.getResource("type").getURI();
      String label = solution.getLiteral("label").getString();
      double score = StringUtils.getLevenshteinScore(label, prefix);
      items.add(new SearchResultItem(type, label, score));
    }
    Collections.sort(items, new Comparator<SearchResultItem>() {
View Full Code Here

  }

  public List<ReconciliationCandidate> wrapResultset(ResultSet resultSet,String queryString, double matchThreshold){
    List<ReconciliationCandidate> candidates = new ArrayList<ReconciliationCandidate>();
    while(resultSet.hasNext()){
      QuerySolution solution = resultSet.nextSolution();
      Resource entity = solution.getResource("entity");
      ReconciliationCandidate candidate = new ReconciliationCandidate(entity.getURI(), queryString, new String[] {}, 1.0d,true);
     
      candidates.add(candidate);
    }
    if(candidates.size() > 1 || matchThreshold > 1 ){
View Full Code Here

 
  @Override
  public ImmutableList<SearchResultItem> wrapTypeSuggestResultSet(ResultSet resultSet, String prefix, int limit) {
    List<SearchResultItem> result = new ArrayList<SearchResultItem>();
    while(resultSet.hasNext()){
      QuerySolution sol = resultSet.nextSolution();
      String pUri = sol.getResource("type").getURI();
      String label = getPreferredLabel(sol);
      result.add(new SearchResultItem(pUri, label));
    }
    return ImmutableList.copyOf(result);
  }
View Full Code Here

  @Override
  public ImmutableList<SearchResultItem> wrapPropertySuggestResultSet(ResultSet resultSet, String prefix, int limit) {
    List<SearchResultItem> result = new ArrayList<SearchResultItem>();
    while(resultSet.hasNext()){
      QuerySolution sol = resultSet.nextSolution();
      String pUri = sol.getResource("p").getURI();
      String label = getPreferredLabel(sol);
      result.add(new SearchResultItem(pUri, label));
    }
    return ImmutableList.copyOf(result);
  }
View Full Code Here

TOP

Related Classes of com.hp.hpl.jena.query.QuerySolution

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.