Update in … setzen with english translations
Change-Id: I50d2e1fc20cf974982c35137e8574deff7320ede
diff --git a/common.R b/common.R
index e207647..9bd2116 100644
--- a/common.R
+++ b/common.R
@@ -32,6 +32,15 @@
)
}
+de2en <- function(text) {
+ deeplr::translate2(
+ text,
+ target_lang = "EN",
+ source_lang = "DE",
+ auth_key = "87372412-770c-73c5-cdb9-2c6bee43afc4:fx"
+ )
+}
+
highliteSubstrings <- function (string, substrings) {
what = paste0('(', paste0(substrings, collapse="|"), ')')
with = '<b>\\1</b>'
@@ -52,16 +61,24 @@
mutate(Collocate=sprintf('<a href="%s">%s</a>', webUIRequestUrl, collocate)) %>%
mutate(example=str_replace(example, ".*(\\W+\\w+\\W+\\w+\\W+<mark.*/mark>.*)", "\\1")) %>%
mutate(example=str_replace(example, "(.*<mark.*/mark>\\W+\\w+\\W+\\w+).*", "\\1")) %>%
- rowwise() %>%
+# rowwise() %>%
# mutate(Example=highliteSubstrings(example, wordsFromQuery(query))) %>%
mutate(Example=example) %>%
- select(Collocate, Example, logDice, pmi, ll) %>%
+ select(Collocate, EN, Example, logDice, pmi) %>%
# head(50) %>%
datatable(escape = F, rownames = FALSE) %>%
- formatRound(columns=~logDice + pmi + ll, digits=2)
+ formatRound(columns=~logDice + pmi, digits=2)
}
+show_lvc_table <- function(df, pageLength = 10) {
+ df %>%
+# mutate(Collocate=sprintf('<a href="%s">%s</a>', webUIRequestUrl, collocate)) %>%
+ select(LVC, EN, logDice, pmi, ll) %>%
+ datatable(options = list(pageLength = pageLength), escape = F, rownames = FALSE) %>%
+ formatRound(columns=~logDice + pmi + ll, digits=2)
+}
+
show_simple_table_tr <- function(df, pageLength = 20) {
df %>%
mutate(Collocate=sprintf('<a href="%s">%s</a>', webUIRequestUrl, collocate)) %>%