Completed
Pull Request — master (#141)
by Chris
11:04
created

abydos.fingerprint._fingerprint   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 97
Duplicated Lines 0 %

Test Coverage

Coverage 90.91%

Importance

Changes 0
Metric Value
eloc 41
dl 0
loc 97
ccs 10
cts 11
cp 0.9091
rs 10
c 0
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A Fingerprint.fingerprint() 0 7 1
1
# -*- coding: utf-8 -*-
2
3
# Copyright 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 1
"""abydos.fingerprint._fingerprint.
20
21
The fingerprint._Fingerprint module implements abstract class Fingerprint
22
and defines contants for most common letters.
23
"""
24
25 1
from __future__ import (
26
    absolute_import,
27
    division,
28
    print_function,
29
    unicode_literals,
30
)
31
32
# fmt: off
33
# most common letters, as defined in Cisłak & Grabowski
34 1
MOST_COMMON_LETTERS_CG = ('e', 't', 'a', 'o', 'i', 'n', 's', 'h', 'r', 'd',
35
                          'l', 'c', 'u', 'm', 'w', 'f')
36
37
# most common letters (case-folded to lowercase), as shown in Google Books
38
# English n-grams, among letters a-z & digits 0-9
39 1
MOST_COMMON_LETTERS_EN_LC = ('e', 't', 'a', 'i', 'o', 'n', 's', 'r', 'h', 'l',
40
                             'd', 'c', 'u', 'm', 'f', 'p', 'g', 'y', 'w', 'b',
41
                             'v', 'k', 'x', 'j', 'q', 'z', '1', '2', '0', '9',
42
                             '3', '4', '8', '5', '6', '7')
43
44
# most common letters, as shown in Google Books English n-grams, among letters
45
# A-Z, a-z & digits 0-9
46 1
MOST_COMMON_LETTERS = ('e', 't', 'a', 'o', 'i', 'n', 's', 'r', 'h', 'l', 'd',
47
                       'c', 'u', 'm', 'f', 'p', 'g', 'y', 'w', 'b', 'v', 'k',
48
                       'T', 'I', 'A', 'S', 'C', 'x', 'M', 'P', 'E', 'B', 'H',
49
                       'R', 'N', 'D', 'L', 'F', 'W', 'O', 'q', 'G', 'z', 'j',
50
                       'J', 'U', 'V', 'K', 'Y', '1', '2', '0', 'X', '9', 'Q',
51
                       '3', 'Z', '4', '8', '5', '6', '7',)
52
53
# most common letters (case-folded to lowercase), as shown in Google Books
54
# German n-grams, among letters (a-z and umlauted vowels & eszett) & digits 0-9
55 1
MOST_COMMON_LETTERS_DE = ('e', 'n', 'i', 'r', 's', 't', 'a', 'd', 'h', 'u',
56
                          'l', 'g', 'c', 'o', 'm', 'b', 'f', 'w', 'k', 'z',
57
                          'v', 'p', 'ü', 'ä', 'ß', 'ö', 'j', 'y', 'x', 'q',
58
                          '1', '2', '3', '4', '0', '5', '6', '9', '8', '7')
59
60
# most common letters (case-folded to lowercase), as shown in Google Books
61
# German n-grams, among letters (A-Z, a-z, umlauted vowels & ) & digits
62
# 0-9
63 1
MOST_COMMON_LETTERS_DE_LC = ('e', 'n', 'i', 'r', 's', 't', 'a', 'd', 'h', 'u',
64
                             'l', 'c', 'g', 'o', 'm', 'b', 'f', 'w', 'k', 'z',
65
                             'v', 'p', 'ü', 'ä', 'S', 'A', 'D', 'B', 'E', 'G',
66
                             'M', 'ß', 'V', 'K', 'ö', 'W', 'F', 'P', 'R', 'I',
67
                             'H', 'L', 'T', 'N', 'Z', 'y', 'U', 'j', 'J', 'O',
68
                             'C', 'x', 'q', 'Ü', 'Q', 'X', 'Ä', 'Ö', '1', '2',
69
                             'Y', '3', '4', '0', '5', '6', '9', '8', '7')
70
# fmt: on
71
72
73 1
class Fingerprint(object):
74
    """Abstract Fingerprint class."""
75
76 1
    def fingerprint(self, word):
77
        """Fingerprint string.
78
79
        Args:
80
            word (str): Word to fingerprint
81
        """
82
        pass
83
84
85 1
__all__ = [
86
    MOST_COMMON_LETTERS,
0 ignored issues
show
introduced by
Invalid object 'MOST_COMMON_LETTERS' in __all__, must contain only strings
Loading history...
87
    MOST_COMMON_LETTERS_CG,
0 ignored issues
show
introduced by
Invalid object 'MOST_COMMON_LETTERS_CG' in __all__, must contain only strings
Loading history...
88
    MOST_COMMON_LETTERS_DE,
0 ignored issues
show
introduced by
Invalid object 'MOST_COMMON_LETTERS_DE' in __all__, must contain only strings
Loading history...
89
    MOST_COMMON_LETTERS_DE_LC,
0 ignored issues
show
introduced by
Invalid object 'MOST_COMMON_LETTERS_DE_LC' in __all__, must contain only strings
Loading history...
90
    MOST_COMMON_LETTERS_EN_LC,
0 ignored issues
show
introduced by
Invalid object 'MOST_COMMON_LETTERS_EN_LC' in __all__, must contain only strings
Loading history...
91
]
92
93
if __name__ == '__main__':
94
    import doctest
95
96
    doctest.testmod()
97