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

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

import java.io.IOException;
import java.util.Optional;

/**
 * Manages the Brain of the Curiosone.
 * Contains utility methods to conversate, compute and/or randomly generate an answer to a given
 * Sentence.
 * @see  com.github.bot.curiosone.core.nlp.Phrase The Phrase Class
 * @see  com.github.bot.curiosone.core.nlp.Sentence The Sentence Class
 */
public class Brain {

  /**
   * Private Constructor.
   */
  private Brain() {}

  /**
   * Answers to a conversational message.
   * @param  phrase
   *         the message to generate the response to
   * @return  an Optional instance, containing the response, if the message needs a conversational
   *          answer. The response is encapsulated in a BrainResponse instance.
   * @see  com.github.bot.curiosone.core.nlp.Phrase The Phrase Class
   * @see  <a href="https://goo.gl/sWfXyh">The Optional Class</a>
   * @see  com.github.bot.curiosone.core.extraction.BrainResponse The BrainResponse Class
   */
  public static Optional<BrainResponse> conversate(Phrase phrase) {
    Optional<BrainResponse> answ = Conversation.getAnswer(phrase);
    return answ.isPresent() ? answ : BadWords.getAnswer(phrase);
  }

  /**
   * Generates a random response.
   * @param  phrase
   *         the message to generate the response to
   * @return  a BrainResponse instance, representing the randomly generated response.
   * @see  com.github.bot.curiosone.core.nlp.Phrase The Phrase Class
   * @see  com.github.bot.curiosone.core.extraction.BrainResponse The BrainResponse Class
   */
  public static BrainResponse random(Phrase phrase) {
    return RandomAnswer.getAnswer(phrase);
  }

  /**
   * Answers to a sentence.
   * This method is able to undestrad whether the Curiosone is responding to an affirmation or a
   * question.
   * @param  sentence
   *         the sentence to generate the response to
   * @param  scope
   *         the scope of the conversation
   * @return  an Optional instance, containing the response for the input Sentence
   * @see  com.github.bot.curiosone.core.nlp.Phrase The Phrase Class
   * @see  <a href="https://goo.gl/sWfXyh">The Optional Class</a>
   * @see  com.github.bot.curiosone.core.extraction.BrainResponse The BrainResponse Class
   */
  public static Optional<BrainResponse> compute(Sentence sentence, String scope) {
    return sentence.isQuestion()
        ? Question.getAnswer(sentence, scope) : Affirmation.getAnswer(sentence, scope);
  }
}

@@ -366,110 +366,40 @@
 see 
- com.github.bot.curiosone.core.nlp.Phrase The Phrase Class%0A * @see  com.github.bot.curiosone.core.nlp.
+Phrase The Phrase Class%0A * @see 
 Sent
@@ -823,42 +823,8 @@
 ee  
-com.github.bot.curiosone.core.nlp.
 Phra
@@ -858,40 +858,17 @@
 ee  
-%3Ca href=%22https://goo.gl/sWfXyh%22%3E
+Optional 
 The 
@@ -873,36 +873,32 @@
 e Optional Class
-%3C/a%3E
 %0A   * @see  com.
@@ -897,49 +897,8 @@
 ee  
-com.github.bot.curiosone.core.extraction.
 Brai
@@ -1356,42 +1356,8 @@
 ee  
-com.github.bot.curiosone.core.nlp.
 Phra
@@ -1391,49 +1391,8 @@
 ee  
-com.github.bot.curiosone.core.extraction.
 Brai
@@ -1915,42 +1915,8 @@
 ee  
-com.github.bot.curiosone.core.nlp.
 Phra
@@ -1950,40 +1950,17 @@
 ee  
-%3Ca href=%22https://goo.gl/sWfXyh%22%3E
+Optional 
 The 
@@ -1977,12 +1977,8 @@
 lass
-%3C/a%3E
 %0A   
@@ -1989,49 +1989,8 @@
 ee  
-com.github.bot.curiosone.core.extraction.
 Brai

fix Brain javadoc