<commit_before>require 'java'

# Looks up the id of the npc with the specified name.
def lookup_npc(name)
  return lookup_entity(:npc, name)
end

# Looks up the id of the item with the specified name.
def lookup_item(name)
  return lookup_entity(:item, name)
end

# Looks up the id of the object with the specified name.
def lookup_object(name)
  return lookup_entity(:object, name)
end

# Looks up the id of an entity of the specified type (either :npc, :item, or :object)
def lookup_entity(type, name)
  type = type.to_s
  name = name.to_s.gsub('_', ' ')
  
  cached = NAME_CACHE[type + name]
  return cached unless cached.nil?

  id = name[name.rindex(' ') + 1, name.length - 1].to_i if name.include?(' ')
  id = find_entities(type, name, 1).first if (id .nil? || id.zero?)
  
  raise "The #{type} called #{name} could not be identified." if id.nil?

  NAME_CACHE[type + name] = id
  return id
end

# Finds entities with the specified type (e.g. npc) and name, returning possible ids as an array.
def find_entities(type, name, limit=5)
  ids = []
  name.downcase!

  Kernel.const_get("#{type.capitalize}Definition").definitions.each do |definition|
    break if (ids.length == limit)
    ids << definition.id.to_i if (definition.name.to_s.downcase == name)
  end

  return ids
end
<commit_msg>Correct typo in name-lookup plugin.<commit_after>require 'java'

# Looks up the id of the npc with the specified name.
def lookup_npc(name)
  return lookup_entity(:npc, name)
end

# Looks up the id of the item with the specified name.
def lookup_item(name)
  return lookup_entity(:item, name)
end

# Looks up the id of the object with the specified name.
def lookup_object(name)
  return lookup_entity(:object, name)
end

# Looks up the id of an entity of the specified type (either :npc, :item, or :object)
def lookup_entity(type, name)
  type = type.to_s
  name = name.to_s.gsub('_', ' ')
  
  cached = NAME_CACHE[type + name]
  return cached unless cached.nil?

  id = name[name.rindex(' ') + 1, name.length - 1].to_i if name.include?(' ')
  id = find_entities(type, name, 1).first if (id.nil? || id.zero?)
  
  raise "The #{type} called #{name} could not be identified." if id.nil?

  NAME_CACHE[type + name] = id
  return id
end

# Finds entities with the specified type (e.g. npc) and name, returning possible ids as an array.
def find_entities(type, name, limit=5)
  ids = []
  name.downcase!

  Kernel.const_get("#{type.capitalize}Definition").definitions.each do |definition|
    break if (ids.length == limit)
    ids << definition.id.to_i if (definition.name.to_s.downcase == name)
  end

  return ids
end

{'fraction_non_alphanumeric': 0.11710677382319173, 'fraction_numerical': 0.0030616150019135095, 'mean_word_length': 3.858736059479554, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6865523', 'n_tokens_mistral': 899, 'n_tokens_neox': 877, 'n_words': 309}