Esempio n. 1
0
 private void setQuestionView() {
   txtQuestion.setText(currentQ.getQuestion());
   rda.setText(currentQ.getOptionA());
   rdb.setText(currentQ.getOptionB());
   rdc.setText(currentQ.getOptionC());
   qid++;
 }
Esempio n. 2
0
  public String createMyHit(
      RequesterService service,
      ArrayList<Object> inputs,
      int numberOfOutputs,
      int numberOfAssignments) {

    /* Some parameters used for initializing MTurk HIT.*/
    String title = "Select best description";
    String description = "Please selec the best description.";
    String keywords = "selection, description";
    Question question = new Question(inputs, numberOfOutputs);
    double reward = 0.01;
    long assignmentDurationInSeconds = 60 * 30; // 30 minutes
    long autoApprovalDelayInSeconds = 60; // 1 minute
    long lifetimeInSeconds = 60 * 60 * 24 * 7; // 1 week
    HIT hit =
        service.createHIT(
            null,
            title,
            description,
            keywords,
            question.getQuestion(),
            reward,
            assignmentDurationInSeconds,
            autoApprovalDelayInSeconds,
            lifetimeInSeconds,
            numberOfAssignments,
            null,
            null,
            null);
    return hit.getHITId();
  }
Esempio n. 3
0
 public static List<Question> generateQuestionSet(int difficulty, int questionSetSize) {
   List<Question> questionList = new ArrayList<>(questionSetSize);
   for (int i = 0; i < questionSetSize; ++i) {
     try {
       Question q = generateQuestion(difficulty, 4 * questionSetSize, true);
       q.question = q.getQuestion().replaceAll("\\s\\s", " ");
       q.question = q.getQuestion().replaceAll("\\(\\s", "(");
       q.question = q.getQuestion().replaceAll("\\s\\)", ")");
       q.question = q.getQuestion().replaceAll("\\s\\?", "?");
       q.question = q.getQuestion().replaceAll("\\s\\.", ".");
       for (int j = 0; j < q.getChoices().size(); ++j) {
         q.getChoices().set(j, q.getChoices().get(j).trim());
       }
       questionList.add(q);
     } catch (SQLException e) {
       e.printStackTrace();
     }
   }
   return questionList;
 }
  private void displayQuestion(int questionNum) {
    currentQuestion = questions.get(questionNum);
    textViewQuestion.setText(currentQuestion.getQuestion());
    String[] optionsText = currentQuestion.getOptions();
    // We can randomly set one particular option to be the correct option (to use correctOption)
    // and then fill up the other options
    currentQuestion.setCorrectOption(0); // the correct option is the first one.
    for (int i = 0; i < 4; i++) {
      radioButtons[i].setText(optionsText[i]);
    }

    selectedOption = -1;
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_send_answer);
    getActionBar().setDisplayHomeAsUpEnabled(true);

    qService = new QuestionDataSource(this);
    aService = new AnswerDataSource(this);

    questionInt = getIntent().getExtras().getInt("questionInt");
    question = qService.GetQuestion(questionInt);

    TextView tvQuestion = (TextView) findViewById(R.id.tvQuestion);
    tvQuestion.setText(question.getQuestion());
    TextView tvQuestionDetail = (TextView) findViewById(R.id.tvQuestionDetail);
    tvQuestionDetail.setText(question.getQuestion());

    Button btnAddAnswer = (Button) findViewById(R.id.btnAddAnswer);
    Button btnRequestReview = (Button) findViewById(R.id.btnRequestReview);
    etAnswer = (EditText) findViewById(R.id.etAnswer);

    btnAddAnswer.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            addAnswer();
            onBackPressed();
          }
        });
    btnRequestReview.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            askFeedback();
            onBackPressed();
          }
        });
  }
Esempio n. 6
0
  public static QuestionFragment newInstance(
      Question question, int position, int total, String testName) {

    Bundle args = new Bundle();
    args.putString(AKEY, question.getA());
    args.putString(BKEY, question.getB());
    args.putString(CKEY, question.getC());
    args.putString(DKEY, question.getD());
    args.putString(QUESTION_KEY, question.getQuestion());
    args.putInt(POSKEY, position);
    args.putInt(TOTKEY, total);
    args.putString(TESTKEY, testName);
    QuestionFragment fragment = new QuestionFragment();
    fragment.setArguments(args);
    return fragment;
  }
 protected void askFeedback() {
   // TODO
   String answerText = etAnswer.getText().toString();
   answer = new Answer(answerText, getAnswerer(), AnswerState.UnderReview);
   question =
       new Question(
           question.getId(),
           question.getQuestion(),
           question.getAsker(),
           getAnswerer(),
           QuestionState.UpForFeedback,
           null);
   question.setAnswer(answer);
   qService.UpdateQuestion(question);
   aService.CreateAnswer(answer, questionInt);
 }
Esempio n. 8
0
  public static void main(String[] args) throws IOException {
    Parser p = new Parser();
    p.parseAll();

    PrintWriter pw = new PrintWriter(new File(fname));
    AnswerPrinter ap = new AnswerPrinter(5, pw);

    int k = 0;
    ProgressTracker pt = new ProgressTracker(p.questions.size());
    Thread t = new Thread(pt);
    t.start();
    MLQuestionClassifier classify = new MLQuestionClassifier("train_5500.label.txt");
    WikiFilter wikiFilter = new WikiFilter();
    BaselineFilter baselineFilter = new BaselineFilter();
    for (int i : p.questions.keySet()) {
      Question q = p.questions.get(i);

      System.out.println("******CLASSIFYING QUESTION********");
      classify.classifyQuestion(q); // writes to q
      System.out.println("******RETRIEVING DOCUMENTS********");
      DocumentSet d =
          (new BaselineDocumentRetriever(p.raw_documents, p.raw_word_counts, p.raw_stem_counts))
              .getDocuments(q);
      System.out.println("******WIKI FILTER********");
      ArrayList<Answer> as = wikiFilter.filter(q, d);
      System.out.println("******NER FILTER********");
      ArrayList<Answer> nerFilter = baselineFilter.filter(as, q);
      System.out.println("******EXTRACTING ANSWERS********");
      ArrayList<Answer> finals = (new BaselineAnswerExtractor()).extractAnswers(q, nerFilter);

      if (finals.size() < 1) continue;
      System.out.println("Question: " + q.getQuestion() + "\nAnswer: " + finals.get(0).answer);

      k++;
      pt.updateCompletion(k);
      ap.printAnswers(q, finals);
      if (k > 2) break;
    }

    pw.flush();
    pw.close();
  }
Esempio n. 9
0
 @Test
 public void testCreation() throws Exception {
   Question q = new Question.Builder("Why is java so hard?").id("10").build();
   Assert.assertEquals(q.getQuestion(), "Why is java so hard?");
   Assert.assertEquals(q.getId(), "10");
 }