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

Commit

Permalink
* Further fiddling with the loc_in_brackets fuzzying
Browse files Browse the repository at this point in the history
* add tests for this.
  • Loading branch information
Sven Geggus committed Sep 26, 2018
1 parent 6bd12e7 commit 1f88f8f
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 3 deletions.
6 changes: 6 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
osml10n (2.5.3) unstable; urgency=medium

* further fiddling with the loc_in_brackets feature

-- Sven Geggus <[email protected]> Wed, 26 Sep 2018 13:37:46 +0200

osml10n (2.5.2) unstable; urgency=medium

* Relax the loc_in_brackets switch to be a bit more fuzzy. If "true" behave
Expand Down
5 changes: 4 additions & 1 deletion plpgsql/get_localized_name_from_tags.sql
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,10 @@ CREATE or REPLACE FUNCTION osml10n_gen_combined_name(local_name text,
strict option to disable this behaviour.
*/
if (pos = 1) THEN
loc_in_brackets = false;
IF regexp_match(substring(unacc,length(unacc_local)+1,1),'[\s\(\)\-,;:/\[\]]') IS NOT NULL THEN
raise notice 'swapping primary/second name';
loc_in_brackets = false;
END IF;
END IF;
name = tag;
nobrackets=false;
Expand Down
27 changes: 25 additions & 2 deletions tests/runtests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,18 @@ DB=$1

exitval=0

passed=0
failed=0

# $1 result
# $2 expected
function printresult() {
if [ "$1" = "$2" ]; then
echo -n -e "[\033[0;32mOK\033[0;0m] "
((passed++))
else
echo -n -e "[\033[1;31mFAILED\033[0;0m] "
((failed++))
exitval=1
fi
echo -e "(expected >$2<, got >$1<)"
Expand Down Expand Up @@ -154,6 +159,22 @@ EOF
)
printresult "$res" "‪Brixen|Bressanone‬"

# This is a fictual tagging as I do not know of an italian speaking town
# wehre the names are that similar
echo "select osml10n_get_placename_from_tags('"name"=>"Merano - Meran","name:de"=>"Meran","name:it"=>"Merano"',true,false, '|') as name;"
res=$(psql -X -t -A $DB <<EOF
select osml10n_get_placename_from_tags('"name"=>"Merano - Meran","name:de"=>"Meran","name:it"=>"Merano"',true,false, '|') as name;
EOF
)
printresult "$res" "‪Merano|Meran‬"

echo "select osml10n_get_placename_from_tags('"name"=>"Meran - Merano","name:de"=>"Meran","name:it"=>"Merano"',true,false, '|') as name;"
res=$(psql -X -t -A $DB <<EOF
select osml10n_get_placename_from_tags('"name"=>"Meran - Merano","name:de"=>"Meran","name:it"=>"Merano"',true,false, '|') as name;
EOF
)
printresult "$res" "‪Meran|Merano‬"

echo "select osml10n_get_placename_from_tags('"name"=>"Roma","name:de"=>"Rom"',false,false, '|');"
res=$(psql -X -t -A $DB <<EOF
select osml10n_get_placename_from_tags('"name"=>"Roma","name:de"=>"Rom"',false,false, '|');
Expand Down Expand Up @@ -232,9 +253,9 @@ EOF
)
printresult "$res" "‪Juchon|주촌‬"

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

echo -e "\n$passed tests passed $failed tests failed."

exit $exitval

0 comments on commit 1f88f8f

Please sign in to comment.