This is an automated email from the ASF dual-hosted git repository.
sergeykamov pushed a commit to branch NLPCRAFT-468
in repository https://gitbox.apache.org/repos/asf/incubator-nlpcraft.git
The following commit(s) were added to refs/heads/NLPCRAFT-468 by this push:
new a6ce6e2 WIP.
a6ce6e2 is described below
commit a6ce6e2ac8f7dcb6c69ada3f6252ebbf4ad233d3
Author: Sergey Kamov <[email protected]>
AuthorDate: Tue Oct 12 21:01:01 2021 +0300
WIP.
---
...rdsDetector.java => NCListBasedWordsDetector.java} | 19 +++++++++----------
1 file changed, 9 insertions(+), 10 deletions(-)
diff --git
a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/components/detectors/NCFileWordsDetector.java
b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/components/detectors/NCListBasedWordsDetector.java
similarity index 72%
rename from
nlpcraft/src/main/scala/org/apache/nlpcraft/model/components/detectors/NCFileWordsDetector.java
rename to
nlpcraft/src/main/scala/org/apache/nlpcraft/model/components/detectors/NCListBasedWordsDetector.java
index 6d8144d..3af4512 100644
---
a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/components/detectors/NCFileWordsDetector.java
+++
b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/components/detectors/NCListBasedWordsDetector.java
@@ -20,25 +20,24 @@ package org.apache.nlpcraft.model.components.detectors;
import org.apache.nlpcraft.model.nlp.NCNlpWord;
import org.apache.nlpcraft.model.nlp.NCNlpWordsDetector;
-import java.io.File;
-import java.net.URL;
import java.util.Collections;
import java.util.List;
+import java.util.Set;
+import java.util.stream.Collectors;
/**
- * TODO: do we need it?
- * File based detector default implementation.
- * Helper.
+ *
*/
-public class NCFileWordsDetector implements NCNlpWordsDetector {
- public NCFileWordsDetector(File data) {
- }
+public class NCListBasedWordsDetector implements NCNlpWordsDetector {
+ private final Set<String> words;
- public NCFileWordsDetector(URL data) {
+ public NCListBasedWordsDetector(Set<String> words) {
+ this.words = words == null ? Collections.emptySet() : words;
}
@Override
public List<NCNlpWord> detect(List<NCNlpWord> sen) {
- return Collections.emptyList();
+ // TODO: stems, normal form.
+ return sen.stream().filter(p ->
words.contains(p.getWord())).collect(Collectors.toList());
}
}