return map: node ID -> first token index (int) it covers
420492
def horizontal_positions(docgraph, sentence_root=None):
    """"""
    # calculate positions for the whole graph
    root_cond = (sentence_root is None) or (sentence_root == docgraph.root)
    if root_cond or ('tokens' not in docgraph.node[sentence_root]):
        sentence_root = docgraph.root
        token_nodes = docgraph.tokens
        path = {}
    else:  # calculate positions only for the given sentence subgraph
        token_nodes = docgraph.node[sentence_root]['tokens']
        path = {sentence_root: 0}

    for i, token_node in enumerate(token_nodes):
        start_node = token_node
        while get_parents(docgraph, start_node, strict=True):
            if start_node not in path:
                path[start_node] = i
            start_node = get_parents(docgraph, start_node, strict=True)[0]
    return path
31515
def get_id_type_map(id_list: Iterable[str]) -> Dict[str, List[str]]:
    
    type_map = {}
    filter_out_types = [
        'cliqueLeader',
        'Class',
        'Node',
        'Individual',
        'quality',
        'sequence feature'
    ]

    for node in get_scigraph_nodes(id_list):
        type_map[node['id']] = [typ.lower() for typ in node['meta']['types']
                                if typ not in filter_out_types]

    return type_map
252262
def _indices(self):
        """"""
        path = self.parent
        layer = path.parent
        for path_index in range(len(layer.paths)):
            if path == layer.paths[path_index]:
                for node_index in range(len(path.nodes)):
                    if self == path.nodes[node_index]:
                        return Point(path_index, node_index)
        return None
814976
def tokens2text(docgraph, token_ids):
    
    return ' '.join(docgraph.node[token_id][docgraph.ns+':token']
                    for token_id in token_ids)
5686
def relayIndextoCoord(self, i):
    
    x = i % self.relayWidth
    y = i / self.relayWidth
    return x, y
888068
def getidfkeyswithnodes():
    """"""
    idf = IDF(StringIO(""))
    keys = idfobjectkeys(idf)
    keysfieldnames = ((key, idf.newidfobject(key.upper()).fieldnames) 
                for key in keys)
    keysnodefdnames = ((key,  (name for name in fdnames 
                                if (name.endswith('Node_Name')))) 
                            for key, fdnames in keysfieldnames)
    nodekeys = [key for key, fdnames in keysnodefdnames if list(fdnames)]
    return nodekeys
138044
def get_nodekey(self, token, types=types, coll_abc=collections.abc):
        '''
        '''
        # Check the mro.
        for mro_type in type(token).__mro__:
            yield mro_type.__name__

        # Check for callability.
        if callable(token):
            yield 'callable'

        # Check for the collections.abc types.
        abc_types = (
            'Hashable',
            'Iterable',
            'Iterator',
            'Sized',
            'Container',
            'Callable',
            'Set',
            'MutableSet',
            'Mapping',
            'MutableMapping',
            'MappingView',
            'KeysView',
            'ItemsView',
            'ValuesView',
            'Sequence',
            'MutableSequence',
            'ByteString')
        for type_name in abc_types:
            type_ = getattr(coll_abc, type_name, None)
            if type_ is None:
                continue
            if isinstance(token, type_):
                yield type_name

        # Check for the standard interpreter types in the types module.
        interp_types = (
            'BuiltinFunctionType',
            'BuiltinMethodType',
            'CodeType',
            'DynamicClassAttribute',
            'FrameType',
            'FunctionType',
            'GeneratorType',
            'GetSetDescriptorType',
            'LambdaType',
            'MappingProxyType',
            'MemberDescriptorType',
            'MethodType',
            'ModuleType',
            'SimpleNamespace',
            'TracebackType')
        for type_name in interp_types:
            type_ = getattr(types, type_name, None)
            if type_ is None:
                continue
            if isinstance(token, type_):
                yield type_name
964787
private static int getMapCount(int srcCount, int numNodes) {
    int numMaps = (int)(srcCount / OP_PER_MAP);
    numMaps = Math.min(numMaps, numNodes * MAX_MAPS_PER_NODE);
    return Math.max(numMaps, 1);
  }
430463
def token(self, id, **kwargs):
        
        data = self.get('tokens', id, **kwargs)
        return data
