<commit_before>#!/usr/bin/python

# -*- coding: utf-8 -*-

import sys

mydict = { }

f = open("../Data/TangRhymesMap.csv")

for line in f:
  line = line.rstrip()
  rhyme, char = line.split(",")
  #key = str(char)
  #value = str(rhyme)
  key = char.decode("utf-8")
  value = rhyme.decode("utf-8")
  mydict[key] = value

f = open("../Data/SamplePoem.txt")
for line in f:
  line = line.rstrip()
  for key in line.decode("utf-8"):
    print key + " = " + mydict[key] + '\n'
<commit_msg>Added Ping, Shang, Qu and Ru tags<commit_after>#!/usr/bin/python
# -*- coding: utf-8 -*-

import sys
import re
import codecs

ping = re.compile(u'.平')
shang = re.compile(u'上聲')
ru = re.compile(u'入')
qu = re.compile(u'去')

mydict = { }

# f = open("../Data/TangRhymesMap.csv")
f = codecs.open("../Data/TangRhymesMap.csv", "r", "utf-8")

for line in f:
  line = line.rstrip()
  value, key = line.split(",")
  #key = char.decode("utf-8")
  #value = rhyme.decode("utf-8")
  mydict[key] = value

f = codecs.open("../Data/SamplePoem.txt", "r", "utf-8")
for line in f:
  line = line.rstrip()
  for key in line:
    if ping.match(mydict[key]):
      print key + " = " + " Ping"
    elif shang.match(mydict[key]):
      print key + " = " + " Shang"
    elif qu.match(mydict[key]):
      print key + " = " + " Qu"
    elif ru.match(mydict[key]):
      print key + " = " + " Ru"
    else:
      print key + " = " + " *"

{'fraction_non_alphanumeric': 0.2113587347232207, 'fraction_numerical': 0.006470165348670022, 'mean_word_length': 2.782608695652174, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '6370583', 'n_tokens_mistral': 582, 'n_tokens_neox': 571, 'n_words': 125}