-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #102 from curiosone-bot/next-improve-extraction-test
Next improve extraction test
- Loading branch information
Showing
2 changed files
with
61 additions
and
0 deletions.
There are no files selected for viewing
42 changes: 42 additions & 0 deletions
42
src/test/java/com/github/bot/curiosone/core/extraction/QuestionTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package com.github.bot.curiosone.core.extraction; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import com.github.bot.curiosone.core.knowledge.SemanticNetwork; | ||
import com.github.bot.curiosone.core.knowledge.SemanticRelationType; | ||
import com.github.bot.curiosone.core.nlp.Phrase; | ||
import com.github.bot.curiosone.core.nlp.Sentence; | ||
|
||
import java.io.IOException; | ||
|
||
import org.junit.Test; | ||
|
||
public class QuestionTest { | ||
|
||
@Test | ||
public void testGetAnswer() throws IOException { | ||
SemanticNetwork sn = SemanticNetwork.getInstance(); | ||
sn.learn("abcdedfgh", SemanticRelationType.IS_A, "alphabet"); | ||
|
||
Sentence s = Sentence.extract(new Phrase("Who is abcdedfgh?")).get(0); | ||
assertThat(Question.getAnswer(s, "")).isPresent(); | ||
|
||
s = Sentence.extract(new Phrase("Where is abcdedfgh?")).get(0); | ||
assertThat(Question.getAnswer(s, "")).isPresent(); | ||
|
||
s = Sentence.extract(new Phrase("Who is Gogol?")).get(0); | ||
assertThat(Question.getAnswer(s, "")).isPresent(); | ||
|
||
s = Sentence.extract(new Phrase("Where is Gogol?")).get(0); | ||
assertThat(Question.getAnswer(s, "")).isPresent(); | ||
|
||
s = Sentence.extract(new Phrase("What is Gogol?")).get(0); | ||
assertThat(Question.getAnswer(s, "")).isPresent(); | ||
|
||
s = Sentence.extract(new Phrase("Why is Gogol?")).get(0); | ||
assertThat(Question.getAnswer(s, "")).isNotPresent(); | ||
|
||
s = Sentence.extract(new Phrase("When is Gogol?")).get(0); | ||
assertThat(Question.getAnswer(s, "")).isNotPresent(); | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
src/test/java/com/github/bot/curiosone/core/extraction/RandomAnswerTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.github.bot.curiosone.core.extraction; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import com.github.bot.curiosone.core.nlp.Phrase; | ||
|
||
import org.junit.Test; | ||
|
||
public class RandomAnswerTest { | ||
|
||
@Test | ||
public void testRandomAnswer() { | ||
Phrase p = new Phrase("youdont knowany single token of this very very long sentence"); | ||
assertThat(RandomAnswer.getAnswer(p)).isIn( | ||
new BrainResponse("What a nice day to talk to a chatbot!", ""), | ||
new BrainResponse("Can you reformulate your sentence please?", ""), | ||
new BrainResponse("Tell me something interesting please.", "")); | ||
} | ||
} |