1315835
private IndexConstraintNodeInfo nodeInfoFromIndexDefinition(IndexReference indexReference, SchemaRead schemaRead, TokenNameLookup tokens){
        int[] labelIds = indexReference.schema().getEntityTokenIds();
        if (labelIds.length != 1) throw new IllegalStateException("Index with more than one label");
        String labelName =  tokens.labelGetName(labelIds[0]);
        List<String> properties = new ArrayList<>();
        Arrays.stream(indexReference.properties()).forEach((i) -> properties.add(tokens.propertyKeyGetName(i)));
        try {
            return new IndexConstraintNodeInfo(
                    // Pretty print for index name
                    String.format(":%s(%s)", labelName, StringUtils.join(properties, ",")),
                    labelName,
                    properties,
                    schemaRead.indexGetState(indexReference).toString(),
                    !indexReference.isUnique() ? "INDEX" : "UNIQUENESS",
                    schemaRead.indexGetState(indexReference).equals(InternalIndexState.FAILED) ? schemaRead.indexGetFailure(indexReference) : "NO FAILURE",
                    schemaRead.indexGetPopulationProgress(indexReference).getCompleted() / schemaRead.indexGetPopulationProgress(indexReference).getTotal() * 100,
                    schemaRead.indexSize(indexReference),
                    schemaRead.indexUniqueValuesSelectivity(indexReference),
                    indexReference.userDescription(tokens)
            );
        } catch(IndexNotFoundKernelException e) {
            return new IndexConstraintNodeInfo(
                    // Pretty print for index name
                    String.format(":%s(%s)", labelName, StringUtils.join(properties, ",")),
                    labelName,
                    properties,
                    "NOT_FOUND",
                    !indexReference.isUnique() ? "INDEX" : "UNIQUENESS",
                    "NOT_FOUND",
                    0,0,0,
                    indexReference.userDescription(tokens)
            );
        }
    }
75790
def nodes(self, value):
        
        # pylint: disable=attribute-defined-outside-init
        self._nodes = value
        self._index2node = {node.index: node for node in self._nodes}
1214949
function mapMapNode(node, parent, maps, id)
  {
    var local,
        attrs = __slice.call(node.attributes),
        nodeMaps = [],
        nodeId = uuid(),
        item,
        x = 0,
        len = attrs.length,
        text,
        title,
        mapText,
        i,
        lenn;
      
    for(x;x<len;x++)
    {
      text = attrs[x].value;
      title = attrs[x].name;
      if(title === '__kaleonodebind__')
      {
        mapText = splitText(text);
        item = mapText[0];

        /* create nodemap */
        local = new mapObject({
          local_id: id,
          node_id: nodeId,
          mapIndex: maps.length,
          mapTextIndex: 0,
          text: item,
          mapText: mapText,
          maps: maps,
          type: 'node',
          property: 'nodeName',
          listener: 'nodeName',
          isDirty: false,
          localAttr: 'nodeName',
          node: node,
          values: nodeMaps
        })
        maps.push(local);
        mapText[0] = maps[(maps.length - 1)];
      }
      else if(title === '__kaleoattrsbind__')
      {
        mapAttrName(node, text, nodeMaps, id, nodeId, true);
      }
      else if(title === '__kaleostylebind__')
      {
        mapStyleAttr(node, text, nodeMaps, id, nodeId, true);
      }
      else if(text.match(__matchText))
      {
        mapText = splitText(text);
        lenn = mapText.length;
        i = 0;
        for(i;i<lenn;i++)
        {
          item = mapText[i];
          if(item.match(__matchInsert))
          {
            nodeMaps.push(new mapObject({
              local_id: id,
              node_id: nodeId,
              mapIndex: maps.length,
              mapTextIndex: i,
              text: item,
              mapText: mapText,
              maps: nodeMaps,
              type: 'pointer',
              isInsert: true,
              property: title,
              local: attrs[x],
              localAttr: 'value',
              node: node,
              isAttr: true
            }));
          }
          else if(item.match(__matchText))
          {
            nodeMaps.push(new mapObject({
              local_id: id,
              node_id: nodeId,
              mapIndex: maps.length,
              mapTextIndex: i,
              text: item,
              mapText: mapText,
              maps: nodeMaps,
              type: 'pointer',
              property: title,
              listener: title,
              local: attrs[x],
              localAttr: 'value',
              node: node,
              isAttr: true,
              isPointer: true
            }));
          }
        }
      }
    }
  }
1315153
public static TIntIntHashMap makeNodeIndex(Collection<Instance> instances) {
        TIntIntHashMap index = new TIntIntHashMap();
        int p = 0;
        for (Instance i : instances) {
            Mapping m = i.getModel().getMapping();
            for (Node n : m.getOfflineNodes()) {
                index.put(n.id(), p);
            }
            for (Node n : m.getOnlineNodes()) {
                index.put(n.id(), p);
            }
            p++;
        }
        return index;
    }
476173
function getNodeIndex(node) {
	var ret = 0;
	while (node.previousSibling) {
		ret++;
		node = node.previousSibling;
	}
	return ret;
}
188691
def iter_starts_with_index(self):
        """"""
        for i in range(1, len(self.endpoints)):
            yield i, self.get_coordinates(i)
353856
private String getTokenOrBlank(final List<String> tokens, final int reverseIndex) {

		final int length = tokens.size();
		final int index  = length - reverseIndex - 1;

		if (index >= 0 && length > 0 && index < length) {
			return tokens.get(index);
		}

		return "";
	}
427722
private static <T extends Node> Map.Entry<CSNodeWrapper, T> findEntry(Map<CSNodeWrapper, T> map, Integer id) {
        if (id == null) return null;

        for (final Map.Entry<CSNodeWrapper, T> entry : map.entrySet()) {
            if (entry.getKey().getNextNode() != null && entry.getKey().getNextNode().getId().equals(id)) {
                return entry;
            }
        }

        return null;
    }