package com.github.bot.curiosone.core.extraction;

import static org.assertj.core.api.Assertions.assertThat;

import com.github.bot.curiosone.core.nlp.Phrase;
import com.github.bot.curiosone.core.nlp.Sentence;

import org.junit.Test;

public class QuestionTest {

  @Test
  public void testGetAnswer() {
    Sentence 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();
  }
}

@@ -103,16 +103,149 @@
 tThat;%0A%0A
+import com.github.bot.curiosone.core.knowledge.SemanticNetwork;%0Aimport com.github.bot.curiosone.core.knowledge.SemanticRelationType;%0A
 import c
@@ -285,16 +285,16 @@
 Phrase;%0A
-
 import c
@@ -337,16 +337,45 @@
 tence;%0A%0A
+import java.io.IOException;%0A%0A
 import o
@@ -461,22 +461,410 @@
 r() 
-%7B%0A    Sentence
+throws IOException %7B%0A    SemanticNetwork sn = SemanticNetwork.getInstance();%0A    sn.learn(%22abcdedfgh%22, SemanticRelationType.IS_A, %22alphabet%22);%0A%0A    Sentence s = Sentence.extract(new Phrase(%22Who is abcdedfgh?%22)).get(0);%0A    assertThat(Question.getAnswer(s, %22%22)).isPresent();%0A%0A    s = Sentence.extract(new Phrase(%22Where is abcdedfgh?%22)).get(0);%0A    assertThat(Question.getAnswer(s, %22%22)).isPresent();%0A%0A   
  s =

improve QuestionTest