forked from osm-fr/osmose-backend
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Name_Dictionary_Lang_fr.py
124 lines (106 loc) · 5.38 KB
/
Name_Dictionary_Lang_fr.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#-*- coding: utf-8 -*-
###########################################################################
## ##
## Copyrights Etienne Chové <[email protected]> 2009 ##
## ##
## This program is free software: you can redistribute it and/or modify ##
## it under the terms of the GNU General Public License as published by ##
## the Free Software Foundation, either version 3 of the License, or ##
## (at your option) any later version. ##
## ##
## This program is distributed in the hope that it will be useful, ##
## but WITHOUT ANY WARRANTY; without even the implied warranty of ##
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ##
## GNU General Public License for more details. ##
## ##
## You should have received a copy of the GNU General Public License ##
## along with this program. If not, see <http://www.gnu.org/licenses/>. ##
## ##
###########################################################################
from .Name_Dictionary import P_Name_Dictionary
class Name_Dictionary_Lang_fr(P_Name_Dictionary):
only_for = ["fr"]
def init(self, logger):
P_Name_Dictionary.init(self, logger)
def init_dictionaries(self):
self.load_external_dictionaries('fr')
self.laod_numbering()
self.load_latin_language()
# French
# Roman numbers
for i in [u"",u"X",u"XX"]:
for j in [u"I",u"II",u"III",u"IV",u"V",u"VI",u"VII",u"VIII",u"IX",u"X"]:
self.DictKnownWords.append(i + j)
self.DictKnownWords.append(i + j + u"ème")
self.DictKnownWords.append(i + j + u"è")
self.DictKnownWords.append(i + j + u"e")
self.DictKnownWords.append(i + j + u"ième")
# Enurations
self.DictKnownWords.append("1e")
self.DictKnownWords.append("1er")
for i in range(2,2000):
self.DictKnownWords.append(u"{0}ème".format(i))
self.DictKnownWords.append(u"{0}è".format(i))
self.DictKnownWords.append(u"{0}e".format(i))
self.DictKnownWords.append(u"{0}ième".format(i))
for i in range(2,2000):
self.DictCorrections[u"{0}ieme".format(i)] = u"{0}ième".format(i)
self.DictCorrections[u"{0}eme".format(i)] = u"{0}ème".format(i)
self.DictCorrections[u"{0}éme".format(i)] = u"{0}ème".format(i)
#BadDict[u"{0}e".format(i)] = u"{0}è".format(i)
# France
# Dictionaries : Routes
for i in range(0,2000):
self.DictKnownWords.append(u"A{0}".format(i))
self.DictKnownWords.append(u"D{0}".format(i))
self.DictKnownWords.append(u"N{0}".format(i))
self.DictKnownWords.append(u"C{0}".format(i))
self.DictKnownWords.append(u"E{0}".format(i))
self.DictKnownWords.append(u"RN{0}".format(i))
###########################################################################
from plugins.Plugin import TestPluginCommon
class Test(TestPluginCommon):
def test(self):
import modules.config as config
from analysers.analyser_sax import Analyser_Sax
class _config:
options = {"language": "fr"}
dir_scripts = config.dir_osmose
class father(Analyser_Sax):
config = _config()
def __init__(self):
pass
a = Name_Dictionary_Lang_fr(father())
a.init(None)
assert not a.node(None, {"highway": "Pont des Anes"})
name = [(u"Pont des Anes", u"Pont des Ânes"),
(u"Pont des Ânes", None),
(u"Rue Saint-André", u"Rue Saint-André"),
(u"Rue Saint-André", None),
(u"Rue de l`Acadie", u"Rue de l'Acadie"),
(u"200ième rue", None),
(u"199ème avenue", None),
(u"199ème Avenude", u"199ème Avenue"),
(u"199ème Avenue", None),
(u"\u00c3\u0087a", u"Ça"),
(u"Ça", None),
]
for (n, f) in name:
rdp = a.node(None, {"name": n})
if f:
self.check_err(rdp, ("name='%s'" % n))
fix = rdp[0]["fix"]["name"]
self.assertEqual(fix, f, u"name='%s' - fix = wanted='%s' / got='%s'" % (n, f, fix))
else:
assert not rdp, ("name='%s'" % n)
assert not a.way(None, {"highway": u"Rue Saint-André"}, None)
assert not a.relation(None, {"highway": u"Rue Saint-André"}, None)
assert not a.way(None, {"name": u"Rue Saint-André"}, None)
assert not a.relation(None, {"name": u"Rue Saint-André"}, None)
self.check_err(a.way(None, {"name": u"Rue Saint-André"}, None))
self.check_err(a.relation(None, {"name": u"Rue Saint-André"}, None))
# code that is not reachable in normal cases
import pytest
a.DictCorrections["buebdgxrtsuei"] = None
with pytest.raises(Exception):
a.node({"name": "ceci est buebdgxrtsuei"})