<commit_before>

const API_ROOT = 'http://metadatasf.tk/api/v1/'
const geoTypeMappings = {
  'geometry: line': 'geometry-line',
  'geometry: point': 'geometry-point',
  'geometry: polygon': 'geometry-polygon',
  'geometry: multiline': 'geometry-multi-line',
  'geometry: multipolygon': 'geometry-multi-polygon',
  'geometry: multipoint': 'geometry-multi-point',
}


export const EndpointsSF = {
  METADATA: endpointMetadata,
  COLUMNS: endpointColumns
}

function endpointMetadata (id) {
  return API_ROOT + `datasetdetails/${id}`
}

function endpointColumns (id) {
  return API_ROOT + `fielddetails/${id}`
 }

export const TransformsSF = {
  METADATA: transformMetadata,
  COLUMNS: transformColumns
}


function transformMetadata (json) {
  // Set default rowLabel
  json[0].rowLabel = json[0].rowLabel || 'Record'
  let metadata = json[0]
  return metadata
}


function transformColumns (json) {
  let result = {}
  let geoTypeMappingKeys = Object.keys(geoTypeMappings)
  let columns = json.reduce(function(map, obj) {
    if(geoTypeMappingKeys.includes(obj.type)){
      obj.type = geoTypeMappings[obj.type]
    }
    map[obj.key] = obj
    return map
  }, {})
  result['columns'] = columns
  result.categoryColumns = json.map(function(item){
    let key
    if(item.isCategory){
      key =  item.key
    }
    return key
  }).filter(n => n)
  result.textColumns = json.map(function(item){<commit_msg>Ignore columns of type geometry when creating the categoryColumns stack<commit_after>

const API_ROOT = 'http://metadatasf.tk/api/v1/'
const geoTypeMappings = {
  'geometry: line': 'geometry-line',
  'geometry: point': 'geometry-point',
  'geometry: polygon': 'geometry-polygon',
  'geometry: multiline': 'geometry-multi-line',
  'geometry: multipolygon': 'geometry-multi-polygon',
  'geometry: multipoint': 'geometry-multi-point',
}


export const EndpointsSF = {
  METADATA: endpointMetadata,
  COLUMNS: endpointColumns
}

function endpointMetadata (id) {
  return API_ROOT + `datasetdetails/${id}`
}

function endpointColumns (id) {
  return API_ROOT + `fielddetails/${id}`
 }

export const TransformsSF = {
  METADATA: transformMetadata,
  COLUMNS: transformColumns
}


function transformMetadata (json) {
  // Set default rowLabel
  json[0].rowLabel = json[0].rowLabel || 'Record'
  let metadata = json[0]
  return metadata
}


function transformColumns (json) {
  let result = {}
  let geoTypeMappingKeys = Object.keys(geoTypeMappings)
  let columns = json.reduce(function(map, obj) {
    if(geoTypeMappingKeys.includes(obj.type)){
      obj.type = geoTypeMappings[obj.type]
    }
    map[obj.key] = obj
    return map
  }, {})
  result['columns'] = columns
  result.categoryColumns = json.map(function(item){
    let key
    if(item.isCategory && item.type.indexOf('geometry') === -1) {
      key = item.key
    }
    return key
  }).filter(n => n)

  result.textColumns = json.map(function(item){
{'fraction_non_alphanumeric': 0.13681677552423513, 'fraction_numerical': 0.0030938466827088347, 'mean_word_length': 4.123239436619718, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '6585726', 'n_tokens_mistral': 950, 'n_tokens_neox': 936, 'n_words': 206}