Skip to content

Commit

Permalink
feat(server): support arrays on NER between conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
louistiti committed Dec 28, 2021
1 parent 10f3132 commit 7cf7f97
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 115 deletions.
96 changes: 18 additions & 78 deletions packages/calendar/data/expressions/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,8 @@
"conditions": [
{
"type": "between",
"from": "the",
"to": "list"
},
{
"type": "between",
"from": "a",
"to": "list"
},
{
"type": "between",
"from": "an",
"to": "list"
},
{
"type": "between",
"from": "my",
"to": "list"
"from": ["the", "a", "an", "my"],
"to": ["list", "list", "list", "list"]
}
]
}
Expand Down Expand Up @@ -56,13 +41,8 @@
"conditions": [
{
"type": "between",
"from": "the",
"to": "list"
},
{
"type": "between",
"from": "my",
"to": "list"
"from": ["the", "my"],
"to": ["list", "list"]
}
]
}
Expand All @@ -80,13 +60,8 @@
"conditions": [
{
"type": "between",
"from": "the",
"to": "list"
},
{
"type": "between",
"from": "my",
"to": "list"
"from": ["the", "my"],
"to": ["list", "list"]
}
]
},
Expand Down Expand Up @@ -114,13 +89,8 @@
"conditions": [
{
"type": "between",
"from": "the",
"to": "list"
},
{
"type": "between",
"from": "my",
"to": "list"
"from": ["the", "my"],
"to": ["list", "list"]
}
]
}
Expand Down Expand Up @@ -149,13 +119,8 @@
"conditions": [
{
"type": "between",
"from": "the",
"to": "list"
},
{
"type": "between",
"from": "my",
"to": "list"
"from": ["the", "my"],
"to": ["list", "list"]
}
]
}
Expand All @@ -175,18 +140,8 @@
"conditions": [
{
"type": "between",
"from": "check",
"to": "from"
},
{
"type": "between",
"from": "complete",
"to": "from"
},
{
"type": "between",
"from": "tick",
"to": "from"
"from": ["check", "complete", "tick"],
"to": ["from", "from", "from"]
}
]
},
Expand All @@ -196,13 +151,8 @@
"conditions": [
{
"type": "between",
"from": "the",
"to": "list"
},
{
"type": "between",
"from": "my",
"to": "list"
"from": ["the", "my"],
"to": ["list", "list"]
}
]
}
Expand All @@ -221,13 +171,8 @@
"conditions": [
{
"type": "between",
"from": "uncheck",
"to": "from"
},
{
"type": "between",
"from": "untick",
"to": "from"
"from": ["uncheck", "untick"],
"to": ["from", "from"]
}
]
},
Expand All @@ -237,13 +182,8 @@
"conditions": [
{
"type": "between",
"from": "the",
"to": "list"
},
{
"type": "between",
"from": "my",
"to": "list"
"from": ["the", "my"],
"to": ["list", "list"]
}
]
}
Expand Down
42 changes: 6 additions & 36 deletions packages/calendar/data/expressions/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,8 @@
"conditions": [
{
"type": "between",
"from": "ajoute",
"to": "à"
},
{
"type": "between",
"from": "ajoute",
"to": "a"
"from": ["ajoute", "ajoute"],
"to": ["à", "a"]
}
]
},
Expand Down Expand Up @@ -140,18 +135,8 @@
"conditions": [
{
"type": "between",
"from": "coche",
"to": "de"
},
{
"type": "between",
"from": "complète",
"to": "de"
},
{
"type": "between",
"from": "complete",
"to": "de"
"from": ["coche", "complète", "complete"],
"to": ["de", "de", "de"]
}
]
},
Expand Down Expand Up @@ -181,23 +166,8 @@
"conditions": [
{
"type": "between",
"from": "décoche",
"to": "de"
},
{
"type": "between",
"from": "decoche",
"to": "de"
},
{
"type": "between",
"from": "invalide",
"to": "de"
},
{
"type": "between",
"from": "remet",
"to": "sur"
"from": ["décoche", "decoche", "invalide", "remet"],
"to": ["de", "de", "de", "sur"]
}
]
},
Expand Down
10 changes: 9 additions & 1 deletion server/src/core/ner.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,15 @@ class Ner {

if (condition.type === 'between') {
// e.g. list.addBetweenCondition('en', 'list', 'create a', 'list')
this.ner[conditionMethod](lang, entity.name, condition.from, condition.to)
if (Array.isArray(condition.from) && Array.isArray(condition.to)) {
const { from, to } = condition

from.forEach((word, index) => {
this.ner[conditionMethod](lang, entity.name, word, to[index])
})
} else {
this.ner[conditionMethod](lang, entity.name, condition.from, condition.to)
}
} else if (condition.type.indexOf('after') !== -1) {
this.ner[conditionMethod](lang, entity.name, condition.from)
} else if (condition.type.indexOf('before') !== -1) {
Expand Down

0 comments on commit 7cf7f97

Please sign in to comment.