Ejemplo n.º 1
0
def do_predict_constants(result: QualityResult):
    if result.problem_content is None or result.problem_content.original_html is None:
        result.modulo_error = Skipped()
        result.yes_str_error = Skipped()
        result.no_str_error = Skipped()
        result.constant_set = ProblemConstantSet()
        return
    try:
        result.modulo = predict_modulo(result.problem_content.original_html)
    except Exception as e:
        result.modulo_error = e

    result.yes_str, result.no_str = predict_yes_no(
        result.problem_content.original_html)

    judge_method = None
    try:
        judge_method = predict_judge_method(
            result.problem_content.original_html)
        if judge_method is not None:
            result.judge_method = judge_method.to_dict()

    except Exception as e:
        result.judge_method_error = e

    result.constant_set = ProblemConstantSet(mod=result.modulo,
                                             yes_str=result.yes_str,
                                             no_str=result.no_str,
                                             judge_method=judge_method)
Ejemplo n.º 2
0
    def test_tricky_yes_no_case_difficult_to_recognize(self):
        # This test exists in order to demonstrate the current wrong behavior that doesn't detect some yes/no strings.
        # Please remove @unittest.expectedFailure when predict_yes_no() behaves
        # correctly.

        yes_str, no_str = predict_yes_no(self._load("abc110-B.html"))
        self.assertEqual("War", yes_str)
        self.assertEqual("No War", no_str)
    def test_tricky_yes_no_case_difficult_to_recognize(self):
        # This test exists in order to demonstrate the current wrong behavior that doesn't detect some yes/no strings.
        # Please remove @unittest.expectedFailure when predict_yes_no() behaves
        # correctly.

        yes_str, no_str = predict_yes_no(self._load("abc110-B.html"))
        self.assertEqual("War", yes_str)
        self.assertEqual("No War", no_str)
Ejemplo n.º 4
0
def do_predict_constants(result: QualityResult):
    if result.problem_content is None:
        result.modulo_error = Skipped()
        result.yes_str_error = Skipped()
        result.no_str_error = Skipped()
        return
    try:
        result.modulo = predict_modulo(result.problem_content.original_html)
    except Exception as e:
        result.modulo_error = e

    result.yes_str, result.no_str = predict_yes_no(
        result.problem_content.original_html)

    result.constant_set = ProblemConstantSet(mod=result.modulo,
                                             yes_str=result.yes_str,
                                             no_str=result.no_str)
def do_predict_constants(result: QualityResult):
    if result.problem_content is None or result.problem_content.original_html is None:
        result.modulo_error = Skipped()
        result.yes_str_error = Skipped()
        result.no_str_error = Skipped()
        result.constant_set = ProblemConstantSet()
        return
    try:
        result.modulo = predict_modulo(result.problem_content.original_html)
    except Exception as e:
        result.modulo_error = e

    result.yes_str, result.no_str = predict_yes_no(
        result.problem_content.original_html)

    result.constant_set = ProblemConstantSet(
        mod=result.modulo,
        yes_str=result.yes_str,
        no_str=result.no_str
    )
Ejemplo n.º 6
0
 def test_case_only_with_no_str(self):
     yes_str, no_str = predict_yes_no(self._load("agc001-D.html"))
     self.assertEqual(None, yes_str)
     self.assertEqual("Impossible", no_str)
Ejemplo n.º 7
0
 def test_yes_no_prediction_fails_when_failing_to_parse_html(self):
     try:
         predict_yes_no("broken html")
         self.fail("Must not reach here")
     except YesNoPredictionFailedError:
         pass
 def test_case_only_with_no_str(self):
     yes_str, no_str = predict_yes_no(self._load("agc001-D.html"))
     self.assertEqual(None, yes_str)
     self.assertEqual("Impossible", no_str)
 def test_yes_no_prediction_fails_when_failing_to_parse_html(self):
     try:
         predict_yes_no("broken html")
         self.fail("Must not reach here")
     except YesNoPredictionFailedError:
         pass