openllet.query.sparqldl.model.Query类的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(9.8k)|赞(0)|评价(0)|浏览(135)

本文整理了Java中openllet.query.sparqldl.model.Query类的一些代码示例,展示了Query类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Query类的具体详情如下:
包路径:openllet.query.sparqldl.model.Query
类名称:Query

Query介绍

[英]Title: Query Interface

Copyright: Copyright (c) 2007

Company: Clark & Parsia, LLC.
[中]标题:查询接口
版权所有:版权所有(c)2007
公司:Clark&Parsia有限责任公司。

代码示例

代码示例来源:origin: com.github.galigator.openllet/openllet-query

for (final QueryAtom atom : query.getAtoms())
  switch (atom.getPredicate())
      aboxQuery.add(atom);
      break;
    default:
final List<QueryAtom> atoms = new ArrayList<>(query.getAtoms());
atoms.removeAll(aboxQuery.getAtoms());
  schemaQuery.add(atom);
  for (final ATermAppl a : query.getDistVarsForType(t))
    if (aboxQuery.getVars().contains(a))
      aboxQuery.addDistVar(a, t);
    if (schemaQuery.getVars().contains(a))
      schemaQuery.addDistVar(a, t);
for (final ATermAppl a : query.getResultVars())
  if (aboxQuery.getVars().contains(a))
    aboxQuery.addResultVar(a);
  if (schemaQuery.getVars().contains(a))
    schemaQuery.addResultVar(a);
for (final ATermAppl v : aboxQuery.getDistVarsForType(VarType.CLASS))
  if (!schemaQuery.getVars().contains(v))
    schemaQuery.add(QueryAtomFactory.SubClassOfAtom(v, ATermUtils.TOP));

代码示例来源:origin: Galigator/openllet

@Override
public Set<ATermAppl> getDistVars()
{
  return _query.getDistVars();
}

代码示例来源:origin: Galigator/openllet

protected Query query(final ATermAppl[] vars, final QueryAtom[] atoms)
{
  final Query q = new QueryImpl(_kb, true);
  for (final ATermAppl var : vars)
    q.addResultVar(var);
  for (final QueryAtom atom : atoms)
    q.add(atom);
  for (final ATermAppl var : q.getUndistVars())
    q.addDistVar(var, VarType.INDIVIDUAL);
  return q;
}

代码示例来源:origin: com.github.galigator.openllet/openllet-query

public QueryResultImpl(final Query query)
{
  _query = query;
  _parameters = query.getQueryParameters();
  _resultVars = new ArrayList<>(query.getResultVars());
  if (query.isDistinct())
    _bindings = new HashSet<>();
  else
    _bindings = new ArrayList<>();
}

代码示例来源:origin: com.github.galigator.openllet/openllet-query

private static boolean hasUndefinedTerm(final Query query)
{
  return hasUndefinedTerm(query.getAtoms(), query.getKB());
}

代码示例来源:origin: com.github.galigator.openllet/openllet-query

final Set<ATermAppl> undistVars = q.getUndistVars();
  for (final QueryAtom atom : q.findAtoms(QueryPredicate.SameAs, null, null))
          replaceA2 = true;
        else
          if (ATermUtils.isVar(a1) && !q.getResultVars().contains(a1))
            replaceA1 = true;
          else
            if (ATermUtils.isVar(a2) && !q.getResultVars().contains(a2))
              replaceA2 = true;
      q = q.apply(b);
      boundSameAs = true;
      break;
for (final QueryAtom atom : q.findAtoms(QueryPredicate.SameAs, null, null))
  if (a1.equals(a2) && !q.getResultVars().contains(a1) && q.getAtoms().size() > 1)
    q.remove(atom);
for (final QueryAtom a : new HashSet<>(q.getAtoms()))
  switch (a.getPredicate())
        q.add(QueryAtomFactory.SubClassOfAtom(clazz, clazz));
      break;
    case PropertyValue:
      final ATermAppl property = a.getArguments().get(1);

代码示例来源:origin: com.github.galigator.openllet/openllet-query

objectCandidates = Collections.singleton(pvIL);
  else
    if (!_plan.getQuery().getDistVarsForType(VarType.LITERAL).contains(pvIL))
      propertyCandidates = _kb.getObjectProperties();
    final ATermAppl clazz = core.getQuery().rollUpTo(c, Collections.<ATermAppl> emptySet(), STOP_ROLLING_ON_CONSTANTS);
    final ATermAppl c = core.getQuery().rollUpTo(var, Collections.<ATermAppl> emptySet(), STOP_ROLLING_ON_CONSTANTS);
    final Collection<ATermAppl> instances = _kb.getInstances(c);
  newQuery.add(atom.apply(binding));
for (final ATermAppl var : newQuery.getUndistVars())
  newQuery.addDistVar(var, VarType.INDIVIDUAL);
    newQuery.add(atom.apply(binding));
  for (final ATermAppl var : newQuery.getUndistVars())
    newQuery.addDistVar(var, VarType.INDIVIDUAL);
    newQuery.addResultVar(var);

代码示例来源:origin: Galigator/openllet

final KnowledgeBase kb = q.getKB();
  final ATermAppl rolledUpClass = q.rollUpTo(currVar, Collections.<ATermAppl> emptySet(), STOP_ROLLING_ON_CONSTANTS);
  _logger.finer("Var bindings: " + varBindings);
final Set<ATermAppl> literalVars = q.getDistVarsForType(VarType.LITERAL);
final Set<ATermAppl> individualVars = q.getDistVarsForType(VarType.INDIVIDUAL);
      if (QueryEngine.execBooleanABoxQuery(q.apply(mappy)))
        exec(mappy);
    if (QueryEngine.execBooleanABoxQuery(q.apply(candidate)))
      exec(candidate);

代码示例来源:origin: com.github.galigator.openllet/openllet-query

private Query setupCores(final Query query)
  final Iterator<ATermAppl> undistVarIterator = query.getUndistVars().iterator();
  if (!undistVarIterator.hasNext())
    return query;
    for (final QueryAtom atom : query.findAtoms(QueryPredicate.PropertyValue, a, null, null))
      if (query.getUndistVars().contains(a2))
    for (final QueryAtom atom : query.findAtoms(QueryPredicate.PropertyValue, null, null, a))
      if (query.getUndistVars().contains(a2))
    for (final QueryAtom atom : query.findAtoms(QueryPredicate.Type, a, null))
  final Query transformedQuery = query.apply(new ResultBindingImpl());
        atoms.add((QueryAtom) a);
    final CoreNewImpl c = (CoreNewImpl) QueryAtomFactory.Core(atoms, query.getUndistVars(), _kb);
    transformedQuery.add(c);
    _logger.fine(() -> c.getUndistVars() + " : " + c.getDistVars() + " : " + c.getQuery().getAtoms());
    transformedQuery.remove(atom);

代码示例来源:origin: Galigator/openllet

query.addResultVar(ATermUtils.makeVar(var));
    query.add(QueryAtomFactory.SubClassOfAtom(s, TermFactory.TOP));
    if (ATermUtils.isVar(s))
      query.addDistVar(s, VarType.CLASS);
      if (_handleVariableSPO)
      query.add(QueryAtomFactory.TypeAtom(s, TermFactory.TOP));
      if (ATermUtils.isVar(s))
        query.addDistVar(s, VarType.CLASS);
        if (_handleVariableSPO)
        query.add(QueryAtomFactory.ObjectPropertyAtom(s));
        if (ATermUtils.isVar(s))
          query.addDistVar(s, VarType.PROPERTY);
          if (_handleVariableSPO)
          query.add(QueryAtomFactory.DatatypePropertyAtom(s));
          if (ATermUtils.isVar(s))
            query.addDistVar(s, VarType.PROPERTY);
            if (_handleVariableSPO)
              query.addDistVar(s, VarType.PROPERTY);
              if (_handleVariableSPO)

代码示例来源:origin: com.github.galigator.openllet/openllet-query

final KnowledgeBase kb = query.getKB();
final Set<ATermAppl> vars = query.getVars(); // getObjVars
  for (final QueryAtom pattern : query.findAtoms(QueryPredicate.PropertyValue, var, null, null))
    if (!ATermUtils.isVar(pattern.getArguments().get(1)))
      inferredTypes.addAll(kb.getDomains(pattern.getArguments().get(1)));
  for (final QueryAtom pattern : query.findAtoms(QueryPredicate.PropertyValue, null, null, var))
    if (!ATermUtils.isVar(pattern.getArguments().get(1)))
      inferredTypes.addAll(kb.getRanges(pattern.getArguments().get(1)));
for (final QueryAtom atom : new ArrayList<>(query.getAtoms()))
  if (atom.getPredicate() == QueryPredicate.Type)
      if (inferred != null && !inferred.isEmpty())
        if (inferred.contains(clazz))
          query.remove(atom);
        else
          if (kb.isClassified())
            final Set<ATermAppl> eqs = kb.getAllEquivalentClasses(clazz);
            if (SetUtils.intersects(inferred, subs) || SetUtils.intersects(inferred, eqs))
              query.remove(atom);

