diff --git a/README.md b/README.md index ecfc584..c69ef51 100644 --- a/README.md +++ b/README.md @@ -241,10 +241,10 @@ test_eq(math_evaluator.eq("\\frac{2003}{2}", "1001"), False) #### Normalized Majority Voting ``` python -math_evaluator.get_maj_answers(["1", "2", "3", "3", "3"]) +math_evaluator.get_maj_answers(["", "", "1", "2", "2", "3", "3", "3"]) ``` - ['1', '1', '1', '3', '3'] + ['', '', '1', '1', '2', '2', '2', '3'] ### Parsing LaTeX diff --git a/nbs/index.ipynb b/nbs/index.ipynb index d1800b5..ad75366 100644 --- a/nbs/index.ipynb +++ b/nbs/index.ipynb @@ -502,7 +502,7 @@ { "data": { "text/plain": [ - "['1', '1', '1', '3', '3']" + "['', '', '1', '1', '2', '2', '2', '3']" ] }, "execution_count": null, @@ -511,7 +511,7 @@ } ], "source": [ - "math_evaluator.get_maj_answers([\"1\", \"2\", \"3\", \"3\", \"3\"])" + "math_evaluator.get_maj_answers([\"\", \"\", \"1\", \"2\", \"2\", \"3\", \"3\", \"3\"])" ] }, { diff --git a/symeval/core.py b/symeval/core.py index d95eb70..9b515d2 100644 --- a/symeval/core.py +++ b/symeval/core.py @@ -221,7 +221,9 @@ def get_maj_answers(self, answers: List[str]) -> List[str]: break else: ans_votes[answer] += 1 - maj_ans: str = ans_votes.most_common(1)[0][0] + maj_ans = ans_votes.most_common(1)[0][0] + if maj_ans == "" and len(ans_votes) > 1: + maj_ans = ans_votes.most_common(2)[1][0] maj_answers.append(maj_ans) return maj_answers @@ -506,14 +508,14 @@ def latex2sympy_interval( DEF_PERCENT_REL_TOL = 1e-3 -def has_non_ascii(s) -> bool: +def has_non_ascii(s: str) -> bool: for char in s: if ord(char) > 127: return True return False -def is_querying4set(query) -> bool: +def is_querying4set(query: str) -> bool: return "ind the" in query or ("all" in query and "separate" in query)