test.py HWP와 HWPX파일 모두 변환하도록 적용\

This commit is contained in:
2025-03-25 14:34:00 +09:00
parent ee09f86aff
commit 8a613b0d79
4 changed files with 38 additions and 23 deletions

View File

@@ -12915,3 +12915,14 @@
2025-03-04 17:58:43,243 - INFO - 변환 성공: 워드(한글)-011941-심진아.hwp -> 워드(한글)-011941-심진아.hml 2025-03-04 17:58:43,243 - INFO - 변환 성공: 워드(한글)-011941-심진아.hwp -> 워드(한글)-011941-심진아.hml
2025-03-04 17:58:43,615 - INFO - 변환 성공: 워드(한글)-011942-이범.hwp -> 워드(한글)-011942-이범.hml 2025-03-04 17:58:43,615 - INFO - 변환 성공: 워드(한글)-011942-이범.hwp -> 워드(한글)-011942-이범.hml
2025-03-04 17:58:43,980 - INFO - 변환 성공: 워드(한글)-012018-송현우.hwp -> 워드(한글)-012018-송현우.hml 2025-03-04 17:58:43,980 - INFO - 변환 성공: 워드(한글)-012018-송현우.hwp -> 워드(한글)-012018-송현우.hml
2025-03-18 16:06:36,574 - INFO - 변환 성공: 워드(한글)-001191-조아현.hwp -> 워드(한글)-001191-조아현.hml
2025-03-18 16:07:22,539 - INFO - 변환 성공: 워드(한글)-001191-조아현.hwp -> 워드(한글)-001191-조아현.hml
2025-03-18 16:11:42,156 - INFO - 변환 성공: 워드(한글)-001191-조아현 copy.hwp -> 워드(한글)-001191-조아현 copy.hml
2025-03-18 16:16:56,532 - INFO - 변환 성공: 워드(한글)-001191-조아현 copy.hwp -> 워드(한글)-001191-조아현 copy.hml
2025-03-18 16:16:56,562 - INFO - 변환 성공: 워드(한글)-002623-유하균.hwp -> 워드(한글)-002623-유하균.hml
2025-03-18 16:16:56,668 - INFO - 변환 성공: 워드(한글)-004933-이상진.hwp -> 워드(한글)-004933-이상진.hml
2025-03-18 16:46:30,897 - INFO - 변환 성공: 워드(한글)-004574-김소윤.hwp -> 워드(한글)-004574-김소윤.hml
2025-03-18 16:54:36,213 - INFO - 변환 성공: 워드(한글)-001191-조아현.hwp -> 워드(한글)-001191-조아현.hml
2025-03-18 16:54:36,253 - INFO - 변환 성공: 워드(한글)-002623-유하균.hwp -> 워드(한글)-002623-유하균.hml
2025-03-18 16:54:36,355 - INFO - 변환 성공: 워드(한글)-004933-이상진.hwp -> 워드(한글)-004933-이상진.hml
2025-03-25 14:30:44,791 - INFO - 변환 성공: DIW_2503A.hwpx -> DIW_2503A.hml

View File

