本文整理汇总了Java中org.apache.jena.query.ParameterizedSparqlString.setLiteral方法的典型用法代码示例。如果您正苦于以下问题:Java ParameterizedSparqlString.setLiteral方法的具体用法?Java ParameterizedSparqlString.setLiteral怎么用?Java ParameterizedSparqlString.setLiteral使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.jena.query.ParameterizedSparqlString
的用法示例。
在下文中一共展示了ParameterizedSparqlString.setLiteral方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getNounSenses
import org.apache.jena.query.ParameterizedSparqlString; //导入方法依赖的package包/类
/**
* Mapping from {@code ind} translations to WordNet senses for noun part-of-speech.
* The value is String to save memory, it is short QName, where nsPrefix needs
* to be explictly supported, e.g. {@code wn31} for nvarps.
*
* @param nounLiteral Verb literal, please preserve capitalization because case-normalization will be performed here.
* @return
* @todo These aren't sorted/prioritized in any way.
* @todo Need Cached by EHCache or something (never expire but with invalidation), or function-based index.
*/
public List<QName> getNounSenses(final String nounLiteral) {
List<QName> senses = new ArrayList<>();
ParameterizedSparqlString sparql = new ParameterizedSparqlString(
"SELECT ?sense\n"
+ "WHERE {\n"
+ " ?sense wordnet-ontology:translation ?nounLiteral ;"
+ " wordnet-ontology:part_of_speech wordnet-ontology:noun\n"
+ "} LIMIT 100", model);
sparql.setLiteral("nounLiteral", nounLiteral.toLowerCase(), "ind");
log.trace("getNounSenses '{}' SPARQL: {}", nounLiteral, sparql);
Query verbTxQuery = QueryFactory.create(sparql.toString());
QueryExecution qexec = QueryExecutionFactory.create(verbTxQuery, wn31tdb);
try {
ResultSet rs = qexec.execSelect();
for (; rs.hasNext(); ) {
QuerySolution soln = rs.next();
QName senseRes = toQName(soln.get("sense").asResource());
senses.add(senseRes);
}
} finally {
qexec.close();
}
return senses;
}
示例2: getAdjectiveSenses
import org.apache.jena.query.ParameterizedSparqlString; //导入方法依赖的package包/类
/**
* Mapping from {@code ind} translations to WordNet senses for adjective part-of-speech.
* The value is String to save memory, it is short QName, where nsPrefix needs
* to be explictly supported, e.g. {@code wn31} for nvarps.
*
* @param adjectiveLiteral Verb literal, please preserve capitalization because case-normalization will be performed here.
* @return
* @todo These aren't sorted/prioritized in any way.
* @todo Need Cached by EHCache or something (never expire but with invalidation), or function-based index.
*/
public List<QName> getAdjectiveSenses(final String adjectiveLiteral) {
List<QName> senses = new ArrayList<>();
ParameterizedSparqlString sparql = new ParameterizedSparqlString(
"SELECT ?sense\n"
+ "WHERE {\n"
+ " ?sense wordnet-ontology:translation ?adjectiveLiteral ;"
+ " wordnet-ontology:part_of_speech wordnet-ontology:adjective\n"
+ "} LIMIT 100", model);
sparql.setLiteral("adjectiveLiteral", adjectiveLiteral.toLowerCase(), "ind");
log.trace("getAdjectiveSenses '{}' SPARQL: {}", adjectiveLiteral, sparql);
Query verbTxQuery = QueryFactory.create(sparql.toString());
QueryExecution qexec = QueryExecutionFactory.create(verbTxQuery, wn31tdb);
try {
ResultSet rs = qexec.execSelect();
for (; rs.hasNext(); ) {
QuerySolution soln = rs.next();
QName senseRes = toQName(soln.get("sense").asResource());
senses.add(senseRes);
}
} finally {
qexec.close();
}
return senses;
}
示例3: getAdjectiveSatelliteSenses
import org.apache.jena.query.ParameterizedSparqlString; //导入方法依赖的package包/类
/**
* Mapping from {@code ind} translations to WordNet senses for {@link PartOfSpeechType#ADJECTIVE_SATELLITE} part-of-speech.
* The value is String to save memory, it is short QName, where nsPrefix needs
* to be explictly supported, e.g. {@code wn31} for nvarps.
*
* @param adjectiveSatelliteLiteral Verb literal, please preserve capitalization because case-normalization will be performed here.
* @return
* @todo These aren't sorted/prioritized in any way.
* @todo Need Cached by EHCache or something (never expire but with invalidation), or function-based index.
*/
public List<QName> getAdjectiveSatelliteSenses(final String adjectiveSatelliteLiteral) {
List<QName> senses = new ArrayList<>();
ParameterizedSparqlString sparql = new ParameterizedSparqlString(
"SELECT ?sense\n"
+ "WHERE {\n"
+ " ?sense wordnet-ontology:translation ?adjectiveSatelliteLiteral ;"
+ " wordnet-ontology:part_of_speech wordnet-ontology:adjective_satellite\n"
+ "} LIMIT 100", model);
sparql.setLiteral("adjectiveSatelliteLiteral", adjectiveSatelliteLiteral.toLowerCase(), "ind");
log.trace("getAdjectiveSatelliteSenses '{}' SPARQL: {}", adjectiveSatelliteLiteral, sparql);
Query verbTxQuery = QueryFactory.create(sparql.toString());
QueryExecution qexec = QueryExecutionFactory.create(verbTxQuery, wn31tdb);
try {
ResultSet rs = qexec.execSelect();
for (; rs.hasNext(); ) {
QuerySolution soln = rs.next();
QName senseRes = toQName(soln.get("sense").asResource());
senses.add(senseRes);
}
} finally {
qexec.close();
}
return senses;
}
示例4: getVerbSenses
import org.apache.jena.query.ParameterizedSparqlString; //导入方法依赖的package包/类
/**
* Mapping from {@code ind} translations to WordNet senses for verb part-of-speech.
* The value is String to save memory, it is short QName, where nsPrefix needs
* to be explictly supported, e.g. {@code wn31} for nvarps.
*
* @param verbLiteral Verb literal, please preserve capitalization because case-normalization will be performed here.
* @return
* @todo These aren't sorted/prioritized in any way.
* @todo Need Cached by EHCache or something (never expire but with invalidation), or function-based index.
*/
public List<QName> getVerbSenses(final String verbLiteral) {
List<QName> senses = new ArrayList<>();
ParameterizedSparqlString sparql = new ParameterizedSparqlString(
"SELECT ?sense\n"
+ "WHERE {\n"
+ " ?sense wordnet-ontology:translation ?verbLiteral ;"
+ " wordnet-ontology:part_of_speech wordnet-ontology:verb\n"
+ "} LIMIT 100", model);
sparql.setLiteral("verbLiteral", verbLiteral.toLowerCase(), "ind");
log.trace("getVerbSenses '{}' SPARQL: {}", verbLiteral, sparql);
Query verbTxQuery = QueryFactory.create(sparql.toString());
QueryExecution qexec = QueryExecutionFactory.create(verbTxQuery, wn31tdb);
try {
ResultSet rs = qexec.execSelect();
for (; rs.hasNext(); ) {
QuerySolution soln = rs.next();
QName senseRes = toQName(soln.get("sense").asResource());
senses.add(senseRes);
}
} finally {
qexec.close();
}
return senses;
// return FluentIterable.from( verbSenses.get(verbLiteral.toLowerCase()) )
// .transform(new Function<String, QName>() {
// @Override
// public QName apply(String input) {
// return RelEx.this.expandRef(input);
// }
// }).toList();
}