Commit
·
c8b6e7d
1
Parent(s):
c7cf1e8
first commit
Browse files- __init__.py +0 -0
- __pycache__/const.cpython-310.pyc +0 -0
- __pycache__/const.cpython-39.pyc +0 -0
- __pycache__/latex2operatortree.cpython-310.pyc +0 -0
- __pycache__/latex2operatortree.cpython-39.pyc +0 -0
- requirements.txt +0 -0
- test.py +17 -3
- tokenizer.py +1 -0
__init__.py
ADDED
File without changes
|
__pycache__/const.cpython-310.pyc
ADDED
Binary file (16.7 kB). View file
|
|
__pycache__/const.cpython-39.pyc
ADDED
Binary file (16.2 kB). View file
|
|
__pycache__/latex2operatortree.cpython-310.pyc
ADDED
Binary file (818 Bytes). View file
|
|
__pycache__/latex2operatortree.cpython-39.pyc
ADDED
Binary file (825 Bytes). View file
|
|
requirements.txt
ADDED
Binary file (1.15 kB). View file
|
|
test.py
CHANGED
@@ -4,12 +4,26 @@ from const import *
|
|
4 |
from pprint import pprint
|
5 |
from latex2operatortree import *
|
6 |
from transformers import AutoTokenizer, AutoModel
|
|
|
7 |
# text = "Trong các hình vẽ sau $y=\dfrac{x+1}{-x+1}$, hình nào biểu diễn đồ thị của hàm số $y=x^3$, $y=x^5$?"
|
8 |
# pattern = r'\$.*?\$'
|
9 |
|
10 |
# equations = re.findall(pattern, text)
|
11 |
|
12 |
# pprint(latex2tree(text))
|
13 |
-
dir = 'code/'
|
14 |
-
py_vncorenlp.download_model(save_dir=dir)
|
15 |
-
model = py_vncorenlp.VnCoreNLP(save_dir='code/')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
from pprint import pprint
|
5 |
from latex2operatortree import *
|
6 |
from transformers import AutoTokenizer, AutoModel
|
7 |
+
from const import LATEX_VOC
|
8 |
# text = "Trong các hình vẽ sau $y=\dfrac{x+1}{-x+1}$, hình nào biểu diễn đồ thị của hàm số $y=x^3$, $y=x^5$?"
|
9 |
# pattern = r'\$.*?\$'
|
10 |
|
11 |
# equations = re.findall(pattern, text)
|
12 |
|
13 |
# pprint(latex2tree(text))
|
14 |
+
# dir = 'code/'
|
15 |
+
# py_vncorenlp.download_model(save_dir=dir)
|
16 |
+
# model = py_vncorenlp.VnCoreNLP(save_dir='code/')
|
17 |
+
|
18 |
+
|
19 |
+
model_path = "huuminh365/CustomBERT"
|
20 |
+
latex_token = LATEX_VOC
|
21 |
+
# print(len(latex_token), latex_token[:5])
|
22 |
+
|
23 |
+
tok = AutoTokenizer.from_pretrained(model_path)
|
24 |
+
# model = AutoModel.from_pretrained(model_path)
|
25 |
+
|
26 |
+
tok.add_tokens(latex_token)
|
27 |
+
# tok.save_pretrained(f'tokenizer_{model_path}_with_latex')
|
28 |
+
text = 'Tính diện tích hình phẳng giới hạn bởi đồ thị các hàm số $y =x^3$, $y=x^5$, $\dfrac{2}{x}=5$. Cho hàm số $y=f(x)$ liên tục trên $\mathbb{R}$, có đồ thị cắt trục $Ox$ tại các điểm có hoành độ'
|
29 |
+
print(tok.tokenize(text))
|
tokenizer.py
CHANGED
@@ -127,6 +127,7 @@ class PhobertTokenizer(PreTrainedTokenizer):
|
|
127 |
merges = merges_handle.read().split("\n")[:-1]
|
128 |
merges = [tuple(merge.split()[:-1]) for merge in merges]
|
129 |
self.bpe_ranks = dict(zip(merges, range(len(merges))))
|
|
|
130 |
self.cache = {}
|
131 |
|
132 |
def build_inputs_with_special_tokens(self, token_ids_0: List[int], token_ids_1: Optional[List[int]] = None) -> List[int]:
|
|
|
127 |
merges = merges_handle.read().split("\n")[:-1]
|
128 |
merges = [tuple(merge.split()[:-1]) for merge in merges]
|
129 |
self.bpe_ranks = dict(zip(merges, range(len(merges))))
|
130 |
+
|
131 |
self.cache = {}
|
132 |
|
133 |
def build_inputs_with_special_tokens(self, token_ids_0: List[int], token_ids_1: Optional[List[int]] = None) -> List[int]:
|