@@ -349,6 +349,7 @@ class XMLScorer:
# 차이점을 정리하여 result_diff에 저장 # 차이점을 정리하여 result_diff에 저장
result_diff = [] result_diff = []
# 감점을 위한 누락 된 단어만 따로 리스트로 저장 # 감점을 위한 누락 된 단어만 따로 리스트로 저장
missing_list = [] missing_list = []
@@ -530,36 +531,36 @@ class XMLScorer:
def main(): def main():
# scoring_criteria_path = r'./DIW.json' # scoring_criteria_path = r'./DIW.json'
# scoring_criteria_path = r'./DIW_2502A.json' scoring_criteria_path = r'./DIW_2502A.json'
# scoring_criteria_path = r'./DIW_2502B.json' # scoring_criteria_path = r'./DIW_2502B.json'
# scoring_criteria_path = r'./DIW_2502C.json' # scoring_criteria_path = r'./DIW_2502C.json'
# scoring_criteria_path = r'./DIW_2502D.json' # scoring_criteria_path = r'./DIW_2502D.json'
scoring_criteria_path = r'./DIW_2502E.json' # scoring_criteria_path = r'./DIW_2502E.json'
# xml(hml)파일 디렉토리 경로 # xml(hml)파일 디렉토리 경로
# xml_directory = r'./output' # xml_directory = r'./output'
# xml_directory = r'./output/A' xml_directory = r'./output/A/DIW'
# xml_directory = r'./output/B' # xml_directory = r'./output/B/DIW'
# xml_directory = r'./output/C' # xml_directory = r'./output/C/DIW'
# xml_directory = r'./output/D' # xml_directory = r'./output/D/DIW'
xml_directory = r'./output/E' # xml_directory = r'./output/E/DIW'
# 오탈자 체크를 위한 정답 파일 경로 # 오탈자 체크를 위한 정답 파일 경로
# answer_path = r'./output/정답.hml' # answer_path = r'./output/정답.hml'
# answer_path = r'./output/A/DIW_2502A.hml' answer_path = r'./output/A/DIW/DIW_2502A.hml'
# answer_path = r'./output/B/DIW_2502B.hml' # answer_path = r'./output/B/DIW/DIW_2502B.hml'
# answer_path = r'./output/C/DIW_2502C.hml' # answer_path = r'./output/C/DIW/DIW_2502C.hml'
# answer_path = r'./output/D/DIW_2502D.hml' # answer_path = r'./output/D/DIW/DIW_2502D.hml'
answer_path = r'./output/E/DIW_2502E.hml' # answer_path = r'./output/E/DIW/DIW_2502E.hml'
timestamp = datetime.now().strftime("%y%m%d") timestamp = datetime.now().strftime("%y%m%d")
# 엑셀 파일명 (비어있으면 자동생성) # 엑셀 파일명 (비어있으면 자동생성)
# output_path = f"{timestamp}_DIW_2502A_채점결과.xlsx" output_path = f"{timestamp}_DIW_2502A_채점결과.xlsx"
# output_path = f"{timestamp}_DIW_2502B_채점결과.xlsx" # output_path = f"{timestamp}_DIW_2502B_채점결과.xlsx"
# output_path = f"{timestamp}_DIW_2502C_채점결과.xlsx" # output_path = f"{timestamp}_DIW_2502C_채점결과.xlsx"
# output_path = f"{timestamp}_DIW_2502D_채점결과.xlsx" # output_path = f"{timestamp}_DIW_2502D_채점결과.xlsx"
output_path = f"{timestamp}_DIW_2502E_채점결과.xlsx" # output_path = f"{timestamp}_DIW_2502E_채점결과.xlsx"
# 채점 클래스 초기화 # 채점 클래스 초기화
scorer = XMLScorer(scoring_criteria_path) scorer = XMLScorer(scoring_criteria_path)

15
test.py
View File

