<commit_before>#!/usr/bin/env python3

# Program to parse miscell programs and generate CSV sheets.
# Dr <NAME>, 2016
# Distributed under the MIT license.

import string, sys, shlex
letters=list(string.ascii_uppercase)
numbers='0123456789'

# -----------------------------------------------
# Convert number references to letter references.
# -----------------------------------------------
def numtoletter(num):
  a=num%26
  if (a == num):
    return letters[num]
  else:
    return numtoletter(int(num/26)-1) + letters[a]

# ---------
# And back.
# ---------
def lettertonum(letter):
  if len(letter) == 1:
    return letters.index(letter[0].upper())
  else:
    return letters.index(letter[len(letter)-1].upper()) + (26 * (lettertonum(letter[:-1])+1))

# -------------------------
# Validate address strings.
# -------------------------
def validadd(addr):
  upaddr=addr.upper().strip()
  left=''
  right=''
  stop=False
# split at first nonletter
  for a in upaddr:
    if a in letters and not stop:
      left = left + a
    else:
      stop = True
      right = right + a
  
  isLetter=(len(left) > 0)
    
  
  isNumber=True
  for b in right:
    if b not in numbers:
      isNumber=False
  if len(right)==0:
    isNumber=False

  return (isLetter and isNumber)
  
# ----------------------------------------------------
# Convert store to a list representation of the table.
# ----------------------------------------------------
def storetotable(store, maxl, maxn):

# Initialise in memory table
  table = []
  for i in range(maxl+1):    
    table.append([])
    for j in range(maxn+1):
      table[i].append('')

# Import store
  for a in store.keys():
    n = int(a.strip(string.ascii_uppercase).strip(string.ascii_lowercase))-1
    le = lettertonum(a.strip('0123456789'))
    table[le][n] = store[a]<commit_msg>Use numbers variable to strip addresses.<commit_after>#!/usr/bin/env python3

# Program to parse miscell programs and generate CSV sheets.
# Dr <NAME>, 2016
# Distributed under the MIT license.

import string, sys, shlex
letters=list(string.ascii_uppercase)
numbers='0123456789'

# -----------------------------------------------
# Convert number references to letter references.
# -----------------------------------------------
def numtoletter(num):
  a=num%26
  if (a == num):
    return letters[num]
  else:
    return numtoletter(int(num/26)-1) + letters[a]

# ---------
# And back.
# ---------
def lettertonum(letter):
  if len(letter) == 1:
    return letters.index(letter[0].upper())
  else:
    return letters.index(letter[len(letter)-1].upper()) + (26 * (lettertonum(letter[:-1])+1))

# -------------------------
# Validate address strings.
# -------------------------
def validadd(addr):
  upaddr=addr.upper().strip()
  left=''
  right=''
  stop=False
# split at first nonletter
  for a in upaddr:
    if a in letters and not stop:
      left = left + a
    else:
      stop = True
      right = right + a
  
  isLetter=(len(left) > 0)
    
  
  isNumber=True
  for b in right:
    if b not in numbers:
      isNumber=False
  if len(right)==0:
    isNumber=False

  return (isLetter and isNumber)
  
# ----------------------------------------------------
# Convert store to a list representation of the table.
# ----------------------------------------------------
def storetotable(store, maxl, maxn):

# Initialise in memory table
  table = []
  for i in range(maxl+1):    
    table.append([])
    for j in range(maxn+1):
      table[i].append('')

# Import store
  for a in store.keys():
    n = int(a.strip(string.ascii_uppercase).strip(string.ascii_lowercase))-1
    le = lettertonum(a.strip(numbers))
    table[le][n] = store[a]
{'fraction_non_alphanumeric': 0.25872410032715376, 'fraction_numerical': 0.020174482006543076, 'mean_word_length': 1.8958168902920285, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '593285', 'n_tokens_mistral': 1167, 'n_tokens_neox': 1102, 'n_words': 304}