load libreoffice writer eval -batch 2

This commit is contained in:
tsuky_chen
2024-01-26 02:07:26 +08:00
parent d757b39985
commit 3e7cfa8699
18 changed files with 362 additions and 42 deletions

View File

@@ -105,7 +105,6 @@ class SetupController:
cache_path: str = os.path.join(self.cache_dir, "{:}_{:}".format(
uuid.uuid5(uuid.NAMESPACE_URL, url),
os.path.basename(path)))
if not url or not path:
raise Exception(f"Setup Download - Invalid URL ({url}) or path ({path}).")

View File

@@ -47,8 +47,8 @@ class DesktopEnv(gym.Env):
path_to_vm: str,
action_space: str = "computer_13",
task_config: Dict[str, Any] = None,
tmp_dir: str = "tmp",
cache_dir: str = "cache",
tmp_dir: str = "D:\\NJU\\HKUNLP\\Desktop-Env\\tmp",
cache_dir: str = "D:\\NJU\\HKUNLP\\Desktop-Env\\cache",
screen_size: Tuple[int] = (1920, 1080)
):
"""

View File

@@ -7,4 +7,4 @@ from .misc import get_rule, get_accessibility_tree
from .replay import get_replay
from .vlc import get_vlc_playing_info, get_vlc_config
from .vscode import get_vscode_config
from .impress import get_audio_in_slide
# from .impress import get_audio_in_slide

View File

@@ -5,7 +5,7 @@ from .docs import find_default_font, contains_page_break, compare_docx_files, co
from .docs import is_first_line_centered, check_file_exists, compare_contains_image
from .docs import evaluate_colored_words_in_tables, check_highlighted_words, evaluate_strike_through_last_paragraph, \
evaluate_conversion, evaluate_spacing, check_italic_font_size_14, evaluate_alignment, get_unique_train_ids, \
check_no_duplicates
check_no_duplicates, compare_init_lines
from .general import exact_match, fuzzy_match
from .general import check_csv, check_accessibility_tree, run_sqlite3, check_json
from .gimp import increase_saturation, decrease_brightness, check_file_exists, compare_triangle_positions
@@ -16,7 +16,7 @@ from .pdf import check_pdf_pages
#from .table import check_sheet_list, check_xlsx_freeze, check_xlsx_zoom, check_data_validations
from .table import compare_table
from .thunderbird import check_thunderbird_prefs, check_thunderbird_filter
from .vlc import is_vlc_playing, is_vlc_recordings_folder, is_vlc_fullscreen, compare_images, compare_audios, \
compare_videos
# from .vlc import is_vlc_playing, is_vlc_recordings_folder, is_vlc_fullscreen, compare_images, compare_audios, \
# compare_videos
from .thunderbird import check_thunderbird_prefs, check_thunderbird_filter
from .vscode import compare_text_file, compare_config, compare_answer, is_extension_installed, check_json_settings, check_json_keybindings

View File

@@ -56,15 +56,34 @@ def compare_docx_files(file1, file2):
doc2_paragraphs = [p.text for p in doc2.paragraphs]
if len(doc1_paragraphs) != len(doc2_paragraphs):
# print(len(doc1_paragraphs))
# print(len(doc2_paragraphs))
return 0
# Compare each paragraph
for p1, p2 in zip(doc1_paragraphs, doc2_paragraphs):
if p1 != p2:
# print(p1)
# print(p2)
return 0
return 1
def compare_init_lines(file1, file2):
doc1 = Document(file1)
doc2 = Document(file2)
doc1_paragraphs = [p.text for p in doc1.paragraphs]
doc2_paragraphs = [p.text for p in doc2.paragraphs]
# Compare each paragraph
for p1, p2 in zip(doc1_paragraphs, doc2_paragraphs):
if p1 != p2:
# print(p1)
# print(p2)
return 0
return 1
def compare_docx_tables(docx_file1, docx_file2):
doc1 = Document(docx_file1)
@@ -93,6 +112,8 @@ def compare_docx_tables(docx_file1, docx_file2):
def compare_line_spacing(docx_file1, docx_file2):
if not compare_docx_files(docx_file1, docx_file2):
return 0
doc1 = Document(docx_file1)
doc2 = Document(docx_file2)
@@ -200,8 +221,10 @@ def compare_contains_image(docx_file1, docx_file2):
# print(find_default_font("Ani", config_path))
def evaluate_colored_words_in_tables(file_path):
document = Document(file_path)
def evaluate_colored_words_in_tables(file_path1, file_path2):
if not compare_docx_files(file_path1, file_path2):
return 0
document = Document(file_path1)
for table in document.tables:
# Iterate through rows and cells in the table
@@ -221,8 +244,10 @@ def evaluate_colored_words_in_tables(file_path):
return 1 # All words in tables are correctly colored
def check_highlighted_words(file_path):
document = Document(file_path)
def check_highlighted_words(file_path1, file_path2):
if not compare_docx_files(file_path1, file_path2):
return 0
document = Document(file_path1)
for paragraph in document.paragraphs:
for run in paragraph.runs:
@@ -232,8 +257,10 @@ def check_highlighted_words(file_path):
return 1 # No highlighted words found
def evaluate_strike_through_last_paragraph(file_path):
document = Document(file_path)
def evaluate_strike_through_last_paragraph(file_path1, file_path2):
if not compare_docx_files(file_path1, file_path2):
return 0
document = Document(file_path1)
# Get the last paragraph
last_paragraph = document.paragraphs[-1]
@@ -278,8 +305,10 @@ def evaluate_spacing(file_path):
return 0
def check_italic_font_size_14(path):
document = Document(path)
def check_italic_font_size_14(path1, path2):
if not compare_docx_files(path1, path2):
return 0
document = Document(path1)
for paragraph in document.paragraphs:
for run in paragraph.runs:
if run.italic:
@@ -365,6 +394,8 @@ def compare_docx_lines(file1, file2):
doc2 = Document(file2)
doc2_lines = [p.text.strip() for p in doc2.paragraphs if p.text.strip()]
# print(doc1_lines)
# print(doc2_lines)
# Convert the list of lines to sets and compare
return set(doc1_lines) == set(doc2_lines)