Пример #1
0
 def test_woman_last_name(self):
     for name, vok in self._get_tests('woman_last_name_tests'):
         self.assertEqual(vokativ(name, woman=True, last_name=True), vok)
         self.assertEqual(sex(name), 'w')
         self.assertEqual(vokativ(name, woman=True), vok)
         self.assertEqual(vokativ(name, last_name=True), vok)
         self.assertEqual(vokativ(name), vok)
Пример #2
0
 def test_man_first_name(self):
     for name, vok in self._get_tests('man_first_name_tests'):
         self.assertEqual(vokativ(name, woman=False, last_name=False), vok)
         self.assertEqual(sex(name), 'm')
         self.assertEqual(vokativ(name, woman=False), vok)
         self.assertEqual(vokativ(name, last_name=False), vok)
         self.assertEqual(vokativ(name), vok)
Пример #3
0
 def test_woman_last_name(self):
     for name, vok in self._get_tests('woman_last_name_tests'):
         self.assertEqual(vokativ(name, woman=True, last_name=True), vok)
         self.assertEqual(sex(name), 'w')
         self.assertEqual(vokativ(name, woman=True), vok)
         self.assertEqual(vokativ(name, last_name=True), vok)
         self.assertEqual(vokativ(name), vok)
Пример #4
0
 def test_man_first_name(self):
     for name, vok in self._get_tests('man_first_name_tests'):
         self.assertEqual(vokativ(name, woman=False, last_name=False), vok)
         self.assertEqual(sex(name), 'm')
         self.assertEqual(vokativ(name, woman=False), vok)
         self.assertEqual(vokativ(name, last_name=False), vok)
         self.assertEqual(vokativ(name), vok)
Пример #5
0
def load_data():
    print("LOADING DATA...")
    reader = csv.reader(open('names.csv', 'r'), delimiter=',')
    data = {}
    data["NAMES"] = {}

    for row in reader:
        if row[0] == "JMÉNO":
            data["YEARS"] = tuple(row[1:-2])
        elif row[0] == "SOUČET":
            data["YEAR_SUMS"] = convert_row_values(row[1:-2])
            data["SUM"] = int(row[-1])
        else:
            data["NAMES"][row[0]] = {
                "FREQUENCIES": convert_row_values(row[1:-2]),
                "SUM": int(row[-1]),
                "SEX": vokativ.sex(row[0])
            }

    check_data_are_consistent(data)
    return data
Пример #6
0
#!/usr/bin/python
from os import path
import codecs
from vokativ import vokativ
from vokativ import sex


fo = "jmena.xml"
fi = "jmena.txt"
fa = codecs.open( fo, "w", "UTF-8" );

fa.write("<names>\n")
with codecs.open(fi, "r", "UTF-8") as f:
    for line in f:
        name = line.strip()
        name_vokativ = vokativ(name).title()
        name_sex = sex(name)
        fa.write ("\t<item name='%s' vokativ='%s' sex='%s' />\n" % (name, name_vokativ, name_sex))
fa.write("</names>")