Fix bugs in multiple examples
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
import csv
|
||||
import os
|
||||
import datetime
|
||||
import difflib
|
||||
import functools
|
||||
import json
|
||||
import logging
|
||||
import operator
|
||||
import os
|
||||
import re
|
||||
import sqlite3
|
||||
from numbers import Number
|
||||
@@ -13,7 +13,6 @@ from typing import Callable, Any, Union
|
||||
from typing import Dict, List, Pattern
|
||||
|
||||
import lxml.etree
|
||||
import pandas as pd
|
||||
import pdfplumber
|
||||
import yaml
|
||||
from docx import Document
|
||||
@@ -104,13 +103,14 @@ def fuzzy_place_math(result_file_path, rules) -> float:
|
||||
for word in words_list:
|
||||
max_score = 0
|
||||
for ans in expect:
|
||||
score = fuzz.ratio(word, ans)/100
|
||||
score = fuzz.ratio(word, ans) / 100
|
||||
max_score = max(max_score, score)
|
||||
fuzzy_score_list.append(max_score)
|
||||
if len(fuzzy_score_list) != 3:
|
||||
return 0.
|
||||
return sum(fuzzy_score_list) / 3
|
||||
|
||||
|
||||
def check_csv(result: str, rules: Dict[str, List[Dict[str, str]]]) -> float:
|
||||
"""
|
||||
Args:
|
||||
@@ -341,27 +341,30 @@ def check_direct_json_object(result, rules) -> float:
|
||||
logger.debug("check_direct_json_object: result is not a valid json object")
|
||||
return 0.
|
||||
|
||||
|
||||
def compare_time_in_speedtest_results(speedtest_result_path, time_diff):
|
||||
if not speedtest_result_path:
|
||||
return 0
|
||||
|
||||
# open the speedtest results file(csv)
|
||||
date_col = None
|
||||
with open(speedtest_result_path, 'r') as f:
|
||||
reader = pd.read_csv(f)
|
||||
for column in reader.columns:
|
||||
if column.startswith('TEST_DATE'):
|
||||
date_col = column
|
||||
break
|
||||
now_date_time = datetime.datetime.now().strftime('%H:%M')
|
||||
for date in reader[date_col]:
|
||||
try:
|
||||
with open(speedtest_result_path, 'r') as f:
|
||||
for i, line in enumerate(f):
|
||||
if i == 1:
|
||||
date = line.split(',')[1]
|
||||
break
|
||||
now_date_time = datetime.datetime.now().strftime('%H:%M')
|
||||
date_time = date[-5:]
|
||||
# compare the date time with the current date time, if time diff less than time_diff para, then return true
|
||||
if not abs((datetime.datetime.strptime(date_time, '%H:%M') - datetime.datetime.strptime(now_date_time,
|
||||
'%H:%M')).total_seconds()) / 60 < int(
|
||||
time_diff):
|
||||
time_diff):
|
||||
return 0
|
||||
return 1
|
||||
except:
|
||||
logger.debug("compare_time_in_speedtest_results: file not found or not readable")
|
||||
return 0
|
||||
|
||||
|
||||
def is_included_all_json_objects(gold_file_path, result_file_path):
|
||||
|
||||
Reference in New Issue
Block a user