Introduce term struct
diff --git a/termmapper_test.go b/termmapper_test.go
index 0492c35..679ac25 100644
--- a/termmapper_test.go
+++ b/termmapper_test.go
@@ -63,12 +63,31 @@
assert := assert.New(t)
- // case1: 1 -> 1 the term is wrapped
- testStr := replaceWrappedTerm("{\"@type\":\"koral:term\",\"match\":\"match:eq\",\"foundry\":\"myfoundry\",\"layer\":\"mylayer\",\"key\":\"mykey\"}", "myfoundry2", "mylayer2", "mykey2")
+ // case1: 1 -> 1 the term is wrapped with eq
+ // case1: 1 -> 1 the term is wrapped with ne
+ // [ADV] -> [ADV]
+ testStr := replaceWrappedTerms(
+ "{\"@type\":\"koral:term\",\"match\":\"match:eq\",\"foundry\":\"myfoundry\",\"layer\":\"mylayer\",\"key\":\"mykey\"}",
+ []Term{{"myfoundry2",
+ "mylayer2",
+ "mykey2",
+ }},
+ )
assert.Equal(testStr, "{\"@type\":\"koral:term\",\"match\":\"match:eq\",\"foundry\":\"myfoundry2\",\"layer\":\"mylayer2\",\"key\":\"mykey2\"}")
+ testStr = replaceWrappedTerms(
+ "{\"@type\":\"koral:term\",\"match\":\"match:ne\",\"foundry\":\"myfoundry\",\"layer\":\"mylayer\",\"key\":\"mykey\"}",
+ []Term{{"myfoundry2",
+ "mylayer2",
+ "mykey2",
+ }},
+ )
+ assert.Equal(testStr, "{\"@type\":\"koral:term\",\"match\":\"match:ne\",\"foundry\":\"myfoundry2\",\"layer\":\"mylayer2\",\"key\":\"mykey2\"}")
+
// case2: 1 -> 1 the term is an operand in a termGroup with the same relation/operation
+ // [ADV & ...] -> [ADV]
// case3: 1 -> 1 the term is an operand in a termGroup with a different relation/operation
+ // [ADV | ...] -> [ADV]
testStr = replaceGroupedTerm(
"{\"@type\":\"koral:termGroup\",\"relation\":\"relation:and\",\"operation\":\"operation:and\",\"operands\":[{\"@type\":\"koral:term\",\"match\":\"match:eq\",\"foundry\":\"myfoundry\",\"layer\":\"mylayer\",\"key\":\"mykey\"},{\"@type\":\"koral:term\",\"match\":\"match:eq\",\"foundry\":\"myfoundry\",\"layer\":\"mylayer\",\"key\":\"mykey2\"}]}",
[]int{0},
@@ -88,6 +107,7 @@
assert.Equal(testStr, "{\"@type\":\"koral:termGroup\",\"relation\":\"relation:and\",\"operation\":\"operation:and\",\"operands\":[{\"@type\":\"koral:term\",\"match\":\"match:ne\",\"foundry\":\"myfoundryX\",\"layer\":\"mylayerX\",\"key\":\"mykeyX\"},{\"@type\":\"koral:term\",\"match\":\"match:eq\",\"foundry\":\"myfoundry\",\"layer\":\"mylayer\",\"key\":\"mykey2\"}]}")
// case4: n -> 1 the term is an operand in a termGroup with the same relation/operation
+ // [PRON & Poss=yes & PronType=Prs] -> [PPOSAT]
testStr = replaceGroupedTerm(
"{\"@type\":\"koral:termGroup\",\"relation\":\"relation:and\",\"operation\":\"operation:and\",\"operands\":[{\"@type\":\"koral:term\",\"match\":\"match:ne\",\"foundry\":\"myfoundry\",\"layer\":\"mylayer\",\"key\":\"mykey\"},{\"@type\":\"koral:term\",\"match\":\"match:eq\",\"foundry\":\"myfoundry\",\"layer\":\"mylayer\",\"key\":\"mykey2\"}]}",
[]int{0, 1},
@@ -97,10 +117,42 @@
)
assert.Equal(testStr, "{\"@type\":\"koral:termGroup\",\"relation\":\"relation:and\",\"operation\":\"operation:and\",\"operands\":[{\"@type\":\"koral:term\",\"match\":\"match:ne\",\"foundry\":\"myfoundryX\",\"layer\":\"mylayerX\",\"key\":\"mykeyX\"}]}")
- // case5: n -> 1 the term is an operand in a termGroup with a different relation/operation
- // case6: 1 -> n the term is wrapped
- // case7: 1 -> n the term is an operand in a termGroup with the same relation/operation
- // case8: 1 -> n the term is an operand in a termGroup with a different relation/operation
- // case9: n -> n the term is an operand in a termGroup with the same relation/operation
- // case10: n -> n the term is an operand in a termGroup with a different relation/operation
+ // case5: 1 -> n the term is wrapped
+ // [PPOSAT] -> [PRON & Poss=yes & PronType=Prs]
+ testStr = replaceWrappedTerms(
+ "{\"@type\":\"koral:term\",\"match\":\"match:eq\",\"foundry\":\"myfoundry\",\"layer\":\"mylayer\",\"key\":\"mykey\"}",
+ []Term{{
+ "myfoundry1",
+ "mylayer1",
+ "mykey1",
+ }, {
+ "myfoundry2",
+ "mylayer2",
+ "mykey2",
+ }},
+ )
+ assert.Equal(testStr, "{\"@type\":\"koral:termGroup\",\"relation\":\"relation:and\",\"operation\":\"operation:and\",\"operands\":[{\"@type\":\"koral:term\",\"match\":\"match:eq\",\"foundry\":\"myfoundry1\",\"layer\":\"mylayer1\",\"key\":\"mykey1\"},{\"@type\":\"koral:term\",\"match\":\"match:eq\",\"foundry\":\"myfoundry2\",\"layer\":\"mylayer2\",\"key\":\"mykey2\"}]}")
+
+ // [!PPOSAT] -> [!PRON | !Poss=yes | !PronType=Prs]
+ testStr = replaceWrappedTerms(
+ "{\"@type\":\"koral:term\",\"match\":\"match:ne\",\"foundry\":\"myfoundry\",\"layer\":\"mylayer\",\"key\":\"mykey\"}",
+ []Term{{
+ "myfoundry1",
+ "mylayer1",
+ "mykey1",
+ }, {
+ "myfoundry2",
+ "mylayer2",
+ "mykey2",
+ }},
+ )
+ assert.Equal(testStr, "{\"@type\":\"koral:termGroup\",\"relation\":\"relation:or\",\"operation\":\"operation:or\",\"operands\":[{\"@type\":\"koral:term\",\"match\":\"match:ne\",\"foundry\":\"myfoundry1\",\"layer\":\"mylayer1\",\"key\":\"mykey1\"},{\"@type\":\"koral:term\",\"match\":\"match:ne\",\"foundry\":\"myfoundry2\",\"layer\":\"mylayer2\",\"key\":\"mykey2\"}]}")
+
+ // case6: 1 -> n the term is an operand in a termGroup with the same relation/operation
+ // [PPOSAT] -> [PRON & Poss=yes & PronType=Prs]
+
+ // case7: 1 -> n the term is an operand in a termGroup with a different relation/operation
+ // case8: n -> n the term is an operand in a termGroup with the same relation/operation
+ // case9: n -> n the term is an operand in a termGroup with a different relation/operation
+
}