-
Notifications
You must be signed in to change notification settings - Fork 5
/
config.py
51 lines (41 loc) · 1.78 KB
/
config.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
from tokenizers_collection.config import tokenizer_registry as collection_tokenizer_registry
from tokenizers import (
tokenizer_MicroTokenizer_with_HMM,
tokenizer_MicroTokenizer_with_DAG,
tokenizer_MicroTokenizer_with_joint_model,
tokenizer_MicroTokenizer_with_CRF,
tokenizer_MicroTokenizer_with_custom_joint_model,
tokenizer_MicroTokenizer_with_custom_CRF_model,
tokenizer_MicroTokenizer_with_max_match_forward,
tokenizer_MicroTokenizer_with_max_match_backward,
tokenizer_MicroTokenizer_with_max_match_bidirectional
)
def make_func_accept_corpus_kwarg(func):
def decorator(*args, **kwargs):
kwargs.pop('corpus', None)
return func(*args, **kwargs)
return decorator
tokenizer_registry = {
k: make_func_accept_corpus_kwarg(v)
for k, v in collection_tokenizer_registry.items()
}
tokenizer_registry.update(
{
'MicroTokenizer_with_HMM': tokenizer_MicroTokenizer_with_HMM,
'MicroTokenizer_with_DAG': tokenizer_MicroTokenizer_with_DAG,
'MicroTokenizer_with_joint_model': tokenizer_MicroTokenizer_with_joint_model,
'MicroTokenizer_with_CRF': tokenizer_MicroTokenizer_with_CRF,
'MicroTokenizer_with_custom_joint_model': tokenizer_MicroTokenizer_with_custom_joint_model,
'MicroTokenizer_with_custom_CRF_model': tokenizer_MicroTokenizer_with_custom_CRF_model,
'MicroTokenizer_with_max_match_forward': tokenizer_MicroTokenizer_with_max_match_forward,
'MicroTokenizer_with_max_match_backward': tokenizer_MicroTokenizer_with_max_match_backward,
'MicroTokenizer_with_max_match_bidirectional': tokenizer_MicroTokenizer_with_max_match_bidirectional
}
)
# TODO: likely to be over-design
corpus_registry = {
"MSR": 'msr',
"AS": 'as',
"PKU": 'pku',
"CityU": "cityu"
}