-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Portuguese grammar and abbreviations
- Loading branch information
Showing
7 changed files
with
200 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
{ | ||
"abbreviations": { | ||
"quadra": "Qd", | ||
"vila": "Vil" | ||
}, | ||
"classifications": { | ||
"avenida": "Av", | ||
"caminho": "Cam", | ||
"estrada": "Estr", | ||
"rua": "R", | ||
"travessa": "Tv" | ||
}, | ||
"directions": { | ||
"lés-nordeste": "ENE", | ||
"nordeste": "NE", | ||
"oeste": "O", | ||
"sudeste": "SE", | ||
"lés-sudeste": "ESE", | ||
"nor-nordeste": "NNE", | ||
"sul": "S", | ||
"nor-noroeste": "NNO", | ||
"noroeste": "NO", | ||
"norte": "N", | ||
"oés-sudoeste": "OSO", | ||
"oés-noroeste": "ONO", | ||
"sudoeste": "SO", | ||
"sul-sudeste": "SSE", | ||
"su-sudoeste": "SSO", | ||
"leste": "L" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
{ | ||
"meta": { | ||
"regExpFlags": "gi" | ||
}, | ||
"v5": { | ||
"em": [ | ||
["^ A(s?) ", " na$1 "], | ||
["^ O(s?) ", " no$1 "], | ||
|
||
["^ (Marginal|Parte|Passagem|Ponte|Radial|Rede|Servidão) ", " na $1 "], | ||
["^ (Anel|Bosque|Boulevard|Cais|Canal|Caracol|Casal|Catete|Coronel|Duque|Fim|General|Impasse|Jardim|Juiz|Lote|Marechal|Mirante|Oriente|Parque|Professor|Setor|Tenente|Terminal|Túnel) ", " no $1 "], | ||
|
||
["^ ([^\\- ]+dade)(s?) ", " na$2 $1$2 "], | ||
["^ ([^\\- ]+z) ", " na $1 "], | ||
["^ ([^\\- ]+z)es ", " nas $1es "], | ||
["^ ([^\\- ]+[çz]ão) ", " na $1 "], | ||
["^ ([^\\- ]+[çz]ões) ", " nas $1 "], | ||
|
||
["^ ([^\\- ]+dor) ", " no $1 "], | ||
["^ ([^\\- ]+dor)es ", " nos $1es "], | ||
|
||
["^ (?!n[ao]s? )([^\\- ]+)([ao]s?) ", " n$2 $1$2 "], | ||
|
||
["^ (?!n[ao]s? )(\\S)", " em $1"] | ||
], | ||
"a": [ | ||
["^ A(s?) ", " à$1 "], | ||
["^ O(s?) ", " ao$1 "], | ||
|
||
["^ (Marginal|Parte|Passagem|Ponte|Radial|Rede|Servidão) ", " à $1 "], | ||
["^ (Anel|Bosque|Boulevard|Cais|Canal|Caracol|Casal|Catete|Coronel|Duque|Fim|General|Impasse|Jardim|Juiz|Lote|Marechal|Mirante|Oriente|Parque|Professor|Setor|Tenente|Terminal|Túnel) ", " ao $1 "], | ||
|
||
["^ ([^\\- ]+dade)(s?) ", " à$2 $1$2 "], | ||
["^ ([^\\- ]+z) ", " à $1 "], | ||
["^ ([^\\- ]+z)es ", " às $1es "], | ||
["^ ([^\\- ]+[çz]ão) ", " à $1 "], | ||
["^ ([^\\- ]+[çz]ões) ", " às $1 "], | ||
|
||
["^ ([^\\- ]+dor) ", " ao $1 "], | ||
["^ ([^\\- ]+dor)es ", " aos $1es "], | ||
|
||
["^ ([^\\- ]+)a(s?) ", " à$2 $1a$2 "], | ||
["^ (?!aos? )([^\\- ]+)o(s?) ", " ao$2 $1o$2 "], | ||
|
||
["^ (?!aos? |às? )(\\S)", " a $1"] | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// Add grammar option to {way_name} depending on phrase context | ||
|
||
var replaces = [ | ||
[' (n[ao] +)?\{(destination|junction_name|way_name|waypoint_name)\}', ' {$1:em}'], // eslint-disable-line no-useless-escape | ||
[' (ao +|à +)?\{(destination|junction_name|way_name|waypoint_name)\}', ' {$1:a}'] // eslint-disable-line no-useless-escape | ||
]; | ||
|
||
function optionize(phrase) { | ||
var result = phrase; | ||
replaces.forEach(function(pattern) { | ||
var re = new RegExp(pattern[0], 'gi'); | ||
result = result.replace(re, pattern[1]); | ||
}); | ||
|
||
return result; | ||
} | ||
|
||
function iterate(values) { | ||
Object.keys(values).forEach(function (key) { | ||
var value = values[key]; | ||
if (typeof value === 'string') { | ||
values[key] = optionize(value); | ||
} else if (typeof value === 'object') { | ||
iterate(value); | ||
} | ||
}); | ||
} | ||
|
||
module.exports = function(content) { | ||
// Iterate all content string values recursively | ||
iterate(content.v5); | ||
|
||
return content; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters