Returns the DBContext as a list of interpretations, i.e., a list of
        facts true for each example in the format for TreeLiker.
508016
def dataset(self):
        '''
        
        '''
        target = self.db.target_table
        db_examples = self.db.rows(target, [self.db.target_att, self.db.pkeys[target]])

        examples = []
        for cls, pk in sorted(db_examples, key=lambda ex: ex[0]):
            facts = self._facts(pk, self.db.pkeys[target], target, visited=set())
            examples.append('%s %s' % (cls, ', '.join(facts)))

        return '\n'.join(examples)
157408
protected List<JCDiagnostic> getWhereClauses() {
        List<JCDiagnostic> clauses = List.nil();
        for (WhereClauseKind kind : WhereClauseKind.values()) {
            List<JCDiagnostic> lines = List.nil();
            for (Map.Entry<Type, JCDiagnostic> entry : whereClauses.get(kind).entrySet()) {
                lines = lines.prepend(entry.getValue());
            }
            if (!lines.isEmpty()) {
                String key = kind.key();
                if (lines.size() > 1)
                    key += ".1";
                JCDiagnostic d = diags.fragment(key, whereClauses.get(kind).keySet());
                d = new JCDiagnostic.MultilineDiagnostic(d, lines.reverse());
                clauses = clauses.prepend(d);
            }
        }
        return clauses.reverse();
    }
298879
public List<String> getLiterals() {
    return this.templateChunks.stream()
        .filter(templateChunk -> Literal.class.isAssignableFrom(templateChunk.getClass()))
        .map(TemplateChunk::toString)
        .filter(Objects::nonNull)
        .collect(Collectors.toList());
  }
547751
def facts(self, fields=None, cuts=None, order=None, page=None,
              page_size=None, page_max=None):
        

        def prep(cuts, columns=None):
            q = select(columns=columns).select_from(self.fact_table)
            bindings = []
            _, q, bindings = Cuts(self).apply(q, bindings, cuts)
            q = self.restrict_joins(q, bindings)
            return q, bindings

        # Count
        count = count_results(self, prep(cuts, [1])[0])

        # Facts
        q, bindings = prep(cuts)
        fields, q, bindings = Fields(self).apply(q, bindings, fields)
        ordering, q, bindings = Ordering(self).apply(q, bindings, order)
        page, q = Pagination(self).apply(q, page, page_size, page_max)
        q = self.restrict_joins(q, bindings)
        return {
            'total_fact_count': count,
            'data': list(generate_results(self, q)),
            'cell': cuts,
            'fields': fields,
            'order': ordering,
            'page': page['page'],
            'page_size': page['page_size']
        }
948986
private ParseTree parseTryStatement() {
    SourcePosition start = getTreeStartLocation();
    eat(TokenType.TRY);
    ParseTree body = parseBlock();
    ParseTree catchBlock = null;
    if (peek(TokenType.CATCH)) {
      catchBlock = parseCatch();
    }
    ParseTree finallyBlock = null;
    if (peek(TokenType.FINALLY)) {
      finallyBlock = parseFinallyBlock();
    }
    if (catchBlock == null && finallyBlock == null) {
      reportError("'catch' or 'finally' expected.");
    }
    return new TryStatementTree(getTreeLocation(start), body, catchBlock, finallyBlock);
  }
636832
private String buildWhereClause() {
	
        StringBuilder sqlBuf = new StringBuilder();
       
        String join = null;
        boolean first = true;

        for (Enumeration where = mTables.elements(); where.hasMoreElements();) {
            join = (String) where.nextElement();
	    
            if (join.length() > 0) {
                if (first) {
                    // Skip " AND " in first iteration
                    first = false;
                }
                else {
                    sqlBuf.append(" AND ");
                }
            }

            sqlBuf.append(join);
        }

        if (sqlBuf.length() > 0) 
            return "WHERE " + sqlBuf.toString();
	
        return "WHERE 1 = 1"; // Hacky...
    }
1229300
def get_context(self):
        
        ctx = self._obj.get_context()
        return _ContextProxy(ctx, self._factory)
