Skip to content
This repository was archived by the owner on Jul 14, 2022. It is now read-only.

Commit 1f88f8f

Browse files
author
Sven Geggus
committed
* Further fiddling with the loc_in_brackets fuzzying
* add tests for this.
1 parent 6bd12e7 commit 1f88f8f

File tree

3 files changed

+35
-3
lines changed

3 files changed

+35
-3
lines changed

debian/changelog

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
osml10n (2.5.3) unstable; urgency=medium
2+
3+
* further fiddling with the loc_in_brackets feature
4+
5+
-- Sven Geggus <[email protected]> Wed, 26 Sep 2018 13:37:46 +0200
6+
17
osml10n (2.5.2) unstable; urgency=medium
28

39
* Relax the loc_in_brackets switch to be a bit more fuzzy. If "true" behave

plpgsql/get_localized_name_from_tags.sql

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,10 @@ CREATE or REPLACE FUNCTION osml10n_gen_combined_name(local_name text,
164164
strict option to disable this behaviour.
165165
*/
166166
if (pos = 1) THEN
167-
loc_in_brackets = false;
167+
IF regexp_match(substring(unacc,length(unacc_local)+1,1),'[\s\(\)\-,;:/\[\]]') IS NOT NULL THEN
168+
raise notice 'swapping primary/second name';
169+
loc_in_brackets = false;
170+
END IF;
168171
END IF;
169172
name = tag;
170173
nobrackets=false;

tests/runtests.sh

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,18 @@ DB=$1
2121

2222
exitval=0
2323

24+
passed=0
25+
failed=0
26+
2427
# $1 result
2528
# $2 expected
2629
function printresult() {
2730
if [ "$1" = "$2" ]; then
2831
echo -n -e "[\033[0;32mOK\033[0;0m] "
32+
((passed++))
2933
else
3034
echo -n -e "[\033[1;31mFAILED\033[0;0m] "
35+
((failed++))
3136
exitval=1
3237
fi
3338
echo -e "(expected >$2<, got >$1<)"
@@ -154,6 +159,22 @@ EOF
154159
)
155160
printresult "$res" "‪Brixen|Bressanone‬"
156161

162+
# This is a fictual tagging as I do not know of an italian speaking town
163+
# wehre the names are that similar
164+
echo "select osml10n_get_placename_from_tags('"name"=>"Merano - Meran","name:de"=>"Meran","name:it"=>"Merano"',true,false, '|') as name;"
165+
res=$(psql -X -t -A $DB <<EOF
166+
select osml10n_get_placename_from_tags('"name"=>"Merano - Meran","name:de"=>"Meran","name:it"=>"Merano"',true,false, '|') as name;
167+
EOF
168+
)
169+
printresult "$res" "‪Merano|Meran‬"
170+
171+
echo "select osml10n_get_placename_from_tags('"name"=>"Meran - Merano","name:de"=>"Meran","name:it"=>"Merano"',true,false, '|') as name;"
172+
res=$(psql -X -t -A $DB <<EOF
173+
select osml10n_get_placename_from_tags('"name"=>"Meran - Merano","name:de"=>"Meran","name:it"=>"Merano"',true,false, '|') as name;
174+
EOF
175+
)
176+
printresult "$res" "‪Meran|Merano‬"
177+
157178
echo "select osml10n_get_placename_from_tags('"name"=>"Roma","name:de"=>"Rom"',false,false, '|');"
158179
res=$(psql -X -t -A $DB <<EOF
159180
select osml10n_get_placename_from_tags('"name"=>"Roma","name:de"=>"Rom"',false,false, '|');
@@ -232,9 +253,9 @@ EOF
232253
)
233254
printresult "$res" "‪Juchon|주촌‬"
234255

235-
echo "select osml10n_get_streetname_from_tags('"name"=>"Pha Yar Kai Road ဘုရားကိုင်လမ်း", "highway"=>"secondary", "name:en"=>"Pha Yar Kai Road", "name:my"=>"ဘုရားကိုင်လမ်း"',true,false,'|');"
256+
echo "select osml10n_get_streetname_from_tags('"name"=>"ဘုရားကိုင်လမ်း Pha Yar Kai Road", "highway"=>"secondary", "name:en"=>"Pha Yar Kai Road", "name:my"=>"ဘုရားကိုင်လမ်း"',true,false,'|');"
236257
res=$(psql -X -t -A $DB <<EOF
237-
select osml10n_get_streetname_from_tags('"name"=>"Pha Yar Kai Road ဘုရားကိုင်လမ်း", "highway"=>"secondary", "name:en"=>"Pha Yar Kai Road", "name:my"=>"ဘုရားကိုင်လမ်း"',true,false,'|');
258+
select osml10n_get_streetname_from_tags('"name"=>"ဘုရားကိုင်လမ်း Pha Yar Kai Road", "highway"=>"secondary", "name:en"=>"Pha Yar Kai Road", "name:my"=>"ဘုရားကိုင်လမ်း"',true,false,'|');
238259
EOF
239260
)
240261
printresult "$res" "‪ဘုရားကိုင်လမ်း|Pha Yar Kai Rd.‬"
@@ -253,5 +274,7 @@ EOF
253274
)
254275
printresult "$res" "Indien|भारत|India"
255276

277+
echo -e "\n$passed tests passed $failed tests failed."
278+
256279
exit $exitval
257280

0 commit comments

Comments
 (0)