Generelles Zahlenmatching auf Jahrmatching geändert.
This commit is contained in:
parent
52ed5e8984
commit
667dc7d68d
2 changed files with 23 additions and 15 deletions
|
|
@ -6,6 +6,7 @@ library("stringi")
|
|||
library("SPARQL")
|
||||
library("stringr")
|
||||
library("tictoc")
|
||||
library("rlang")
|
||||
|
||||
source("../sparql.R")
|
||||
|
||||
|
|
@ -63,17 +64,19 @@ for (spalte_excel in SPALTEN[1]:SPALTEN[length(SPALTEN)]) {
|
|||
}
|
||||
|
||||
excel_search_all <- unlist(strsplit(gsub("[^[:alnum:] ]", "", current_excel), " +"))
|
||||
excel_search_numbers <- str_extract_all(current_excel, "\\(?[0-9]+\\)?")
|
||||
excel_search_numbers <- unlist(str_extract_all(current_excel, "(?:19|20)\\d{2}"))
|
||||
|
||||
|
||||
for (zeile_db in 1:nrow(inDB[, INHALTE_DB])) {
|
||||
|
||||
current_db <- tolower(inDB[zeile_db,INHALTE_DB])
|
||||
|
||||
db_search_all <- unlist(strsplit(gsub("[^[:alnum:] ]", "", current_db), " +"))
|
||||
db_search_numbers <- str_extract_all(current_db, "\\(?[0-9]+\\)?")
|
||||
db_search_numbers <- unlist(str_extract_all(current_db, "(?:19|20)\\d{2}"))
|
||||
|
||||
count_all <- 0
|
||||
count_numbers <- 0
|
||||
percent_match_numbers <- 0.1
|
||||
|
||||
for (k in 1:length(excel_search_all)) {
|
||||
if (excel_search_all[k] %in% db_search_all) {
|
||||
|
|
@ -81,22 +84,25 @@ for (spalte_excel in SPALTEN[1]:SPALTEN[length(SPALTEN)]) {
|
|||
count_all <- count_all + 1
|
||||
}
|
||||
}
|
||||
|
||||
for (l in 1:length(excel_search_numbers)) {
|
||||
if (excel_search_numbers[l] %in% db_search_numbers) {
|
||||
|
||||
count_numbers <- count_numbers + 1
|
||||
|
||||
if ((length(db_search_numbers) > 0) && (length(excel_search_numbers) > 0)) {
|
||||
for (l in 1:length(excel_search_numbers)) {
|
||||
if (excel_search_numbers[l] %in% db_search_numbers) {
|
||||
|
||||
count_numbers <- count_numbers + 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
percent_match_all <- count_all / length(excel_search_all)
|
||||
percent_match_numbers <- count_numbers / length(excel_search_numbers)
|
||||
|
||||
if (length(excel_search_numbers) > 0) {
|
||||
percent_match_numbers <- count_numbers / length(excel_search_numbers)
|
||||
}
|
||||
|
||||
if ((percent_match_all > 0.80) && (percent_match_numbers > 0.99)) {
|
||||
|
||||
|
||||
to_replace_done[zeile_excel, spalte_excel] <- str_remove_all(inDB[zeile_db,ID], "[<>]")
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -107,6 +113,5 @@ for (spalte_excel in SPALTEN[1]:SPALTEN[length(SPALTEN)]) {
|
|||
toc()
|
||||
|
||||
pfad_output <- paste(PFAD_EXCEL, "replaced_" , FILENAME_EXCEL, sep="")
|
||||
|
||||
write_xlsx(to_replace_done, pfad_output)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue