From 49b975bdf1db4d1e43dd1c589ee48015e7d9f5c6 Mon Sep 17 00:00:00 2001
From: sbosse <sbosse@uni-bremen.de>
Date: Tue, 27 Aug 2024 00:16:14 +0200
Subject: [PATCH] Tue 27 Aug 00:14:56 CEST 2024

---
 test/test-nlp.js | 47 +++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 47 insertions(+)
 create mode 100644 test/test-nlp.js

diff --git a/test/test-nlp.js b/test/test-nlp.js
new file mode 100644
index 0000000..608bb7b
--- /dev/null
+++ b/test/test-nlp.js
@@ -0,0 +1,47 @@
+/* Text analyzer (compromise) */
+var dialog = [
+ 'The fox hunts the egg,',
+ 'Do you know how old the earth is?',
+ 'I like gray roses',
+ 'Do you dream neon black and think about it?' ,
+ 'The opera about richard nixon visiting china',
+ 'Where am I?',
+ 'Where do I live?',
+ 'I like roses wherever they grow',
+ 'Who are you?',
+ 'How old are you?',
+ 'I want to go to the stadion. Show me the way.',
+ 'Please, show me the way to the stadion',
+ 'I am on the way',
+]
+
+var parsers = dialog.map(function (sentence) { return nlp(sentence) });
+
+
+parsers[0].verbs().toNegative();
+print(dialog[0],parsers[0].text());
+
+var classification=[];
+for(var i=0;i<dialog.length;i++)
+classification.push([dialog[i],
+      parsers[i].nouns().text(),
+      parsers[i].pronouns().text(),
+      parsers[i].verbs().text(),
+      parsers[i].adverbs().text(),
+      parsers[i].adjectives().text(),
+      parsers[i].conjunctions().text(),
+      parsers[i].prepositions().text()]);
+
+Table(classification,
+  ['Dialog','Nouns','Pronouns','Verbs','Adverbs','Adjectives',
+   'Conjunctions','Prepositions']);
+
+print(dialog[6],parsers[6].has('where * #Pronoun'))
+
+
+parser=nlp('Where are you?'); locate=parser.has('where * #Pronoun');
+person=parser.pronouns().has('I')?'You':
+       parser.pronouns().has('you')?'I':
+       parser.nouns().first().text();
+
+print(locate,person);