595762
def contexts(self):
        
        if not hasattr(self, "_contexts"):
            cs = {}
            for cr in self.doc["contexts"]:
                cs[cr["name"]] = copy.deepcopy(cr["context"])
            self._contexts = cs
        return self._contexts
641215
def context(self):
        
        ret = libxml2mod.xmlXPathParserGetContext(self._o)
        if ret is None:raise xpathError('xmlXPathParserGetContext() failed')
        __tmp = xpathContext(_obj=ret)
        return __tmp
1007889
def to_dict(self,include_node_id=False,no_attributes=False,track_namespaces=False):
        
        flat_result = []

        def make_ns_slug(name_counter,slug='n'):
            while "%s%s" % (slug,name_counter['counter']) in namespace_mapping.values():
                name_counter['counter']  = name_counter['counter']+1

            return "%s%s" % (slug,name_counter['counter'])

        name_counter = {'counter':0}

        if track_namespaces:

            fact_thrus = self.fact_thru.all().prefetch_related(
                'fact__fact_term',
                'fact__fact_values',
                'fact__fact_values__fact_data_type',
                'fact__fact_values__fact_data_type__namespace',
                'fact__value_iobject_id',
                'fact__value_iobject_id__namespace',
                'namespace_map__namespaces_thru__namespace',
                'node_id')
        else:
            fact_thrus = self.fact_thru.all().prefetch_related(
                'fact__fact_term',
                'fact__fact_values',
                'fact__fact_values__fact_data_type',
                'fact__fact_values__fact_data_type__namespace',
                'fact__value_iobject_id',
                'fact__value_iobject_id__namespace',
                'node_id')

        export_ns_dict = {}

        namespace_mapping=  {"%s-%s" % (self.iobject_type.namespace.uri,self.iobject_type_revision): 'n0'}
        #fact_thrus = self.fact_thru.all()
        for fact_thru in fact_thrus:
            #print fact_thru.node_id
            #print fact_thru.fact.fact_term
            #for positional_namespace in fact_thru.namespace_map.namespaces_thru.all():
            #    print positional_namespace

            value_list = []
            first = True
            fact_datatype_name = None
            fact_datatype_ns = None

            fact_dict = {'node_id': fact_thru.node_id.name,
                         'term': fact_thru.fact.fact_term.term,
                         'attribute' : fact_thru.fact.fact_term.attribute,
                         '@@namespace_map' : fact_thru.namespace_map,
                         }

            for fact_value in fact_thru.fact.fact_values.all():
                if first:
                    first=False
                    fact_datatype_name = fact_value.fact_data_type.name
                    fact_datatype_ns = fact_value.fact_data_type.namespace.uri
                    if (fact_datatype_name == DINGOS_DEFAULT_FACT_DATATYPE and
                                fact_datatype_ns == DINGOS_NAMESPACE_URI) or fact_thru.fact.value_iobject_id:
                        pass
                    else:
                        if not fact_datatype_ns in namespace_mapping:
                            namespace_slug = make_ns_slug(name_counter)
                            namespace_mapping[fact_datatype_ns] = namespace_slug
                        else:
                            namespace_slug= namespace_mapping[fact_datatype_ns]
                        fact_dict['@@type'] = '%s:%s' % (namespace_slug,fact_datatype_name)

                value_list.append(fact_value.value)




            fact_dict['value_list'] = value_list


            if fact_thru.fact.value_iobject_id:
                value_iobject_id_ns = fact_thru.fact.value_iobject_id.namespace.uri
                if not value_iobject_id_ns in namespace_mapping:
                    namespace_slug = make_ns_slug(name_counter)
                    namespace_mapping[value_iobject_id_ns] = namespace_slug
                else:
                    namespace_slug= namespace_mapping[value_iobject_id_ns]

                value_iobject_id  =fact_thru.fact.value_iobject_id.uid
                if fact_dict['attribute']:
                    # Here we treat the case that the reference is part of an attribute such as
                    # 'phase_id'
                    fact_dict['value_list'] = ["%s:%s" % (namespace_slug,value_iobject_id)]
                else:
                    # Otherwise, we sneak in an idref attribute. Because the code that
                    # generates the dictionary simply dumps all untreated key-value paris
                    # into the generated dictionary, this works... but is a bit of a hack, really.

                    fact_dict['@idref'] = "%s:%s" % (namespace_slug,value_iobject_id)

            flat_result.append(fact_dict)

        result = DingoObjDict()


        result.from_flat_repr(flat_result,
            include_node_id=include_node_id,
            no_attributes=no_attributes,
            track_namespaces=track_namespaces,
            namespace_mapping=namespace_mapping
            )


        if not no_attributes:
            if not track_namespaces:
                result['@@iobject_type'] = self.iobject_type.name
                result['@@iobject_type_ns'] = self.iobject_type.namespace.uri
                return result
            else:
                result['@ns'] = namespace_mapping["%s-%s" % (self.iobject_type.namespace.uri,self.iobject_type_revision)]
                #result['@@iobject_type'] = self.iobject_type.name
                return {'namespaces': dict(map(lambda x : (x[1],x[0]), namespace_mapping.items())),
                        'objects' : [result]
                }
        else:
            return result
