Subtract redundant smoothing constants in mergeDuplicateCollocates
Change-Id: I1b042974735c4b2e9a664e21d1eb87cf0794d5c4
diff --git a/tests/testthat/test-collocations.R b/tests/testthat/test-collocations.R
index f847d8b..aa4a771 100644
--- a/tests/testthat/test-collocations.R
+++ b/tests/testthat/test-collocations.R
@@ -45,3 +45,58 @@
removeWithinSpan("contains(<base/s=s>, (machen []{0,1} aufmerksam | aufmerksam []{0,1} machen))", "base/s=s"),
"(machen []{0,1} aufmerksam | aufmerksam []{0,1} machen)")
})
+
+
+test_that("mergeDuplicateCollocatesWorksAsExpected", {
+ ldf <- tibble(
+ node = c("focus(in [tt/p=NN] {[tt/l=nehmen]})"),
+ collocate = c("Anspruch"),
+ label = c(""),
+ vc = c(""),
+ query = c("Anspruch focus(in [tt/p=NN] {[tt/l=nehmen]})"),
+ webUIRequestUrl = c(
+ "https://korap.ids-mannheim.de/?q=Anspruch%20focus%28in%20%5btt%2fp%3dNN%5d%20%7b%5btt%2fl%3dnehmen%5d%7d%29&ql=poliqarp"
+ ),
+ w = c(1),
+ leftContextSize = c(1),
+ rightContextSize = c(0),
+ N = c(23578528381.5),
+ O = c(0.5),
+ O1 = c(1168410.5),
+ O2 = c(1296870.5),
+ E = c(64.2651265093014),
+ pmi = c(11.9173498777957),
+ mi2 = c(29.8406639214616),
+ mi3 = c(47.7639779651274),
+ logDice = c(11.6899933757298),
+ ll = c(3717716.74208791)
+ )
+ rdf <- tibble(
+ node = c("focus({[tt/l=nehmen] in} [tt/p=NN])"),
+ collocate = c("Anspruch"),
+ label = c(""),
+ vc = c(""),
+ query = c("focus({[tt/l=nehmen] in} [tt/p=NN]) Anspruch"),
+ webUIRequestUrl = c(
+ "https://korap.ids-mannheim.de/?q=focus%28%7b%5btt%2fl%3dnehmen%5d%20in%7d%20%5btt%2fp%3dNN%5d%29%20Anspruch&ql=poliqarp"
+ ),
+ w = c(1),
+ leftContextSize = c(0),
+ rightContextSize = c(1),
+ N = c(23578528381.5),
+ O = c(0.5),
+ O1 = c(17077.5),
+ O2 = c(1296870.5),
+ E = c(0.939299756346416),
+ pmi = c(7.99469408391783),
+ mi2 = c(15.8990457079122),
+ mi3 = c(23.8033973319065),
+ logDice = c(2.57887487309409),
+ ll = c(2181.35986032019)
+ )
+ merged <- mergeDuplicateCollocates(ldf, rdf, smoothingConstant = 0.5)
+ expect_equal(merged$O, 0.5)
+ expect_equal(merged$O1, 1185487.5)
+ expect_equal(merged$O2, 1296870.5)
+ expect_equal(merged$query, "Anspruch focus(in [tt/p=NN] {[tt/l=nehmen]}) | focus({[tt/l=nehmen] in} [tt/p=NN]) Anspruch")
+})