Skip to content

Commit 785ed5b

Browse files
xiexinchstephen-nju
authored andcommitted
[Fix] Update lawbench data path (open-compass#2037)
1 parent 0a4314e commit 785ed5b

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

opencompass/datasets/lawbench/utils/modules/alignment.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
chinese_punct = "!?。"#$%&'()*+,-/:;<=>@[\]^_`{|}~⦅⦆「」、、〃》「」『』【】〔〕〖〗〘〙〚〛〜〝〞〟〰〾〿–—‘'‛“”„‟…‧﹏"
99
english_punct = punctuation
1010
punct = chinese_punct + english_punct
11+
cache_dir = os.environ.get('COMPASS_DATA_CACHE', '')
1112

1213
def check_all_chinese(word):
1314
"""
@@ -22,7 +23,7 @@ def read_cilin():
2223
Cilin 詞林 is a thesaurus with semantic information
2324
"""
2425
# TODO -- fix this path
25-
lines = open(os.path.join(os.path.dirname(__file__), "..", "..", "..", "..", "..", "data", "lawbench", "eval_assets", "cilin.txt"), "r", encoding="gbk").read().strip().split("\n")
26+
lines = open(os.path.join(cache_dir, "data", "lawbench", "eval_assets", "cilin.txt"), "r", encoding="gbk").read().strip().split("\n")
2627
semantic_dict = {}
2728
semantic_classes = {}
2829
for line in lines:
@@ -39,7 +40,7 @@ def read_cilin():
3940

4041
def read_confusion():
4142
confusion_dict = {}
42-
with open(os.path.join(os.path.dirname(__file__), "..", "..", "..", "..", "..", "data", "lawbench", "eval_assets", "confusion_dict.txt"), "r", encoding="utf-8") as f:
43+
with open(os.path.join(cache_dir, "data", "lawbench", "eval_assets", "confusion_dict.txt"), "r", encoding="utf-8") as f:
4344
for line in f:
4445
li = line.rstrip('\n').split(" ")
4546
confusion_dict[li[0]] = li[1:]

opencompass/datasets/lawbench/utils/modules/classifier.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
"inds",
1111
],
1212
)
13-
char_smi = CharFuncs(os.path.join(os.path.dirname(__file__), "..", "..", "..", "..", "..", "data", "lawbench", "eval_assets", "char_meta.txt"))
13+
cache_dir = os.environ.get('COMPASS_DATA_CACHE', '')
14+
char_smi = CharFuncs(os.path.join(cache_dir, "data", "lawbench", "eval_assets", "char_meta.txt"))
1415

1516
def check_spell_error(src_span: str,
1617
tgt_span: str,

0 commit comments

Comments
 (0)