<commit_before>const path = require('path')
const _ = require('lodash')
const log = require('@frontiernav/logger').get(__filename)
const getName = require('../util/getName')
const getAllRaw = require('../util/getAllRaw')
const getRaw = require('../util/getRaw')
const Enemies = require('./Enemies')
const EnemyDropTables = require('./EnemyDropTables')
const { nameToId } = require('@frontiernav/graph')

const rawFile = path.resolve(__dirname, '../../data/database/common/CHR_EnArrange.json')
const nameFile = path.resolve(__dirname, '../../data/database/common_ms/fld_enemyname.json')

const getDropTables = async raw => {
  const tableIds = [
    raw.DropTableID,
    raw.DropTableID2,
    raw.DropTableID3
  ]

  return Promise
    .all(
      tableIds.map(tableId => (
        EnemyDropTables
          .getById(tableId)
          .then(dropTable => nameToId(dropTable.name))
          .catch(() => null)
      ))
    )
    .then(drops => drops
      .filter(d => d)
      .map(id => ({ id }))
    )
}

const toEntity = _.memoize(async raw => {
  const enemy = await Enemies.toEntity(raw)

  const name = await getName({
    id: raw.Name,
    file: nameFile
  })<commit_msg>fix(xc2): DropTableID2 maps to quest only drops not regular drops<commit_after>const path = require('path')
const _ = require('lodash')
const log = require('@frontiernav/logger').get(__filename)
const getName = require('../util/getName')
const getAllRaw = require('../util/getAllRaw')
const getRaw = require('../util/getRaw')
const Enemies = require('./Enemies')
const EnemyDropTables = require('./EnemyDropTables')
const { nameToId } = require('@frontiernav/graph')

const rawFile = path.resolve(__dirname, '../../data/database/common/CHR_EnArrange.json')
const nameFile = path.resolve(__dirname, '../../data/database/common_ms/fld_enemyname.json')

const getDropTables = async raw => {
  const tableIds = [
    raw.DropTableID, // Drops
    // raw.DropTableID2, // Quest Drops, maps to EnDropQuest instead with conditions.
    raw.DropTableID3 // Core Crystals
  ]

  return Promise
    .all(
      tableIds.map(tableId => (
        EnemyDropTables
          .getById(tableId)
          .then(dropTable => nameToId(dropTable.name))
          .catch(() => null)
      ))
    )
    .then(drops => drops
      .filter(d => d)
      .map(id => ({ id }))
    )
}

const toEntity = _.memoize(async raw => {
  const enemy = await Enemies.toEntity(raw)

  const name = await getName({
    id: raw.Name,
    file: nameFile
  })
{'fraction_non_alphanumeric': 0.15412329863891114, 'fraction_numerical': 0.0024019215372297837, 'mean_word_length': 3.1511627906976742, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 19, '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': '4625699', 'n_tokens_mistral': 814, 'n_tokens_neox': 808, 'n_words': 170}