patch: minor bug fixes for evaluator and task configurations, documentation update (#121)

* fix: /cursor_position api return format fix

* chore: update README.md to remove deprecated command

* fix: add base score for evaluators and minor bug fixes

* fix: add base score for setup configurations

---------

Co-authored-by: Jiaqi Deng <jiaqideng@Jiaqis-MacBook-Pro.local>
This commit is contained in:
MillanK
2025-01-18 22:25:18 +08:00
committed by GitHub
parent 89426951c9
commit 983283a86a
13 changed files with 115 additions and 20 deletions

View File

@@ -47,7 +47,7 @@ def find_default_font(config_file_path, rules):
return 1 if default_font == expected_font else 0
def contains_page_break(docx_file):
def contains_page_break(docx_file, rules):
if not docx_file:
return 0
@@ -57,6 +57,11 @@ def contains_page_break(docx_file):
logger.error(f"Error: {e}")
return 0
try:
expected_page_break_count = rules["page_break_count"]
except Exception as e:
expected_page_break_count = None
namespaces = {'w': 'http://schemas.openxmlformats.org/wordprocessingml/2006/main'}
for paragraph in doc.paragraphs:
@@ -65,9 +70,15 @@ def contains_page_break(docx_file):
for br in br_elems:
if br is not None and '{http://schemas.openxmlformats.org/wordprocessingml/2006/main}type' in br.attrib and \
br.attrib['{http://schemas.openxmlformats.org/wordprocessingml/2006/main}type'] == 'page':
return 1
return 0
page_break_count += 1
if expected_page_break_count is not None and page_break_count != expected_page_break_count:
return 0
if page_break_count > 0:
return 1
else:
return 0
def compare_docx_files(file1, file2, **options):
ignore_blanks = options.get('ignore_blanks', True)
@@ -867,7 +878,10 @@ def compare_references(file1, file2, **options):
total_similarity += similarity
result = total_similarity / len(ref1)
if result >= reference_base_result:
epsilon = 0.01
if result >= reference_base_result + epsilon:
return (result - reference_base_result) / (1 - reference_base_result)
else:
return 0