Java 类com.hp.hpl.jena.query.QueryException 实例源码

项目:DoSeR    文件:MainEvaluation.java   
public String getRedirect(final String entityUri) {
    final String query = "SELECT ?types WHERE{ <" + entityUri
            + "> <http://dbpedia.org/ontology/wikiPageRedirects> ?types. }";
    ResultSet results = null;
    QueryExecution qexec = null;
    try {
        final com.hp.hpl.jena.query.Query cquery = QueryFactory
                .create(query);
        qexec = QueryExecutionFactory.create(cquery, redirects);
        results = qexec.execSelect();
    } catch (final QueryException e) {
        Logger.getRootLogger().error(e.getStackTrace());
    } finally {
        if (results != null) {
            while (results.hasNext()) {
                final QuerySolution sol = results.nextSolution();
                final String type = sol.getResource("types").toString();
                return type;
            }
        }
    }
    return null;
}
项目:DoSeR    文件:FullyEvaluateCategories.java   
private Set<String> queryEntitiesFromCategory(final String catUri) {
    Set<String> set = new HashSet<String>();
    final String query = "SELECT ?entities WHERE{ ?entities <http://purl.org/dc/terms/subject> <"
            + catUri + ">. }";
    try {
        final com.hp.hpl.jena.query.Query cquery = QueryFactory
                .create(query);
        final QueryExecution qexec = QueryExecutionFactory
                .create(cquery, m);
        final ResultSet results = qexec.execSelect();
        while (results.hasNext()) {
            final QuerySolution sol = results.nextSolution();
            set.add(sol.getResource("entities").getURI()
                    .replaceAll("http://dbpedia.org/resource/", ""));
        }

    } catch (final QueryException e) {
        Logger.getRootLogger().error(e.getStackTrace());
    }
    return set;
}
项目:DoSeR    文件:EvaluatePureDbpediaCategories.java   
private String queryEntitiesFromCategory(final String catUri) {
    String res = null;

    final String query = "SELECT ?entities WHERE{ ?entities <http://purl.org/dc/terms/subject> <"
            + catUri + ">. }";
    try {
        final com.hp.hpl.jena.query.Query cquery = QueryFactory
                .create(query);
        final QueryExecution qexec = QueryExecutionFactory
                .create(cquery, m);
        final ResultSet results = qexec.execSelect();
        List<String> entities = new LinkedList<String>();
        while (results.hasNext()) {
            final QuerySolution sol = results.nextSolution();
            entities.add(sol.getResource("entities").getURI());
        }
        if (entities.size() != 0) {
            int randomNr = this.random.nextInt(entities.size());
            return entities.get(randomNr);
        }

    } catch (final QueryException e) {
        Logger.getRootLogger().error(e.getStackTrace());
    }
    return res;
}
项目:DoSeR    文件:DbpediaGraphModification.java   
private boolean hasSubCategory(String uri) {
    final String query = "SELECT ?entities WHERE{ ?types <http://www.w3.org/2004/02/skos/core#broader> <"
            + uri + ">. }";
    boolean hasSubtype = false;
    try {
        final com.hp.hpl.jena.query.Query cquery = QueryFactory
                .create(query);
        final QueryExecution qexec = QueryExecutionFactory
                .create(cquery, skosModel);
        final ResultSet results = qexec.execSelect();
        while (results.hasNext()) {
            hasSubtype = true;
            break;
        }

    } catch (final QueryException e) {
        Logger.getRootLogger().error(e.getStackTrace());
    }
    return hasSubtype;
}
项目:DoSeR    文件:DbpediaGraphModification.java   
private Set<String> queryEntitiesFromCategory(final String catUri) {
    Set<String> set = new HashSet<String>();
    final String query = "SELECT ?entities WHERE{ ?entities <http://purl.org/dc/terms/subject> <"
            + catUri + ">. }";
    try {
        final com.hp.hpl.jena.query.Query cquery = QueryFactory
                .create(query);
        final QueryExecution qexec = QueryExecutionFactory
                .create(cquery, m);
        final ResultSet results = qexec.execSelect();
        while (results.hasNext()) {
            final QuerySolution sol = results.nextSolution();
            set.add(sol.getResource("entities").getURI()
                    .replaceAll("http://dbpedia.org/resource/", ""));
        }

    } catch (final QueryException e) {
        Logger.getRootLogger().error(e.getStackTrace());
    }
    return set;
}
项目:DoSeR    文件:Sampling.java   
private String queryEntitiesFromCategory(final String catUri) {
    String res = null;

    final String query = "SELECT ?entities WHERE{ ?entities <http://purl.org/dc/terms/subject> <"
            + catUri + ">. }";
    try {
        final com.hp.hpl.jena.query.Query cquery = QueryFactory
                .create(query);
        final QueryExecution qexec = QueryExecutionFactory
                .create(cquery, m);
        final ResultSet results = qexec.execSelect();
        List<String> entities = new LinkedList<String>();
        while (results.hasNext()) {
            final QuerySolution sol = results.nextSolution();
            entities.add(sol.getResource("entities").getURI());
        }
        if (entities.size() != 0) {
            int randomNr = this.random.nextInt(entities.size());
            return entities.get(randomNr);
        }

    } catch (final QueryException e) {
        Logger.getRootLogger().error(e.getStackTrace());
    }
    return res;
}
项目:DoSeR    文件:TimeNumberDisambiguation.java   
private String getRedirect(String uri) {
    final Model model = DisambiguationMainService.getInstance().getDBpediaRedirects();
    final String query = "SELECT ?label WHERE{ <" + uri
            + "> <http://dbpedia.org/ontology/wikiPageRedirects> ?label. }";
    ResultSet results = null;
    QueryExecution qexec = null;
    String redirect = null;
    try {
        final com.hp.hpl.jena.query.Query cquery = QueryFactory.create(query);
        qexec = QueryExecutionFactory.create(cquery, model);
        results = qexec.execSelect();
    } catch (final QueryException e) {
        Logger.getRootLogger().error(e.getStackTrace());
    } finally {
        if (results.hasNext()) {
            final QuerySolution sol = results.nextSolution();
            redirect = sol.getResource("label").getURI();
        }
    }
    return redirect;
}
项目:DoSeR    文件:RDFGraphOperations.java   
public static Set<Type> getRDFTypesFromEntity(final String entityUri) {
    Set<Type> set = new HashSet<Type>();
    final Model model = DisambiguationMainService.getInstance().getDBPediaInstanceTypes();
    final String query = "SELECT ?types WHERE{ <" + entityUri
            + "> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> ?types. }";
    ResultSet results = null;
    QueryExecution qexec = null;
    try {
        final com.hp.hpl.jena.query.Query cquery = QueryFactory
                .create(query);
        qexec = QueryExecutionFactory.create(cquery, model);
        results = qexec.execSelect();
    } catch (final QueryException e) {
        Logger.getRootLogger().error(e.getStackTrace());
    } finally {
        if (results != null) {
            while (results.hasNext()) {
                final QuerySolution sol = results.nextSolution();
                final String type = sol.getResource("types").toString();
                set.add(new Type("", type, true, 0));
            }
        }
    }
    return set;
}
项目:DoSeR    文件:RDFGraphOperations.java   
public static String getDbPediaDescription(final String uri)
        throws QueryException {
    String res = null;
    final Model model = DisambiguationMainService.getInstance()
            .getDBPediaDescription();
    final String query = "SELECT ?description WHERE{ <" + uri
            + "> <http://dbpedia.org/ontology/abstract> ?description. }";
    ResultSet results = null; // NOPMD by quh on 14.02.14 10:04
    QueryExecution qexec = null;
    try {
        final com.hp.hpl.jena.query.Query cquery = QueryFactory
                .create(query);
        qexec = QueryExecutionFactory.create(cquery, model);
        results = qexec.execSelect();
    } finally {
        if ((results != null) && results.hasNext()) {
            res = results.nextSolution().getLiteral("description")
                    .getString();
        }
        if (qexec != null) {
            qexec.close();
        }
    }
    return res;
}
项目:DoSeR    文件:RDFGraphOperations.java   
public static List<String> getDbPediaLabel(final String uri)
        throws QueryException {
    final List<String> labellist = new LinkedList<String>();

    final Model model = DisambiguationMainService.getInstance()
            .getDBPediaLabels();
    final String query = "SELECT ?label WHERE{ <" + uri
            + "> <http://www.w3.org/2000/01/rdf-schema#label> ?label. }";
    ResultSet results = null; // NOPMD by quh on 14.02.14 10:04
    QueryExecution qexec = null;

    final com.hp.hpl.jena.query.Query cquery = QueryFactory.create(query);
    qexec = QueryExecutionFactory.create(cquery, model);
    results = qexec.execSelect();

    if (results != null) {
        while (results.hasNext()) {
            final QuerySolution sol = results.nextSolution();
            final String label = sol.getLiteral("label").getLexicalForm();
            labellist.add(label);
        }
        qexec.close();
    }
    return labellist;
}
项目:DoSeR    文件:RDFGraphOperations.java   
public static List<String> getDbPediaLabel_GER(final String uri)
        throws QueryException {
    final List<String> labellist = new LinkedList<String>();

    final Model model = DisambiguationMainService.getInstance()
            .getDBPediaLabels_GER();
    final String query = "SELECT ?label WHERE{ <" + uri
            + "> <http://www.w3.org/2000/01/rdf-schema#label> ?label. }";
    ResultSet results = null; // NOPMD by quh on 14.02.14 10:04
    QueryExecution qexec = null;

    final com.hp.hpl.jena.query.Query cquery = QueryFactory.create(query);
    qexec = QueryExecutionFactory.create(cquery, model);
    results = qexec.execSelect();

    if (results != null) {
        while (results.hasNext()) {
            final QuerySolution sol = results.nextSolution();
            final String label = sol.getLiteral("label").getLexicalForm();
            labellist.add(label);
        }
        qexec.close();
    }
    return labellist;
}
项目:DoSeR    文件:RDFGraphOperations.java   
private static String queryDbPediaCategoryLabel(final String catUri) {
    String res = null;
    final Model model = DisambiguationMainService.getInstance()
            .getDBPediaCategoryLabels();

    final String query = "SELECT ?label WHERE{ <" + catUri
            + "> <http://www.w3.org/2000/01/rdf-schema#label> ?label. }";
    try {
        final com.hp.hpl.jena.query.Query cquery = QueryFactory
                .create(query);
        final QueryExecution qexec = QueryExecutionFactory.create(cquery,
                model);
        final ResultSet results = qexec.execSelect(); // NOPMD by quh on
                                                        // 18.02.14 15:05
        while (results.hasNext()) {
            final QuerySolution sol = results.nextSolution();
            final String name = sol.getLiteral("label").getLexicalForm();
            res = name;
        }
    } catch (final QueryException e) {
        Logger.getRootLogger().error(e.getStackTrace());
    }
    return res;
}
项目:DoSeR    文件:RDFGraphOperations.java   
private static String queryDbPediaCategoryLabel_GER(final String catUri) {
    String res = null;
    final Model model = DisambiguationMainService.getInstance()
            .getDBPediaCategoryLabels_GER();

    final String query = "SELECT ?label WHERE{ <" + catUri
            + "> <http://www.w3.org/2000/01/rdf-schema#label> ?label. }";
    try {
        final com.hp.hpl.jena.query.Query cquery = QueryFactory
                .create(query);
        final QueryExecution qexec = QueryExecutionFactory.create(cquery,
                model);
        final ResultSet results = qexec.execSelect(); // NOPMD by quh on
                                                        // 18.02.14 15:05
        while (results.hasNext()) {
            final QuerySolution sol = results.nextSolution();
            final String name = sol.getLiteral("label").getLexicalForm();
            // RDFHack ToDo: Inform how to resolve the dbpedia tql files correctly

            res = name;
        }
    } catch (final QueryException e) {
        Logger.getRootLogger().error(e.getStackTrace());
    }
    return res;
}
项目:DoSeR    文件:RDFGraphOperations.java   
public static List<Type> queryYagoCategories(final String uri) {
    final Model model = DisambiguationMainService.getInstance()
            .getYagoTransitiveTypes();

    final List<Type> types = new LinkedList<Type>();
    final String query = "SELECT ?type WHERE{ <"
            + uri
            + "> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> ?type. }";
    try {
        final com.hp.hpl.jena.query.Query que = QueryFactory.create(query);
        final QueryExecution qexec = QueryExecutionFactory.create(que,
                model);
        final ResultSet results = qexec.execSelect(); // NOPMD by quh on
                                                        // 18.02.14 15:05
        while (results.hasNext()) {
            final QuerySolution sol = results.nextSolution();
            final String name = sol.getResource("type").toString();
            types.add(new Type("", name, true, 0));
        }
    } catch (final QueryException e) {
        Logger.getRootLogger().error(e.getStackTrace());
    }
    return types;
}
项目:DoSeR    文件:RDFGraphOperations.java   
private static String queryYagoCategoryLabel(final String catUri) {
    String res = null;
    final Model model = DisambiguationMainService.getInstance()
            .getYagoCategoryLabels();

    final String query = "SELECT ?label WHERE{ <" + catUri
            + "> <http://www.w3.org/2004/02/skos/core#> ?label. }";
    try {
        final com.hp.hpl.jena.query.Query que = QueryFactory.create(query);
        final QueryExecution qexec = QueryExecutionFactory.create(que,
                model);
        final ResultSet results = qexec.execSelect(); // NOPMD by quh on
                                                        // 18.02.14 15:05
        while (results.hasNext()) {
            final QuerySolution sol = results.nextSolution();
            final String name = sol.getLiteral("label").getLexicalForm();
            res = name;
        }
    } catch (final QueryException e) {
        Logger.getRootLogger().error(e.getStackTrace());
    }
    return res;
}
项目:DoSeR    文件:CreateDBpediaIndexV2.java   
public List<String> getDbPediaLabel(final String uri) throws QueryException, QueryParseException {
    final List<String> labellist = new LinkedList<String>();
    try {
        final String query = "SELECT ?label WHERE{ <" + uri
                + "> <http://www.w3.org/2000/01/rdf-schema#label> ?label. }";
        ResultSet results = null;
        QueryExecution qexec = null;

        final com.hp.hpl.jena.query.Query cquery = QueryFactory.create(query);
        qexec = QueryExecutionFactory.create(cquery, this.labelmodel);
        results = qexec.execSelect();

        if (results != null) {
            while (results.hasNext()) {
                final QuerySolution sol = results.nextSolution();
                final String label = sol.getLiteral("label").getLexicalForm();
                labellist.add(label);
            }
            qexec.close();
        }
    } catch (QueryParseException e) {
        Logger.getRootLogger().info("Query parse Exception");
    }
    return labellist;
}
项目:DoSeR    文件:CreateDBpediaIndexV2.java   
public String getDbPediaShortDescription(final String uri) throws QueryException, QueryParseException {
    String labellist = "";
    try {
        final String query = "SELECT ?comment WHERE{ <" + uri
                + "> <http://www.w3.org/2000/01/rdf-schema#comment> ?comment. }";
        ResultSet results = null;
        QueryExecution qexec = null;

        final com.hp.hpl.jena.query.Query cquery = QueryFactory.create(query);
        qexec = QueryExecutionFactory.create(cquery, this.shortdescmodel);
        results = qexec.execSelect();

        if (results != null) {
            while (results.hasNext()) {
                final QuerySolution sol = results.nextSolution();
                String desc = sol.getLiteral("comment").getLexicalForm();
                labellist = desc;
            }
            qexec.close();
        }
    } catch (QueryParseException e) {
        Logger.getRootLogger().info("Query parse Exception");
    }
    return labellist;
}
项目:DoSeR    文件:CreateDBpediaIndexV2.java   
public String getDbPediaLongDescription(final String uri) throws QueryException, QueryParseException {
    String labellist = "";
    try {
        final String query = "SELECT ?comment WHERE{ <" + uri
                + "> <http://dbpedia.org/ontology/abstract> ?comment. }";
        ResultSet results = null;
        QueryExecution qexec = null;

        final com.hp.hpl.jena.query.Query cquery = QueryFactory.create(query);
        qexec = QueryExecutionFactory.create(cquery, this.longdescmodel);
        results = qexec.execSelect();

        if (results != null) {
            while (results.hasNext()) {
                final QuerySolution sol = results.nextSolution();
                final String desc = sol.getLiteral("comment").getLexicalForm();
                labellist = desc;
            }
            qexec.close();
        }
    } catch (QueryParseException e) {
        Logger.getRootLogger().info("Query parse Exception");
    }
    return labellist;
}
项目:DoSeR    文件:CreateDBpediaIndexV2.java   
public Set<String> getRDFTypesFromEntity(final String entityUri) {
    Set<String> set = new HashSet<String>();
    final String query = "SELECT ?types WHERE{ <" + entityUri
            + "> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> ?types. }";
    ResultSet results = null;
    QueryExecution qexec = null;
    try {
        final com.hp.hpl.jena.query.Query cquery = QueryFactory.create(query);
        qexec = QueryExecutionFactory.create(cquery, instancemappingtypes);
        results = qexec.execSelect();
    } catch (final QueryException e) {
        Logger.getRootLogger().error(e.getStackTrace());
    } finally {
        if (results != null) {
            while (results.hasNext()) {
                final QuerySolution sol = results.nextSolution();
                final String type = sol.getResource("types").toString();
                set.add(type);
            }
        }
    }
    return set;
}
项目:DoSeR    文件:DBpediaCategoryCorrection.java   
public Set<String> querySubCategories(final String uri) {
    final Set<String> types = new HashSet<String>();
    final String query = "SELECT ?sub WHERE { <"+uri+"> <http://www.w3.org/2004/02/skos/core#broader> ?sub }";

    try {
        final com.hp.hpl.jena.query.Query que = QueryFactory.create(query);
        final QueryExecution qexec = QueryExecutionFactory.create(que,
                categorySkosModel);
        final ResultSet results = qexec.execSelect();

        while (results.hasNext()) {
            final QuerySolution sol = results.nextSolution();
            final String name = sol.getResource("sub").toString();
            types.add(new String(name));
        }
    } catch (final QueryException e) {
        Logger.getRootLogger().error(e.getStackTrace());
    }
    return types;
}
项目:DoSeR    文件:RDFGraphOperations.java   
public static Set<Type> getBroaderCategoriesOfCategory(final String category) {
    final Model model = DisambiguationMainService.getInstance()
            .getDBPediaArticleCategories();
    final Set<Type> types = new HashSet<Type>();
    final String query = "SELECT ?types WHERE{ <" + category
            + "> <http://www.w3.org/2004/02/skos/core#broader> ?types. }";
    ResultSet results = null;
    QueryExecution qexec = null;
    try {
        final com.hp.hpl.jena.query.Query cquery = QueryFactory
                .create(query);
        qexec = QueryExecutionFactory.create(cquery, model);
        results = qexec.execSelect();
    } catch (final QueryException e) {
        Logger.getRootLogger().error(e.getStackTrace());
    } finally {
        if (results != null) {
            while (results.hasNext()) {
                final QuerySolution sol = results.nextSolution();
                final String uri = sol.getResource("types").toString();
                final String name = queryDbPediaCategoryLabel(uri);
                final Type type = new Type(name, uri, true, 1);
                types.add(type);
            }
        }
        if (qexec != null) {
            qexec.close();
        }
    }
    return types;
}
项目:DoSeR    文件:RDFGraphOperations.java   
public static Set<Type> getDbpediaCategoriesFromEntity(
        final String entityUri) {
    final Model model = DisambiguationMainService.getInstance()
            .getDBPediaArticleCategories();
    final Set<Type> types = new HashSet<Type>();
    final String query = "SELECT ?types WHERE{ <" + entityUri
            + "> <http://purl.org/dc/terms/subject> ?types. }";
    ResultSet results = null;
    QueryExecution qexec = null;
    try {
        final com.hp.hpl.jena.query.Query cquery = QueryFactory
                .create(query);
        qexec = QueryExecutionFactory.create(cquery, model);
        results = qexec.execSelect();
    } catch (final QueryException e) {
        Logger.getRootLogger().error(e.getStackTrace());
    } finally {
        if (results != null) {
            while (results.hasNext()) {
                final QuerySolution sol = results.nextSolution();
                final String uri = sol.getResource("types").toString();
                final String name = queryDbPediaCategoryLabel(uri);
                final Type type = new Type(name, uri, true, 1);
                types.add(type);
            }
        }
        if (qexec != null) {
            qexec.close();
        }
    }
    return types;
}
项目:DoSeR    文件:RDFGraphOperations.java   
public static Set<Type> getDbpediaCategoriesFromEntity_GER(
            final String entityUri) {
        final Model model = DisambiguationMainService.getInstance()
                .getDBPediaArticleCategories_GER();
        final Set<Type> types = new HashSet<Type>();
        final String query = "SELECT ?types WHERE{ <" + entityUri
                + "> <http://purl.org/dc/terms/subject> ?types. }";
        ResultSet results = null;
        QueryExecution qexec = null;
        try {
            final com.hp.hpl.jena.query.Query cquery = QueryFactory
                    .create(query);
            qexec = QueryExecutionFactory.create(cquery, model);
            results = qexec.execSelect();
        } catch (final QueryException e) {
            Logger.getRootLogger().error(e.getStackTrace());
        } finally {
            if (results != null) {
                while (results.hasNext()) {
                    final QuerySolution sol = results.nextSolution();
                    final String uri = sol.getResource("types").getURI();
//                  final String uri = sol.getResource("types").toString();
                    // RDF Hack - ToDo: Inform how to load the new dbpedia tql files correctly
                    String newuri = uri.split(" ")[0].replaceAll(">", "");
                    final String name = queryDbPediaCategoryLabel_GER(newuri);
                    final Type type = new Type(name, newuri, true, 1);
                    types.add(type);
                }
            }
            if (qexec != null) {
                qexec.close();
            }
        }
        return types;
    }
