org.apache.jena.atlas.web.auth.SimpleAuthenticator Java Examples
The following examples show how to use
org.apache.jena.atlas.web.auth.SimpleAuthenticator.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TrigKSTripleReader.java From EventCoreference with Apache License 2.0 | 6 votes |
public static ArrayList<Statement> readTriplesFromKs(String subjectUri, String sparqlQuery){ ArrayList<Statement> triples = new ArrayList<Statement>(); HttpAuthenticator authenticator = new SimpleAuthenticator(user, pass.toCharArray()); try { qCount++; QueryExecution x = QueryExecutionFactory.sparqlService(serviceEndpoint, sparqlQuery, authenticator); ResultSet resultset = x.execSelect(); while (resultset.hasNext()) { QuerySolution solution = resultset.nextSolution(); String relString = solution.get("predicate").toString(); RDFNode obj = solution.get("object"); Model model = ModelFactory.createDefaultModel(); Resource subj = model.createResource(subjectUri); Statement s = createStatement(subj, ResourceFactory.createProperty(relString), obj); triples.add(s); } } catch (Exception e) { //e.printStackTrace(); } return triples; }
Example #2
Source File: TrigKSTripleReader.java From EventCoreference with Apache License 2.0 | 6 votes |
public static ArrayList<String> readEventIdsFromKs(String sparqlQuery)throws Exception { ArrayList<String> eventIds = new ArrayList<String>(); //System.out.println("serviceEndpoint = " + serviceEndpoint); //System.out.println("sparqlQuery = " + sparqlQuery); //System.out.println("user = " + user); //System.out.println("pass = " + pass); HttpAuthenticator authenticator = new SimpleAuthenticator(user, pass.toCharArray()); QueryExecution x = QueryExecutionFactory.sparqlService(serviceEndpoint, sparqlQuery, authenticator); ResultSet resultset = x.execSelect(); while (resultset.hasNext()) { QuerySolution solution = resultset.nextSolution(); //System.out.println("solution.toString() = " + solution.toString()); //( ?event = <http://www.newsreader-project.eu/data/Dasym-Pilot/425819_relink_dominant.naf#ev24> ) String currentEvent = solution.get("event").toString(); //System.out.println("currentEvent = " + currentEvent); //http://www.newsreader-project.eu/data/Dasym-Pilot/425819_relink_dominant.naf#ev24 if (!eventIds.contains(currentEvent)) { eventIds.add(currentEvent); } } return eventIds; }
Example #3
Source File: ProcessEventObjectsStream.java From EventCoreference with Apache License 2.0 | 5 votes |
private static void inferIdentityRelations(String sparqlQuery, boolean matchILI, boolean matchLemma, boolean matchMultiple, int iliSize, Node eventId, DatasetGraph g) { if (matchILI || matchLemma) { sparqlQuery += "GROUP BY ?ev"; } HttpAuthenticator authenticator = new SimpleAuthenticator(user, pass.toCharArray()); QueryExecution x = QueryExecutionFactory.sparqlService(serviceEndpoint, sparqlQuery, authenticator); ResultSet resultset = x.execSelect(); int threshold; while (resultset.hasNext()) { QuerySolution solution = resultset.nextSolution(); if (matchILI || matchLemma) { if (matchILI) threshold = conceptMatchThreshold; else threshold=phraseMatchThreshold; if (matchMultiple) { //System.out.println(solution); if (checkIliLemmaThreshold(iliSize, solution.get("conceptcount").asLiteral().getInt(), solution.get("myconceptcount").asLiteral().getInt(), threshold)) { insertIdentity(g, eventId, solution.get("ev").asNode()); } } else { if (checkIliLemmaThreshold(1, solution.get("conceptcount").asLiteral().getInt(), 1, threshold)) { insertIdentity(g, eventId, solution.get("ev").asNode()); } } } else { insertIdentity(g, eventId, solution.get("ev").asNode()); } } }
Example #4
Source File: ProcessEventObjectsStream.java From EventCoreference with Apache License 2.0 | 5 votes |
private static ArrayList<Node> inferMultitimesIdentityRelations (String sparqlQuery, boolean matchILI, boolean matchLemma, boolean matchMultiple, int iliSize, String eventId) { if (matchILI || matchLemma) { sparqlQuery += "GROUP BY ?ev"; } HttpAuthenticator authenticator = new SimpleAuthenticator(user, pass.toCharArray()); QueryExecution x = QueryExecutionFactory.sparqlService(serviceEndpoint, sparqlQuery, authenticator); ResultSet resultset = x.execSelect(); int threshold; ArrayList<Node> rslt = new ArrayList<Node>(); while (resultset.hasNext()) { QuerySolution solution = resultset.nextSolution(); if (matchILI || matchLemma) { if (matchILI) threshold = conceptMatchThreshold; else threshold=phraseMatchThreshold; if (matchMultiple) { //System.out.println(solution); if (checkIliLemmaThreshold(iliSize, solution.get("conceptcount").asLiteral().getInt(), solution.get("myconceptcount").asLiteral().getInt(), threshold)) { rslt.add(solution.get("ev").asNode()); } } else { if (checkIliLemmaThreshold(1, solution.get("conceptcount").asLiteral().getInt(), 1, threshold)) { rslt.add(solution.get("ev").asNode()); } } } else { rslt.add(solution.get("ev").asNode()); } } return rslt; }