@@ -64,9 +64,12 @@ def convert_hwp_to_xml(input_folder, output_folder):
# HWP 파일 검색 및 변환 # HWP 파일 검색 및 변환
input_path = Path(input_folder) input_path = Path(input_folder)
for hwp_file in input_path.glob("*.hwp"): for hwp_file in input_path.glob("*.hwpx") | input_path.glob("*.hwp"):
try: try:
# 파일 열기 # 파일 열기
if hwp_file.suffix == ".hwpx":
hwp.Open(str(hwp_file), "HWPX")
elif hwp_file.suffix == ".hwp":
hwp.Open(str(hwp_file), "HWP") hwp.Open(str(hwp_file), "HWP")
#hwpactionid 기반 #hwpactionid 기반
@@ -129,11 +132,11 @@ if __name__ == "__main__":
# 변환할 폴더 경로 설정 # 변환할 폴더 경로 설정
folders = [ folders = [
# (r"C:\Users\dra\project\HWP\HWP-Scoring\input\A\DIW",r"C:\Users\dra\project\HWP\HWP-Scoring\output\A"), (r"C:\Users\dra\project\HWP\HWP-Scoring\input\A\DIW",r"C:\Users\dra\project\HWP\HWP-Scoring\output\A\DIW"),
# (r"C:\Users\dra\project\HWP\HWP-Scoring\input\B\DIW",r"C:\Users\dra\project\HWP\HWP-Scoring\output\B"), # (r"C:\Users\dra\project\HWP\HWP-Scoring\input\B\DIW",r"C:\Users\dra\project\HWP\HWP-Scoring\output\B\DIW"),
# (r"C:\Users\dra\project\HWP\HWP-Scoring\input\C\DIW",r"C:\Users\dra\project\HWP\HWP-Scoring\output\C"), # (r"C:\Users\dra\project\HWP\HWP-Scoring\input\C\DIW",r"C:\Users\dra\project\HWP\HWP-Scoring\output\C\DIW"),
# (r"C:\Users\dra\project\HWP\HWP-Scoring\input\D\DIW",r"C:\Users\dra\project\HWP\HWP-Scoring\output\D"), # (r"C:\Users\dra\project\HWP\HWP-Scoring\input\D\DIW",r"C:\Users\dra\project\HWP\HWP-Scoring\output\D\DIW"),
(r"C:\Users\dra\project\HWP\HWP-Scoring\input\E\DIW",r"C:\Users\dra\project\HWP\HWP-Scoring\output\e_test") # (r"C:\Users\dra\project\HWP\HWP-Scoring\input\E\DIW",r"C:\Users\dra\project\HWP\HWP-Scoring\output\E\DIW"),
] ]
# 변환 실행 # 변환 실행

View File

@@ -1 +1 @@
[{"kind":2,"language":"xpath","value":"//FONTFACE[@Lang='Hangul']/FONT[@Id=//CHARSHAPE[@Id=//CHAR[contains(text(),'{searchValue}')]/parent::TEXT/@CharShape]/FONTID/@Hangul]/@Name"},{"kind":2,"language":"xpath","value":"//CHAR[contains(text(),'생산가능인구')]/following-sibling::FOOTNOTE"},{"kind":2,"language":"xpath","value":"/following-sibling::FOOTNOTE/descendant::CHAR[contains(text(),'전체 인구가 늘더라도 생산가능인구가 감소한다면 생산가능인구가 짊어져야 하는 비용은 증가한다.')]"},{"kind":2,"language":"xpath","value":"boolean(//CHAR[substring(., string-length(.) - string-length('생산가능인구') + 1) = '생산가능인구']/following-sibling::FOOTNOTE/descendant::CHAR[contains(text(),'전체 인구가 늘더라도 생산가능인구가 감소한다면 생산가능인구가 짊어져야 하는 비용은 증가한다')])"},{"kind":2,"language":"xpath","value":"//CHAR[substring(., string-length(.) - string-length('생산가능인구') + 1) = '생산가능인구']"},{"kind":2,"language":"xpath","value":"boolean(//CHAR[contains(text(),'생산가능인구')]/ancestor::TEXT/FOOTNOTE/descendant::CHAR[contains(text(),'전체 인구가 늘더라도 생산가능인구가 감소한다면 생산가능인구가 짊어져야 하는 비용은 증가한다')])"},{"kind":2,"language":"xpath","value":"boolean(//CHAR[contains(text(),'생산가능인구')]/following-sibling::FOOTNOTE/descendant::CHAR[contains(text(),'전체 인구가 늘더라도 생산가능인구가 감소한다면 생산가능인구가 짊어져야 하는 비용은 증가한다')])"},{"kind":2,"language":"xpath","value":"boolean(//CHAR[contains(text(),'생산가능인구')]/ancestor::TEXT/FOOTNOTE/descendant::CHAR[contains(normalize-space(text()),'전체 인구가 늘더라도 생산가능인구가 감소한다면 생산가능인구가 짊어져야 하는 비용은 증가한다')])"},{"kind":2,"language":"xpath","value":"//CHAR[contains(text(),'생산가능인구')]/ancestor::TEXT/FOOTNOTE/descendant::CHAR/translate(text(), ' ',' ')"}] [{"kind":2,"language":"xpath","value":"//RECTANGLE//CHAR[text()='인구절벽']/ancestor::RECTANGLE/descendant::LINESHAPE/@Style"}]