-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Paquet d'R amb funcions per projectes de localització (#1)
Facilita els passos per omplir name:ca amb LangToolsOSM
- Loading branch information
Showing
12 changed files
with
697 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
^.*\.Rproj$ | ||
^\.Rproj\.user$ | ||
^exotopònims$ | ||
^ppcc$ |
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,15 @@ | ||
Type: Package | ||
Package: toponimsCat | ||
Title: Eines per ajudar a afegir l'etiqueta "name:ca" a OpenStreetMap | ||
Version: 0.1 | ||
Authors@R: | ||
person("Joan", "Maspons", role=c("aut", "cre"), email="[email protected]") | ||
Maintainer: Joan Maspons <[email protected]> | ||
Description: Genera ordres per crear informes d'objectes d'OpenStreetMap | ||
amb LangToolsOSM a partir de filtres i àrees determinades, crea fitxers | ||
per revisar les modificacions i pujar els canvis. | ||
License: ODbl GPL? | ||
Imports: | ||
data.table | ||
Encoding: UTF-8 | ||
RoxygenNote: 7.1.2 |
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,8 @@ | ||
# Generated by roxygen2: do not edit by hand | ||
|
||
export(actualitzaInformesCarregats) | ||
export(generaInforme) | ||
export(generaRevisions_regexName) | ||
export(generaRevisions_regexTranslations) | ||
export(preparaEdicions) | ||
export(recompteCasosInformes) |
Large diffs are not rendered by default.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,4 @@ | ||
library(testthat) | ||
library(toponimsCat) | ||
|
||
test_check("toponimsCat") |
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,104 @@ | ||
test_that("generaInformes funciona", { | ||
ordre0<- generaInforme(arrelProjecte="exotopònims/Rússia", | ||
fitxerInforme="informe-Sibèria.tsv", | ||
filtreArea="['name:ca'='Districte Federal de Sibèria'][admin_level=3]", | ||
filtreObjectes="nwr[wikidata][name][!'name:ca']") | ||
|
||
if (length(ordre0) > 0) | ||
system(ordre0) | ||
expect_true(file.exists("exotopònims/Rússia/informes/informe-Sibèria.tsv")) | ||
|
||
ordre1<- generaInforme(arrelProjecte="ppcc/calle-carrer", | ||
fitxerInforme="informe-Calle_carrer-l'Alacantí.tsv", | ||
filtreArea="['name:ca'='l\\'Alacantí'][admin_level=7]", | ||
filtreObjectes="nwr[name~'^[Cc]alle'][!'name:ca']") | ||
if (length(ordre1) > 0) | ||
system(ordre1) | ||
expect_true(file.exists("ppcc/calle-carrer/informes/informe-Calle_carrer-l'Alacantí.tsv")) | ||
|
||
ordre0<- generaInforme(arrelProjecte="exotopònims/Rússia", | ||
fitxerInforme="informe-Sibèria.tsv", | ||
filtreArea="['name:ca'='Districte Federal de Sibèria'][admin_level=3]", | ||
filtreObjectes="nwr[wikidata][!'name:ca']", | ||
actualitzaFitxer=TRUE) | ||
ordre1<- generaInforme(arrelProjecte="ppcc/calle-carrer", | ||
fitxerInforme="informe-Calle_carrer-l'Alacantí.tsv", | ||
filtreArea="['name:ca'='l\\'Alacantí'][admin_level=7]", | ||
filtreObjectes="nwr[name~'^[Cc]alle'][!'name:ca']", | ||
actualitzaFitxer=TRUE) | ||
expect_type(ordre0, "character") | ||
expect_type(ordre1, "character") | ||
file.rename("ppcc/calle-carrer/ANTIC/informe-Calle_carrer-l'Alacantí.tsv", "ppcc/calle-carrer/informes/informe-Calle_carrer-l'Alacantí.tsv") | ||
file.rename("exotopònims/Rússia/ANTIC/informe-Sibèria.tsv", "exotopònims/Rússia/informes/informe-Sibèria.tsv") | ||
}) | ||
|
||
|
||
test_that("recompteCasosInformes funciona", { | ||
res<- list() | ||
res$arrel<- recompteCasosInformes(arrelProjecte="ppcc/calle-carrer") | ||
res$fitxers<- recompteCasosInformes(informes=dir("ppcc/calle-carrer/informes", pattern="\\.tsv$", full.names=TRUE)) | ||
res$df<- recompteCasosInformes(dades=data.frame(informe=dir("ppcc/calle-carrer/informes", pattern="\\.tsv$", full.names=TRUE))) | ||
|
||
expect_length(unique(res), 1) | ||
expect_s3_class(res[[1]], "data.frame") | ||
expect_equal(names(res[[1]]), c("informe", "nObjects", "nCasos", "revisat")) | ||
|
||
res<- list() | ||
res$arrel<- recompteCasosInformes(arrelProjecte="exotopònims/Rússia") | ||
res$fitxers<- recompteCasosInformes(informes=dir("exotopònims/Rússia/informes", pattern="\\.tsv$", full.names=TRUE)) | ||
res$df<- recompteCasosInformes(dades=data.frame(informe=dir("exotopònims/Rússia/informes", pattern="\\.tsv$", full.names=TRUE))) | ||
|
||
expect_length(unique(res), 1) | ||
expect_s3_class(res[[1]], "data.frame") | ||
expect_equal(names(res[[1]]), c("informe", "nObjects", "nCasos", "revisat")) | ||
|
||
res<- recompteCasosInformes(arrelProjecte="") | ||
expect_equal(res, data.frame()) | ||
}) | ||
|
||
|
||
test_that("generaRevisions funciona", { | ||
res<- generaRevisions_regexName(informes=dir("ppcc/calle-carrer/informes", pattern="\\.tsv$", full.names=TRUE), | ||
arrelProjecte="ppcc/calle-carrer", cerca="([Cc])alle ", substitueix="\\1arrer ") | ||
expect_type(res, "character") | ||
expect_true(file.exists("ppcc/calle-carrer/revisions/revisio-Calle_carrer-l'Alacantí.tsv")) | ||
|
||
res<- generaRevisions_regexTranslations(informes=dir("exotopònims/Rússia/informes", pattern="\\.tsv$", full.names=TRUE), | ||
arrelProjecte="exotopònims/Rússia", cerca=" \\(.+\\)", substitueix="") | ||
expect_type(res, "character") | ||
expect_true(file.exists("exotopònims/Rússia/revisions/revisio-Sibèria.tsv")) | ||
}) | ||
|
||
|
||
test_that("preparaEdicions funciona", { | ||
file.rename("ppcc/calle-carrer/revisions/revisio-Calle_carrer-l'Alacantí.tsv", "ppcc/calle-carrer/revisions/FET/revisio-Calle_carrer-l'Alacantí.tsv") | ||
res<- preparaEdicions(arrelProjecte="ppcc/calle-carrer", usuari="usuari") | ||
expect_type(res, "character") | ||
expect_true(file.exists("ppcc/calle-carrer/edicions/informe-Calle_carrer-l'Alacantí.tsv")) | ||
|
||
file.rename("exotopònims/Rússia/revisions/revisio-Sibèria.tsv", "exotopònims/Rússia/revisions/FET/revisio-Sibèria.tsv") | ||
res<- preparaEdicions(arrelProjecte="exotopònims/Rússia", usuari="usuari") | ||
expect_type(res, "character") | ||
expect_true(file.exists("exotopònims/Rússia/edicions/informe-Sibèria.tsv")) | ||
}) | ||
|
||
|
||
test_that("actualitzaInformesCarregats funciona", { | ||
file.copy("ppcc/calle-carrer/informes/informe-Calle_carrer-l'Alacantí.tsv", "ppcc/calle-carrer/informes/informe-Calle_carrer-l'Alacantí.tsv_ORI") | ||
file.copy("exotopònims/Rússia/informes/informe-Sibèria.tsv", "exotopònims/Rússia/informes/informe-Sibèria.tsv_ORI") | ||
|
||
res<- suppressWarnings(actualitzaInformesCarregats(arrelProjecte="ppcc/calle-carrer", esborraInformesDesactualitzats=FALSE)) | ||
expect_type(res, "character") | ||
expect_true(file.exists(res)) | ||
expect_true(file.exists("ppcc/calle-carrer/edicions/FET/informe-Calle_carrer-l'Alacantí_v0.tsv")) | ||
expect_false(file.exists("ppcc/calle-carrer/edicions/informe-Calle_carrer-l'Alacantí.tsv")) | ||
|
||
res<- actualitzaInformesCarregats(arrelProjecte="exotopònims/Rússia", esborraInformesDesactualitzats=FALSE) | ||
expect_type(res, "character") | ||
expect_true(file.exists(res)) | ||
expect_true(file.exists("exotopònims/Rússia/edicions/FET/informe-Sibèria_v0.tsv")) | ||
expect_false(file.exists("exotopònims/Rússia/edicions/informe-Sibèria.tsv")) | ||
# file.copy("ppcc/calle-carrer/informes/informe-Calle_carrer-l'Alacantí.tsv_ORI", "exotopònims/Rússia/informes/informe-Calle_carrer-l'Alacantí.tsv") | ||
# file.copy("exotopònims/Rússia/informes/informe-Sibèria.tsv_ORI", "exotopònims/Rússia/informes/informe-Sibèria.tsv") | ||
|
||
}) |
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