代码示例来源:origin: com.github.galigator.openllet/openllet-query

final KnowledgeBase kb = query.getKB();
kb.ensureConsistency();
for (final QueryAtom atom : query.getAtoms())
else
  if (!query.getConstants().isEmpty())
    final ATermAppl testInd = query.getConstants().iterator().next();
    final ATermAppl testClass = query.rollUpTo(testInd, Collections.<ATermAppl> emptySet(), false);
    final ATermAppl testVar = query.getUndistVars().iterator().next();
    final ATermAppl testClass = query.rollUpTo(testVar, Collections.<ATermAppl> emptySet(), false);

代码示例来源:origin: Galigator/openllet

private void exec(final Query q, final ResultBinding binding, final boolean first)
  if (q.getDistVars().isEmpty())
  final Iterator<ATermAppl> i = q.getDistVars().iterator();
  final ATermAppl clazz = q.rollUpTo(var, empty, false);
    for (final QueryAtom atom : q.findAtoms(QueryPredicate.PropertyValue, var, null, null))
      instances.retainAll(_kb.retrieveIndividualsWithProperty(atom.getArguments().get(1)));
    for (final QueryAtom atom : q.findAtoms(QueryPredicate.PropertyValue, null, null, var))
      instances.retainAll(_kb.retrieveIndividualsWithProperty(ATermUtils.makeInv(atom.getArguments().get(1))));
    final Query q2 = q.apply(newBinding);
    exec(q2, newBinding, false);

代码示例来源:origin: com.github.galigator.openllet/openllet-owlapi

@Override
public void visit(final OWLDifferentIndividualsAxiom axiom)
{
  final List<ATermAppl> differents = new ArrayList<>();
  axiom.individuals().forEach(ind ->
  {
    final ATermAppl term = _indConv.getTerm(ind);
    for (final ATermAppl dterm : differents)
      _query.add(QueryAtomFactory.DifferentFromAtom(term, dterm));
  });
}

代码示例来源:origin: Galigator/openllet

_query.add(atom);
    if (ATermUtils.isVar(a1))
      if (!uv.contains(a1))
        _query.addDistVar(a1, VarType.PROPERTY);
    break;
  case Type:
    if (ATermUtils.isVar(aa1))
      if (!uv.contains(aa1))
        _query.addDistVar(aa1, VarType.CLASS);
    break;
  default:

代码示例来源:origin: com.github.galigator.openllet/openllet-query

public static QueryResult exec(final Query query)
  if (query.getAtoms().isEmpty())
    return results;
  query.getKB().ensureConsistency();
        results.add(execSingleQuery(q));
      r = new MultiQueryResults(query.getResultVars(), results);

代码示例来源:origin: Galigator/openllet

public LiteralIterator(final Query q, final ResultBinding binding)
  final KnowledgeBase kb = q.getKB();
  _binding = binding;
  _litVars = q.getDistVarsForType(VarType.LITERAL);
    boolean first = true;
    for (final QueryAtom atom : q.findAtoms(QueryPredicate.PropertyValue, null, null, litVar))

代码示例来源:origin: com.github.galigator.openllet/openllet-query

/**
 * {@inheritDoc}
 */
@Override
public CoreNewImpl apply(final ResultBinding binding)
{
  return new CoreNewImpl(_query.apply(binding), _atom.apply(binding));
}

代码示例来源:origin: Galigator/openllet

@Test
public void testMixedQuery()
{
  classes(_A, _B, _C);
  individuals(_a);
  _kb.addSubClass(_A, _C);
  _kb.addSubClass(_B, _C);
  _kb.addType(_a, _A);
  final Query q1 = query(SubClassOfAtom(x, _C), TypeAtom(y, x));
  q1.addDistVar(x, VarType.CLASS);
  q1.addResultVar(x);
  final QueryResult qr = QueryEngine.exec(q1);
  final List<ATermAppl> results = new ArrayList<>();
  for (final ResultBinding result : qr)
  {
    System.out.println(result);
    results.add(result.getValue(x));
  }
  assertIteratorValues(results.iterator(), new ATermAppl[] { _A, _C });
}

代码示例来源:origin: com.github.galigator.openllet/openllet-query

public NoReorderingQueryPlan(final Query query)
{
  super(query);
  _index = 0;
  _size = query.getAtoms().size();
}

相关文章