Skip to content

Commit

Permalink
Merge pull request #102 from curiosone-bot/next-improve-extraction-test
Browse files Browse the repository at this point in the history
Next improve extraction test
  • Loading branch information
Simone Primarosa authored Oct 22, 2017
2 parents 4ae65f0 + ac8a209 commit f7cd687
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 0 deletions.
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();
}
}
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.", ""));
}
}

0 comments on commit f7cd687

Please sign in to comment.