├── .gitignore ├── img └── kosapcing_img.png ├── model ├── kospacing_wv.np ├── kospacing.params ├── kospacing_wv.mdl └── w2idx.dic ├── requirements.txt ├── utils ├── spacing_utils.py └── embedding_maker.py ├── embedding.py ├── README.md ├── LICENSE └── train.py /.gitignore: -------------------------------------------------------------------------------- 1 | data/* 2 | trainlstm.py 3 | resources/* 4 | */__pycache__/* 5 | .vscode/ 6 | 7 | -------------------------------------------------------------------------------- /img/kosapcing_img.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haven-jeon/TrainKoSpacing/HEAD/img/kosapcing_img.png -------------------------------------------------------------------------------- /model/kospacing_wv.np: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haven-jeon/TrainKoSpacing/HEAD/model/kospacing_wv.np -------------------------------------------------------------------------------- /model/kospacing.params: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haven-jeon/TrainKoSpacing/HEAD/model/kospacing.params -------------------------------------------------------------------------------- /model/kospacing_wv.mdl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haven-jeon/TrainKoSpacing/HEAD/model/kospacing_wv.mdl -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | mxnet-mkl >= 1.6.0 # mxnet-cu101mkl >= 1.6.0 2 | tqdm >= 4.19.5 3 | pandas >= 0.22.0 4 | gensim >= 3.8.1 5 | gluonnlp >= 0.9.1 6 | 7 | -------------------------------------------------------------------------------- /utils/spacing_utils.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | # Copyright 2020 Heewon Jeon. All rights reserved. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | def sent_to_spacing_chars(sent): 17 | # 공백은 ^ 18 | chars = sent.strip().replace(' ', '^') 19 | # char_list = [li.strip().replace(' ', '^') for li in sents] 20 | 21 | # 문장의 시작 포인트 « 22 | # 문장의 끌 포인트 » 23 | tagged_chars = "«" + chars + "»" 24 | # char_list = [ "«" + li + "»" for li in char_list] 25 | 26 | # 문장 -> 문자열 27 | char_list = ' '.join(list(tagged_chars)) 28 | # char_list = [ ' '.join(list(li)) for li in char_list] 29 | return(char_list) 30 | -------------------------------------------------------------------------------- /embedding.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | # Copyright 2020 Heewon Jeon. All rights reserved. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | import argparse 17 | from utils.embedding_maker import create_embeddings 18 | 19 | 20 | parser = argparse.ArgumentParser(description='Korean Autospacing Embedding Maker') 21 | 22 | parser.add_argument('--num-iters', type=int, default=5, 23 | help='number of iterations to train (default: 5)') 24 | 25 | parser.add_argument('--min-count', type=int, default=100, 26 | help='mininum word counts to filter (default: 100)') 27 | 28 | parser.add_argument('--embedding-size', type=int, default=100, 29 | help='embedding dimention size (default: 100)') 30 | 31 | parser.add_argument('--num-worker', type=int, default=16, 32 | help='number of thread (default: 16)') 33 | 34 | parser.add_argument('--window-size', type=int, default=8, 35 | help='skip-gram window size (default: 8)') 36 | 37 | parser.add_argument('--corpus_dir', type=str, default='data', 38 | help='training resource dir') 39 | 40 | parser.add_argument('--train', action='store_true', default=True, 41 | help='do embedding trainig (default: True)') 42 | 43 | parser.add_argument('--model-file', type=str, default='kospacing_wv.mdl', 44 | help='output object from Word2Vec() (default: kospacing_wv.mdl)') 45 | 46 | parser.add_argument('--numpy-wv', type=str, default='kospacing_wv.np', 47 | help='numpy object file path from Word2Vec() (default: kospacing_wv.np)') 48 | 49 | parser.add_argument('--w2idx', type=str, default='w2idx.dic', 50 | help='item to index json dictionary (default: w2idx.dic)') 51 | 52 | parser.add_argument('--model-dir', type=str, default='model', 53 | help='dir to save models (default: model)') 54 | 55 | opt = parser.parse_args() 56 | 57 | if opt.train: 58 | create_embeddings(opt.corpus_dir, opt.model_dir + '/' + 59 | opt.model_file, opt.model_dir + '/' + opt.numpy_wv, 60 | opt.model_dir + '/' + opt.w2idx, min_count=opt.min_count, 61 | iter=opt.num_iters, 62 | size=opt.embedding_size, workers=opt.num_worker, window=opt.window_size) 63 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | - [Automatic Korean word spacing with neural n-gram detector(NND)](#automatic-korean-word-spacing-with-neural-n-gram-detectornnd) 3 | - [Introduction](#introduction) 4 | - [Architecture](#architecture) 5 | - [Performances](#performances) 6 | - [How to Run](#how-to-run) 7 | - [Installation](#installation) 8 | - [Dependencies](#dependencies) 9 | - [Data](#data) 10 | - [Format](#format) 11 | - [Requirement](#requirement) 12 | - [Training](#training) 13 | - [Evaluation](#evaluation) 14 | - [Citation](#citation) 15 | 16 | 17 | # Automatic Korean word spacing with neural n-gram detector(NND) 18 | 19 | We propose a Korean word spacing method using Convolution based Neural N-gram Detector(NND) model for the problem of word spacing Korean sentences that have been completely removed. The NND model solves the disadvantages of the existing RNN model and can achieve high performance in the sequence labeling problem of natural language processing. Experimental results show that the NND model is 98.02% accuracy. 20 | This model strongly related (Py)KoSpacing model[^2], but some points was improved. 21 | 22 | ## Introduction 23 | 24 | - Maximize automatic Korean word spacing performance by using parallel convolution filters as a tool for extracting syllable n-gram probability information. 25 | - This model was constructed using five NND(Neural N-gram Detector)s. 26 | - Better performance than Bi-Directional LSTM(or GRU) based spacing engine under the same conditions. 27 | 28 | ## Architecture 29 | 30 | ![kosapcing_img](img/kosapcing_img.png) 31 | 32 | ## Performances 33 | 34 | - Training Set : UCorpus-HG train set (846,930) 35 | - Test Set : UCorpus-HG test set (94,103) 36 | 37 | We used four evaluation measures: character-unit precision ($P_{char}$), word-unit recall ($R_{word}$), word-unit precision ($P_{word}$), and word-unit F1-measure ($F1_{word}$). 38 | 39 | 40 | | Algorithm | $P_{char}$ | $P_{word}$ | $R_{word}$ | $F1_{word}$ | 41 | | ------------------ | ---------- | ---------- | ---------- | ---------- | 42 | | CRF[^1] | 0.9337 | 0.8471 | 0.8481 | 0.8476 | 43 | | Bi-Directional GRU | 0.9689 | | | | 44 | | Bi-Directional GRU with CRF | 0.9717 | | | | 45 | | NND only | 0.9726 | 0.9588 | 0.9591 | 0.9589 | 46 | | NND(with Bi-Directional GRU) | 0.9802 | 0.9787 | 0.9788 | 0.9787 | 47 | 48 | - $P_{char}$ = # correctly spaced characters/# characters in the test data. 49 | - $R_{word}$ = # correctly spaced words/# words in the test data. 50 | - $P_{word}$ = # correctly spaced words/# words produced by the system. 51 | - $F1_{word}$ =$2 \times \frac{ P_{word} \times R_{word}} {(P_{word} + R_{word})}$ 52 | 53 | *UCorpus-HG from [2017 Exobrain corpus](http://aiopen.etri.re.kr/service_corpus.php)* 54 | 55 | ## How to Run 56 | 57 | 58 | ### Installation 59 | 60 | - For training, a GPU is strongly recommended for speed. CPU is supported but training could be extremely slow. 61 | - Support only above Python 3.7. 62 | 63 | ### Dependencies 64 | 65 | ```bash 66 | pip install -r requirements.txt 67 | ``` 68 | 69 | ### Data 70 | 71 | We mainly focus on the Sejong corpus, and the code takes its altered format as input. However, due to the license issue, we are restricted to distribute this dataset. You should be able to get it [here](http://aiopen.etri.re.kr/service_corpus.php). 72 | 73 | #### Format 74 | 75 | Bziped file consisting of one sentence per line. 76 | 77 | ``` 78 | gogamza@192.168.1.1:~/KoSpacing/data$ bzcat UCorpus_spacing_train.txt.bz2 | head 79 | 엠마누엘 웅가로 / 의상서 실내 장식품으로… 디자인 세계 넓혀 80 | 프랑스의 세계적인 의상 디자이너 엠마누엘 웅가로가 실내 장식용 직물 디자이너로 나섰다. 81 | 웅가로는 침실과 식당, 욕실에서 사용하는 갖가지 직물제품을 디자인해 최근 파리의 갤러리 라파예트백화점에서 '색의 컬렉션'이라는 이름으로 전시회를 열었다. 82 | ``` 83 | 84 | ### Requirement 85 | 86 | - Python (>= 3.7) 87 | - MXNet (>= 1.6.0) 88 | - tqdm (>= 4.19.5) 89 | - Pandas (>= 0.22.0) 90 | - Gensim (>= 3.8.1) 91 | - GluonNLP (>= 0.9.1) 92 | 93 | For MXNet, it needs to install right version regarding training envirement(mxnet-cu90, mxnet-cu101,..). 94 | 95 | ### Training 96 | 97 | ```bash 98 | python train.py --train --train-samp-ratio 1.0 --num-epoch 20 --train_data data/UCorpus_spacing_train.txt.bz2 --test_data data/UCorpus_spacing_test.txt.bz2 --outputs train_log_to --model_type kospacing 99 | ``` 100 | 101 | ### Evaluation 102 | 103 | ```bash 104 | python train.py --model-params model/kospacing.params --model_type kospacing 105 | sent > 중국은2018년평창동계올림픽의반환점에이르기까지아직노골드행진이다. 106 | 중국은2018년평창동계올림픽의반환점에이르기까지아직노골드행진이다. 107 | spaced sent[0.12sec/sent] > 중국은 2018년 평창동계올림픽의 반환점에 이르기까지 아직 노골드 행진이다. 108 | ``` 109 | 110 | ## Citation 111 | 112 | ```markdowns 113 | @misc{heewon2018, 114 | author = {Heewon Jeon}, 115 | title = {Automatic Korean word spacing with neural n-gram detector}, 116 | publisher = {GitHub}, 117 | journal = {GitHub repository}, 118 | howpublished = {\url{https://github.com/haven-jeon/Train_KoSpacing}} 119 | ``` 120 | 121 | [^1]: https://github.com/scrapinghub/python-crfsuite 122 | [^2]: https://github.com/haven-jeon/PyKoSpacing 123 | -------------------------------------------------------------------------------- /utils/embedding_maker.py: -------------------------------------------------------------------------------- 1 | __all__ = [ 2 | 'create_embeddings', 'load_embedding', 'load_vocab', 3 | 'encoding_and_padding', 'get_embedding_model' 4 | ] 5 | 6 | import bz2 7 | import json 8 | import os 9 | 10 | import numpy as np 11 | import pkg_resources 12 | from gensim.models import Word2Vec 13 | 14 | from utils.spacing_utils import sent_to_spacing_chars 15 | 16 | 17 | def pad_sequences(sequences, 18 | maxlen=None, 19 | dtype='int32', 20 | padding='pre', 21 | truncating='pre', 22 | value=0.): 23 | 24 | if not hasattr(sequences, '__len__'): 25 | raise ValueError('`sequences` must be iterable.') 26 | lengths = [] 27 | for x in sequences: 28 | if not hasattr(x, '__len__'): 29 | raise ValueError('`sequences` must be a list of iterables. ' 30 | 'Found non-iterable: ' + str(x)) 31 | lengths.append(len(x)) 32 | 33 | num_samples = len(sequences) 34 | if maxlen is None: 35 | maxlen = np.max(lengths) 36 | 37 | # take the sample shape from the first non empty sequence 38 | # checking for consistency in the main loop below. 39 | sample_shape = tuple() 40 | for s in sequences: 41 | if len(s) > 0: 42 | sample_shape = np.asarray(s).shape[1:] 43 | break 44 | 45 | x = (np.ones((num_samples, maxlen) + sample_shape) * value).astype(dtype) 46 | for idx, s in enumerate(sequences): 47 | if not len(s): 48 | continue # empty list/array was found 49 | if truncating == 'pre': 50 | trunc = s[-maxlen:] 51 | elif truncating == 'post': 52 | trunc = s[:maxlen] 53 | else: 54 | raise ValueError('Truncating type "%s" not understood' % 55 | truncating) 56 | 57 | # check `trunc` has expected shape 58 | trunc = np.asarray(trunc, dtype=dtype) 59 | if trunc.shape[1:] != sample_shape: 60 | raise ValueError( 61 | 'Shape of sample %s of sequence at position %s is different from expected shape %s' 62 | % (trunc.shape[1:], idx, sample_shape)) 63 | 64 | if padding == 'post': 65 | x[idx, :len(trunc)] = trunc 66 | elif padding == 'pre': 67 | x[idx, -len(trunc):] = trunc 68 | else: 69 | raise ValueError('Padding type "%s" not understood' % padding) 70 | return x 71 | 72 | 73 | def create_embeddings(data_dir, 74 | model_file, 75 | embeddings_file, 76 | vocab_file, 77 | splitc=' ', 78 | **params): 79 | """ 80 | making embedding from files. 81 | :**params additional Word2Vec() parameters 82 | :splitc char for splitting in data_dir files 83 | :model_file output object from Word2Vec() 84 | :data_dir data dir to be process 85 | :embeddings_file numpy object file path from Word2Vec() 86 | :vocab_file item to index json dictionary 87 | """ 88 | class SentenceGenerator(object): 89 | def __init__(self, dirname): 90 | self.dirname = dirname 91 | 92 | def __iter__(self): 93 | for fname in os.listdir(self.dirname): 94 | print("processing~ '{}'".format(fname)) 95 | for line in bz2.open(os.path.join(self.dirname, fname), "rt"): 96 | yield sent_to_spacing_chars(line.strip()).split(splitc) 97 | 98 | sentences = SentenceGenerator(data_dir) 99 | 100 | model = Word2Vec(sentences, **params) 101 | model.save(model_file) 102 | # model = Word2Vec.load("model_2.w2v") 103 | weights = model.wv.syn0 104 | default_vec = np.mean(weights, axis=0, keepdims=True) 105 | padding_vec = np.zeros((1, weights.shape[1])) 106 | 107 | weights_default = np.concatenate([weights, default_vec, padding_vec], 108 | axis=0) 109 | 110 | np.save(open(embeddings_file, 'wb'), weights_default) 111 | 112 | vocab = dict([(k, v.index) for k, v in model.wv.vocab.items()]) 113 | vocab['__ETC__'] = weights_default.shape[0] - 2 114 | vocab['__PAD__'] = weights_default.shape[0] - 1 115 | with open(vocab_file, 'w') as f: 116 | f.write(json.dumps(vocab)) 117 | 118 | 119 | def load_embedding(embeddings_file): 120 | return (np.load(embeddings_file)) 121 | 122 | 123 | def load_vocab(vocab_path): 124 | with open(vocab_path, 'r') as f: 125 | data = json.loads(f.read()) 126 | word2idx = data 127 | idx2word = dict([(v, k) for k, v in data.items()]) 128 | return word2idx, idx2word 129 | 130 | 131 | def encoding_and_padding(word2idx_dic, sequences, **params): 132 | """ 133 | 1. making item to idx 134 | 2. padding 135 | :word2idx_dic 136 | :sequences: list of lists where each element is a sequence 137 | :maxlen: int, maximum length 138 | :dtype: type to cast the resulting sequence. 139 | :padding: 'pre' or 'post', pad either before or after each sequence. 140 | :truncating: 'pre' or 'post', remove values from sequences larger than 141 | maxlen either in the beginning or in the end of the sequence 142 | :value: float, value to pad the sequences to the desired value. 143 | """ 144 | seq_idx = [[word2idx_dic.get(a, word2idx_dic['__ETC__']) for a in i] 145 | for i in sequences] 146 | params['value'] = word2idx_dic['__PAD__'] 147 | return (pad_sequences(seq_idx, **params)) 148 | 149 | 150 | def get_embedding_model(name='fee_prods', path='data/embedding'): 151 | weights = pkg_resources.resource_filename( 152 | 'dsc', os.path.join(path, name, 'weights.np')) 153 | w2idx = pkg_resources.resource_filename( 154 | 'dsc', os.path.join(path, name, 'idx.json')) 155 | return ((load_embedding(weights), load_vocab(w2idx)[0])) 156 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /model/w2idx.dic: -------------------------------------------------------------------------------- 1 | {"\u00ab": 3, "\uc5e0": 1352, "\ub9c8": 64, "\ub204": 283, "\uc5d8": 721, "^": 0, "\uc6c5": 757, "\uac00": 11, "\ub85c": 15, "/": 330, "\uc758": 8, "\uc0c1": 56, "\uc11c": 18, "\uc2e4": 104, "\ub0b4": 58, "\uc7a5": 54, "\uc2dd": 137, "\ud488": 292, "\uc73c": 32, "\u2026": 199, "\ub514": 255, "\uc790": 28, "\uc778": 33, "\uc138": 99, "\uacc4": 103, "\ub113": 726, "\ud600": 399, "\u00bb": 4, "\ud504": 282, "\ub791": 284, "\uc2a4": 81, "\uc801": 52, "\uc774": 1, "\ub108": 274, "\uc6a9": 141, "\uc9c1": 177, "\ubb3c": 116, "\ub098": 22, "\uc130": 633, "\ub2e4": 2, ".": 5, "\ub294": 6, "\uce68": 314, "\uacfc": 48, "\ub2f9": 119, ",": 25, "\uc695": 477, "\uc5d0": 7, "\uc0ac": 24, "\ud558": 13, "\uac16": 405, "\uc9c0": 12, "\uc81c": 50, "\uc744": 9, "\ud574": 36, "\ucd5c": 260, "\uadfc": 245, "\ud30c": 227, "\ub9ac": 27, "\uac24": 1477, "\ub7ec": 71, "\ub77c": 37, "\uc608": 182, "\ud2b8": 209, "\ubc31": 243, "\ud654": 79, "\uc810": 193, "'": 55, "\uc0c9": 371, "\uceec": 969, "\ub809": 1116, "\uc158": 714, "\ub984": 266, "\uc804": 53, "\uc2dc": 34, "\ud68c": 106, "\ub97c": 23, "\uc5f4": 251, "\uc5c8": 47, "\ubaa9": 226, "\uc6b4": 126, "\ubd80": 45, "\ud130": 149, "\ud0c1": 550, "\ubcf4": 43, "\ub0c5": 1523, "\ud0a8": 662, "\uc55e": 286, "\uce58": 101, "\uae4c": 105, "\uadf8": 17, "\ud55c": 14, "\uc791": 139, "\ub4e4": 29, "\ub450": 132, "\ub4dc": 178, "\uac83": 35, "\uc740": 16, "\uc870": 89, "\ub0a8": 156, "\ubbf8": 95, "\ud48d": 442, "\uac15": 190, "\ub82c": 782, "\uc6d0": 69, "\ub07c": 391, "\uc218": 38, "\ucc44": 336, "\uac19": 159, "\uc548": 94, "\uc628": 249, "\ubc30": 200, "\ub4f1": 124, "\ubd84": 133, "\uc704": 84, "\uae30": 19, "\ud559": 97, "\ubb34": 65, "\ub2ac": 1117, "\uaf43": 506, "\uc8fc": 49, "\ub958": 408, "\ub8e8": 273, "\uace0": 10, "\uc788": 30, "\"": 41, "\ud560": 91, "\ub54c": 102, "\uc637": 576, "\ub9cc": 44, "\uc640": 90, "\ub978": 183, "\ubc29": 118, "\uac10": 173, "\ub290": 201, "\ub080": 919, "\ub9d0": 76, "\uc9d1": 167, "\ucc3d": 326, "\ucc9c": 198, "\ubabb": 192, "\uc54a": 108, "\uac8c": 39, "\uacf5": 107, "\uac04": 100, "\uc911": 98, "\uc694": 80, "\uc654": 301, "\ub9e4": 237, "\uc77c": 42, "1": 68, "\ubc18": 165, "\ub0b8": 513, "\uccb4": 146, "\ud154": 593, "\ub808": 288, "\ube44": 88, "\uccad": 236, "\uc57c": 85, "\uc815": 40, "\ub3c4": 21, "\ub298": 276, "\ub300": 31, "\ub825": 196, "\uc74c": 122, "\uaecf": 778, "\ud3bc": 792, "\uc990": 635, "\uac70": 73, "\ub180": 456, "\ucc98": 152, "\ub7fc": 241, "\ucc3b": 1266, "\uc794": 487, "\uc811": 395, "\ud65c": 296, "\ub3d9": 67, "\ud3ed": 444, "\uac08": 343, "\ud68d": 471, "\uc5bc": 253, "\uc2e0": 70, "\uc4f0": 364, "\uc544": 26, "\ud329": 1185, "\uad6d": 61, "\uc0b0": 142, "\uc591": 181, "\uc131": 74, "\ub2a5": 305, "\uc678": 222, "\uc190": 258, "\uc5c6": 78, "\uc5b4": 20, "\ube59": 861, "\uc0e4": 951, "\ubca0": 469, "\ud1b5": 134, "\uc5ec": 57, "\uc0dd": 72, "\ud2b9": 297, "\ud788": 127, "\ucca0": 333, "\ub354": 157, "\ub370": 109, "\uc18c": 66, "\ub9ce": 259, "\ucc3e": 359, "\ub358": 125, "\uc62c": 247, "\uc838": 268, "\ub208": 242, "\uae38": 250, "\ud648": 970, "\ud0c0": 206, "(": 77, "\uc601": 138, "0": 111, "2": 115, "-": 308, "4": 175, "6": 212, "3": 153, "5": 161, ")": 75, "\ud325": 1379, "7": 231, "\uba70": 121, "\uc785": 154, "\ubcf8": 184, "9": 180, "\u223c": 772, "8": 207, "\uc120": 92, "\uba85": 117, "\uc5b9": 1042, "\uc0b6": 519, "\ub2e8": 131, "\ucc30": 378, "\ub5a1": 759, "\uc824": 1154, "\ud3ec": 248, "\u338f": 1427, "\ud06c": 280, "\ud50c": 643, "\ud2f1": 1085, "\ub4e0": 228, "\ud2c0": 505, "\ud615": 229, "\uac01": 129, "\ubaa8": 83, "\ud544": 325, "\ub179": 740, "\uba74": 51, "\uaca8": 310, "\uc800": 155, "\uc558": 136, "\ud6e8": 732, "\uc52c": 700, "\uae68": 431, "\ub057": 815, "\uad6c": 62, "\uc4f8": 613, "\uaca9": 291, "\uac12": 687, "\uc2fc": 824, "\ub611": 711, "\ub86f": 646, "\ud310": 265, "\ucf54": 367, "\ubc15": 269, "\ud76c": 352, "\uc528": 223, "\uacbd": 87, "\ub80c": 910, "\uc988": 543, "\uad74": 358, "\uc808": 267, "\uc798": 307, "\uc0b4": 195, "\ud3b4": 671, "\ud604": 170, "\uc7ac": 147, "\ub530": 203, "\ub41c": 140, "\uc885": 220, "\uc6b0": 63, "\ud305": 913, "\ubc95": 204, "\ud14c": 394, "\ub118": 429, "\ud638": 194, "\ubc34": 1292, "\ud0dd": 437, "\ub144": 130, "\uc720": 120, "\ub418": 82, "\uac1c": 114, "\uc5c5": 162, "\uc9c8": 211, "\uacb0": 168, "\uc37c": 829, "\uc99d": 302, "\ud0a4": 293, "%": 349, "\ub0ac": 407, "\ub610": 210, "\ub3fc": 423, "\ub410": 412, "\uac78": 256, "\ub7fd": 430, "\ud655": 313, "\ub7f0": 172, "\ubb38": 60, "\ubc1c": 148, "\uacac": 379, "\ud53c": 244, "S": 547, "M": 622, "G": 708, "\ud4e8": 616, "K": 595, "F": 761, "C": 497, "\ub974": 143, "A": 553, "U": 939, "O": 751, "P": 611, "\ubcf5": 281, "\ub2c9": 1103, "N": 727, "L": 673, "R": 813, "\uc644": 435, "W": 935, "D": 652, "X": 1159, "\uc600": 176, "\ucc28": 150, "\uc27d": 604, "\ucc22": 1052, "\ud760": 1084, "\ucc38": 294, "\uc6b8": 187, "\uad00": 96, "\uad11": 360, "\ub9c9": 328, "\ubbfc": 145, "\uc18d": 144, "\uc5f0": 112, "\ud64d": 508, "\uad50": 113, "\uc5ed": 179, "\ud569": 270, "E": 692, "\uc9c4": 110, "\ud765": 552, "\ubc0f": 499, "T": 538, "\ubc88": 208, "\uc624": 86, "\ucf58": 930, "\ud2f0": 501, "\ub128": 1345, "\ud0c8": 507, "\ud589": 151, "\ud611": 380, "\ud540": 993, "\uccd0": 350, "\ub824": 93, "\uc900": 277, "\ub78c": 128, "\ub8cc": 362, "\ub220": 1035, "\uc5bb": 560, "\ub828": 298, "\ube4c": 679, "\ub7c9": 454, "\ubc8c": 332, "\ub09c": 166, "\ud6c4": 191, "\ud56d": 373, "\ud3b8": 219, "\ucde8": 398, "\ud588": 59, "\uba55": 1346, "\uba54": 467, "\uce74": 375, "\uac1d": 518, "\ud669": 356, "\uae08": 135, "\ub3c5": 289, "\ub124": 279, "\ub35c": 696, "\ub780": 240, "\uc2f1": 770, "\ucf69": 800, "\uc54c": 213, "\uacf3": 342, "\uc7c1": 386, "\ucf00": 601, "\ub0d0": 376, "\ubabd": 750, "\uace8": 419, "\ub9bd": 400, "\uc2ec": 163, "\ub5a8": 432, "\ubd88": 160, "\uccab": 533, "\ud314": 481, "\ub18d": 409, "\uc6d4": 214, "\uc124": 186, "\uae34": 374, "\u339e": 1148, "\ub0bc": 690, "m": 480, "\uc560": 320, "\uc9d0": 534, "\ucd94": 252, "\ub85d": 254, "\ud5c8": 346, "\uc2b5": 164, "\ub2c8": 46, "\ub840": 421, "\ub838": 322, "\uc787": 820, "\ub2ec": 174, "\ub9b4": 485, "\ud07c": 465, "\ub192": 443, "\ud300": 655, "\uc1a1": 365, "\ud0b7": 1549, "\ud30e": 1165, "\ub534": 963, "\ub9f9": 715, "\ubd81": 295, "\uc784": 218, "\ubab8": 392, "\ucef4": 572, "\ud328": 470, "\ub109": 994, "\ube14": 741, "\ucd9c": 221, "\ud63c": 338, "\ubcbc": 724, "\uc6cc": 304, "\ubcc0": 285, "\uaf2d": 597, "\uac89": 976, "\ub860": 261, "\uc5c4": 390, "\uc88b": 318, "\ubbc0": 569, "\ucee4": 463, "\ubc84": 188, "\uc998": 578, "\ubc14": 123, "\uadc0": 397, "\ub9db": 659, "\uc6e8": 736, "\uac14": 366, "\ub150": 494, "\ub9de": 369, "\ucdb0": 777, "\uc6c0": 348, "\uce6b": 990, "\ub454": 642, "\ucf8c": 783, "\uae54": 674, "\ud770": 790, "\ube68": 541, "\uc21c": 275, "\uad7d": 985, "\u339d": 1172, "\ub98e": 973, "\uc904": 323, "\ub465": 618, "\uae00": 415, "\ubc1b": 215, "\ub36e": 803, "\ud37c": 562, "\ud0b9": 1095, "\ubfd0": 381, "\uc559": 532, "\uae40": 246, "\ud78c": 625, "\ub9bc": 355, "\ud53d": 797, "\ucd08": 272, "\ub141": 678, "\uc154": 688, "\ub110": 681, "\ucee8": 795, "\ubca4": 871, "\uc13c": 685, "\ud398": 540, "\uc15c": 1608, "\uc1fc": 808, "\ud22c": 316, "\ube0c": 554, "\ub2dd": 1113, "\ub3cc": 235, "\ud5a5": 290, "\uade4": 1967, "\uacb9": 925, "\ubc94": 402, "\uc8c4": 546, "\uc84c": 329, "\uc871": 321, "\ubc1d": 417, "\ub451": 810, "\uae09": 299, "\ub9b0": 230, "\uad8c": 225, "\uc874": 383, "\ud568": 233, "\uaed8": 335, "\ud614": 527, "\uc9d3": 490, "\uce5c": 317, "\ucc99": 539, "\ubcc4": 319, "\ub79c": 663, "\uc220": 239, "\uc7a0": 396, "\uc058": 794, "\uac74": 158, "\uaca0": 234, "\uaebc": 563, "\ub4ef": 306, "\ubd99": 464, "\ud798": 416, "\uc368": 410, "\ub125": 1408, "\ub9e8": 733, "\uad70": 238, "\ud3c9": 271, "\ub9dd": 311, "\uc12d": 565, "\ub69c": 831, "\ub837": 921, "\ud1a0": 312, "\uc999": 1756, "\uaddc": 372, "\uc0bc": 357, "J": 1005, "\ud0dc": 224, "\ud6c8": 588, "\ub274": 649, "\ud45c": 216, "\ubc97": 570, "\uc5d4": 448, "\ubc16": 384, "\uc9e7": 838, "\ub2f4": 278, "\uc751": 446, "\ub2f5": 406, "\ud658": 287, "\uc11d": 257, "\uc724": 510, "\uade0": 609, "\ucf64": 1007, "\ubcd1": 309, "\ud5d8": 370, "\uc57d": 264, "\ub839": 341, "\ud761": 766, "\uac80": 361, "\uc545": 354, "\ud6a8": 474, "\uaf42": 1026, "\uc554": 542, "\ub374": 1096, "\ud754": 535, "\ub798": 169, "\uc5fd": 886, "\uc721": 327, "\uc2b7": 769, "\ub4a4": 300, "\uc555": 580, "\ubf51": 807, "\uac11": 483, "\ud575": 645, "\uc561": 586, "\ud3d0": 531, "\ucdcc": 1902, "\uae4a": 549, "\uc219": 436, "\uac90": 840, "\uc0c8": 217, "\uc0d8": 1114, "\uc881": 880, "\uad34": 582, "\ud150": 851, "\ub81b": 1438, "\ucda9": 401, "\ub1cc": 754, "\uc564": 1058, "\ub178": 189, "\uace4": 514, "\uc2b4": 525, "\uc9d5": 520, "\uba40": 638, "\uca61": 1329, "\uc8fd": 351, "\ub0a0": 185, "\uc598": 498, "\ub4e3": 545, "\ub78d": 806, "\uc878": 654, "\uc5b8": 262, "\ub458": 440, "\uba38": 205, "\uc2f6": 368, "\ud608": 734, "\ub420": 334, "\uc2ed": 500, "\ubc24": 451, "\u25b2": 744, "\ub140": 202, "\ucc45": 263, "\ucd0c": 629, "\ub0ae": 608, "\uc625": 551, "\ub099": 617, "\ub044": 590, "\ud0d5": 620, "\uca4d": 773, "\uc313": 796, "\uc2f8": 493, "v": 956, "e": 389, "\ubd09": 450, "\ucef5": 801, "\uc5cc": 1043, "\uce89": 1985, "\ucd1d": 345, "\ub7b5": 697, "\ud639": 495, "\uba39": 339, "\ub2cc": 461, "?": 171, "\ud734": 621, "\ub5a0": 353, "\ubc00": 403, "\ucc29": 476, "\uce90": 763, "\uc7a1": 331, "\uc288": 779, "\ud0d0": 768, "\uba48": 798, "\ucd98": 657, "\ub048": 739, "\ubcfc": 404, "\uc5c9": 712, "\ub6b1": 823, "\uc775": 489, "\ub17c": 420, "\ub790": 536, "\ud29c": 1179, "\ubcbd": 503, "\ub52a": 988, "\uce20": 665, "\uce59": 623, "\ucabd": 337, "\ud070": 387, "\ub807": 232, "\ub09a": 1030, "\ucf1c": 458, "\uafbc": 728, "\uc2ef": 1513, "\ubea8": 1164, "\ubc11": 669, "\ud718": 612, "\uaf3c": 977, "\uc9dd": 559, "\uaff0": 1167, "\ucc2c": 445, "\ud640": 698, "\ud5e4": 600, "\uc3e0": 1280, "\uc6b1": 492, "\ub04a": 691, "\ucfe0": 765, "\ube45": 1263, "\ub04c": 521, "\ub904": 858, "\uc5fc": 526, "\uac77": 789, "\uc26c": 599, "\uce35": 523, "\ube48": 594, "\ub9d8": 1068, "\ube7c": 661, "\ud480": 466, "\uc2b9": 344, "\ub3d5": 1039, "\uadf9": 324, "\ud3f4": 911, "\uafd4": 968, "\uc5d1": 1194, "\uc139": 1075, "\ub193": 303, "\uc635": 1133, "\ubb18": 627, "\ub527": 1930, "\ub6f0": 564, "\ub2f7": 884, "\uc595": 1645, "\uc22b": 926, "\uafb8": 424, "\uac81": 631, "\uc9dc": 522, "\ub9e5": 668, "\ub369": 723, "\ubf08": 940, "\ub7ab": 787, "\ub5c4": 1884, "\uc2ac": 496, "\ud6e4": 1359, "\uc2eb": 749, "\uc80a": 614, "\ub5a4": 414, "\uc5c7": 453, "\u339c": 1497, "\ub8e9": 812, "\ubb50": 557, "\ub764": 1294, "\uc880": 491, "\uc529": 509, "\ud3a0": 1142, "\uc989": 568, "\ub0ad": 785, "\uc820": 737, "\ud138": 694, "\uba87": 438, "\ubb3b": 587, "\ub3c8": 422, "\ub73b": 457, "\ub2d9": 952, "\uc78a": 703, "\uc5bd": 1076, "\ub2d8": 315, "\ubc2d": 725, "\uc61b": 658, "\ub355": 452, "\uace7": 512, "Y": 1064, "\uc27c": 1747, "\uba3c": 459, "\ub2eb": 764, "\ub5bb": 462, "\ucf5c": 842, "\ube60": 385, "\uacaa": 776, "\uc8e0": 607, "\uc783": 676, "\ub20c": 877, "\ub7a8": 660, "\uc228": 484, "V": 682, "\uc5b5": 340, "\uc148": 718, "\ud3f0": 1066, "\ud2bc": 747, "\uc9f8": 441, "\u321c": 1661, "\ud399": 1874, "\ud050": 1108, "\ucbe4": 584, "\uce7c": 689, "\uc370": 1219, "\uacbc": 644, "\uc11e": 881, "\ube75": 986, "\ubd90": 1245, "\uba4b": 841, "\ub550": 989, "\ucd2c": 974, "\ud321": 1224, "\uace1": 515, "\ubd04": 743, "\ub00c": 850, "\ub4dd": 425, "\uce21": 455, "\uc641": 1849, "\uaec4": 1190, "\ub05d": 382, "\ub8e1": 1037, "\ubb54": 814, "\uc6c3": 418, "\uae5d": 992, "\uaef4": 702, "\ub784": 849, "\ucd95": 377, "\uacf1": 865, "\ucc0c": 574, "\ub69d": 834, "\uc88c": 589, "\ub9e1": 592, "\ud758": 537, "\uce75": 1421, "\ub9ad": 922, "\uc96c": 1817, "\ub518": 961, "\ub123": 598, "\uc1c4": 780, "\ub0c8": 555, "\ube5a": 816, "\ud5cc": 575, "\ucc0d": 615, "\uc12f": 722, "\ud587": 825, "\ud6cc": 846, "\ub96d": 916, "\ucc1c": 1495, "\uc918": 866, "\ub2ed": 729, "\uac40": 1442, "\ud2c8": 811, "\uc655": 479, "\ud034": 933, "\ub0b3": 755, "\ud551": 844, "\ud749": 863, "\ub835": 583, "\ub86d": 605, "\ub538": 641, "\ud601": 478, "\ub728": 516, "\uc639": 937, "\uc728": 511, "\ubaab": 996, "=": 650, "\ub8b0": 833, "\ub0e5": 577, "\ubc1f": 899, "\ub2a6": 670, "\ub8f9": 738, "\ub4b7": 683, "\ubb35": 664, "\uc0ad": 835, "\uc05c": 767, "\ub2e5": 528, "\uae5c": 874, "\uafc8": 571, "\ubf40": 1278, "\ucca8": 854, "\ud750": 566, "\ubc38": 1610, "\ubd89": 799, "\ubeec": 1856, "\ub545": 502, "\ub8f8": 1290, "\ud790": 868, "\ub960": 653, "\uc3d8": 972, "\uc634": 1327, "\uc12c": 666, "\uc149": 1562, "\ucd09": 634, "\ub0a9": 701, "\ucce4": 561, "\ubab0": 426, "\uc74d": 791, "\uae43": 878, "\ub72c": 1050, "g": 581, "\uc78e": 817, "\u00b7": 197, "\uc7a3": 1101, "\uc1a5": 1307, "\ub987": 667, "\ubc25": 602, "\u2113": 1879, "\uafc0": 1024, "\uc465": 905, "\ub378": 867, "\uae65": 1025, "\ubca8": 837, "\u25c7": 1019, "\ud401": 1880, "\ud759": 875, "\uc22f": 1713, "\ucda4": 762, "\ub5bc": 756, "\ub531": 748, "\uad73": 774, "\ud478": 630, "\ub2e6": 914, "\ubdd4": 1229, "\uc308": 1503, "\uc300": 771, "\uce78": 908, "\uafe9": 1720, "H": 931, "\ubbff": 567, "B": 632, "\ub4c0": 1317, "\uce98": 1479, "\uc62e": 699, "\ud32c": 1014, "\uc2e3": 1209, "\ucf30": 704, "\uae4d": 1347, "\ub8ec": 979, "\uad81": 556, "\uac31": 1109, "\uac71": 693, "\ub918": 1539, "\ud134": 745, "\ud5ec": 1126, "\uc5ff": 1020, "\uce69": 1299, "\uc796": 680, "\ub301": 923, "\ud1f4": 585, "\uc464": 1072, "\ud649": 1127, "\uaed1": 1265, "\ucf13": 1137, "\ud61c": 524, "\uc3df": 786, "\ub0b1": 1061, "\ub9bf": 784, "\ucdc4": 1286, "\uc3d9": 1887, "\ud0c4": 488, "\uc816": 753, "\ub871": 848, "\ub744": 895, "\ubd10": 548, "\ub797": 1156, "\ub7f4": 647, "\ube5b": 486, "\ud0d1": 920, "\ubbac": 1823, "\ud5dd": 1314, "\ube80": 1635, "\ub3cb": 912, "\uc0d0": 1482, "\ub0c4": 758, "\ub053": 982, "t": 473, "\ub95c": 1134, "\uacfd": 1001, "\uc30d": 775, "\u25cb": 966, "\ub529": 948, "\uad04": 1000, "\ud720": 1641, "\ud131": 887, "\uac07": 1135, "\ucea0": 1028, "\ub77d": 363, "\ub284": 1355, "\ub258": 1089, "\uaf3d": 883, "\ubccd": 1073, "\uc98c": 1079, "\ucfe8": 1349, "\ub7ad": 1105, "\ud391": 1378, "\ub155": 950, "\ubfcc": 684, "\ucca9": 901, "\ucd18": 1646, "\ud33d": 900, "\ub194": 1207, "\uc606": 637, "\ub2d0": 610, "\ube7d": 1368, "\uafe8": 1637, "\ud6a1": 1003, "\ub46c": 1177, "\uc6e0": 529, "\ub760": 904, "\u33a1": 1931, "\uaecd": 1031, "\ud074": 628, "\uc20d": 1632, "\uce60": 504, "\ub291": 1273, "\ub9c1": 981, "\ud0b4": 1354, "\ub730": 1067, "\uc194": 720, "\ucd1b": 1386, "\ubcb3": 1850, "\uc9e0": 1583, "\ub1a8": 1446, "\ub08c": 675, "\ubcd5": 1088, "\ub7ed": 804, "\ubed0": 1038, "\uae0d": 873, "\ucffc": 1433, "\uc1e0": 746, "\u2015": 1383, "\u2192": 1271, "\ubd24": 781, "\uc789": 967, "\uc140": 1063, "\ub12c": 1728, "\ub51b": 1420, "\uccbc": 1590, "\ub2ee": 1080, "\uc068": 999, "\uada4": 1166, "\ub35f": 1227, "\uba78": 805, "I": 648, "\ub834": 943, "\uc557": 828, "\ub054": 672, "\ub461": 1284, "\ud1a4": 946, "\ud6fc": 1081, "\uc22d": 819, "\uc735": 603, "&": 1399, "\ucc3c": 1324, "\ud380": 1131, "\uc37d": 1255, "\ub800": 606, "\ubed4": 909, "\ub989": 1006, "\uc19f": 894, "\ud0ac": 719, "\uacb8": 864, "<": 413, ">": 411, "\uc92c": 1011, "\uce6d": 706, "\ub428": 941, "\ud15c": 906, "\ub364": 836, "\uc580": 907, "\ud0d3": 832, "\uac1a": 1149, "\ub738": 1099, "\ub6f8": 1818, "\ub6f4": 1881, "\ubd95": 845, "\ud384": 1107, "\uc4f4": 695, "\ub818": 1315, "\ub959": 980, "p": 686, "\ud751": 826, "\uc549": 427, "\uc0bd": 1046, "\ub4ed": 859, "\uc123": 1529, "\ub9fa": 855, "\uba58": 971, "\ud610": 760, "\uad1c": 872, "\uaf2c": 656, "\ub0c9": 713, "\u318d": 1592, "\ud5d0": 953, "\uc568": 1217, "\uce84": 958, "\ub86c": 1118, "\ubc45": 1087, "\uc81d": 1373, "i": 428, "d": 636, "o": 347, "a": 393, "n": 388, "h": 517, "\ud39c": 991, "\ucef8": 1176, "b": 869, "\ucc59": 934, "\ub367": 821, "\uc65c": 439, "\ud56b": 1932, "\ub9f4": 1237, "\uae0b": 847, "\uc7a6": 1181, "\ub801": 717, "Z": 1651, "\ub2ff": 885, "\ud5e8": 1267, "\ucf08": 1447, "\ube10": 1480, "\uc2a8": 468, "\ubd05": 1155, "\uc653": 1867, "\ubd93": 1041, "\ud47c": 1032, "\ud54d": 1330, "\uaf34": 843, "\ub3d7": 1501, "c": 447, "\ubba4": 1069, "\ub864": 1130, "\ub799": 1301, "\ud14d": 1139, "\ub010": 1270, "\ubc0d": 1246, "\ud0e0": 1374, "\uc9d9": 1016, "\ubb36": 917, "\uaf80": 1152, "\ubbf9": 1619, "\u25cf": 1606, "\ubc99": 1160, "\ud2f8": 1418, "\ub93c": 1699, "\uc0cc": 1222, "\ud69f": 1412, "\ubdf0": 1034, "\uad49": 1242, "\ub4ec": 705, "\uca0c": 903, ":": 579, "\ud22d": 1104, "\uc0f9": 1751, "\uca4c": 707, "\uc813": 1004, "\ub154": 929, "\uc0c0": 1274, "\ub7ac": 735, "\ud230": 1762, "\uc060": 1674, "\ud5db": 1013, "\uae50": 852, "\uaf64": 975, "\uba4d": 730, "\ub304": 1055, "\ub10b": 1244, "\ubb47": 853, "\ucc2e": 793, "\ub084": 954, "\ubaac": 1053, "\ub748": 1652, "\ub0a1": 1054, "\uc170": 1258, "\uac13": 984, "\uc708": 1241, "\ud584": 1232, "\uc369": 860, "\ub314": 949, "\ub5b4": 1192, "\uaf08": 856, "\ub5b3": 1212, "\uba67": 1721, "s": 482, "k": 626, "\uc9e4": 1410, "\uba5c": 1173, "\uc9d6": 1029, "\ud769": 1059, "\ud0f1": 1112, "\uc232": 870, "\ubcd0": 1834, "\ucad3": 788, "\ud54f": 962, "\uc136": 1804, "\uc5ee": 1264, "\ub0af": 822, "\uc2f9": 932, "\ud0e4": 1338, "\ud514": 827, "\uadd3": 1256, "\uc14b": 857, "\uc7bf": 1515, "\ub2a0": 1304, "\ubc85": 918, "\uc90d": 1186, "l": 558, "\uc77d": 544, "\ub9d1": 892, "\uc231": 1310, "\ud280": 960, "\ub6ab": 928, "\uc5ca": 1676, "\ud37d": 1281, "\ud729": 1110, "\uc633": 896, "\uc717": 1040, "\uc950": 731, "\uc53b": 944, "\ub729": 888, "\uc90c": 902, "\ud508": 809, "\ucb50": 1955, "\uac38": 1261, "\ube57": 876, "\ubc0b": 1540, "\ub310": 1170, "\uc610": 1214, "\ub7ff": 1392, "\uce94": 1143, "\ud320": 1302, "\uca54": 893, "\ud1b1": 891, "\uae01": 1262, "\uc501": 1521, "\ucfc4": 1225, "\ub72f": 997, "\ud145": 1121, "r": 449, "f": 879, "\ub8f0": 1144, "\ubb63": 1320, "u": 596, "j": 965, "\ub8fb": 1168, "\ubd07": 1382, "\ub07d": 1733, "\uaf41": 1094, "\uac2f": 1102, "\ud241": 936, "\uc954": 1404, "\uc67c": 898, "\ucc14": 1015, "\uc3dc": 1690, "\ucf67": 1174, "\uafc7": 1283, "\ub560": 1905, "!": 460, "\uc0db": 1581, "y": 752, "\uc0f4": 1578, "\ubab9": 942, "\ub9f5": 1782, "\uce30": 1146, "\uc70c": 1182, "\ub315": 1247, "\ub51c": 957, "\ud2f4": 1083, "\ubc49": 1097, "\uad82": 1370, "\uae4e": 1070, "\uc168": 530, "\uacc1": 839, "\uaebe": 1051, "\uc274": 1215, "\uc2a5": 1835, "\uad76": 1119, "\ub540": 889, "\ub4b9": 1389, "\ud23c": 1205, "\ub289": 1342, "\uc500": 709, "\uc553": 1048, "\u25b6": 1027, "\ub985": 1056, "\ub9d9": 1057, "\ub214": 1506, "\ub480": 1422, "\ud683": 1801, "\uad7f": 915, "\uc50c": 1049, "\ub188": 591, "\uc584": 1448, "\ud30d": 1187, "\uba71": 1527, "\ud0d4": 1195, "\ud6d4": 1021, "\ubc09": 1615, "\ube8f": 1498, "\uc4f1": 1434, "\uc660": 1189, "\ubfb0": 1395, "\ubc40": 1132, "\uaf49": 1161, "\ud31d": 1524, "\ud6d1": 1296, "\uca50": 1171, "\uae6c": 1617, "\ucff5": 1253, "\uad18": 1451, "\uc538": 1956, "\ub429": 1023, "\ub365": 1411, "\ubb44": 1550, "\ub137": 710, "\ub6a4": 1591, "\ud141": 1683, "\uc0c5": 1371, "\ub0ab": 1086, "\ub10c": 830, "\ub78f": 1563, "\ud48b": 1216, "\ub7b4": 1012, "\ub460": 802, "\uc19c": 1044, "\ubed1": 1413, "\uaecc": 1471, "\ub138": 1707, "\ub2f3": 1665, "\ub38c": 1365, "\uc090": 964, "\uc58c": 1475, "\uc5ce": 1010, "\uc648": 1306, "\ubb49": 995, "\ub308": 1272, "\ub014": 1657, "\uc0bf": 1213, "\uc6ec": 882, "\uc30c": 1653, "\ub2db": 1888, "\ud578": 1200, "\uba64": 1535, "\ub1e8": 1223, "\uc9ec": 1780, "\uad75": 1093, "\uc7a4": 1364, "\ubed7": 1002, "\ucc58": 1827, "w": 818, "\ud1a1": 1203, "\ub385": 1701, "\ucef7": 1162, "\ucf24": 1743, "\uc539": 1122, "\uacf0": 978, "\ub975": 1248, "\uac94": 1335, "\ubc43": 998, "\ud0c9": 1842, "\uc575": 1157, "\uc7ad": 1362, "\ucc54": 1593, "\uae61": 1090, "\ud2bf": 1220, "\ud1b0": 1435, "~": 1180, "\ud1a8": 1022, "\ud2cb": 1889, "\ud6d7": 1461, "\uc2ad": 1536, "\ubfdc": 1178, "\ucea1": 1906, "\uc290": 1625, "\uc270": 1439, "\ub215": 1339, "\uc597": 1183, "\ucda7": 1857, "\uc178": 1715, "\uc5e5": 1757, "\ub625": 945, "\ub7a9": 1457, "\uac84": 1366, "\uc73d": 1082, "\ud234": 1460, "\ub9cf": 1522, "\ubfd4": 1221, "\uc887": 1576, "\ub618": 1169, "\ubb58": 927, "\uc9f1": 1163, "\ub313": 1344, "\ubee3": 1633, "\uccb8": 1805, "\uc587": 1462, "\u00d7": 1312, "\ubc9a": 1478, "\ub205": 1444, "\ubfcd": 1851, "\uc607": 1526, "\ubed8": 1375, "\uac8b": 1708, "\ucb49": 1123, "\u3131": 1463, "\ube54": 1875, "\ucf65": 1975, "\ubcf6": 1472, "\ucda5": 1486, "\uc21f": 1390, "\ud3c8": 1210, "\ub810": 1424, "\ucb48": 1145, "\ub3d4": 1554, "\uc5e3": 1499, "\u2460": 1303, "\u2462": 1417, "\u2463": 1659, "\u2461": 1321, "\ucb10": 1702, "\uc379": 1260, "\uc82f": 1268, "\ud479": 1138, "\ud143": 1601, "\ucfe1": 1758, "\uafcb": 1611, "\uc9da": 955, "\ub299": 862, "\uad88": 1764, "\uac1b": 1488, "\ud31c": 1642, "\ub059": 1647, "\ub754": 1734, "\ub9e3": 1300, "\u2464": 1890, "\ub0c7": 1376, "\ub968": 1793, "q": 1722, "\ub9f7": 1858, "\uc719": 1623, "\ucabc": 1065, "\uc90f": 1658, "x": 1316, "\ucf20": 1557, "\ud3fc": 1295, "+": 1398, "\ucc48": 1636, "\ub380": 1968, "\ub158": 1257, "\ud3ad": 1824, "\uadc4": 1654, "\uacf6": 1940, "\ubafc": 1863, "\ucf55": 1571, "\uaf3f": 1489, "z": 1388, "\u33ca": 1838, "\ub2aa": 1703, "\uceeb": 1819, "\ubc27": 1716, "\uba4e": 1487, "\ud0ec": 1891, "\ucc10": 1666, "\uad90": 1201, "\ucf04": 1809, "\uac85": 1776, "\u25ce": 924, "\ubf1b": 1700, "\uc5f7": 1620, "\ub234": 1911, "\ud168": 1852, ";": 1124, "\uff5e": 573, "\u300e": 624, "\u300f": 619, "\u5316": 1071, "\u570b": 890, "\u300c": 434, "\u300d": 433, "\u653f": 1047, "\u8ca1": 1494, "\ub36b": 1820, "\u8eab": 1618, "\u8ecd": 1318, "\u7523": 1208, "\u81f3": 1958, "\u9ad8": 1325, "\u5584": 1428, "\u81ea": 1196, "\u71df": 1814, "\u8005": 1129, "\u6c34": 1275, "\u6e96": 1726, "\u4e0d": 1017, "\u53ef": 1924, "\u591a": 1767, "\u6d88": 1744, "\u8cbb": 1555, "\u7368": 1843, "\u8207": 1745, "\u5b98": 1322, "\u6b0a": 1340, "\u8ad6": 1236, "\u65b0": 1282, "\u820a": 1917, "\u5f0f": 1514, "\u5148": 1543, "\u5f8c": 1735, "\u5f97": 1885, "\u9ee8": 1254, "\u65cf": 1525, "\u696d": 1098, "\u5831": 1381, "\u6b63": 1008, "\u53f2": 1350, "\u7f8e": 1128, "\u4e2d": 1036, "\u53cd": 1491, "\u91d1": 716, "\u5927": 959, "\u7532": 1903, "\u7269": 1211, "\u4e3b": 1106, "\u5ddd": 1465, "\u5236": 1331, "\ub55c": 1815, "\u6c11": 1092, "\u5fc3": 1204, "\u8981": 1572, "\u8eca": 1907, "\u8def": 1752, "\u4e0a": 1184, "\u7b56": 1643, "\ub9f8": 1941, "\u5f15": 1959, "\u53d7": 1731, "\u524d": 1452, "\u4ee3": 1336, "\u50f9": 1202, "\u6027": 1018, "\u738b": 1385, "\u671d": 1476, "\u7684": 938, "\u5931": 1853, "\u9ad4": 1313, "\u7236": 1602, "\u5b50": 1111, "\u4ef6": 1821, "\u76ca": 1925, "\u6709": 1508, "\u5229": 1401, "\u4fe1": 1288, "\u5ea6": 1443, "\u6536": 1416, "\u660e": 1297, "@": 677, "\u25c6": 1259, "\u25c8": 1648, "\uc384": 1033, "\u2605": 1868, "\u25a0": 1234, "\uc6f9": 1357, "\u9280": 1584, "\u91cd": 1588, "\u89aa": 1662, "\uc6f0": 1541, "\u25bd": 1218, "\u25b7": 1781, "*": 1078, "\u5e02": 1387, "\ucee5": 1240, "\u97d3": 1140, "\u6295": 1445, "\u6cf0": 1753, "Q": 1765, "\u793e": 1291, "\u82f1": 1789, "\u8cc7": 1147, "\u65e5": 1009, "#": 1490, "\u3010": 1431, "\u3011": 1436, "\u4eba": 897, "\u7a7a": 1746, "\uc9ca": 1565, "\u3145": 1768, "\u5317": 1228, "\u751f": 1062, "\u6b7b": 1502, "\ucbd4": 1969, "\u56db": 1560, "\u5408": 1474, "\u9662": 1696, "\u79c1": 1544, "\uc5fe": 1577, "\u674e": 947, "\u4fdd": 1585, "\uaebd": 1511, "\u5e74": 1467, "\ubf50": 1828, "\u6545": 1986, "\u912d": 1276, "\u5357": 1238, "\ube74": 1473, "\u8349": 1596, "\ucc21": 1367, "\u6797": 1582, "\ud613": 1629, "\u521d": 1912, "\u52d5": 1279, "\u5100": 1829, "\u6708": 1566, "\u77f3": 1468, "\ub515": 1624, "\u6230": 1397, "\u679c": 1693, "\u8a71": 1737, "\uc74a": 1469, "\u5225": 1481, "\u9115": 1748, "\u5916": 1091, "\u57ce": 1516, "\u795e": 1060, "\ucc27": 1672, "\u541b": 1783, "\u534a": 1895, "\u5c0f": 1326, "\u5e73": 1429, "\u8d99": 1684, "\u967d": 1607, "\u767d": 1405, "\u624b": 1749, "\u6bdb": 1687, "\u6fa4": 1926, "\u6771": 1120, "\u5fb7": 1458, "\u6d77": 1348, "\u83ef": 1372, "\u7acb": 1573, "\u654e": 1287, "\u540c": 1380, "\u4eac": 1437, "\u6700": 1976, "\u53e4": 1532, "\uae41": 1531, "\u6703": 1136, "\ube61": 1369, "\u8072": 1844, "\u8cea": 1704, "\u540d": 1500, "\u6a02": 1784, "\u6b4c": 1839, "\u7121": 1249, "\u7232": 1717, "\u56e0": 1896, "\u5c71": 1077, "\u6df8": 1604, "\u4e16": 1305, "\u722d": 1942, "\u6578": 1545, "\u9999": 1913, "\u548c": 1453, "\u6cd5": 1226, "\u9032": 1630, "\u79aa": 1943, "\u4e00": 1100, "\u5dde": 1430, "\u611f": 1594, "\u6c23": 1193, "\u8a69": 1311, "\u96c6": 1732, "\u4e94": 1534, "\u60e1": 1759, "\u958b": 1586, "\u82b1": 1609, "\u9f8d": 1450, "\u982d": 1766, "\u5bfa": 1825, "\u796d": 1377, "\u8056": 1484, "\u6bcd": 1533, "\u50cf": 1845, "\u8655": 1882, "\u60c5": 1391, "\u5149": 1567, "\u96f2": 1869, "\u539f": 1393, "\u5929": 1250, "\u9bae": 1729, "\u4e4b": 1323, "\u8f49": 1854, "\u7cbe": 1769, "\uc29b": 1556, "\u4ec1": 1548, "\u9593": 1409, "\ud0a5": 1677, "\u7d19": 1919, "\u6750": 1794, "\u8a18": 1517, "\u5143": 1492, "\u516c": 1239, "\u667a": 1897, "\u5171": 1328, "\u89c0": 1512, "\u7528": 1353, "\u5cf6": 1770, "\uba69": 1589, "\u5b97": 1454, "\u9ec3": 1680, "\u53f8": 1771, "\u76f8": 1337, "\u73fe": 1709, "\u6848": 1876, "\u6d41": 1546, "\u529b": 1277, "\u9762": 1485, "\u547d": 1631, "\u7570": 1681, "\u8b70": 1688, "\u5f9e": 1568, "\u6cb3": 1440, "\u5bb6": 1191, "\u9996": 1898, "\u54f2": 1723, "\u5728": 1449, "\u6c38": 1598, "\uafb9": 1230, "\u53e3": 1840, "\u52a0": 1725, "\ud5c9": 1682, "\ub561": 1419, "\u79d1": 1864, "\u7389": 1949, "\u689d": 1987, "\u8a00": 1406, "\u6751": 1836, "\u592b": 1612, "\u5a66": 1927, "\u5f35": 1151, "\u660c": 1830, "\u767c": 1574, "\u5d14": 1551, "\u6210": 1285, "\u5951": 1810, "\ubccf": 1831, "\u897f": 1407, "\u5c0d": 1188, "\u6734": 1197, "\u5b9a": 1269, "\u5bb9": 1738, "\u7fa9": 1206, "\u5168": 1332, "\u7165": 1621, "\u76e7": 1252, "\u4e5d": 1933, "\u4e8b": 1153, "\u5b89": 1243, "\u6a21": 1892, "\u690d": 1977, "\u4ee5": 1920, "\u4f5c": 1542, "\u767e": 1870, "\u6d0b": 1859, "\u826f": 1841, "\u6d2a": 1772, "\u75c5": 1944, "\u5468": 1660, "\u5de5": 1678, "\ud295": 1978, "\u9577": 1233, "\u7d93": 1175, "\u6e90": 1396, "\u5175": 1846, "\u706b": 1667, "\u9751": 1691, "\u6d1e": 1595, "\u5973": 1400, "\u8a9e": 1363, "\u5167": 1293, "\u6c5f": 1552, "\u672c": 1198, "\u7530": 1553, "\u5409": 1822, "\u7956": 1518, "\u8ca8": 1414, "\u5730": 1199, "\u7bc0": 1802, "\u7a05": 1811, "\u7199": 1934, "\u5c39": 1877, "\u884c": 1141, "\u8ce3": 1832, "\u975e": 1394, "\u7406": 1115, "\u58fd": 1928, "\u77e5": 1464, "\u5df1": 1798, "\u5834": 1441, "\u518d": 1785, "\u7576": 1960, "\u9806": 1945, "\u9053": 1150, "\u4e09": 1158, "\u55aa": 1710, "\u5be6": 1298, "\u8f38": 1415, "\u5165": 1333, "\ub463": 1739, "\u98df": 1575, "\u671f": 1628, "\u51fa": 1289, "\u63db": 1786, "\u5b6b": 1697, "\u6d3b": 1795, "\u5e38": 1587, "\u6fdf": 1402, "\u592a": 1638, "\u98a8": 1558, "\u901a": 1425, "\u7d42": 1921, "\u4e8c": 1871, "\u9700": 1803, "\u8272": 1694, "\uc3f4": 1922, "\u6280": 1886, "\u7f85": 1787, "\u58eb": 1483, "\u771e": 1724, "\u99ac": 1561, "\u6625": 1673, "\ud6c5": 1899, "\uc7bd": 1664, "\ubee4": 1649, "\ubd48": 1403, "\u91ab": 1799, "\u57fa": 1530, "\u898f": 1736, "\u6642": 1319, "\u5e1d": 1970, "\u8fad": 1961, "\uca0d": 1847, "\u6cf3": 1979, "\u7dda": 1865, "\uc1f3": 1935, "\ucf85": 1714, "\ub0d8": 1988, "\uc9e2": 1929, "\ube64": 1231, "\ubd59": 1616, "\ub15c": 1564, "\uaf5d": 1455, "\ud719": 1579, "\ub11b": 1971, "\u25b3": 651, "\ubf55": 1613, "\u6240": 1605, "\u5747": 1972, "\u5343": 1962, "\u52e2": 1914, "\u5fe0": 1893, "\u6cbb": 1351, "\u4ea4": 1655, "\u8001": 1663, "\u5bcc": 1900, "\u91ce": 1669, "\u80fd": 1639, "\u7d66": 1872, "\u6839": 1848, "\u6587": 1045, "\u4f86": 1730, "\u90e8": 1432, "\u76f4": 1675, "\u7701": 1773, "\u5e9c": 1496, "\u6557": 1456, "\u6728": 1599, "\u9580": 1309, "\u25bc": 1519, "\u6f22": 1504, "\u610f": 1360, "\u4fd7": 1816, "\u571f": 1640, "\u842c": 1718, "\u300a": 983, "\u300b": 987, "\u8b8a": 1740, "\u5efa": 1855, "\u8aaa": 1547, "\u754c": 1670, "\u4f5b": 1600, "\u79ae": 1235, "\u60f3": 1689, "\u54c1": 1423, "\u66f8": 1341, "\u5bae": 1833, "\u601d": 1650, "\u7387": 1470, "\u8ce2": 1908, "\u4e0b": 1334, "\u6613": 1980, "\u4f01": 1754, "\u4fca": 1626, "\u5f90": 1790, "\u5b78": 1074, "\u5b5d": 1936, "\u6b66": 1569, "\u904b": 1668, "\u661f": 1915, "\u4fee": 1788, "\u8c61": 1777, "\u5546": 1509, "\u65b9": 1466, "\u50b3": 1570, "\u4f7f": 1763, "\u5f8b": 1909, "\u5fd7": 1812, "\u798f": 1837, "\u5f62": 1796, "\u97f3": 1950, "\u3147": 1806, "\u8853": 1826, "\u88fd": 1910, "\uac54": 1614, "\u5802": 1711, "\u4e9e": 1705, "\u90fd": 1597, "\u91cc": 1580, "\u95dc": 1426, "\u666f": 1791, "\ucef9": 1774, "\u8abf": 1603, "\u80b2": 1946, "\u5668": 1989, "\u52d9": 1741, "\ubbc4": 1384, "\u5b58": 1951, "\u544a": 1952, "\u554f": 1778, "\u984c": 1904, "\u6c0f": 1963, "\u8863": 1860, "\u5b57": 1634, "\u8607": 1947, "\u683c": 1538, "\u5206": 1520, "\uac17": 1727, "\uc1e4": 1493, "\u611b": 1953, "\u4f4d": 1656, "\u5411": 1685, "\u578b": 1686, "\u677e": 1981, "\u226b": 1861, "\ud6d9": 1510, "\u6a5f": 1343, "\u7e3d": 1894, "\ud565": 1507, "\ubb61": 1695, "\uba53": 1883, "{": 639, "}": 640, "[": 472, "]": 475, "\u00ad": 1125, "\uc42c": 1973, "\ubbd0": 1982, "\u652f": 1308, "\u54e1": 1692, "\u8a2d": 1775, "\u985e": 1807, "\u7cfb": 1937, "\u7d71": 1698, "\u6307": 1862, "\u91cf": 1813, "\u8996": 1797, "\u9748": 1679, "\u9020": 1559, "\u89e3": 1974, "\u8a08": 1712, "\u8fb2": 1627, "\u5104": 1537, "\u9769": 1671, "\u8b58": 1706, "\u6539": 1644, "\u5ff5": 1990, "\u76e3": 1779, "\u6d3e": 1755, "\u8868": 1916, "\u76ee": 1622, "\u4ed6": 1878, "\u8b49": 1954, "\u50b5": 1800, "\u878d": 1356, "\u90e1": 1760, "\u8239": 1719, "\u85e5": 1964, "\u8003": 1948, "\u670d": 1761, "\u5e2b": 1991, "\u69cb": 1750, "\u8150": 1505, "\u81e3": 1866, "\ub091": 1938, "|": 1251, "\uc7dd": 1459, "\uc0af": 1939, "\u56de": 1923, "\u79fb": 1918, "\u5176": 1957, "\u3014": 1358, "\u3015": 1361, "\u2500": 742, "\uff0d": 1528, "\u63a5": 1792, "\u5144": 1965, "\ucbe7": 1901, "\ube73": 1742, "\u226a": 1873, "\uc314": 1966, "\ub0d4": 1983, "_": 1808, "\u67d0": 1984, "__ETC__": 1992, "__PAD__": 1993} -------------------------------------------------------------------------------- /train.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | # Copyright 2020 Heewon Jeon. All rights reserved. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | import argparse 17 | import bz2 18 | import logging 19 | import re 20 | import time 21 | from functools import lru_cache 22 | from timeit import default_timer as timer 23 | 24 | import gluonnlp as nlp 25 | import mxnet as mx 26 | import mxnet.autograd as autograd 27 | import numpy as np 28 | from mxnet import gluon 29 | from mxnet.gluon import nn, rnn 30 | from tqdm import tqdm 31 | 32 | from utils.embedding_maker import (encoding_and_padding, load_embedding, 33 | load_vocab) 34 | 35 | logFormatter = logging.Formatter("%(asctime)s [%(threadName)-12.12s] [%(levelname)-5.5s] %(message)s") 36 | logger = logging.getLogger() 37 | 38 | parser = argparse.ArgumentParser(description='Korean Autospacing Trainer') 39 | parser.add_argument('--num-epoch', 40 | type=int, 41 | default=5, 42 | help='number of iterations to train (default: 5)') 43 | 44 | parser.add_argument('--n-hidden', 45 | type=int, 46 | default=200, 47 | help='GRU hidden size (default: 200)') 48 | 49 | parser.add_argument('--max-seq-len', 50 | type=int, 51 | default=200, 52 | help='max sentence length on input (default: 200)') 53 | 54 | parser.add_argument('--num-gpus', 55 | type=int, 56 | default=1, 57 | help='number of gpus (default: 1)') 58 | 59 | parser.add_argument('--vocab-file', 60 | type=str, 61 | default='model/w2idx.dic', 62 | help='vocabarary file (default: model/w2idx.dic)') 63 | 64 | parser.add_argument( 65 | '--embedding-file', 66 | type=str, 67 | default='model/kospacing_wv.np', 68 | help='embedding matrix file (default: model/kospacing_wv.np)') 69 | 70 | parser.add_argument('--train', 71 | action='store_true', 72 | default=False, 73 | help='do trainig (default: False)') 74 | 75 | parser.add_argument( 76 | '--model-file', 77 | type=str, 78 | default='kospacing_wv.mdl', 79 | help='output object from Word2Vec() (default: kospacing_wv.mdl)') 80 | 81 | parser.add_argument('--train-samp-ratio', 82 | type=float, 83 | default=0.50, 84 | help='random train sample ration (default: 0.50)') 85 | 86 | parser.add_argument('--model-prefix', 87 | type=str, 88 | default='kospacing', 89 | help='prefix of output model file (default: kospacing)') 90 | 91 | parser.add_argument('--model-params', 92 | type=str, 93 | default='kospacing_0.params', 94 | help='model params file (default: kospacing_0.params)') 95 | 96 | parser.add_argument('--test', 97 | action='store_true', 98 | default=False, 99 | help='eval train set (default: False)') 100 | 101 | parser.add_argument('--batch_size', 102 | type=int, 103 | default=100, 104 | help='train batch size') 105 | 106 | parser.add_argument('--test_batch_size', 107 | type=int, 108 | default=100, 109 | help='test batch size') 110 | 111 | parser.add_argument('--n_workers', 112 | type=int, 113 | default=10, 114 | help='number of dataloader workers') 115 | 116 | parser.add_argument('--train_data', 117 | type=str, 118 | default='data/UCorpus_spacing_train.txt.bz2', 119 | help='bziped train data') 120 | 121 | parser.add_argument('--test_data', 122 | type=str, 123 | default='data/UCorpus_spacing_test.txt.bz2', 124 | help='bziped test data') 125 | 126 | parser.add_argument('--model_type', 127 | type=str, 128 | default='kospacing', 129 | help='kospacing or kospacing2') 130 | 131 | parser.add_argument('--outputs', 132 | type=str, 133 | default='outputs', 134 | help='directory to save log and model params') 135 | 136 | opt = parser.parse_args() 137 | 138 | nlp.utils.mkdir(opt.outputs) 139 | 140 | fileHandler = logging.FileHandler(opt.outputs + '/' + 'log.log') 141 | fileHandler.setFormatter(logFormatter) 142 | logger.addHandler(fileHandler) 143 | 144 | consoleHandler = logging.StreamHandler() 145 | consoleHandler.setFormatter(logFormatter) 146 | logger.addHandler(consoleHandler) 147 | 148 | logger.setLevel(logging.DEBUG) 149 | logger.info(opt) 150 | 151 | GPU_COUNT = opt.num_gpus 152 | ctx = [mx.gpu(i) for i in range(GPU_COUNT)] 153 | 154 | 155 | # Model class 156 | class korean_autospacing_base(gluon.HybridBlock): 157 | def __init__(self, n_hidden, vocab_size, embed_dim, max_seq_length, 158 | **kwargs): 159 | super(korean_autospacing_base, self).__init__(**kwargs) 160 | # 입력 시퀀스 길이 161 | self.in_seq_len = max_seq_length 162 | # 출력 시퀀스 길이 163 | self.out_seq_len = max_seq_length 164 | # GRU의 hidden 개수 165 | self.n_hidden = n_hidden 166 | # 고유문자개수 167 | self.vocab_size = vocab_size 168 | # max_seq_length 169 | self.max_seq_length = max_seq_length 170 | # 임베딩 차원수 171 | self.embed_dim = embed_dim 172 | 173 | with self.name_scope(): 174 | self.embedding = nn.Embedding(input_dim=self.vocab_size, 175 | output_dim=self.embed_dim) 176 | 177 | self.conv_unigram = nn.Conv2D(channels=128, 178 | kernel_size=(1, self.embed_dim)) 179 | 180 | self.conv_bigram = nn.Conv2D(channels=256, 181 | kernel_size=(2, self.embed_dim), 182 | padding=(1, 0)) 183 | 184 | self.conv_trigram = nn.Conv2D(channels=128, 185 | kernel_size=(3, self.embed_dim), 186 | padding=(1, 0)) 187 | 188 | self.conv_forthgram = nn.Conv2D(channels=64, 189 | kernel_size=(4, self.embed_dim), 190 | padding=(2, 0)) 191 | 192 | self.conv_fifthgram = nn.Conv2D(channels=32, 193 | kernel_size=(5, self.embed_dim), 194 | padding=(2, 0)) 195 | 196 | self.bi_gru = rnn.GRU(hidden_size=self.n_hidden, layout='NTC', bidirectional=True) 197 | self.dense_sh = nn.Dense(100, activation='relu', flatten=False) 198 | self.dense = nn.Dense(1, activation='sigmoid', flatten=False) 199 | 200 | def hybrid_forward(self, F, inputs): 201 | embed = self.embedding(inputs) 202 | embed = F.expand_dims(embed, axis=1) 203 | unigram = self.conv_unigram(embed) 204 | bigram = self.conv_bigram(embed) 205 | trigram = self.conv_trigram(embed) 206 | forthgram = self.conv_forthgram(embed) 207 | fifthgram = self.conv_fifthgram(embed) 208 | 209 | grams = F.concat(unigram, 210 | F.slice_axis(bigram, 211 | axis=2, 212 | begin=0, 213 | end=self.max_seq_length), 214 | trigram, 215 | F.slice_axis(forthgram, 216 | axis=2, 217 | begin=0, 218 | end=self.max_seq_length), 219 | F.slice_axis(fifthgram, 220 | axis=2, 221 | begin=0, 222 | end=self.max_seq_length), 223 | dim=1) 224 | 225 | grams = F.transpose(grams, (0, 2, 3, 1)) 226 | grams = F.reshape(grams, (-1, self.max_seq_length, -3)) 227 | grams = self.bi_gru(grams) 228 | fc1 = self.dense_sh(grams) 229 | return (self.dense(fc1)) 230 | 231 | 232 | # https://raw.githubusercontent.com/haven-jeon/Train_KoSpacing/master/img/kosapcing_img.png 233 | class korean_autospacing2(gluon.HybridBlock): 234 | def __init__(self, n_hidden, vocab_size, embed_dim, max_seq_length, 235 | **kwargs): 236 | super(korean_autospacing2, self).__init__(**kwargs) 237 | # 입력 시퀀스 길이 238 | self.in_seq_len = max_seq_length 239 | # 출력 시퀀스 길이 240 | self.out_seq_len = max_seq_length 241 | # GRU의 hidden 개수 242 | self.n_hidden = n_hidden 243 | # 고유문자개수 244 | self.vocab_size = vocab_size 245 | # max_seq_length 246 | self.max_seq_length = max_seq_length 247 | # 임베딩 차원수 248 | self.embed_dim = embed_dim 249 | 250 | with self.name_scope(): 251 | self.embedding = nn.Embedding(input_dim=self.vocab_size, 252 | output_dim=self.embed_dim) 253 | 254 | self.conv_unigram = nn.Conv2D(channels=128, 255 | kernel_size=(1, self.embed_dim)) 256 | 257 | self.conv_bigram = nn.Conv2D(channels=128, 258 | kernel_size=(2, self.embed_dim), 259 | padding=(1, 0)) 260 | 261 | self.conv_trigram = nn.Conv2D(channels=64, 262 | kernel_size=(3, self.embed_dim), 263 | padding=(2, 0)) 264 | 265 | self.conv_forthgram = nn.Conv2D(channels=32, 266 | kernel_size=(4, self.embed_dim), 267 | padding=(3, 0)) 268 | 269 | self.conv_fifthgram = nn.Conv2D(channels=16, 270 | kernel_size=(5, self.embed_dim), 271 | padding=(4, 0)) 272 | # for reverse convolution 273 | self.conv_rev_bigram = nn.Conv2D(channels=128, 274 | kernel_size=(2, self.embed_dim), 275 | padding=(1, 0)) 276 | 277 | self.conv_rev_trigram = nn.Conv2D(channels=64, 278 | kernel_size=(3, self.embed_dim), 279 | padding=(2, 0)) 280 | 281 | self.conv_rev_forthgram = nn.Conv2D(channels=32, 282 | kernel_size=(4, 283 | self.embed_dim), 284 | padding=(3, 0)) 285 | 286 | self.conv_rev_fifthgram = nn.Conv2D(channels=16, 287 | kernel_size=(5, 288 | self.embed_dim), 289 | padding=(4, 0)) 290 | self.bi_gru = rnn.GRU(hidden_size=self.n_hidden, layout='NTC', bidirectional=True) 291 | # self.bi_gru = rnn.BidirectionalCell( 292 | # rnn.GRUCell(hidden_size=self.n_hidden), 293 | # rnn.GRUCell(hidden_size=self.n_hidden)) 294 | self.dense_sh = nn.Dense(100, activation='relu', flatten=False) 295 | self.dense = nn.Dense(1, activation='sigmoid', flatten=False) 296 | 297 | def hybrid_forward(self, F, inputs): 298 | embed = self.embedding(inputs) 299 | embed = F.expand_dims(embed, axis=1) 300 | rev_embed = embed.flip(axis=2) 301 | 302 | unigram = self.conv_unigram(embed) 303 | bigram = self.conv_bigram(embed) 304 | trigram = self.conv_trigram(embed) 305 | forthgram = self.conv_forthgram(embed) 306 | fifthgram = self.conv_fifthgram(embed) 307 | 308 | rev_bigram = self.conv_rev_bigram(rev_embed).flip(axis=2) 309 | rev_trigram = self.conv_rev_trigram(rev_embed).flip(axis=2) 310 | rev_forthgram = self.conv_rev_forthgram(rev_embed).flip(axis=2) 311 | rev_fifthgram = self.conv_rev_fifthgram(rev_embed).flip(axis=2) 312 | 313 | grams = F.concat(unigram, 314 | F.slice_axis(bigram, 315 | axis=2, 316 | begin=0, 317 | end=self.max_seq_length), 318 | F.slice_axis(rev_bigram, 319 | axis=2, 320 | begin=0, 321 | end=self.max_seq_length), 322 | F.slice_axis(trigram, 323 | axis=2, 324 | begin=0, 325 | end=self.max_seq_length), 326 | F.slice_axis(rev_trigram, 327 | axis=2, 328 | begin=0, 329 | end=self.max_seq_length), 330 | F.slice_axis(forthgram, 331 | axis=2, 332 | begin=0, 333 | end=self.max_seq_length), 334 | F.slice_axis(rev_forthgram, 335 | axis=2, 336 | begin=0, 337 | end=self.max_seq_length), 338 | F.slice_axis(fifthgram, 339 | axis=2, 340 | begin=0, 341 | end=self.max_seq_length), 342 | F.slice_axis(rev_fifthgram, 343 | axis=2, 344 | begin=0, 345 | end=self.max_seq_length), 346 | dim=1) 347 | 348 | grams = F.transpose(grams, (0, 2, 3, 1)) 349 | grams = F.reshape(grams, (-1, self.max_seq_length, -3)) 350 | grams = self.bi_gru(grams) 351 | fc1 = self.dense_sh(grams) 352 | return (self.dense(fc1)) 353 | 354 | 355 | def y_encoding(n_grams, maxlen=200): 356 | # 입력된 문장으로 정답셋 인코딩함 357 | init_mat = np.zeros(shape=(len(n_grams), maxlen), dtype=np.int8) 358 | for i in range(len(n_grams)): 359 | init_mat[i, np.cumsum([len(j) for j in n_grams[i]]) - 1] = 1 360 | return init_mat 361 | 362 | 363 | def split_train_set(x_train, p=0.98): 364 | """ 365 | > split_train_set(pd.DataFrame({'a':[1,2,3,4,None], 'b':[5,6,7,8,9]})) 366 | (array([0, 4, 3]), [1, 2]) 367 | """ 368 | import numpy as np 369 | train_idx = np.random.choice(range(x_train.shape[0]), 370 | int(x_train.shape[0] * p), 371 | replace=False) 372 | set_tr_idx = set(train_idx) 373 | test_index = [i for i in range(x_train.shape[0]) if i not in set_tr_idx] 374 | return ((train_idx, np.array(test_index))) 375 | 376 | 377 | def get_generator(x, y, batch_size): 378 | tr_set = gluon.data.ArrayDataset(x, y.astype('float32')) 379 | tr_data_iterator = gluon.data.DataLoader(tr_set, 380 | batch_size=batch_size, 381 | shuffle=True, 382 | num_workers=opt.n_workers) 383 | return (tr_data_iterator) 384 | 385 | 386 | def pick_model(model_nm, n_hidden, vocab_size, embed_dim, max_seq_length): 387 | if model_nm.lower() == 'kospacing': 388 | model = korean_autospacing_base(n_hidden=n_hidden, 389 | vocab_size=vocab_size, 390 | embed_dim=embed_dim, 391 | max_seq_length=max_seq_length) 392 | elif model_nm.lower() == 'kospacing2': 393 | model = korean_autospacing2(n_hidden=n_hidden, 394 | vocab_size=vocab_size, 395 | embed_dim=embed_dim, 396 | max_seq_length=max_seq_length) 397 | else: 398 | assert False 399 | return model 400 | 401 | 402 | def model_init(n_hidden, vocab_size, embed_dim, max_seq_length, ctx): 403 | # 모형 인스턴스 생성 및 트래이너, loss 정의 404 | # n_hidden, vocab_size, embed_dim, max_seq_length 405 | model = pick_model(opt.model_type, n_hidden, vocab_size, embed_dim, max_seq_length) 406 | model.collect_params().initialize(mx.init.Xavier(), ctx=ctx) 407 | model.embedding.weight.set_data(weights) 408 | model.hybridize(static_alloc=True) 409 | # 임베딩 영역 가중치 고정 410 | model.embedding.collect_params().setattr('grad_req', 'null') 411 | trainer = gluon.Trainer(model.collect_params(), 'rmsprop') 412 | loss = gluon.loss.SigmoidBinaryCrossEntropyLoss(from_sigmoid=True) 413 | loss.hybridize(static_alloc=True) 414 | return (model, loss, trainer) 415 | 416 | 417 | def evaluate_accuracy(data_iterator, net, pad_idx, ctx, n=5000): 418 | # 각 시퀀스의 길이만큼 순회하며 정확도 측정 419 | # 최적화되지 않음 420 | acc = mx.metric.Accuracy(axis=0) 421 | num_of_test = 0 422 | for i, (data, label) in enumerate(data_iterator): 423 | data = data.as_in_context(ctx) 424 | label = label.as_in_context(ctx) 425 | # get sentence length 426 | data_np = data.asnumpy() 427 | lengths = np.argmax(np.where(data_np == pad_idx, np.ones_like(data_np), 428 | np.zeros_like(data_np)), 429 | axis=1) 430 | output = net(data) 431 | pred_label = output.squeeze(axis=2) > 0.5 432 | 433 | for i in range(data.shape[0]): 434 | num_of_test += data.shape[0] 435 | acc.update(preds=pred_label[i, :lengths[i]], 436 | labels=label[i, :lengths[i]]) 437 | if num_of_test > n: 438 | break 439 | return acc.get()[1] 440 | 441 | 442 | def train(epochs, 443 | tr_data_iterator, 444 | te_data_iterator, 445 | va_data_iterator, 446 | model, 447 | loss, 448 | trainer, 449 | pad_idx, 450 | ctx, 451 | mdl_desc="spacing_model", 452 | decay=False): 453 | # 학습 코드 454 | tot_test_acc = [] 455 | tot_train_loss = [] 456 | for e in range(epochs): 457 | tic = time.time() 458 | # Decay learning rate. 459 | if e > 1 and decay: 460 | trainer.set_learning_rate(trainer.learning_rate * 0.7) 461 | train_loss = [] 462 | iter_tqdm = tqdm(tr_data_iterator, 'Batches') 463 | for i, (x_data, y_data) in enumerate(iter_tqdm): 464 | x_data_l = gluon.utils.split_and_load(x_data, 465 | ctx, 466 | even_split=False) 467 | y_data_l = gluon.utils.split_and_load(y_data, 468 | ctx, 469 | even_split=False) 470 | 471 | with autograd.record(): 472 | losses = [ 473 | loss(model(x), y) for x, y in zip(x_data_l, y_data_l) 474 | ] 475 | for l in losses: 476 | l.backward() 477 | trainer.step(x_data.shape[0]) 478 | curr_loss = np.mean([mx.nd.mean(l).asscalar() for l in losses]) 479 | train_loss.append(curr_loss) 480 | iter_tqdm.set_description("loss {}".format(curr_loss)) 481 | mx.nd.waitall() 482 | 483 | # caculate test loss 484 | test_acc = evaluate_accuracy( 485 | te_data_iterator, 486 | model, 487 | pad_idx, 488 | ctx=ctx[0] if isinstance(ctx, list) else mx.gpu(0)) 489 | valid_acc = evaluate_accuracy( 490 | va_data_iterator, 491 | model, 492 | pad_idx, 493 | ctx=ctx[0] if isinstance(ctx, list) else mx.gpu(0)) 494 | logger.info('[Epoch %d] time cost: %f' % (e, time.time() - tic)) 495 | logger.info("[Epoch %d] Train Loss: %f, Test acc : %f Valid acc : %f" % 496 | (e, np.mean(train_loss), test_acc, valid_acc)) 497 | tot_test_acc.append(test_acc) 498 | tot_train_loss.append(np.mean(train_loss)) 499 | model.save_parameters(opt.outputs + '/' + "{}_{}.params".format(mdl_desc, e)) 500 | return (tot_test_acc, tot_train_loss) 501 | 502 | 503 | def pre_processing(setences): 504 | # 공백은 ^ 505 | char_list = [li.strip().replace(' ', '^') for li in setences] 506 | # 문장의 시작 포인트 « 507 | # 문장의 끌 포인트 » 508 | char_list = ["«" + li + "»" for li in char_list] 509 | # 문장 -> 문자열 510 | char_list = [''.join(list(li)) for li in char_list] 511 | return char_list 512 | 513 | 514 | def make_input_data(inputs, 515 | train_ratio, 516 | sampling, 517 | make_lag_set=False, 518 | batch_size=200): 519 | with bz2.open(inputs, 'rt') as f: 520 | line_list = [i.strip() for i in f.readlines() if i.strip() != ''] 521 | logger.info('complete loading train file!') 522 | 523 | # 아버지가 방에 들어가신다. -> '«아버지가^방에^들어가신다.»' 524 | processed_seq = pre_processing(line_list) 525 | logger.info(processed_seq[0]) 526 | # n percent random sample 527 | logger.info('random sampling on training set!') 528 | samp_idx = np.random.choice(range(len(processed_seq)), 529 | int(len(processed_seq) * sampling), 530 | replace=False) 531 | processed_seq_samp = [processed_seq[i] for i in samp_idx] 532 | sp_sents = [i.split('^') for i in processed_seq_samp] 533 | 534 | sp_sents = list(filter(lambda x: len(x) >= 8, sp_sents)) 535 | 536 | # max 8 어절 씩 1어절 shift하여 학습 데이터 생성 537 | if make_lag_set is True: 538 | n_gram = [[k, v, z, a, c, d, e, f] 539 | for sent in sp_sents for k, v, z, a, c, d, e, f in zip( 540 | sent, sent[1:], sent[2:], sent[3:], sent[4:], sent[5:], 541 | sent[6:], sent[7:])] 542 | else: 543 | n_gram = sp_sents 544 | # max 200문자 이하만 사용 545 | n_gram = [i for i in n_gram if len("^".join(i)) <= opt.max_seq_len] 546 | # y 정답 인코딩 547 | n_gram_y = y_encoding(n_gram, opt.max_seq_len) 548 | logger.info(n_gram[0]) 549 | logger.info(n_gram_y[0]) 550 | # vocab file 로딩 551 | w2idx, _ = load_vocab(opt.vocab_file) 552 | 553 | # 학습셋을 만들기 위해 공백을 제거하고 문자 인덱스로 인코딩함 554 | logger.info('index eocoding!') 555 | ngram_coding_seq = encoding_and_padding( 556 | word2idx_dic=w2idx, 557 | sequences=[''.join(gram) for gram in n_gram], 558 | maxlen=opt.max_seq_len, 559 | padding='post', 560 | truncating='post') 561 | logger.info(ngram_coding_seq[0]) 562 | if train_ratio < 1: 563 | # 학습셋 테스트셋 생성 564 | tr_idx, te_idx = split_train_set(ngram_coding_seq, train_ratio) 565 | 566 | y_train = n_gram_y[tr_idx, ] 567 | x_train = ngram_coding_seq[tr_idx, ] 568 | 569 | y_test = n_gram_y[te_idx, ] 570 | x_test = ngram_coding_seq[te_idx, ] 571 | 572 | # train generator 573 | train_generator = get_generator(x_train, y_train, batch_size) 574 | valid_generator = get_generator(x_test, y_test, 500) 575 | return (train_generator, valid_generator) 576 | else: 577 | train_generator = get_generator(ngram_coding_seq, n_gram_y, batch_size) 578 | return (train_generator) 579 | 580 | 581 | if opt.train: 582 | # 사전 파일 로딩 583 | w2idx, idx2w = load_vocab(opt.vocab_file) 584 | # 임베딩 파일 로딩 585 | weights = load_embedding(opt.embedding_file) 586 | vocab_size = weights.shape[0] 587 | embed_dim = weights.shape[1] 588 | 589 | train_generator, valid_generator = make_input_data( 590 | opt.train_data, 591 | train_ratio=0.95, 592 | sampling=opt.train_samp_ratio, 593 | make_lag_set=True, 594 | batch_size=opt.batch_size) 595 | 596 | test_generator = make_input_data(opt.test_data, 597 | sampling=1, 598 | train_ratio=1, 599 | make_lag_set=True, 600 | batch_size=opt.test_batch_size) 601 | 602 | model, loss, trainer = model_init(n_hidden=opt.n_hidden, 603 | vocab_size=vocab_size, 604 | embed_dim=embed_dim, 605 | max_seq_length=opt.max_seq_len, 606 | ctx=ctx) 607 | logger.info('start training!') 608 | train(epochs=opt.num_epoch, 609 | tr_data_iterator=train_generator, 610 | te_data_iterator=test_generator, 611 | va_data_iterator=valid_generator, 612 | model=model, 613 | loss=loss, 614 | trainer=trainer, 615 | pad_idx=w2idx['__PAD__'], 616 | ctx=ctx, 617 | mdl_desc=opt.model_prefix) 618 | 619 | 620 | class pred_spacing: 621 | def __init__(self, model, w2idx): 622 | self.model = model 623 | self.w2idx = w2idx 624 | self.pattern = re.compile(r'\s+') 625 | 626 | @lru_cache(maxsize=None) 627 | def get_spaced_sent(self, raw_sent): 628 | raw_sent_ = "«" + raw_sent + "»" 629 | raw_sent_ = raw_sent_.replace(' ', '^') 630 | sents_in = [ 631 | raw_sent_, 632 | ] 633 | mat_in = encoding_and_padding(word2idx_dic=self.w2idx, 634 | sequences=sents_in, 635 | maxlen=opt.max_seq_len, 636 | padding='post', 637 | truncating='post') 638 | mat_in = mx.nd.array(mat_in, ctx=mx.cpu(0)) 639 | results = self.model(mat_in) 640 | mat_set = results[0, ] 641 | preds = np.array( 642 | ['1' if i > 0.5 else '0' for i in mat_set[:len(raw_sent_)]]) 643 | return self.make_pred_sents(raw_sent_, preds) 644 | 645 | def make_pred_sents(self, x_sents, y_pred): 646 | res_sent = [] 647 | for i, j in zip(x_sents, y_pred): 648 | if j == '1': 649 | res_sent.append(i) 650 | res_sent.append(' ') 651 | else: 652 | res_sent.append(i) 653 | subs = re.sub(self.pattern, ' ', ''.join(res_sent).replace('^', ' ')) 654 | subs = subs.replace('«', '') 655 | subs = subs.replace('»', '') 656 | return subs 657 | 658 | 659 | if not opt.train and not opt.test: 660 | # 사전 파일 로딩 661 | w2idx, idx2w = load_vocab(opt.vocab_file) 662 | # 임베딩 파일 로딩 663 | weights = load_embedding(opt.embedding_file) 664 | vocab_size = weights.shape[0] 665 | embed_dim = weights.shape[1] 666 | model = pick_model(opt.model_type, opt.n_hidden, vocab_size, embed_dim, opt.max_seq_len) 667 | 668 | # model.collect_params().initialize(mx.init.Xavier(), ctx=mx.cpu(0)) 669 | # model.embedding.weight.set_data(weights) 670 | model.load_parameters(opt.model_params, ctx=mx.cpu(0)) 671 | predictor = pred_spacing(model, w2idx) 672 | 673 | while 1: 674 | sent = input("sent > ") 675 | print(sent) 676 | start = timer() 677 | spaced = predictor.get_spaced_sent(sent) 678 | end = timer() 679 | print("spaced sent[{:03.2f}sec/sent] > {}".format(end - start, spaced)) 680 | 681 | if not opt.train and opt.test: 682 | logger.info("calculate accuracy!") 683 | # 사전 파일 로딩 684 | w2idx, idx2w = load_vocab(opt.vocab_file) 685 | # 임베딩 파일 로딩 686 | weights = load_embedding(opt.embedding_file) 687 | vocab_size = weights.shape[0] 688 | embed_dim = weights.shape[1] 689 | 690 | model = pick_model(opt.model_type, opt.n_hidden, vocab_size, embed_dim, opt.max_seq_len) 691 | 692 | # model.initialize(ctx=ctx[0] if isinstance(ctx, list) else mx.gpu(0)) 693 | model.load_parameters(opt.model_params, 694 | ctx=ctx[0] if isinstance(ctx, list) else mx.gpu(0)) 695 | valid_generator = make_input_data(opt.test_data, 696 | sampling=1, 697 | train_ratio=1, 698 | make_lag_set=True, 699 | batch_size=100) 700 | valid_acc = evaluate_accuracy( 701 | valid_generator, 702 | model, 703 | w2idx['__PAD__'], 704 | ctx=ctx[0] if isinstance(ctx, list) else mx.gpu(0), 705 | n=30000) 706 | logger.info('valid accuracy : {}'.format(valid_acc)) 707 | --------------------------------------------------------------------------------