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

// SUPPRESS CHECKSTYLE AvoidStarImport
import static org.junit.Assert.*;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

import org.junit.Test;

public class SentenceTest {
  @Test
  public void testInstantiation() {
    List<Phrase> phrases = Phrase.extract("What is an apple?");
    System.out.println(phrases);

    assertTrue(phrases.size() == 1);
    Phrase phrase = phrases.get(0);

    List<Sentence> sentences = Sentence.extract(phrase);
    System.out.println(sentences);

    assertTrue(sentences.size() > 0);
    Sentence sentence = sentences.get(0);

    assertTrue(sentence.respect(POS.PRON, POS.VP));
    assertTrue(sentence.respect(POS.PRON, POS.V, POS.DET, POS.N));
    assertFalse(sentence.respect(POS.PRON, POS.VP, POS.N));
    assertFalse(sentence.respect(POS.PRON, POS.N));

    List<Word>[] parameters = sentence.parse(POS.PRON, POS.V, POS.NP);
    assertTrue(parameters.length == 3);
    System.out.println(parameters[0]);
    System.out.println(parameters[1]);
    System.out.println(parameters[2]);


    List<Word> words = sentence.get(POS.V);
    assertTrue(words.size() > 0);
    System.out.println(words);
  }

  @Test
  public void testEquals() {
    List<Sentence> ls = Sentence.extract(new Phrase("What is an apple?"));
    List<Sentence> ls2 = Sentence.extract(new Phrase("What is an apple?"));
    assertEquals(ls.get(0), ls.get(0));
    assertEquals(ls.get(0), ls2.get(0));
    assertNotEquals(ls.get(0),null);
    assertNotEquals(ls.get(0), "Bla bla bla");
    assertNotEquals(ls.get(0), new StringBuffer("bla bla bla"));
  }

  @Test
  public void testHashCode() {
    List<Sentence> ls = Sentence.extract(new Phrase("What is an apple?"));
    List<Sentence> ls2 = Sentence.extract(new Phrase("What is an apple?"));
    assertTrue(Integer.class.isInstance(ls.get(0).hashCode()));
    assertEquals(ls.get(0).hashCode(), ls2.get(0).hashCode());
  }

  @Test
  public void testGetWord() {
    List<String> lw = Sentence.extract(
        new Phrase("What is an apple?")).get(0).getWords();
    assertEquals("what", lw.get(0));
    assertEquals("is", lw.get(1));
    assertEquals("an", lw.get(2));
    assertEquals("apple", lw.get(3));
  }
}

@@ -1992,22 +1992,20 @@
    List%3C
-String
+Word
 %3E lw = S
@@ -2024,17 +2024,8 @@
 act(
-%0A        
 new 
@@ -2102,24 +2102,34 @@
 %22, lw.get(0)
+.getText()
 );%0A    asser
@@ -2151,16 +2151,26 @@
 w.get(1)
+.getText()
 );%0A    a
@@ -2196,16 +2196,26 @@
 w.get(2)
+.getText()
 );%0A    a
@@ -2244,16 +2244,26 @@
 w.get(3)
+.getText()
 );%0A  %7D%0A%7D

Fix Sentence test