824961
def ontologyConceptTree(self):
        
        treedict = {}
        if self.all_skos_concepts:
            treedict[0] = self.toplayer_skos
            for element in self.all_skos_concepts:
                if element.children():
                    treedict[element] = element.children()
            return treedict
        return treedict
81643
def context_chain(self) -> List['Context']:
        """"""
        contexts = []
        ctx = self  # type: Optional[Context]
        while ctx is not None:
            contexts.append(ctx)
            ctx = ctx.parent

        return contexts
1129376
private static JAXBContext getContext(String[] contexts) throws Exception {
		List<String> ctx = Lists.asList(BASE_CONTEXT, contexts);
		return JAXBContext.newInstance(JOINER.join(ctx));
	}
881352
function BaseStatement(
    statementOptions, context, services, connectionConfig)
{
  // call super
  EventEmitter.call(this);

  // validate input
  Errors.assertInternal(Util.isObject(statementOptions));
  Errors.assertInternal(Util.isObject(context));

  context.services         = services;
  context.connectionConfig = connectionConfig;
  context.isFetchingResult = true;

  // TODO: add the parameters map to the statement context

  var statement = this;

  /**
   * Returns this statement's SQL text.
   *
   * @returns {String}
   */
  this.getSqlText = function()
  {
    return context.sqlText;
  };

  /**
   * Returns the current status of this statement.
   *
   * @returns {String}
   */
  this.getStatus = function()
  {
    return context.isFetchingResult ? states.FETCHING : states.COMPLETE;
  };

  /**
   * Returns the columns produced by this statement.
   *
   * @returns {Object[]}
   */
  this.getColumns = function()
  {
    return context.result ? context.result.getColumns() : undefined;
  };

  /**
   * Given a column identifier, returns the corresponding column. The column
   * identifier can be either the column name (String) or the column index
   * (Number). If a column is specified and there is more than one column with
   * that name, the first column with the specified name will be returned.
   *
   * @param {String | Number} columnIdentifier
   *
   * @returns {Object}
   */
  this.getColumn = function(columnIdentifier)
  {
    return context.result ? context.result.getColumn(columnIdentifier) :
        undefined;
  };

  /**
   * Returns the number of rows returned by this statement.
   *
   * @returns {Number}
   */
  this.getNumRows = function()
  {
    return context.result ? context.result.getReturnedRows() : undefined;
  };

  /**
   * Returns the number of rows updated by this statement.
   *
   * @returns {Number}
   */
  this.getNumUpdatedRows = function()
  {
    return context.result ? context.result.getNumUpdatedRows() : undefined;
  };

  /**
   * Returns an object that contains information about the values of the
   * current warehouse, current database, etc., when this statement finished
   * executing.
   *
   * @returns {Object}
   */
  this.getSessionState = function()
  {
    return context.result ? context.result.getSessionState() : undefined;
  };

  /**
   * Returns the request id that was used when the statement was issued.
   *
   * @returns {String}
   */
  this.getRequestId = function()
  {
    return context.requestId;
  };

  /**
   * Returns the statement id generated by the server for this statement.
   * If the statement is still executing and we don't know the statement id
   * yet, this method will return undefined.
   *
   * @returns {String}
   */
  this.getStatementId = function()
  {
    return context.statementId;
  };

  /**
   * Cancels this statement if possible.
   *
   * @param {Function} [callback]
   */
  this.cancel = function(callback)
  {
    sendCancelStatement(context, statement, callback);
  };

  /**
   * Issues a request to get the statement result again.
   *
   * @param {Function} callback
   */
  context.refresh = function(callback)
  {
    // pick the appropriate function to get the result based on whether we
    // have the statement id or request id (we should have at least one)
    var sendRequestFn = context.statementId ?
        sendRequestPostExec : sendRequestPreExec;

    // the current result error might be transient,
    // so issue a request to get the result again
    sendRequestFn(context, function(err, body)
    {
      // refresh the result
      context.onStatementRequestComp(err, body);

      // if a callback was specified, invoke it
      if (Util.isFunction(callback))
      {
        callback(context);
      }
    });
  };

  /**
   * Called when the statement request is complete.
   *
   * @param err
   * @param body
   */
  context.onStatementRequestComp = function(err, body)
  {
    // if we already have a result or a result error, we invoked the complete
    // callback once, so don't invoke it again
    var suppressComplete = context.result || context.resultError;

    // clear the previous result error
    context.resultError = null;

    // if there was no error, call the success function
    if (!err)
    {
      context.onStatementRequestSucc(body);
    }
    else
    {
      // save the error
      context.resultError = err;

      // if we don't have a statement id and we got a response from GS, extract
      // the statement id from the data
      if (!context.statementId &&
          Errors.isOperationFailedError(err) && err.data)
      {
        context.statementId = err.data.queryId;
      }
    }

    // we're no longer fetching the result
    context.isFetchingResult = false;

    if (!suppressComplete)
    {
      // emit a complete event
      context.emit('statement-complete', Errors.externalize(err), statement);

      // if a complete function was specified, invoke it
      if (Util.exists(context.complete))
      {
        invokeStatementComplete(statement, context);
      }
    }
    else
    {
      Logger.getInstance().debug('refreshed result of statement with %s',
          context.requestId ?
              Util.format('request id = %s', context.requestId) :
              Util.format('statement id = %s', context.statementId));
    }
  };

  /**
   * Called when the statement request is successful. Subclasses must provide
   * their own implementation.
   *
   * @param {Object} body
   */
  context.onStatementRequestSucc = function(body){};
}
1349506
def background_knowledge(self):
        '''
        
        '''
        modeslist, getters = [self.mode(self.__target_predicate(), [('+', self.db.target_table)], head=True)], []
        determinations, types = [], []
        for (table, ref_table) in self.db.connected.keys():
            if ref_table == self.db.target_table:
                continue  # Skip backward connections
            modeslist.append(
                self.mode('%s_has_%s' % (table.lower(), ref_table), [('+', table), ('-', ref_table)], recall='*'))
            determinations.append(
                ':- determination(%s/1, %s_has_%s/2).' % (self.__target_predicate(), table.lower(), ref_table))
            types.extend(self.concept_type_def(table))
            types.extend(self.concept_type_def(ref_table))
            getters.extend(self.connecting_clause(table, ref_table))
        for table, atts in self.db.cols.items():
            for att in atts:
                if att == self.db.target_att and table == self.db.target_table or \
                                att in self.db.fkeys[table] or att == self.db.pkeys[table]:
                    continue
                modeslist.append(self.mode('%s_%s' % (table, att), [('+', table), ('#', att.lower())], recall='*'))
                determinations.append(':- determination(%s/1, %s_%s/2).' % (self.__target_predicate(), table, att))
                types.extend(self.constant_type_def(table, att))
                getters.extend(self.attribute_clause(table, att))
        return '\n'.join(self.user_settings() + modeslist + determinations + types + getters + self.dump_tables())
1251452
public List<Literal> perceive() {
        if (!isRunning())
            return null;
        if (this.getSimulation() == null)
            return null;
        List<Literal> percepts = this.updateBeliefs(this.getSimulation());
        return percepts;
    }
1197414
def find_comprehension_as_statement(node):
    """"""
    return (
        isinstance(node, ast.Expr)
        and isinstance(node.value, (ast.ListComp,
                                    ast.DictComp,
                                    ast.SetComp))
    )