<commit_before>const { wikidataTimeToISOString, wikidataTimeToEpochTime } = require('./helpers')

module.exports = (datatype, datavalue, options) => {
  return claimParsers[datatype](datavalue, options)
}

const simple = (datavalue) => datavalue.value
const monolingualtext = (datavalue) => datavalue.value.text
const item = (datavalue, options) => prefixedId(datavalue, options.entityPrefix)
const property = (datavalue, options) => {
  return prefixedId(datavalue, options.propertyPrefix)
}
const prefixedId = function (datavalue, prefix) {
  const { id } = datavalue.value
  return typeof prefix === 'string' ? `${prefix}:${id}` : id
}
const quantity = (datavalue) => parseFloat(datavalue.value.amount)
const coordinate = (datavalue) => {
  return [ datavalue.value.latitude, datavalue.value.longitude ]
}
const time = (datavalue, options) => {
  return getTimeConverter(options.timeConverter)(datavalue.value.time)
}
const getTimeConverter = (key = 'iso') => timeConverters[key]
const identity = (arg) => arg

const timeConverters = {
  iso: wikidataTimeToISOString,
  epoch: wikidataTimeToEpochTime,
  none: identity
}

const claimParsers = {
  string: simple,
  commonsMedia: simple,
  url: simple,
  'external-id': simple,
  monolingualtext,
  'wikibase-item': item,
  'wikibase-property': property,
  time,
  quantity,
  'globe-coordinate': coordinate
}<commit_msg>parse_claim: added support for 'math' datatype fixed #4<commit_after>const { wikidataTimeToISOString, wikidataTimeToEpochTime } = require('./helpers')

module.exports = (datatype, datavalue, options) => {
  return claimParsers[datatype](datavalue, options)
}

const simple = (datavalue) => datavalue.value
const monolingualtext = (datavalue) => datavalue.value.text
const item = (datavalue, options) => prefixedId(datavalue, options.entityPrefix)
const property = (datavalue, options) => {
  return prefixedId(datavalue, options.propertyPrefix)
}
const prefixedId = function (datavalue, prefix) {
  const { id } = datavalue.value
  return typeof prefix === 'string' ? `${prefix}:${id}` : id
}
const quantity = (datavalue) => parseFloat(datavalue.value.amount)
const coordinate = (datavalue) => {
  return [ datavalue.value.latitude, datavalue.value.longitude ]
}
const time = (datavalue, options) => {
  return getTimeConverter(options.timeConverter)(datavalue.value.time)
}
const getTimeConverter = (key = 'iso') => timeConverters[key]
const identity = (arg) => arg

const timeConverters = {
  iso: wikidataTimeToISOString,
  epoch: wikidataTimeToEpochTime,
  none: identity
}

const claimParsers = {
  string: simple,
  commonsMedia: simple,
  url: simple,
  'external-id': simple,
  math: simple,
  monolingualtext,
  'wikibase-item': item,
  'wikibase-property': property,
  time,
  quantity,
  'globe-coordinate': coordinate
}
{'fraction_non_alphanumeric': 0.1312410841654779, 'fraction_numerical': 0.0003566333808844508, 'mean_word_length': 5.493055555555555, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 23, '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': '1330153', 'n_tokens_mistral': 943, 'n_tokens_neox': 937, 'n_words': 205}