项目:DoSeR    文件:RDFGraphOperations.java   
public static List<Type> getWordnetPredecessorTypesOfDbPediaCategory(
        final String dbpediaCat, final int layer) {
    // Transform Uri to yago wikicategoryUri!
    final String[] splitter = dbpediaCat.split(":");
    final String uri = "http://yago-knowledge.org/resource/wikicategory_"
            + splitter[splitter.length - 1];

    // Query the supertype of this resource!
    final Model model = DisambiguationMainService.getInstance()
            .getYagoTaxonomy();
    final String query = "Select ?type WHERE{ <"
            + uri
            + "> <http://www.w3.org/2000/01/rdf-schema#subClassOf> ?type. }";
    // System.out.println(query);
    final List<Type> resultList = new LinkedList<Type>();
    try {
        final com.hp.hpl.jena.query.Query que = QueryFactory.create(query);
        final QueryExecution qexec = QueryExecutionFactory.create(que,
                model);
        final ResultSet results = qexec.execSelect(); // NOPMD by quh on
                                                        // 18.02.14 15:05
        while (results.hasNext()) {
            final QuerySolution sol = results.nextSolution();
            final String typeUri = sol.getResource("type").toString();
            final String name = queryYagoCategoryLabel(typeUri);
            final Type type = new Type(name, typeUri, true, layer);
            resultList.add(type);
        }
    } catch (final QueryException e) {
        Logger.getRootLogger().error(e.getStackTrace());
    }
    return resultList;
}
项目:DoSeR    文件:RDFGraphOperations.java   
public static List<Type> queryWordnetTypePredecessor(final String uri,
        final int layer) {
    final List<Type> types = new LinkedList<Type>();
    final Model model = DisambiguationMainService.getInstance()
            .getYagoTaxonomy();
    final String query = "SELECT ?types WHERE{ <"
            + uri
            + "> <http://www.w3.org/2000/01/rdf-schema#subClassOf> ?types. }";
    try {
        final com.hp.hpl.jena.query.Query cquery = QueryFactory
                .create(query);
        final QueryExecution qexec = QueryExecutionFactory.create(cquery,
                model);
        final ResultSet results = qexec.execSelect(); // NOPMD by quh on
                                                        // 18.02.14 15:05
        while (results.hasNext()) {
            final QuerySolution sol = results.nextSolution();
            final String type = sol.getResource("types").toString();
            final String name = queryYagoCategoryLabel(type);
            types.add(new Type(name, type, true, layer));
            // System.out.println("Type: "+name+" Uri: "+type);
        }
    } catch (final QueryException e) {
        Logger.getRootLogger().error(e.getStackTrace());
    }
    return types;
}
项目:DoSeR    文件:CreateDBPediaIndex.java   
public List<String> getDbPediaLabel(final String uri)
        throws QueryException, QueryParseException {
    final List<String> labellist = new LinkedList<String>();
    try {
        final String query = "SELECT ?label WHERE{ <"
                + uri
                + "> <http://www.w3.org/2000/01/rdf-schema#label> ?label. }";
        ResultSet results = null; // NOPMD by quh on 14.02.14 10:04
        QueryExecution qexec = null;

        final com.hp.hpl.jena.query.Query cquery = QueryFactory
                .create(query);
        qexec = QueryExecutionFactory.create(cquery, this.labelmodel);
        results = qexec.execSelect();

        if (results != null) {
            while (results.hasNext()) {
                final QuerySolution sol = results.nextSolution();
                final String label = sol.getLiteral("label")
                        .getLexicalForm();
                labellist.add(label);
            }
            qexec.close();
        }
    } catch (QueryParseException e) {
        Logger.getRootLogger().info("Query parse Exception");
    }
    return labellist;
}
项目:DoSeR    文件:CreateDBPediaIndex.java   
public String getDbPediaShortDescription(final String uri)
        throws QueryException, QueryParseException {
    String labellist = "";
    try {
        final String query = "SELECT ?comment WHERE{ <"
                + uri
                + "> <http://www.w3.org/2000/01/rdf-schema#comment> ?comment. }";
        ResultSet results = null;
        QueryExecution qexec = null;

        final com.hp.hpl.jena.query.Query cquery = QueryFactory
                .create(query);
        qexec = QueryExecutionFactory.create(cquery, this.shortdescmodel);
        results = qexec.execSelect();

        if (results != null) {
            while (results.hasNext()) {
                final QuerySolution sol = results.nextSolution();
                String desc = sol.getLiteral("comment").getLexicalForm();
                labellist = desc;
            }
            qexec.close();
        }
    } catch (QueryParseException e) {
        Logger.getRootLogger().info("Query parse Exception");
    }
    return labellist;
}
项目:DoSeR    文件:CreateDBPediaIndex.java   
public String getDbPediaLongDescription(final String uri)
        throws QueryException, QueryParseException {
    String labellist = "";
    try {
        final String query = "SELECT ?comment WHERE{ <" + uri
                + "> <http://dbpedia.org/ontology/abstract> ?comment. }";
        ResultSet results = null;
        QueryExecution qexec = null;

        final com.hp.hpl.jena.query.Query cquery = QueryFactory
                .create(query);
        qexec = QueryExecutionFactory.create(cquery, this.longdescmodel);
        results = qexec.execSelect();

        if (results != null) {
            while (results.hasNext()) {
                final QuerySolution sol = results.nextSolution();
                final String desc = sol.getLiteral("comment")
                        .getLexicalForm();
                labellist = desc;
            }
            qexec.close();
        }
    } catch (QueryParseException e) {
        Logger.getRootLogger().info("Query parse Exception");
    }
    return labellist;
}
项目:cqels    文件:MappingIteratorBase.java   
@Override
public void close() {
    if (finished) {
        return;
    }
    try {
        closeIterator();
    } catch (QueryException ex) {
        Log.warn(this, "QueryException in close()", ex);
    }
    finished = true;
}
项目:DoSeR    文件:KnowledgeBaseEntryCreation.java   
public static Map<String, String> createKnowledgeBaseEntryOutOfDbPediaURI(
        final String uri) throws ModifyKnowledgeBaseException {
    final Map<String, String> res = new HashMap<String, String>();
    try {
        final List<String> labelList = RDFGraphOperations
                .getDbPediaLabel(uri);
        final String description = RDFGraphOperations
                .getDbPediaDescription(uri);
        if (checkResource(uri, labelList)) {
            // Set ID
            final String split[] = uri.split("/");
            res.put("ID", "DbPedia_" + split[split.length - 1]);

            // Set Labels
            for (int i = 0; i < labelList.size(); ++i) {
                if (i == 0) {
                    res.put("label", labelList.get(i));
                } else {
                    res.put("label_" + i, labelList.get(i));
                }
            }

            // Set Description
            if (description == null) {
                res.put("description", "");
            } else {
                res.put("description", description);
            }
            // Set Mainlink
            res.put("mainlink", uri.toLowerCase(Locale.US));

            // Set Occurrences
            res.put("occurrences", "");

            // Set Surrounding labels
            res.put("surroundinglabels", "");
        }
    } catch (final QueryException e) {
        throw new ModifyKnowledgeBaseException("DbPedia Uri Invalid", e);
    }
    return res;
}