<commit_before>import { fetchXml } from '../../utility/xml'

import { writeToFile } from '../../utility/file'

import {
  urlForLthingVoting,
  urlForVotes,
  urlForCase,
} from '../urls'

function getCase(caseId, lthing) {
  const url = urlForCase(caseId, lthing)
  return fetchXml(url)
}

async function getCaseClassification(caseId, lthing) {
  const xml = await getCase(caseId, lthing)

  const sectionIds = []
  const subjectIds = []

  xml.þingmál.efnisflokkar[0].yfirflokkur.forEach(section => {
    sectionIds.push(parseInt(section.$.id, 10))
    section.efnisflokkur.forEach(subject => {
      subjectIds.push(parseInt(subject.$.id, 10))
    })
  })

  return { sectionIds, subjectIds }
}

async function parseCasesFromVotings(votings) {
  const caseLookup = {}
  const cases = []

  for (const voting of votings) {
    const caseId = voting.$.málsnúmer
    const lthing = voting.$.þingnúmer
    if (!caseLookup[caseId]) {
      let classification = null<commit_msg>Transform caseId and lthing to int for cases<commit_after>import { fetchXml } from '../../utility/xml'

import { writeToFile } from '../../utility/file'

import {
  urlForLthingVoting,
  urlForVotes,
  urlForCase,
} from '../urls'

function getCase(caseId, lthing) {
  const url = urlForCase(caseId, lthing)
  return fetchXml(url)
}

async function getCaseClassification(caseId, lthing) {
  const xml = await getCase(caseId, lthing)

  const sectionIds = []
  const subjectIds = []

  xml.þingmál.efnisflokkar[0].yfirflokkur.forEach(section => {
    sectionIds.push(parseInt(section.$.id, 10))
    section.efnisflokkur.forEach(subject => {
      subjectIds.push(parseInt(subject.$.id, 10))
    })
  })

  return { sectionIds, subjectIds }
}

async function parseCasesFromVotings(votings) {
  const caseLookup = {}
  const cases = []

  for (const voting of votings) {
    const caseId = parseInt(voting.$.málsnúmer, 10)
    const lthing = parseInt(voting.$.þingnúmer, 10)
    if (!caseLookup[caseId]) {
      let classification = null
{'fraction_non_alphanumeric': 0.13140866102538576, 'fraction_numerical': 0.006968641114982578, 'mean_word_length': 3.740566037735849, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 6}, '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': '4876485', 'n_tokens_mistral': 706, 'n_tokens_neox': 699, 'n_words': 144}