Skip to content

Commit a3962b2

Browse files
committed
Add default cache dir
1 parent cc35167 commit a3962b2

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

supar/utils/common.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
# -*- coding: utf-8 -*-
22

3+
import os
4+
35
PAD = '<pad>'
46
UNK = '<unk>'
57
BOS = '<bos>'
68
EOS = '<eos>'
79

810
MIN = -1e32
11+
12+
CACHE = os.path.expanduser('~/.cache/supar')

supar/utils/fn.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import zipfile
88

99
import torch
10+
from supar.utils.common import CACHE
1011

1112

1213
def ispunct(token):
@@ -238,7 +239,7 @@ def pad(tensors, padding_value=0, total_length=None, padding_side='right'):
238239

239240

240241
def download(url, reload=False):
241-
path = os.path.join(os.path.expanduser('~/.cache/supar'), os.path.basename(urllib.parse.urlparse(url).path))
242+
path = os.path.join(CACHE, os.path.basename(urllib.parse.urlparse(url).path))
242243
os.makedirs(os.path.dirname(path), exist_ok=True)
243244
if reload:
244245
os.remove(path) if os.path.exists(path) else None

0 commit comments

Comments
 (0)