helper function to map named to numbered entities
551988
function createNamedToNumberedLookup(items, radix) {
        var i, entity, lookup = {}, base10, base16;
        items = items.split(',');
        radix = radix || 10;
        // Map from named to numbered entities.
        for (i = 0; i < items.length; i += 2) {
            entity = '&' + items[i + 1] + ';';
            base10 = parseInt(items[i], radix);
            lookup[entity] = '&#'+base10+';';
        }
        //FF and IE need to create a regex from hex values ie &nbsp; == \xa0
        lookup["\\xa0"] = '&#160;';
        return lookup;
    }
298592
function _entityToValue(item, lib) {
    if (typeof item === JS_STRING_TYPE) {
        // Only JSON-serializable entities may be put into a list
        var constant = lib.lookupConstant(item);
        if (constant !== undefined) return constant;
    }
    // Also unquote any item we got that also happens to be a quote
    if (item && item[RUNIQ_QUOTED_ENTITY_PROP_NAME]) {
        return item[RUNIQ_QUOTED_ENTITY_PROP_NAME];
    }
    return item;
}
1221423
function getRelevantIndexes(text, inlineRanges, entityRanges = [], decoratorRanges = []) {
  let relevantIndexes = [];
  // set indexes to corresponding keys to ensure uniquenes
  relevantIndexes = addIndexes(relevantIndexes, inlineRanges);
  relevantIndexes = addIndexes(relevantIndexes, entityRanges);
  relevantIndexes = addIndexes(relevantIndexes, decoratorRanges);
  // add text start and end to relevant indexes
  relevantIndexes.push(0);
  relevantIndexes.push(text.length);
  const uniqueRelevantIndexes = relevantIndexes.filter(
    (value, index, self) => self.indexOf(value) === index
  );
  // and sort it
  return uniqueRelevantIndexes.sort((aa, bb) => (aa - bb));
}
1337304
function __map(items, fn, includeNull) {
  // whether to return nulls in array of results; default = true;
  includeNull = includeNull == null ? true : includeNull;
  if (items == null) return items;
  var result;
  if (Array.isArray(items)) {
    result = [];
    items.forEach(function (v, ix) {
      var r = fn(v, ix);
      if (r != null || includeNull) {
        result[ix] = r;
      }
    });
  } else {
    result = fn(items);
  }
  return result;
}
742387
def _generate_ngrams_with_context_helper(ngrams_iter: iter, ngrams_len: int) -> map:
        """"""
        return map(lambda term: (term[1], term[0], term[0] + ngrams_len), enumerate(ngrams_iter))
700834
def visit_num(self, node, parent):
        """"""
        return nodes.Const(
            node.n,
            getattr(node, "lineno", None),
            getattr(node, "col_offset", None),
            parent,
        )
992997
function convertEntity(entity) {
    switch (entity[0]) {
        case '"': {
            if(entity.indexOf("^^") > 0) {
                var parts = entity.split("^^");
                return {literal: parts[0] + "^^<" + parts[1] + ">" };
            } else {
                return { literal: entity };
            }
        }
        case '_': return { blank: entity.replace('b', '') };
        default:  return { token: 'uri', value: entity, prefix: null, suffix: null };
    }
}
483581
def withNamedBits(cls, **values):
        
        enums = set(cls.namedValues.items())
        enums.update(values.items())

        class X(cls):
            namedValues = namedval.NamedValues(*enums)

        X.__name__ = cls.__name__
        return X
79233
function(enm) {
    var titleMap = []; //canonical titleMap format is a list.
    enm.forEach(function(name) {
      titleMap.push({name: name, value: name});
    });
    return titleMap;
  }
129361
def join(mapping, bind, values):
    
    return [' '.join([six.text_type(v) for v in values if v is not None])]
581070
def entities(self):
    """"""
    start = 0
    end = 0
    prev_tag = u'O'
    chunks = []
    for i, (w, tag) in enumerate(self.ne_chunker.annotate(self.words)):
      if tag != prev_tag:
        if prev_tag == u'O':
          start = i
        else:
          chunks.append(Chunk(self.words[start: i], start, i, tag=prev_tag,
                              parent=self))
        prev_tag = tag
    if tag != u'O':
      chunks.append(Chunk(self.words[start: i+1], start, i+1, tag=tag,
                          parent=self))
    return chunks
122817
function parseTypeName(entityTypeName) {
  if (!entityTypeName) {
    return null;
  }

  var typeParts = entityTypeName.split(":#");
  if (typeParts.length > 1) {
    return makeTypeHash(typeParts[0], typeParts[1]);
  }

  if (__stringStartsWith(entityTypeName, MetadataStore.ANONTYPE_PREFIX)) {
    var typeHash = makeTypeHash(entityTypeName);
    typeHash.isAnonymous = true
    return typeHash;
  }
  var entityTypeNameNoAssembly = entityTypeName.split(",")[0];
  var typeParts = entityTypeNameNoAssembly.split(".");
  if (typeParts.length > 1) {
    var shortName = typeParts[typeParts.length - 1];
    var namespaceParts = typeParts.slice(0, typeParts.length - 1);
    var ns = namespaceParts.join(".");
    return makeTypeHash(shortName, ns);
  } else {
    return makeTypeHash(entityTypeName);
  }
}
282732
function(str, param) {
      var map = this[param + 'Map'];
      if (hasOwn(map, str)) {
        return map[str];
      }
      return this.parseNumber(str, param);
    }
787268
def _mark_entities(self, c, markers):
        
        sent = c.get_parent().words
        positions = [
            [c[i].get_word_start(), c[i].get_word_end()]
            for i in range(self.cardinality)
        ]
        seq = mark_entities(sent, positions, markers=markers, style="insert")
        return [w for w in seq if w.strip()]
692747
def schema_map(schema):
    """"""
    mapper = {}
    for name in getFieldNames(schema):
        mapper[name] = name
    return mapper
1116640
function getMutations(spec, attr) {
      var fns = compose(extraction, cleanup, stitch)(spec);
      return _.callmap(fns, attr);
    }
815659
def named_refs(obj):
    
    refs = []
    v = _typedefof(obj)
    if v:
        v = v.refs
        if v and _callable(v):
            for ref in v(obj, True):
                try:
                    refs.append((ref.name, ref.ref))
                except AttributeError:
                    pass
    return refs