1
|
|
|
# -*- coding: utf-8 -*- |
2
|
|
|
|
3
|
|
|
# Copyright 2014-2018 by Christopher C. Little. |
4
|
|
|
# This file is part of Abydos. |
5
|
|
|
# |
6
|
|
|
# Abydos is free software: you can redistribute it and/or modify |
7
|
|
|
# it under the terms of the GNU General Public License as published by |
8
|
|
|
# the Free Software Foundation, either version 3 of the License, or |
9
|
|
|
# (at your option) any later version. |
10
|
|
|
# |
11
|
|
|
# Abydos is distributed in the hope that it will be useful, |
12
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
13
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14
|
|
|
# GNU General Public License for more details. |
15
|
|
|
# |
16
|
|
|
# You should have received a copy of the GNU General Public License |
17
|
|
|
# along with Abydos. If not, see <http://www.gnu.org/licenses/>. |
18
|
|
|
|
19
|
|
|
"""abydos.tests.test_phonetic_alpha_sis. |
20
|
|
|
|
21
|
|
|
This module contains unit tests for abydos.phonetic.alpha_sis |
22
|
|
|
""" |
23
|
|
|
|
24
|
|
|
from __future__ import unicode_literals |
25
|
|
|
|
26
|
|
|
import unittest |
27
|
|
|
|
28
|
|
|
from abydos.phonetic.alpha_sis import alpha_sis |
29
|
|
|
|
30
|
|
|
|
31
|
|
|
class AlphaSisTestCases(unittest.TestCase): |
32
|
|
|
"""Test Alpha-SIS functions. |
33
|
|
|
|
34
|
|
|
test cases for abydos.phonetic.alpha_sis |
35
|
|
|
""" |
36
|
|
|
|
37
|
|
|
def test_alpha_sis(self): |
38
|
|
|
"""Test abydos.phonetic.alpha_sis.""" |
39
|
|
|
self.assertEqual(alpha_sis('')[0], '00000000000000') |
40
|
|
|
|
41
|
|
|
self.assertEqual(alpha_sis('Rodgers')[0], '04740000000000') |
42
|
|
|
self.assertEqual(alpha_sis('Rogers')[0], '04740000000000') |
43
|
|
|
self.assertEqual(alpha_sis('Kant')[0], '07210000000000') |
44
|
|
|
self.assertEqual(alpha_sis('Knuth')[0], '02100000000000') |
45
|
|
|
self.assertEqual(alpha_sis('Harper')[0], '24940000000000') |
46
|
|
|
self.assertEqual(alpha_sis('Collier')[0], '07540000000000') |
47
|
|
|
self.assertEqual(alpha_sis('Schultz')[0], '06500000000000') |
48
|
|
|
self.assertEqual(alpha_sis('Livingston')[0], '05827012000000') |
49
|
|
|
|
50
|
|
|
# tests of repeated letters |
51
|
|
|
self.assertEqual(alpha_sis('Colllier')[0], '07554000000000') |
52
|
|
|
self.assertEqual(alpha_sis('Collllier')[0], '07554000000000') |
53
|
|
|
self.assertEqual(alpha_sis('Colllllier')[0], '07555400000000') |
54
|
|
|
self.assertEqual(alpha_sis('Collllllier')[0], '07555400000000') |
55
|
|
|
self.assertEqual(alpha_sis('Colalalier')[0], '07555400000000') |
56
|
|
|
|
57
|
|
|
# max_length bounds tests |
58
|
|
|
self.assertEqual(alpha_sis('Niall', max_length=-1)[0], |
59
|
|
|
'02500000000000000000000000000000000000000000000000' + |
60
|
|
|
'00000000000000') |
61
|
|
|
self.assertEqual(alpha_sis('Niall', max_length=0)[0], '0250') |
62
|
|
|
|
63
|
|
|
|
64
|
|
|
if __name__ == '__main__': |
65
|
|
|
unittest.main() |
66
|
|
|
|