├── .gitignore
├── LICENSE
├── MANIFEST.in
├── README.md
├── arch.png
├── kospacing_arch.png
├── pykospacing
├── __init__.py
├── embedding_maker.py
├── kospacing.py
├── pykos.py
└── resources
│ ├── __init__.py
│ ├── dicts
│ └── c2v.dic
│ └── models
│ ├── fingerprint.pb
│ ├── saved_model.pb
│ └── variables
│ ├── variables.data-00000-of-00001
│ └── variables.index
├── requirements.txt
├── setup.py
└── test.py
/.gitignore:
--------------------------------------------------------------------------------
1 | __pycache__
2 | .eggs
3 | dist
4 | venv
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 | Preamble
9 |
10 | The GNU General Public License is a free, copyleft license for
11 | software and other kinds of works.
12 |
13 | The licenses for most software and other practical works are designed
14 | to take away your freedom to share and change the works. By contrast,
15 | the GNU General Public License is intended to guarantee your freedom to
16 | share and change all versions of a program--to make sure it remains free
17 | software for all its users. We, the Free Software Foundation, use the
18 | GNU General Public License for most of our software; it applies also to
19 | any other work released this way by its authors. You can apply it to
20 | your programs, too.
21 |
22 | When we speak of free software, we are referring to freedom, not
23 | price. Our General Public Licenses are designed to make sure that you
24 | have the freedom to distribute copies of free software (and charge for
25 | them if you wish), that you receive source code or can get it if you
26 | want it, that you can change the software or use pieces of it in new
27 | free programs, and that you know you can do these things.
28 |
29 | To protect your rights, we need to prevent others from denying you
30 | these rights or asking you to surrender the rights. Therefore, you have
31 | certain responsibilities if you distribute copies of the software, or if
32 | you modify it: responsibilities to respect the freedom of others.
33 |
34 | For example, if you distribute copies of such a program, whether
35 | gratis or for a fee, you must pass on to the recipients the same
36 | freedoms that you received. You must make sure that they, too, receive
37 | or can get the source code. And you must show them these terms so they
38 | know their rights.
39 |
40 | Developers that use the GNU GPL protect your rights with two steps:
41 | (1) assert copyright on the software, and (2) offer you this License
42 | giving you legal permission to copy, distribute and/or modify it.
43 |
44 | For the developers' and authors' protection, the GPL clearly explains
45 | that there is no warranty for this free software. For both users' and
46 | authors' sake, the GPL requires that modified versions be marked as
47 | changed, so that their problems will not be attributed erroneously to
48 | authors of previous versions.
49 |
50 | Some devices are designed to deny users access to install or run
51 | modified versions of the software inside them, although the manufacturer
52 | can do so. This is fundamentally incompatible with the aim of
53 | protecting users' freedom to change the software. The systematic
54 | pattern of such abuse occurs in the area of products for individuals to
55 | use, which is precisely where it is most unacceptable. Therefore, we
56 | have designed this version of the GPL to prohibit the practice for those
57 | products. If such problems arise substantially in other domains, we
58 | stand ready to extend this provision to those domains in future versions
59 | of the GPL, as needed to protect the freedom of users.
60 |
61 | Finally, every program is threatened constantly by software patents.
62 | States should not allow patents to restrict development and use of
63 | software on general-purpose computers, but in those that do, we wish to
64 | avoid the special danger that patents applied to a free program could
65 | make it effectively proprietary. To prevent this, the GPL assures that
66 | patents cannot be used to render the program non-free.
67 |
68 | The precise terms and conditions for copying, distribution and
69 | modification follow.
70 |
71 | TERMS AND CONDITIONS
72 |
73 | 0. Definitions.
74 |
75 | "This License" refers to version 3 of the GNU General Public License.
76 |
77 | "Copyright" also means copyright-like laws that apply to other kinds of
78 | works, such as semiconductor masks.
79 |
80 | "The Program" refers to any copyrightable work licensed under this
81 | License. Each licensee is addressed as "you". "Licensees" and
82 | "recipients" may be individuals or organizations.
83 |
84 | To "modify" a work means to copy from or adapt all or part of the work
85 | in a fashion requiring copyright permission, other than the making of an
86 | exact copy. The resulting work is called a "modified version" of the
87 | earlier work or a work "based on" the earlier work.
88 |
89 | A "covered work" means either the unmodified Program or a work based
90 | on the Program.
91 |
92 | To "propagate" a work means to do anything with it that, without
93 | permission, would make you directly or secondarily liable for
94 | infringement under applicable copyright law, except executing it on a
95 | computer or modifying a private copy. Propagation includes copying,
96 | distribution (with or without modification), making available to the
97 | public, and in some countries other activities as well.
98 |
99 | To "convey" a work means any kind of propagation that enables other
100 | parties to make or receive copies. Mere interaction with a user through
101 | a computer network, with no transfer of a copy, is not conveying.
102 |
103 | An interactive user interface displays "Appropriate Legal Notices"
104 | to the extent that it includes a convenient and prominently visible
105 | feature that (1) displays an appropriate copyright notice, and (2)
106 | tells the user that there is no warranty for the work (except to the
107 | extent that warranties are provided), that licensees may convey the
108 | work under this License, and how to view a copy of this License. If
109 | the interface presents a list of user commands or options, such as a
110 | menu, a prominent item in the list meets this criterion.
111 |
112 | 1. Source Code.
113 |
114 | The "source code" for a work means the preferred form of the work
115 | for making modifications to it. "Object code" means any non-source
116 | form of a work.
117 |
118 | A "Standard Interface" means an interface that either is an official
119 | standard defined by a recognized standards body, or, in the case of
120 | interfaces specified for a particular programming language, one that
121 | is widely used among developers working in that language.
122 |
123 | The "System Libraries" of an executable work include anything, other
124 | than the work as a whole, that (a) is included in the normal form of
125 | packaging a Major Component, but which is not part of that Major
126 | Component, and (b) serves only to enable use of the work with that
127 | Major Component, or to implement a Standard Interface for which an
128 | implementation is available to the public in source code form. A
129 | "Major Component", in this context, means a major essential component
130 | (kernel, window system, and so on) of the specific operating system
131 | (if any) on which the executable work runs, or a compiler used to
132 | produce the work, or an object code interpreter used to run it.
133 |
134 | The "Corresponding Source" for a work in object code form means all
135 | the source code needed to generate, install, and (for an executable
136 | work) run the object code and to modify the work, including scripts to
137 | control those activities. However, it does not include the work's
138 | System Libraries, or general-purpose tools or generally available free
139 | programs which are used unmodified in performing those activities but
140 | which are not part of the work. For example, Corresponding Source
141 | includes interface definition files associated with source files for
142 | the work, and the source code for shared libraries and dynamically
143 | linked subprograms that the work is specifically designed to require,
144 | such as by intimate data communication or control flow between those
145 | subprograms and other parts of the work.
146 |
147 | The Corresponding Source need not include anything that users
148 | can regenerate automatically from other parts of the Corresponding
149 | Source.
150 |
151 | The Corresponding Source for a work in source code form is that
152 | same work.
153 |
154 | 2. Basic Permissions.
155 |
156 | All rights granted under this License are granted for the term of
157 | copyright on the Program, and are irrevocable provided the stated
158 | conditions are met. This License explicitly affirms your unlimited
159 | permission to run the unmodified Program. The output from running a
160 | covered work is covered by this License only if the output, given its
161 | content, constitutes a covered work. This License acknowledges your
162 | rights of fair use or other equivalent, as provided by copyright law.
163 |
164 | You may make, run and propagate covered works that you do not
165 | convey, without conditions so long as your license otherwise remains
166 | in force. You may convey covered works to others for the sole purpose
167 | of having them make modifications exclusively for you, or provide you
168 | with facilities for running those works, provided that you comply with
169 | the terms of this License in conveying all material for which you do
170 | not control copyright. Those thus making or running the covered works
171 | for you must do so exclusively on your behalf, under your direction
172 | and control, on terms that prohibit them from making any copies of
173 | your copyrighted material outside their relationship with you.
174 |
175 | Conveying under any other circumstances is permitted solely under
176 | the conditions stated below. Sublicensing is not allowed; section 10
177 | makes it unnecessary.
178 |
179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180 |
181 | No covered work shall be deemed part of an effective technological
182 | measure under any applicable law fulfilling obligations under article
183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184 | similar laws prohibiting or restricting circumvention of such
185 | measures.
186 |
187 | When you convey a covered work, you waive any legal power to forbid
188 | circumvention of technological measures to the extent such circumvention
189 | is effected by exercising rights under this License with respect to
190 | the covered work, and you disclaim any intention to limit operation or
191 | modification of the work as a means of enforcing, against the work's
192 | users, your or third parties' legal rights to forbid circumvention of
193 | technological measures.
194 |
195 | 4. Conveying Verbatim Copies.
196 |
197 | You may convey verbatim copies of the Program's source code as you
198 | receive it, in any medium, provided that you conspicuously and
199 | appropriately publish on each copy an appropriate copyright notice;
200 | keep intact all notices stating that this License and any
201 | non-permissive terms added in accord with section 7 apply to the code;
202 | keep intact all notices of the absence of any warranty; and give all
203 | recipients a copy of this License along with the Program.
204 |
205 | You may charge any price or no price for each copy that you convey,
206 | and you may offer support or warranty protection for a fee.
207 |
208 | 5. Conveying Modified Source Versions.
209 |
210 | You may convey a work based on the Program, or the modifications to
211 | produce it from the Program, in the form of source code under the
212 | terms of section 4, provided that you also meet all of these conditions:
213 |
214 | a) The work must carry prominent notices stating that you modified
215 | it, and giving a relevant date.
216 |
217 | b) The work must carry prominent notices stating that it is
218 | released under this License and any conditions added under section
219 | 7. This requirement modifies the requirement in section 4 to
220 | "keep intact all notices".
221 |
222 | c) You must license the entire work, as a whole, under this
223 | License to anyone who comes into possession of a copy. This
224 | License will therefore apply, along with any applicable section 7
225 | additional terms, to the whole of the work, and all its parts,
226 | regardless of how they are packaged. This License gives no
227 | permission to license the work in any other way, but it does not
228 | invalidate such permission if you have separately received it.
229 |
230 | d) If the work has interactive user interfaces, each must display
231 | Appropriate Legal Notices; however, if the Program has interactive
232 | interfaces that do not display Appropriate Legal Notices, your
233 | work need not make them do so.
234 |
235 | A compilation of a covered work with other separate and independent
236 | works, which are not by their nature extensions of the covered work,
237 | and which are not combined with it such as to form a larger program,
238 | in or on a volume of a storage or distribution medium, is called an
239 | "aggregate" if the compilation and its resulting copyright are not
240 | used to limit the access or legal rights of the compilation's users
241 | beyond what the individual works permit. Inclusion of a covered work
242 | in an aggregate does not cause this License to apply to the other
243 | parts of the aggregate.
244 |
245 | 6. Conveying Non-Source Forms.
246 |
247 | You may convey a covered work in object code form under the terms
248 | of sections 4 and 5, provided that you also convey the
249 | machine-readable Corresponding Source under the terms of this License,
250 | in one of these ways:
251 |
252 | a) Convey the object code in, or embodied in, a physical product
253 | (including a physical distribution medium), accompanied by the
254 | Corresponding Source fixed on a durable physical medium
255 | customarily used for software interchange.
256 |
257 | b) Convey the object code in, or embodied in, a physical product
258 | (including a physical distribution medium), accompanied by a
259 | written offer, valid for at least three years and valid for as
260 | long as you offer spare parts or customer support for that product
261 | model, to give anyone who possesses the object code either (1) a
262 | copy of the Corresponding Source for all the software in the
263 | product that is covered by this License, on a durable physical
264 | medium customarily used for software interchange, for a price no
265 | more than your reasonable cost of physically performing this
266 | conveying of source, or (2) access to copy the
267 | Corresponding Source from a network server at no charge.
268 |
269 | c) Convey individual copies of the object code with a copy of the
270 | written offer to provide the Corresponding Source. This
271 | alternative is allowed only occasionally and noncommercially, and
272 | only if you received the object code with such an offer, in accord
273 | with subsection 6b.
274 |
275 | d) Convey the object code by offering access from a designated
276 | place (gratis or for a charge), and offer equivalent access to the
277 | Corresponding Source in the same way through the same place at no
278 | further charge. You need not require recipients to copy the
279 | Corresponding Source along with the object code. If the place to
280 | copy the object code is a network server, the Corresponding Source
281 | may be on a different server (operated by you or a third party)
282 | that supports equivalent copying facilities, provided you maintain
283 | clear directions next to the object code saying where to find the
284 | Corresponding Source. Regardless of what server hosts the
285 | Corresponding Source, you remain obligated to ensure that it is
286 | available for as long as needed to satisfy these requirements.
287 |
288 | e) Convey the object code using peer-to-peer transmission, provided
289 | you inform other peers where the object code and Corresponding
290 | Source of the work are being offered to the general public at no
291 | charge under subsection 6d.
292 |
293 | A separable portion of the object code, whose source code is excluded
294 | from the Corresponding Source as a System Library, need not be
295 | included in conveying the object code work.
296 |
297 | A "User Product" is either (1) a "consumer product", which means any
298 | tangible personal property which is normally used for personal, family,
299 | or household purposes, or (2) anything designed or sold for incorporation
300 | into a dwelling. In determining whether a product is a consumer product,
301 | doubtful cases shall be resolved in favor of coverage. For a particular
302 | product received by a particular user, "normally used" refers to a
303 | typical or common use of that class of product, regardless of the status
304 | of the particular user or of the way in which the particular user
305 | actually uses, or expects or is expected to use, the product. A product
306 | is a consumer product regardless of whether the product has substantial
307 | commercial, industrial or non-consumer uses, unless such uses represent
308 | the only significant mode of use of the product.
309 |
310 | "Installation Information" for a User Product means any methods,
311 | procedures, authorization keys, or other information required to install
312 | and execute modified versions of a covered work in that User Product from
313 | a modified version of its Corresponding Source. The information must
314 | suffice to ensure that the continued functioning of the modified object
315 | code is in no case prevented or interfered with solely because
316 | modification has been made.
317 |
318 | If you convey an object code work under this section in, or with, or
319 | specifically for use in, a User Product, and the conveying occurs as
320 | part of a transaction in which the right of possession and use of the
321 | User Product is transferred to the recipient in perpetuity or for a
322 | fixed term (regardless of how the transaction is characterized), the
323 | Corresponding Source conveyed under this section must be accompanied
324 | by the Installation Information. But this requirement does not apply
325 | if neither you nor any third party retains the ability to install
326 | modified object code on the User Product (for example, the work has
327 | been installed in ROM).
328 |
329 | The requirement to provide Installation Information does not include a
330 | requirement to continue to provide support service, warranty, or updates
331 | for a work that has been modified or installed by the recipient, or for
332 | the User Product in which it has been modified or installed. Access to a
333 | network may be denied when the modification itself materially and
334 | adversely affects the operation of the network or violates the rules and
335 | protocols for communication across the network.
336 |
337 | Corresponding Source conveyed, and Installation Information provided,
338 | in accord with this section must be in a format that is publicly
339 | documented (and with an implementation available to the public in
340 | source code form), and must require no special password or key for
341 | unpacking, reading or copying.
342 |
343 | 7. Additional Terms.
344 |
345 | "Additional permissions" are terms that supplement the terms of this
346 | License by making exceptions from one or more of its conditions.
347 | Additional permissions that are applicable to the entire Program shall
348 | be treated as though they were included in this License, to the extent
349 | that they are valid under applicable law. If additional permissions
350 | apply only to part of the Program, that part may be used separately
351 | under those permissions, but the entire Program remains governed by
352 | this License without regard to the additional permissions.
353 |
354 | When you convey a copy of a covered work, you may at your option
355 | remove any additional permissions from that copy, or from any part of
356 | it. (Additional permissions may be written to require their own
357 | removal in certain cases when you modify the work.) You may place
358 | additional permissions on material, added by you to a covered work,
359 | for which you have or can give appropriate copyright permission.
360 |
361 | Notwithstanding any other provision of this License, for material you
362 | add to a covered work, you may (if authorized by the copyright holders of
363 | that material) supplement the terms of this License with terms:
364 |
365 | a) Disclaiming warranty or limiting liability differently from the
366 | terms of sections 15 and 16 of this License; or
367 |
368 | b) Requiring preservation of specified reasonable legal notices or
369 | author attributions in that material or in the Appropriate Legal
370 | Notices displayed by works containing it; or
371 |
372 | c) Prohibiting misrepresentation of the origin of that material, or
373 | requiring that modified versions of such material be marked in
374 | reasonable ways as different from the original version; or
375 |
376 | d) Limiting the use for publicity purposes of names of licensors or
377 | authors of the material; or
378 |
379 | e) Declining to grant rights under trademark law for use of some
380 | trade names, trademarks, or service marks; or
381 |
382 | f) Requiring indemnification of licensors and authors of that
383 | material by anyone who conveys the material (or modified versions of
384 | it) with contractual assumptions of liability to the recipient, for
385 | any liability that these contractual assumptions directly impose on
386 | those licensors and authors.
387 |
388 | All other non-permissive additional terms are considered "further
389 | restrictions" within the meaning of section 10. If the Program as you
390 | received it, or any part of it, contains a notice stating that it is
391 | governed by this License along with a term that is a further
392 | restriction, you may remove that term. If a license document contains
393 | a further restriction but permits relicensing or conveying under this
394 | License, you may add to a covered work material governed by the terms
395 | of that license document, provided that the further restriction does
396 | not survive such relicensing or conveying.
397 |
398 | If you add terms to a covered work in accord with this section, you
399 | must place, in the relevant source files, a statement of the
400 | additional terms that apply to those files, or a notice indicating
401 | where to find the applicable terms.
402 |
403 | Additional terms, permissive or non-permissive, may be stated in the
404 | form of a separately written license, or stated as exceptions;
405 | the above requirements apply either way.
406 |
407 | 8. Termination.
408 |
409 | You may not propagate or modify a covered work except as expressly
410 | provided under this License. Any attempt otherwise to propagate or
411 | modify it is void, and will automatically terminate your rights under
412 | this License (including any patent licenses granted under the third
413 | paragraph of section 11).
414 |
415 | However, if you cease all violation of this License, then your
416 | license from a particular copyright holder is reinstated (a)
417 | provisionally, unless and until the copyright holder explicitly and
418 | finally terminates your license, and (b) permanently, if the copyright
419 | holder fails to notify you of the violation by some reasonable means
420 | prior to 60 days after the cessation.
421 |
422 | Moreover, your license from a particular copyright holder is
423 | reinstated permanently if the copyright holder notifies you of the
424 | violation by some reasonable means, this is the first time you have
425 | received notice of violation of this License (for any work) from that
426 | copyright holder, and you cure the violation prior to 30 days after
427 | your receipt of the notice.
428 |
429 | Termination of your rights under this section does not terminate the
430 | licenses of parties who have received copies or rights from you under
431 | this License. If your rights have been terminated and not permanently
432 | reinstated, you do not qualify to receive new licenses for the same
433 | material under section 10.
434 |
435 | 9. Acceptance Not Required for Having Copies.
436 |
437 | You are not required to accept this License in order to receive or
438 | run a copy of the Program. Ancillary propagation of a covered work
439 | occurring solely as a consequence of using peer-to-peer transmission
440 | to receive a copy likewise does not require acceptance. However,
441 | nothing other than this License grants you permission to propagate or
442 | modify any covered work. These actions infringe copyright if you do
443 | not accept this License. Therefore, by modifying or propagating a
444 | covered work, you indicate your acceptance of this License to do so.
445 |
446 | 10. Automatic Licensing of Downstream Recipients.
447 |
448 | Each time you convey a covered work, the recipient automatically
449 | receives a license from the original licensors, to run, modify and
450 | propagate that work, subject to this License. You are not responsible
451 | for enforcing compliance by third parties with this License.
452 |
453 | An "entity transaction" is a transaction transferring control of an
454 | organization, or substantially all assets of one, or subdividing an
455 | organization, or merging organizations. If propagation of a covered
456 | work results from an entity transaction, each party to that
457 | transaction who receives a copy of the work also receives whatever
458 | licenses to the work the party's predecessor in interest had or could
459 | give under the previous paragraph, plus a right to possession of the
460 | Corresponding Source of the work from the predecessor in interest, if
461 | the predecessor has it or can get it with reasonable efforts.
462 |
463 | You may not impose any further restrictions on the exercise of the
464 | rights granted or affirmed under this License. For example, you may
465 | not impose a license fee, royalty, or other charge for exercise of
466 | rights granted under this License, and you may not initiate litigation
467 | (including a cross-claim or counterclaim in a lawsuit) alleging that
468 | any patent claim is infringed by making, using, selling, offering for
469 | sale, or importing the Program or any portion of it.
470 |
471 | 11. Patents.
472 |
473 | A "contributor" is a copyright holder who authorizes use under this
474 | License of the Program or a work on which the Program is based. The
475 | work thus licensed is called the contributor's "contributor version".
476 |
477 | A contributor's "essential patent claims" are all patent claims
478 | owned or controlled by the contributor, whether already acquired or
479 | hereafter acquired, that would be infringed by some manner, permitted
480 | by this License, of making, using, or selling its contributor version,
481 | but do not include claims that would be infringed only as a
482 | consequence of further modification of the contributor version. For
483 | purposes of this definition, "control" includes the right to grant
484 | patent sublicenses in a manner consistent with the requirements of
485 | this License.
486 |
487 | Each contributor grants you a non-exclusive, worldwide, royalty-free
488 | patent license under the contributor's essential patent claims, to
489 | make, use, sell, offer for sale, import and otherwise run, modify and
490 | propagate the contents of its contributor version.
491 |
492 | In the following three paragraphs, a "patent license" is any express
493 | agreement or commitment, however denominated, not to enforce a patent
494 | (such as an express permission to practice a patent or covenant not to
495 | sue for patent infringement). To "grant" such a patent license to a
496 | party means to make such an agreement or commitment not to enforce a
497 | patent against the party.
498 |
499 | If you convey a covered work, knowingly relying on a patent license,
500 | and the Corresponding Source of the work is not available for anyone
501 | to copy, free of charge and under the terms of this License, through a
502 | publicly available network server or other readily accessible means,
503 | then you must either (1) cause the Corresponding Source to be so
504 | available, or (2) arrange to deprive yourself of the benefit of the
505 | patent license for this particular work, or (3) arrange, in a manner
506 | consistent with the requirements of this License, to extend the patent
507 | license to downstream recipients. "Knowingly relying" means you have
508 | actual knowledge that, but for the patent license, your conveying the
509 | covered work in a country, or your recipient's use of the covered work
510 | in a country, would infringe one or more identifiable patents in that
511 | country that you have reason to believe are valid.
512 |
513 | If, pursuant to or in connection with a single transaction or
514 | arrangement, you convey, or propagate by procuring conveyance of, a
515 | covered work, and grant a patent license to some of the parties
516 | receiving the covered work authorizing them to use, propagate, modify
517 | or convey a specific copy of the covered work, then the patent license
518 | you grant is automatically extended to all recipients of the covered
519 | work and works based on it.
520 |
521 | A patent license is "discriminatory" if it does not include within
522 | the scope of its coverage, prohibits the exercise of, or is
523 | conditioned on the non-exercise of one or more of the rights that are
524 | specifically granted under this License. You may not convey a covered
525 | work if you are a party to an arrangement with a third party that is
526 | in the business of distributing software, under which you make payment
527 | to the third party based on the extent of your activity of conveying
528 | the work, and under which the third party grants, to any of the
529 | parties who would receive the covered work from you, a discriminatory
530 | patent license (a) in connection with copies of the covered work
531 | conveyed by you (or copies made from those copies), or (b) primarily
532 | for and in connection with specific products or compilations that
533 | contain the covered work, unless you entered into that arrangement,
534 | or that patent license was granted, prior to 28 March 2007.
535 |
536 | Nothing in this License shall be construed as excluding or limiting
537 | any implied license or other defenses to infringement that may
538 | otherwise be available to you under applicable patent law.
539 |
540 | 12. No Surrender of Others' Freedom.
541 |
542 | If conditions are imposed on you (whether by court order, agreement or
543 | otherwise) that contradict the conditions of this License, they do not
544 | excuse you from the conditions of this License. If you cannot convey a
545 | covered work so as to satisfy simultaneously your obligations under this
546 | License and any other pertinent obligations, then as a consequence you may
547 | not convey it at all. For example, if you agree to terms that obligate you
548 | to collect a royalty for further conveying from those to whom you convey
549 | the Program, the only way you could satisfy both those terms and this
550 | License would be to refrain entirely from conveying the Program.
551 |
552 | 13. Use with the GNU Affero General Public License.
553 |
554 | Notwithstanding any other provision of this License, you have
555 | permission to link or combine any covered work with a work licensed
556 | under version 3 of the GNU Affero General Public License into a single
557 | combined work, and to convey the resulting work. The terms of this
558 | License will continue to apply to the part which is the covered work,
559 | but the special requirements of the GNU Affero General Public License,
560 | section 13, concerning interaction through a network will apply to the
561 | combination as such.
562 |
563 | 14. Revised Versions of this License.
564 |
565 | The Free Software Foundation may publish revised and/or new versions of
566 | the GNU General Public License from time to time. Such new versions will
567 | be similar in spirit to the present version, but may differ in detail to
568 | address new problems or concerns.
569 |
570 | Each version is given a distinguishing version number. If the
571 | Program specifies that a certain numbered version of the GNU General
572 | Public License "or any later version" applies to it, you have the
573 | option of following the terms and conditions either of that numbered
574 | version or of any later version published by the Free Software
575 | Foundation. If the Program does not specify a version number of the
576 | GNU General Public License, you may choose any version ever published
577 | by the Free Software Foundation.
578 |
579 | If the Program specifies that a proxy can decide which future
580 | versions of the GNU General Public License can be used, that proxy's
581 | public statement of acceptance of a version permanently authorizes you
582 | to choose that version for the Program.
583 |
584 | Later license versions may give you additional or different
585 | permissions. However, no additional obligations are imposed on any
586 | author or copyright holder as a result of your choosing to follow a
587 | later version.
588 |
589 | 15. Disclaimer of Warranty.
590 |
591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599 |
600 | 16. Limitation of Liability.
601 |
602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610 | SUCH DAMAGES.
611 |
612 | 17. Interpretation of Sections 15 and 16.
613 |
614 | If the disclaimer of warranty and limitation of liability provided
615 | above cannot be given local legal effect according to their terms,
616 | reviewing courts shall apply local law that most closely approximates
617 | an absolute waiver of all civil liability in connection with the
618 | Program, unless a warranty or assumption of liability accompanies a
619 | copy of the Program in return for a fee.
620 |
621 | END OF TERMS AND CONDITIONS
622 |
623 | How to Apply These Terms to Your New Programs
624 |
625 | If you develop a new program, and you want it to be of the greatest
626 | possible use to the public, the best way to achieve this is to make it
627 | free software which everyone can redistribute and change under these terms.
628 |
629 | To do so, attach the following notices to the program. It is safest
630 | to attach them to the start of each source file to most effectively
631 | state the exclusion of warranty; and each file should have at least
632 | the "copyright" line and a pointer to where the full notice is found.
633 |
634 |
635 | Copyright (C) 2021 Heewon Jeon
636 |
637 | This program is free software: you can redistribute it and/or modify
638 | it under the terms of the GNU General Public License as published by
639 | the Free Software Foundation, either version 3 of the License, or
640 | (at your option) any later version.
641 |
642 | This program is distributed in the hope that it will be useful,
643 | but WITHOUT ANY WARRANTY; without even the implied warranty of
644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645 | GNU General Public License for more details.
646 |
647 | You should have received a copy of the GNU General Public License
648 | along with this program. If not, see .
649 |
650 | Also add information on how to contact you by electronic and paper mail.
651 |
652 | If the program does terminal interaction, make it output a short
653 | notice like this when it starts in an interactive mode:
654 |
655 | PyKoSpacing Copyright (C) 2021 Heewon Jeon
656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657 | This is free software, and you are welcome to redistribute it
658 | under certain conditions; type `show c' for details.
659 |
660 | The hypothetical commands `show w' and `show c' should show the appropriate
661 | parts of the General Public License. Of course, your program's commands
662 | might be different; for a GUI interface, you would use an "about box".
663 |
664 | You should also get your employer (if you work as a programmer) or school,
665 | if any, to sign a "copyright disclaimer" for the program, if necessary.
666 | For more information on this, and how to apply and follow the GNU GPL, see
667 | .
668 |
669 | The GNU General Public License does not permit incorporating your program
670 | into proprietary programs. If your program is a subroutine library, you
671 | may consider it more useful to permit linking proprietary applications with
672 | the library. If this is what you want to do, use the GNU Lesser General
673 | Public License instead of this License. But first, please read
674 | .
675 |
--------------------------------------------------------------------------------
/MANIFEST.in:
--------------------------------------------------------------------------------
1 | include pykospacing/resources/dicts/*
2 | include pykospacing/resources/models/*
3 | include pykospacing/resources/models/variables/*
4 | include pykospacing/embedding_maker.py
5 | include pykospacing/kospacing.py
6 |
7 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | PyKoSpacing
2 | ---------------
3 |
4 | Python package for automatic Korean word spacing.
5 |
6 | R verson can be found [here](https://github.com/haven-jeon/KoSpacing).
7 |
8 | [](http://www.gnu.org/licenses/gpl-3.0)
9 |
10 |
11 | #### Introduction
12 |
13 | Word spacing is one of the important parts of the preprocessing of Korean text analysis. Accurate spacing greatly affects the accuracy of subsequent text analysis. `PyKoSpacing` has fairly accurate automatic word spacing performance,especially good for online text originated from SNS or SMS.
14 |
15 | For example.
16 |
17 | "아버지가방에들어가신다." can be spaced both of below.
18 |
19 |
20 | 1. "아버지가 방에 들어가신다." means "My father enters the room."
21 | 1. "아버지 가방에 들어가신다." means "My father goes into the bag."
22 |
23 | Common sense, the first is the right answer.
24 |
25 | `PyKoSpacing` is based on Deep Learning model trained from large corpus(more than 100 million NEWS articles from [Chan-Yub Park](https://github.com/mrchypark)).
26 |
27 |
28 | #### Performance
29 |
30 | | Test Set | Accuracy |
31 | |---|---|
32 | | Sejong(colloquial style) Corpus(1M) | 97.1% |
33 | | OOOO(literary style) Corpus(3M) | 94.3% |
34 |
35 | - Accuracy = # correctly spaced characters/# characters in the test data.
36 | - Might be increased performance if normalize compound words.
37 |
38 |
39 | #### Install
40 |
41 | ##### PyPI Install
42 | Pre-requisite:
43 | ```bash
44 | proper installation of python3
45 | proper installation of pip
46 |
47 | pip install tensorflow
48 | pip install keras
49 |
50 |
51 | Windows-Ubuntu case: On following error.
52 | On error: /usr/lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.22' not found
53 | sudo apt-get install libstdc++6
54 | sudo add-apt-repository ppa:ubuntu-toolchain-r/test
55 | sudo apt-get update
56 | sudo apt-get upgrade
57 | sudo apt-get dist-upgrade (This takes long time.)
58 | ```
59 | Darwin(m1) case: You should install tensorflow in a different way.(Use [Miniforge3](https://github.com/conda-forge/miniforge))
60 | ```bash
61 | # Install Miniforge3 for mac
62 | curl -O https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-MacOSX-arm64.sh
63 | chmod +x Miniforge3-MacOSX-arm64.sh
64 | sh Miniforge3-MacOSX-arm64.sh
65 | # Activate Miniforge3 virtualenv
66 | # You should use Python version 3.10 or less.
67 | source ~/miniforge3/bin/activate
68 | # Install the Tensorflow dependencies
69 | conda install -c apple tensorflow-deps
70 | # Install base tensorflow
71 | python -m pip install tensorflow-macos
72 | # Install metal plugin
73 | python -m pip install tensorflow-metal
74 | ```
75 |
76 | To install from GitHub, use
77 |
78 | pip install git+https://github.com/haven-jeon/PyKoSpacing.git
79 |
80 |
81 | #### Example
82 |
83 | ```python
84 | >>> from pykospacing import Spacing
85 | >>> spacing = Spacing()
86 | >>> spacing("김형호영화시장분석가는'1987'의네이버영화정보네티즌10점평에서언급된단어들을지난해12월27일부터올해1월10일까지통계프로그램R과KoNLP패키지로텍스트마이닝하여분석했다.")
87 | "김형호 영화시장 분석가는 '1987'의 네이버 영화 정보 네티즌 10점 평에서 언급된 단어들을 지난해 12월 27일부터 올해 1월 10일까지 통계 프로그램 R과 KoNLP 패키지로 텍스트마이닝하여 분석했다."
88 | >>> # Apply a list of words that must be non-spacing
89 | >>> spacing('귀밑에서턱까지잇따라난수염을구레나룻이라고한다.')
90 | '귀 밑에서 턱까지 잇따라 난 수염을 구레나 룻이라고 한다.'
91 | >>> spacing = Spacing(rules=['구레나룻'])
92 | >>> spacing('귀밑에서턱까지잇따라난수염을구레나룻이라고한다.')
93 | '귀 밑에서 턱까지 잇따라 난 수염을 구레나룻이라고 한다.'
94 | ```
95 |
96 | Setting rules with csv file. (you only need to use `set_rules_by_csv()` method.)
97 |
98 | ```bash
99 | $ cat test.csv
100 | 인덱스,단어
101 | 1,네이버영화
102 | 2,언급된단어
103 | ```
104 |
105 | ```python
106 | >>> from pykospacing import Spacing
107 | >>> spacing = Spacing(rules=[''])
108 | >>> spacing.set_rules_by_csv('./test.csv', '단어')
109 | >>> spacing("김형호영화시장분석가는'1987'의네이버영화정보네티즌10점평에서언급된단어들을지난해12월27일부터올해1월10일까지통계프로그램R과KoNLP패키지로텍스트마이닝하여분석했다.")
110 | "김형호 영화시장 분석가는 '1987'의 네이버영화 정보 네티즌 10점 평에서 언급된단어들을 지난해 12월 27일부터 올해 1월 10일까지 통계 프로그램 R과 KoNLP 패키지로 텍스트마이닝하여 분석했다."
111 | ```
112 |
113 | Run on command line(thanks [lqez](https://github.com/lqez)).
114 |
115 | ```bash
116 | $ cat test_in.txt
117 | 김형호영화시장분석가는'1987'의네이버영화정보네티즌10점평에서언급된단어들을지난해12월27일부터올해1월10일까지통계프로그램R과KoNLP패키지로텍스트마이닝하여분석했다.
118 | 아버지가방에들어가신다.
119 | $ python -m pykospacing.pykos test_in.txt
120 | 김형호 영화시장 분석가는 '1987'의 네이버 영화 정보 네티즌 10점 평에서 언급된 단어들을 지난해 12월 27일부터 올해 1월 10일까지 통계 프로그램 R과 KoNLP 패키지로 텍스트마이닝하여 분석했다.
121 | 아버지가 방에 들어가신다.
122 | ```
123 |
124 | Current model [have problems](https://github.com/haven-jeon/PyKoSpacing/issues/52) in some cases when the input includes English characters.
125 | PyKoSpacing provides the parameter `ignore` and `ignore_pattern` to deal with that problem.
126 |
127 | - **About `ignore` parameter** (str, optional)
128 | - `ignore='none'`: No pre/post-processing will be applied. The output will be the same as the model output.
129 | - `ignore='pre'`: Apply pre-processing which deletes characters that match with `ignore_pattern`. These deleted characters will be merged after model prediction. This option has the problem that it always puts space *after* the deleted characters, since it doesn't know if the deleted character will have a space to the left, right, or both of them.
130 | - `ignore='post'`: Apply post-processing which ignores model outputs on characters that match with `ignore_pattern`. This option has the problem that English characters in model input can also affect near non-English characters.
131 | - `ignore='pre2'`: Apply pre-processing which delete characters which matches with `ignore_pattern`, and predict on **both preprocessed text and original text**. This allows it to know where to put space left, right, or both of the deleted characters. However, this option requires to predict **twice**, which doubles the computation time.
132 | - Default: `ignore='none'`
133 |
134 | - **About `ignore_pattern` parameter** (str, optional)
135 | You can input your own regex pattern to `ignore_pattern`. The regex pattern should be the pattern of characters you want to ignore.
136 | - Default: ``ignore_pattern=r'[^가-힣ㄱ-ㅣ!-@[-`{-~\s]+,*( [^가-힣ㄱ-ㅣ!-@[-`{-~\s]+,*)*[.,!?]* *'``, which matches characters, words, or a sentence of non-Korean and non-ascii symbols.
137 |
138 | Examples of `ignore` parameter
139 |
140 | ```python
141 | >>> from pykospacing import Spacing
142 | >>> spacing = Spacing()
143 | >>> spacing("친구와함께bmw썬바이저를썼다.", ignore='none')
144 | "친구와 함께 bm w 썬바이저를 썼다."
145 | >>> spacing("친구와함께bmw썬바이저를썼다.", ignore='pre')
146 | "친구와 함께bmw 썬바이저를 썼다."
147 | >>> spacing("친구와함께bmw썬바이저를썼다.", ignore='post')
148 | "친구와 함께 bm w 썬바이저를 썼다."
149 | >>> spacing("친구와함께bmw썬바이저를썼다.", ignore='pre2')
150 | "친구와 함께 bmw 썬바이저를 썼다."
151 |
152 | >>> spacing("chicken박스를열고닭다리를꺼내입에문다.crispy한튀김옷덕에내입주변은glossy해진다.", ignore='none')
153 | "chicken박스를 열고 닭다리를 꺼내 입에 문다. crispy 한튀김 옷 덕에 내 입 주변은 glossy해진다."
154 | >>> spacing("chicken박스를열고닭다리를꺼내입에문다.crispy한튀김옷덕에내입주변은glossy해진다.", ignore='pre')
155 | "chicken박스를 열고 닭다리를 꺼내 입에 문다.crispy 한 튀김옷 덕에 내 입 주변은glossy 해진다."
156 | >>> spacing("chicken박스를열고닭다리를꺼내입에문다.crispy한튀김옷덕에내입주변은glossy해진다.", ignore='post')
157 | "chicken박스를 열고 닭다리를 꺼내 입에 문다. crispy 한튀김 옷 덕에 내 입 주변은 glossy해진다."
158 | >>> spacing("chicken박스를열고닭다리를꺼내입에문다.crispy한튀김옷덕에내입주변은glossy해진다.", ignore='pre2')
159 | "chicken박스를 열고 닭다리를 꺼내 입에 문다. crispy 한 튀김옷 덕에 내 입 주변은 glossy해진다."
160 |
161 | >>> spacing("김형호영화시장분석가는'1987'의네이버영화정보네티즌10점평에서언급된단어들을지난해12월27일부터올해1월10일까지통계프로그램R과KoNLP패키지로텍스트마이닝하여분석했다.", ignore='none')
162 | "김형호 영화시장 분석가는 '1987'의 네이버 영화 정보 네티즌 10점 평에서 언급된 단어들을 지난해 12월 27일부터 올해 1월 10일까지 통계 프로그램 R과 KoNLP 패키지로 텍스트마이닝하여 분석했다."
163 | >>> spacing("김형호영화시장분석가는'1987'의네이버영화정보네티즌10점평에서언급된단어들을지난해12월27일부터올해1월10일까지통계프로그램R과KoNLP패키지로텍스트마이닝하여분석했다.", ignore='pre')
164 | "김형호 영화시장 분석가는 '1987'의 네이버 영화 정보 네티즌 10점 평에서 언급된 단어들을 지난해 12월 27일부터 올해 1월 10일까지 통계 프로그램R과KoNLP 패키지로 텍스트마이닝하여 분석했다."
165 | >>> spacing("김형호영화시장분석가는'1987'의네이버영화정보네티즌10점평에서언급된단어들을지난해12월27일부터올해1월10일까지통계프로그램R과KoNLP패키지로텍스트마이닝하여분석했다.", ignore='post')
166 | "김형호 영화시장 분석가는 '1987'의 네이버 영화 정보 네티즌 10점 평에서 언급된 단어들을 지난해 12월 27일부터 올해 1월 10일까지 통계 프로그램 R과 KoNLP 패키지로 텍스트마이닝하여 분석했다."
167 | >>> spacing("김형호영화시장분석가는'1987'의네이버영화정보네티즌10점평에서언급된단어들을지난해12월27일부터올해1월10일까지통계프로그램R과KoNLP패키지로텍스트마이닝하여분석했다.", ignore='pre2')
168 | "김형호 영화시장 분석가는 '1987'의 네이버 영화 정보 네티즌 10점 평에서 언급된 단어들을 지난해 12월 27일부터 올해 1월 10일까지 통계 프로그램 R과 KoNLP 패키지로 텍스트마이닝하여 분석했다."
169 | ```
170 |
171 | #### Model Architecture
172 |
173 | 
174 |
175 |
176 | #### For Training
177 |
178 | - Training code uses an architecture that is more advanced than PyKoSpacing, but also contains the learning logic of PyKoSpacing.
179 | - https://github.com/haven-jeon/Train_KoSpacing
180 |
181 | #### Citation
182 |
183 | ```markdowns
184 | @misc{heewon2018,
185 | author = {Heewon Jeon},
186 | title = {KoSpacing: Automatic Korean word spacing},
187 | publisher = {GitHub},
188 | journal = {GitHub repository},
189 | howpublished = {\url{https://github.com/haven-jeon/KoSpacing}}
190 | ```
191 |
192 | ### Star History
193 |
194 | [](https://star-history.com/#haven-jeon/PyKoSpacing&Date)
195 |
196 |
197 |
--------------------------------------------------------------------------------
/arch.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/haven-jeon/PyKoSpacing/b32a889cbd10b006d2f4aba118f0cd5b677e2979/arch.png
--------------------------------------------------------------------------------
/kospacing_arch.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/haven-jeon/PyKoSpacing/b32a889cbd10b006d2f4aba118f0cd5b677e2979/kospacing_arch.png
--------------------------------------------------------------------------------
/pykospacing/__init__.py:
--------------------------------------------------------------------------------
1 | from pykospacing.kospacing import *
2 |
--------------------------------------------------------------------------------
/pykospacing/embedding_maker.py:
--------------------------------------------------------------------------------
1 | from tensorflow.keras.preprocessing import sequence
2 | import json
3 | import numpy as np
4 |
5 |
6 | __all__ = ['load_embedding', 'load_vocab', 'encoding_and_padding']
7 |
8 |
9 | def load_embedding(embeddings_file):
10 | return(np.load(embeddings_file))
11 |
12 |
13 | def load_vocab(vocab_path):
14 | with open(vocab_path, 'r') as f:
15 | data = json.loads(f.read())
16 | word2idx = data
17 | idx2word = dict([(v, k) for k, v in data.items()])
18 | return word2idx, idx2word
19 |
20 |
21 | def encoding_and_padding(word2idx_dic, sequences, **params):
22 | """
23 | 1. making item to idx
24 | 2. padding
25 |
26 | :word2idx_dic
27 | :sequences: list of lists where each element is a sequence
28 | :maxlen: int, maximum length
29 | :dtype: type to cast the resulting sequence.
30 | :padding: 'pre' or 'post', pad either before or after each sequence.
31 | :truncating: 'pre' or 'post', remove values from sequences larger than
32 | maxlen either in the beginning or in the end of the sequence
33 | :value: float, value to pad the sequences to the desired value.
34 | """
35 | seq_idx = [[word2idx_dic.get(a, word2idx_dic['__ETC__']) for a in i] for i in sequences]
36 | params['value'] = word2idx_dic['__PAD__']
37 | return(sequence.pad_sequences(seq_idx, **params).astype('float32'))
38 |
--------------------------------------------------------------------------------
/pykospacing/kospacing.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | import os
3 |
4 | os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'
5 | import re
6 | import csv
7 |
8 | import numpy as np
9 | import pkg_resources
10 | from tensorflow.keras.layers import TFSMLayer
11 | from pykospacing.embedding_maker import encoding_and_padding, load_vocab
12 |
13 | __all__ = ['Spacing', ]
14 |
15 |
16 | model_path = pkg_resources.resource_filename(
17 | 'pykospacing', os.path.join('resources', 'models'))
18 | dic_path = pkg_resources.resource_filename(
19 | 'pykospacing', os.path.join('resources', 'dicts', 'c2v.dic'))
20 | MODEL = TFSMLayer(model_path,call_endpoint="serving_default")
21 | #MODEL.make_predict_function()
22 | W2IDX, _ = load_vocab(dic_path)
23 | MAX_LEN = 198
24 |
25 |
26 | class Spacing:
27 | """predict spacing for input string
28 | """
29 |
30 | def __init__(self, rules=[]):
31 | self._model = MODEL
32 | self._w2idx = W2IDX
33 | self.max_len = MAX_LEN
34 | self.pattern = re.compile(r'\s+')
35 | self.rules = {}
36 | for r in rules:
37 | if type(r) == str:
38 | self.rules[r] = re.compile('\s*'.join(r))
39 | else:
40 | raise ValueError("rules must to have only string values.")
41 |
42 | def set_rules_by_csv(self, file_path, key=None):
43 | with open(file_path, 'r', encoding='UTF-8') as csvfile:
44 | csv_var = csv.reader(csvfile)
45 | if key == None:
46 | for line in csv_var:
47 | for word in line:
48 | self.rules[word] = re.compile('\s*'.join(word))
49 | else:
50 | csv_var = list(csv_var)
51 | index = -1
52 | for i, word in enumerate(csv_var[0]):
53 | if word == key:
54 | index = i
55 | break
56 |
57 | if index == -1:
58 | raise KeyError(f"'{key}' is not in csv file")
59 |
60 | for line in csv_var:
61 | self.rules[line[index]] = re.compile('\s*'.join(line[index]))
62 |
63 | def get_spaced_sent(self, raw_sent, deleted_str_list=None, deleted_idx_list=None, orig_sent=None, post_process=False):
64 | raw_sent_ = "«" + raw_sent + "»"
65 | raw_sent_ = raw_sent_.replace(' ', '^')
66 | sents_in = [raw_sent_, ]
67 | mat_in = encoding_and_padding(
68 | word2idx_dic=self._w2idx, sequences=sents_in, maxlen=200,
69 | padding='post', truncating='post')
70 | results = self._model(mat_in)
71 | mat_set = results['output_0'][0]
72 | preds = np.array(['1' if i > 0.5 else '0' for i in mat_set[:len(raw_sent_)]])
73 | if orig_sent is not None:
74 | orig_sent_ = "«" + orig_sent + "»"
75 | orig_sent_ = orig_sent_.replace(' ', '^')
76 | sents_in = [orig_sent_, ]
77 | mat_in = encoding_and_padding(
78 | word2idx_dic=self._w2idx, sequences=sents_in, maxlen=200,
79 | padding='post', truncating='post')
80 | results = self._model(mat_in)
81 | mat_set = results['output_0'][0]
82 | orig_preds = np.array(['1' if i > 0.5 else '0' for i in mat_set[:len(orig_sent_)]])
83 | else:
84 | orig_sent_ = None
85 | orig_preds = None
86 | return self.make_pred_sents(raw_sent_, preds, orig_sent_, orig_preds, deleted_str_list, deleted_idx_list, post_process)
87 |
88 | def make_pred_sents(self, x_sents, y_pred,
89 | orig_sent_=None, orig_preds=None, deleted_str_list=None, deleted_idx_list=None, post_process=False):
90 | res_sent = []
91 | accum_idx = 0
92 | adjusted_idx = 0
93 | for i in range(len(x_sents)):
94 | res_sent.append(x_sents[i])
95 | if deleted_str_list: # if ignore is 'pre' or 'pre2' and deleted_str is not empty
96 | if deleted_idx_list[accum_idx] == i: # if have to insert deleted_str
97 | if orig_preds is not None and orig_preds[adjusted_idx] == '1':
98 | # if ignore is 'pre2' and have to insert space before deleted_str
99 | res_sent.append(' ')
100 | res_sent.append(deleted_str_list[accum_idx]) # insert deleted_str
101 | adjusted_idx += len(deleted_str_list[accum_idx])
102 | if accum_idx < len(deleted_idx_list) - 1:
103 | accum_idx += 1
104 | if orig_preds is not None and orig_preds[adjusted_idx] == '1':
105 | # if ignore is 'pre2' and have to insert space after deleted_str
106 | res_sent.append(' ')
107 | if orig_preds is None and y_pred[i] == '1':
108 | # if ignore is 'pre' and have to insert space, just insert space after deleted_str (it is not perfect)
109 | res_sent.append(' ')
110 | else:
111 | if y_pred[i] == '1':
112 | if post_process and deleted_idx_list:
113 | # if ignore is 'post' and have to ignore space, just insert space before the character
114 | for start, end in deleted_idx_list:
115 | if start <= i < end:
116 | break
117 | else:
118 | # only append space if the index is not in the range of deleted_idx_list
119 | res_sent.append(' ')
120 | else:
121 | res_sent.append(' ')
122 | else: # if ignore is 'none' or 'post' or deleted_str is empty
123 | if y_pred[i] == '1':
124 | res_sent.append(' ')
125 | adjusted_idx += 1
126 | subs = re.sub(self.pattern, ' ', ''.join(res_sent).replace('^', ' '))
127 | subs = subs.replace('«', '')
128 | subs = subs.replace('»', '')
129 | return subs
130 |
131 | def apply_rules(self, spaced_sent):
132 | for word, rgx in self.rules.items():
133 | spaced_sent = rgx.sub(word, spaced_sent)
134 | return spaced_sent
135 |
136 | def __call__(self, sent, ignore='none',
137 | ignore_pattern=r'[^가-힣ㄱ-ㅣ!-@[-`{-~\s]+,*( [^가-힣ㄱ-ㅣ!-@[-`{-~\s]+,*)*[.,!?]* *'):
138 | assert ignore in ['none', 'pre', 'pre2', 'post']
139 | if len(sent) > self.max_len:
140 | splitted_sent = [sent[y - self.max_len:y] for y in
141 | range(self.max_len, len(sent) + self.max_len, self.max_len)]
142 | else:
143 | splitted_sent = [sent]
144 | result_sent = []
145 | for i in range(len(splitted_sent)):
146 | if ignore in ['pre', 'pre2']:
147 | # delete the characters that are not Korean or symbol *first*.
148 | # also save the deleted characters and their indices.
149 | # the format of deleted_idx_list is different from the below.
150 | # (it is a list of integers, index of filtered_sent)
151 | filtered_sent = re.sub(ignore_pattern, '', splitted_sent[i])
152 | deleted_str_list = []
153 | deleted_idx_list = []
154 | accum_len = 0
155 | for deleted_str in re.finditer(ignore_pattern, splitted_sent[i]):
156 | deleted_str_list.append(deleted_str.group())
157 | deleted_idx_list.append(deleted_str.span()[0] - accum_len)
158 | accum_len += len(deleted_str.group())
159 | elif ignore == 'post':
160 | # just save the index of the characters that are not Korean or symbol.
161 | # the characters will be deleted *later*.
162 | # the format of deleted_idx_list is different from the above.
163 | # (it is a list of tuples, index of splitted_sent)
164 | filtered_sent = splitted_sent[i]
165 | deleted_str_list = None
166 | deleted_idx_list = []
167 | for deleted_str in re.finditer(ignore_pattern, splitted_sent[i]):
168 | deleted_idx_list.append((deleted_str.span()[0], deleted_str.span()[1]))
169 | else:
170 | # if ignore == 'none', do nothing.
171 | filtered_sent = splitted_sent[i]
172 | deleted_str_list = None
173 | deleted_idx_list = None
174 | # if ignore == 'pre2', orig_sent is needed for double prediction
175 | orig_sent = splitted_sent[i] if ignore == 'pre2' else None
176 | # if ignore == 'post', set post_process to True
177 | post_process = True if ignore == 'post' else False
178 | spaced_sent = self.get_spaced_sent(filtered_sent, deleted_str_list, deleted_idx_list, orig_sent, post_process)
179 | result_sent.append(spaced_sent)
180 | spaced_sent = ''.join(result_sent)
181 | if len(self.rules) > 0:
182 | spaced_sent = self.apply_rules(spaced_sent)
183 | return spaced_sent.strip()
184 |
--------------------------------------------------------------------------------
/pykospacing/pykos.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | import sys
3 | import argparse
4 | from pykospacing import Spacing
5 |
6 |
7 | def get_parser():
8 | parser = argparse.ArgumentParser(description='Python script for automatic Korean word spacing')
9 |
10 | parser.add_argument('infile', type=argparse.FileType('r'),
11 | default=sys.stdin)
12 | parser.add_argument('outfile', type=argparse.FileType('w'), nargs='?',
13 | default=sys.stdout)
14 | parser.add_argument('-o', dest='overwrite', action='store_true', default=False,
15 | help='Overwrite the result itself')
16 |
17 | return parser
18 |
19 |
20 | def main(args=sys.argv[1:]):
21 | args = get_parser().parse_args(args)
22 |
23 | source = args.infile.read()
24 |
25 | result = '\n'
26 | spacing = Spacing()
27 | for line in source.splitlines():
28 | result += spacing(line)
29 | result += '\n'
30 |
31 | if args.overwrite:
32 | args.infile.close()
33 | with open(args.infile.name, 'w', encoding=args.infile.encoding) as f:
34 | f.write(result)
35 | else:
36 | args.outfile.write(result)
37 |
38 | return 0 if (source == result) else 1
39 |
40 |
41 | if __name__ == '__main__':
42 | sys.exit(main())
43 |
--------------------------------------------------------------------------------
/pykospacing/resources/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/haven-jeon/PyKoSpacing/b32a889cbd10b006d2f4aba118f0cd5b677e2979/pykospacing/resources/__init__.py
--------------------------------------------------------------------------------
/pykospacing/resources/dicts/c2v.dic:
--------------------------------------------------------------------------------
1 | {"\u00ab": 7, "\uc637": 758, "\uc744": 4, "^": 0, "\ub9cc": 61, "\ub4dc": 131, "\ub290": 349, "\ub77c": 46, "\ub298": 320, "\ub300": 17, "\ud558": 12, "\ub294": 3, "\ucc9c": 253, "\uc2e4": 101, "\ub0b4": 83, "\uc6a9": 87, "\ud488": 171, "\uc704": 51, "\ud574": 22, "\ub2e4": 2, "\uc2dc": 28, "\ub514": 282, "\uc790": 27, "\uc778": 25, "\uac83": 52, "\uc740": 18, "'": 129, "\uc0c1": 45, "\ub825": 134, "\ub9c8": 102, "\uc74c": 219, "\uaecf": 942, "\ud3bc": 582, "\uce58": 92, "\uc990": 519, "\uac70": 103, "\uc6b4": 127, "\ub180": 601, "\uc774": 1, "\uace0": 9, "\ub9d0": 141, "\uadf8": 77, "\ub978": 244, "\ub108": 356, "\ub4e4": 43, "\ucc98": 193, "\ub7fc": 362, "\ucc3b": 1440, "\uc794": 642, ",": 35, "\uc811": 296, "\ub4f1": 66, "\uc2dd": 142, "\uae30": 16, "\uae4c": 180, "\uc9c0": 11, "\ud65c": 206, "\ub3d9": 69, "\ud3ed": 364, "\ub113": 667, "\ud600": 475, "\uac08": 361, "\uacc4": 73, "\ud68d": 279, ".": 6, "\u00bb": 8, "\ube59": 723, "\uc218": 26, "\uba85": 117, "\uc73c": 30, "\ub85c": 15, "\uc5b9": 1150, "\uc0b6": 619, "\ub2e8": 108, "\ud325": 1302, "\uacfc": 36, "\ucc30": 267, "\ub5a1": 967, "\uc824": 882, "\ub9ac": 34, "\ud3ec": 192, "\uc7a5": 31, "\ub3c4": 23, "\ub098": 50, "\uc640": 82, "\uc788": 29, "1": 143, "9": 387, "3": 242, "/": 671, "0": 203, "6": 352, "\ub610": 227, "\uc0ac": 19, "\ubb3c": 148, "\uad74": 514, "\uc808": 272, "\ub3fc": 322, "\uc81c": 37, "\ubcf4": 40, "\uc54a": 145, "\uc870": 67, "\uc758": 10, "2": 170, "%": 516, "\ub410": 239, "\uc5c8": 185, "\uc911": 75, "\uad6d": 42, "\ucf54": 319, "5": 301, "\uc5ec": 86, "\uac1c": 90, "\ucd5c": 146, "\uc138": 97, "\ub7ec": 137, "\ud589": 89, "-": 521, "\uad00": 55, "\uad11": 276, "\uc5c5": 62, "\uac00": 13, "\ucc38": 259, "\ud560": 76, "\ubc88": 191, "\uc804": 33, "\ud55c": 14, "\uc678": 169, "\uc5d0": 5, "\ub110": 517, "\uc54c": 269, "\ub9b0": 283, "\uba3c": 468, "8": 390, "\ub144": 202, "\ucc28": 123, "\ub840": 368, "\uc5f4": 248, "\ub838": 467, "\ub358": 222, "\uacbd": 59, "\uc8fc": 47, "\ud68c": 63, "\uc548": 78, "\uc787": 621, "\ub2ec": 196, "\uc544": 49, "\ub9b4": 473, "\uc815": 24, "\uad6c": 68, "\uc2b5": 122, "\ub2c8": 64, "\"": 39, "\uc784": 153, "\ubd80": 32, "\ubcf5": 240, "\ub354": 186, "\ub192": 275, "\ubc1c": 99, "\ubaa9": 246, "\ubb34": 96, "\ub98e": 1028, "\ub97c": 20, "\uc904": 341, "\ubbc0": 688, "\uc57c": 118, "\uc0b4": 326, "\ubd88": 177, "\ud654": 72, "(": 291, "4": 307, ")": 300, "\uc608": 161, "\ud53c": 208, "\uc5ed": 125, "\uc871": 323, "\uce5c": 346, "\ucc99": 585, "\uc6b0": 88, "\uc131": 54, "\ubcc4": 270, "\ub0a8": 188, "\ud0c0": 221, "\ub0ac": 465, "\uc591": 155, "\ub125": 865, "\ub9e8": 791, "\ubaa8": 104, "\uc7ac": 93, "\ubc30": 229, "\ub18d": 360, "\ubbfc": 107, "\ud568": 197, "\uad70": 271, "\uc0b0": 98, "\uba74": 57, "\ud3c9": 249, "7": 377, "\uc18c": 71, "\ub9dd": 285, "\ubb38": 65, "\uc12d": 598, "\uc528": 273, "\uc6d0": 38, "\ud5d8": 263, "\uc11c": 21, "\ub7f0": 305, "\uc5c6": 156, "\ud5ec": 803, "\uc2a4": 56, "\ud0a4": 306, "\ud37c": 471, "\uc0bc": 340, "J": 853, "W": 909, "\ub378": 538, "B": 541, "K": 557, "E": 663, "\uc600": 324, "\ub370": 135, "\ucf64": 796, "\uc785": 116, "\uac8c": 60, "\uacf5": 58, "\uac74": 157, "\uac15": 126, "\ud559": 133, "\ub8cc": 224, "\ub2f4": 231, "\uc751": 354, "\uae09": 190, "\uc9c8": 218, "\ubcd1": 292, "\ubc29": 95, "\uc9c4": 81, "\uc124": 138, "\ub2f5": 479, "\ud1b5": 79, "\uccb4": 114, "\ud06c": 223, "\uc6b8": 214, "\uc5f0": 100, "\ube0c": 333, "\ub780": 308, "\ud569": 168, "\ucd08": 258, "\ub09c": 173, "\uac04": 120, "\ubc31": 374, "\ud658": 194, "\uce68": 335, "\ud761": 594, "\uac80": 235, "\uc801": 48, "\ud588": 41, "\uc559": 451, "\uc5fd": 916, "\ucd94": 175, "\ucd9c": 130, "\uacb0": 144, "\uc624": 119, "\ubd84": 112, "\ubc16": 459, "\uac78": 395, "\uba70": 91, "\ud655": 178, "\ub9e4": 163, "\ub204": 314, "\ud3d0": 446, "\uc0c9": 378, "\uc0c8": 238, "\ubc95": 150, "\uac10": 162, "\ud504": 213, "\ud638": 172, "\uace4": 644, "\ud1a0": 266, "\uc2b4": 773, "\uc99d": 182, "\ubc18": 136, "\uc720": 85, "\uc9d5": 428, "\ud6c4": 128, "\ub1cc": 670, "\uc2ec": 149, "\uc2e0": 84, "\u223c": 1003, "\ub0ae": 463, "\uc9d1": 247, "\uc0dd": 110, "\ucc3d": 311, "\uc2f8": 566, "\ud310": 198, "\ud30c": 209, "\ud2b8": 121, "\ub9ce": 257, "\uc791": 187, "\ub418": 111, "\ucc29": 411, "\ube44": 70, "\uce6b": 894, "\uc5c9": 960, "\ub6b1": 1141, "\uc77c": 53, "\uc5b4": 44, "\ub0a0": 232, "\uc601": 113, "\uc900": 212, "\ud56d": 287, "\ub09a": 1080, "\ud5e4": 625, "\ubc14": 164, "\ucabd": 462, "\uc3e0": 861, "\uc694": 106, "\uc998": 716, "\uc2ef": 1489, "\ucca0": 315, "\uc800": 207, "\uc6b1": 445, "\ud6c8": 477, "\ubc15": 176, "\uc721": 250, "\uc18d": 166, "\uac77": 840, "\ub41c": 115, "\ub124": 393, "\ud0b9": 674, "\ud130": 139, "\ubcf8": 184, "\ub5a0": 513, "\uadf9": 325, "\ud5a5": 241, "\uc7c1": 342, "\uccad": 160, "\uc558": 268, "\uce20": 449, "\uadfc": 174, "\ub824": 124, "\uc560": 353, "\ub798": 243, "\uae38": 334, "\ub4e0": 313, "\uc9e7": 834, "\ud314": 573, "\uc810": 159, "\uc628": 290, "\ubab8": 542, "\ub4ef": 531, "\ub9bc": 404, "\ub7fd": 425, "\ub78c": 274, "\ub141": 864, "\ub808": 277, "\uc989": 584, "\uc11d": 201, "\ud669": 261, "\uaddc": 265, "\ud6a8": 339, "\uc61b": 872, "\ub355": 537, "\uad50": 109, "\ub828": 204, "\ubc1b": 179, "\uc27c": 1182, "\ucc3e": 380, "\ub3d5": 728, "\uac01": 167, "\ub7a8": 472, "\uaca0": 236, "\ub73b": 498, "\ubc1d": 251, "\ud78c": 555, "\uc775": 345, "\ub2f9": 80, "\ud328": 391, "\ub958": 331, "\ucc44": 297, "\ucde8": 310, "\ube60": 439, "\uc838": 367, "\uc228": 572, "\ub7c9": 312, "\uc5b5": 420, "\ub178": 183, "\ub2cc": 487, "\ubc84": 318, "\ud2bc": 762, "\ub974": 215, "\uacf3": 373, "\u2026": 1255, "\uc370": 1217, "\ub2a5": 195, "\uc9dc": 636, "\ud615": 216, "\ub193": 400, "\uc190": 336, "\ub2d8": 527, "\ub179": 597, "\uce7c": 707, "\uc120": 74, "\ubbf8": 105, "\uc220": 252, "\ud734": 433, "\ubb54": 1022, "\ud0d0": 717, "\uc6d4": 237, "\uc21c": 328, "\ubc24": 648, "\uade0": 493, "\ud788": 158, "\uc368": 504, "\ud154": 501, "\ud2b9": 181, "\ub791": 418, "\ub3c5": 321, "\ud14c": 372, "\ube14": 444, "\ubd09": 448, "\uce90": 548, "\ub9ad": 655, "\ub123": 660, "\ucc45": 200, "C": 482, "D": 603, "\ud5cc": 447, "\uc9c1": 147, "\ucc0d": 678, "\uc724": 456, "\uc219": 495, "\ub2ed": 908, "\uac40": 1301, "\ub0b3": 923, "\ubd93": 1068, "\ud39c": 858, "\uaca8": 394, "\uc4f0": 483, "\ucd1d": 255, "\ub611": 880, "\uac19": 262, "\ubaab": 972, "\ud604": 140, "\ucef4": 661, "\ud4e8": 765, "\ub450": 199, "\ub140": 496, "\uc2b9": 299, "\ud63c": 457, "\ub85d": 211, "\ub4b7": 744, "\ud3b8": 256, "\ud611": 228, "\ub8f9": 454, "\ud3b4": 692, "\ud45c": 132, "\uce21": 304, "\uae5c": 1010, "\uc5d1": 868, "\ubcfc": 412, "\ucca8": 623, "\uc874": 332, "\ub530": 205, "\ub79c": 397, "\uae40": 189, "\uc158": 399, "\uc1fc": 540, "\ub960": 438, "\ub9bd": 337, "\ub150": 500, "\ubc8c": 316, "\uac1d": 317, "\ud329": 886, "A": 476, "R": 790, "S": 461, "\ub4a4": 370, "\ud0dd": 295, "\uc1a1": 330, "\ud0dc": 234, "\uad8c": 151, "\ucce4": 617, "\ud31d": 1055, "\uaf43": 691, "\ub860": 264, "\ub0c8": 524, "\uae08": 94, "\uc639": 977, "\ub54c": 165, "\ud30d": 1212, "\ub9bf": 755, "\ud398": 392, "\ud2f0": 363, "\uc57d": 220, "\uc5e0": 905, "\ube45": 808, "\ud5c8": 384, "\ucf00": 410, "\ud0c8": 422, "\ubd90": 1100, "\ucd98": 539, "\uac31": 1015, "\uc27d": 484, "\uc0bd": 1092, "\uacc1": 1060, "\ub0b8": 507, "\ucda9": 338, "\uac12": 602, "\ud544": 281, "\ub3cc": 358, "\uac16": 396, "\uce59": 564, "\ube48": 570, "\uc561": 407, "\ub86f": 406, "\uc885": 210, "\uc529": 685, "\ud64d": 403, "\uaebc": 686, "\ub9db": 552, "\ub9de": 329, "\ucdc4": 884, "\ud0c4": 385, "\uc12c": 662, "\ub871": 827, "\ubca8": 709, "\uc816": 1066, "\ube68": 638, "\uaf2d": 750, "\ubd10": 627, "\uc6cc": 347, "\ud48d": 442, "\uc88b": 366, "\uc695": 543, "\ub3cb": 883, "\uc80a": 673, "\ubcc0": 233, "\ub208": 415, "\uc644": 365, "\ud614": 289, "\ucf5c": 651, "\ubc97": 649, "\ud720": 1117, "\uc5c7": 560, "\uc7a0": 512, "\uc130": 596, "\uc555": 443, "\uc2fc": 700, "\ucd95": 280, "\ubd81": 217, "\ud0d5": 567, "\ub5a4": 503, "\uc55e": 286, "\ub9f9": 591, "\uacaa": 592, "\uae68": 599, "\ud608": 559, "\uc3df": 731, "\uc654": 382, "\uc7a1": 409, "\ub984": 369, "\ub2d0": 799, "\uc574": 1462, "\ub420": 260, "\ucbe4": 782, "\ucf58": 499, "\ubcbd": 554, "\uc570": 1254, "\uaecd": 1153, "\ub465": 835, "\uc5d4": 423, "\uc9f8": 515, "\ud76c": 381, "\uc798": 402, "\uc625": 595, "\ubb3b": 710, "\ud640": 659, "\uae34": 413, "\ubfd0": 427, "\ud0b4": 1075, "m": 823, "\ud30e": 912, "P": 579, "V": 703, "\uc5bb": 536, "\uc194": 634, "\ucd1b": 946, "\ub2ac": 1132, "\uccd0": 424, "\uc6e8": 562, "\uae4a": 632, "\uce74": 294, "\uc62c": 254, "\uc84c": 309, "\ub274": 434, "\ud138": 563, "\ub12c": 1184, "\uba38": 408, "\uac24": 829, "\uada4": 1038, "\ub790": 684, "\uc557": 962, "\uc0e4": 822, "\ubabb": 302, "\uc545": 343, "\uaca9": 226, "\uc1e0": 897, "N": 690, "\ud0a8": 578, "\ucf1c": 469, "\ub760": 936, "\ub7ed": 752, "\uc13c": 398, "\uadc0": 490, "\ub69c": 833, "\ucc3c": 1394, "\ud380": 577, "\ub86d": 568, "\ud22c": 225, "\ud0c1": 510, "\ud2c0": 583, "\ub6f0": 589, "\uacac": 327, "\ub989": 876, "\uace1": 550, "\ud765": 511, "\ub545": 704, "\ubc00": 419, "\ub0bc": 643, "<": 815, ">": 696, "?": 509, "\ubc94": 359, "\uc735": 303, "\ub9e1": 526, "\ub835": 534, "\ud1f4": 437, "\u00b7": 245, "\ubc0f": 278, "\ud575": 388, "\uc728": 355, "\ub454": 549, "\uaed8": 293, "\ub77d": 383, "\ucc0c": 804, "\uc9d0": 664, "\uc783": 738, "\ub00c": 798, "\ub05d": 494, "\ub0d0": 430, "\ub4dd": 401, "\ud070": 379, "\ub9c9": 371, "\ub0a9": 518, "\ucd09": 450, "\ub2e5": 624, "\uc6c3": 565, "\ub839": 230, "\ub9c1": 533, "\ub7f4": 784, "\ub809": 737, "G": 600, "\uc564": 763, "&": 819, "L": 615, "\u25cb": 1155, "\uc6c0": 348, "\ud798": 426, "\ub428": 852, "\ub118": 432, "\ub5a8": 502, "\uc288": 571, "\ucf13": 701, "\uc5c4": 455, "\ud2c8": 904, "\ud790": 713, "\ub35c": 741, "I": 535, "\ub17c": 350, "\ud0d3": 781, "\ubc45": 855, "\ube4c": 631, "\ub529": 658, "\uc2f1": 618, "\ucef8": 966, "\ucf69": 770, "\uaf3d": 645, "\ub099": 575, "\ud6e8": 810, "\uc52c": 776, "\ub800": 836, "\ud50c": 376, "\ucd0c": 609, "\uc65c": 650, "\ub9f4": 1441, "\ube5a": 718, "\uba58": 668, "\uc8fd": 607, "\ud750": 586, "\ucee4": 357, "\ud0d1": 693, "\ucee8": 530, "\ucfe0": 588, "\ub2ff": 989, "\ub550": 1116, "t": 811, "\uc2b7": 734, "\ud478": 610, "\ubca0": 416, "\ud5e8": 1128, "\ucf08": 1071, "\ub04c": 470, "\ub8e8": 344, "\uc5ff": 1076, "\ubd05": 1036, "\ud53d": 689, "\uc8c4": 491, "\ubd99": 440, "\ud480": 481, "\ub9fa": 795, "\uba55": 1033, "O": 733, "M": 629, "\ucdb0": 547, "\ud754": 637, "\uc88c": 520, "\ud07c": 405, "\uafd4": 844, "\ubcbc": 843, "\uc300": 789, "T": 497, "\uafb8": 485, "\ucc2c": 478, "\ud718": 587, "\uc5d8": 657, "\uce78": 922, "\ud64b": 1576, "\ub2a6": 640, "\ub20c": 973, "F": 683, "\uc5b8": 298, "U": 785, "\ub0c9": 675, "\ud69f": 1094, "\ud639": 452, "\uc313": 712, "\uc549": 742, "\ub9e5": 611, "\uca0c": 1166, ":": 672, "\uc9d3": 656, "\ub3c8": 486, "\uc140": 778, "\uc880": 608, "\uc0c0": 1230, "\uc060": 1498, "\ub10b": 1410, "\ub458": 528, "\ubc0d": 938, "\uc4f4": 826, "\ubaac": 764, "\ubbff": 706, "\ub07c": 505, "\uce60": 556, "\ubd95": 860, "\uad34": 652, "\uae00": 375, "\ube5b": 699, "\ub080": 941, "\ub837": 910, "\ud5dd": 1152, "\ub51b": 1219, "\ubb18": 761, "\uce35": 417, "\ub0a1": 1097, "\ubd89": 1017, "\ubb47": 1129, "\uc22b": 993, "\uc5bd": 1130, "\uc5bc": 436, "\uc5ee": 1273, "\ub807": 435, "\ub2ee": 1142, "\uad81": 628, "\ub8b0": 553, "\uafbc": 851, "\ubf51": 821, "\ube74": 1490, "\uc988": 421, "\uc26c": 630, "\uc5fc": 453, "\uc2ed": 544, "\uc6c5": 768, "\ub7b5": 431, "\ud300": 466, "\uac71": 725, "\uccab": 525, "\uc796": 949, "\ube8c": 1651, "\uad04": 679, "\ub3d7": 1198, "\uc633": 1039, "\ud134": 593, "\uafc0": 953, "\uace8": 458, "\ub4e3": 705, "\ub08c": 736, "\uac89": 1073, "\ud61c": 389, "\uc2a8": 676, "\ud601": 386, "\uae0d": 669, "\uc14b": 813, "\ub987": 1000, "\ub451": 1090, "\uba40": 757, "\uca61": 1365, "\ubab0": 441, "\ud508": 714, "\ud759": 1085, "\ud320": 1463, "\uc6e0": 665, "\uc2f6": 529, "\uc610": 1168, "\uacbc": 680, "\uc149": 914, "\ub0ad": 824, "\ub728": 633, "\ub4ec": 913, "\ud5db": 1192, "\uae5d": 893, "\uc598": 576, "\ud758": 695, "\ub8fb": 1374, "\ucf30": 720, "\ucf8c": 756, "\ubfdc": 1286, "\ub0c4": 950, "\ud131": 842, "\ub729": 1103, "\ud6cc": 971, "\ub96d": 1037, "\uc37c": 969, "\uad73": 825, "\ub538": 749, "\ub534": 1215, "\uc5ca": 1611, "!": 933, "\ub8e9": 831, "\ud305": 480, "\ud0ac": 614, "\uc655": 606, "\ucca9": 918, "\uce30": 1351, "\uc501": 1399, "\uc4f8": 772, "\ub78d": 892, "\uc70c": 1158, "\ube7c": 719, "\uc9d9": 1044, "\uc410": 1655, "\ubc25": 739, "\uba39": 489, "\uc9dd": 759, "\uae4e": 1078, "\ub2c9": 794, "\uac14": 581, "\uace7": 694, "\ub540": 964, "\ub4b9": 1552, "\ubfcc": 780, "\ub801": 983, "\ud610": 508, "\uc580": 944, "\uc553": 1005, "\ub109": 1001, "\ub8ec": 920, "\ub044": 745, "\uae50": 1122, "\ub985": 1138, "\uc820": 841, "\uc170": 959, "\ub5bc": 895, "\uc500": 711, "\ud145": 1350, "\uae43": 932, "\uc62e": 697, "\uac90": 846, "\uba4b": 952, "\ud584": 1171, "\uc22d": 984, "\uc9d6": 1357, "\ucc22": 1252, "\uba48": 931, "\ubb63": 1815, "\ub5bb": 545, "\u25b6": 802, "\uac11": 561, "\ub054": 828, "\ud0d4": 1248, "\ube8f": 1307, "\uac81": 641, "\ubf08": 885, "\uba78": 848, "\ub084": 839, "\ud751": 812, "\uae01": 1343, "\uc148": 724, "\ub369": 907, "\ud074": 474, "\uc881": 869, "\uac20": 1663, "\uc7a6": 976, "\ud6d1": 1470, "\uc7bc": 1509, "\uaf08": 1018, "\uc2ac": 580, "\uc05c": 871, "\uc918": 754, "\uc554": 522, "\uc154": 646, "\uad1c": 1079, "\ucc2e": 990, "\ubabd": 793, "\uce6d": 654, "\ubb50": 903, "\ub8e1": 845, "\ub220": 832, "\uaf34": 1112, "\ub518": 1110, "\ub7ad": 1053, "\ubd07": 856, "\uaf2c": 748, "\ub258": 1111, "\ud23c": 1059, "\ud230": 1135, "\ubc11": 800, "\ubed0": 1237, "\ub959": 767, "\uba87": 604, "\ub137": 532, "\ud32c": 753, "\uacb8": 726, "\ub0ab": 1105, "\uc67c": 891, "\uc77d": 751, "\ub460": 1277, "\ub0af": 1102, "\ud770": 1047, "\ud54f": 1095, "\uc058": 862, "\ud760": 1108, "\ubed1": 1439, "\ub308": 1327, "\ud729": 1032, "\ub9d8": 1023, "\ub744": 875, "\ub8f8": 847, "\ub38c": 1294, "\ub048": 775, "\ucea0": 551, "\uc464": 1201, "\uae0b": 981, "\ud33d": 857, "\ubb36": 935, "\ub784": 906, "\uafc8": 653, "g": 979, "l": 1124, "o": 806, "b": 1227, "a": 998, "y": 1013, "c": 730, "\uaf41": 1189, "\uc1c4": 622, "\uc30d": 818, "\ub155": 1030, "\ub531": 911, "\ub4ed": 702, "\ubd24": 605, "\uacb9": 888, "\ud769": 1190, "\ub0e5": 708, "\uc717": 1069, "\ub289": 1619, "\ub86c": 1011, "\ud15c": 429, "\uba54": 351, "\ud6a1": 814, "\uac1a": 1012, "\ucc58": 1617, "\ud2f1": 830, "\ub51c": 887, "\ucad3": 1006, "\ud150": 569, "\ub904": 460, "\ub385": 1471, "\uc6ec": 1195, "\uacf0": 1048, "\ud321": 1035, "\ub480": 939, "\ud648": 574, "\ucda4": 639, "\ud551": 488, "\ubdf0": 613, "\ub82c": 820, "\uc168": 769, "\ud050": 854, "\uc7ad": 1262, "X": 975, "\uc568": 1051, "\ubd04": 740, "\ubba4": 677, "\uceec": 620, "\ubc43": 1041, "\ubb35": 771, "\ub2eb": 877, "\ub975": 1496, "\ucd2c": 727, "H": 797, "Y": 1136, "~": 729, "\ub35f": 1452, "\ubc2d": 902, "\ub730": 1072, "\uad76": 1304, "\uc178": 1346, "\uccbc": 1270, "\uc12f": 901, "\ud3a0": 1118, "\ud48b": 1240, "\ub918": 1042, "=": 681, "\ub04a": 698, "\ub764": 1274, "\ub08d": 1654, "\uc232": 879, "\ub215": 1427, "\ub8f0": 870, "\uc0d8": 965, "\uc78a": 917, "\ubb49": 1062, "\uc74d": 878, "\uca4d": 1046, "\ub313": 968, "\ud07d": 1363, "\ucd18": 1207, "\uc789": 805, "\uc20d": 961, "\ud578": 1004, "\ub1e8": 927, "\ubbf9": 945, "\ud587": 957, "\ubcd5": 1164, "\uacfd": 838, "\uc0f4": 1197, "\uae65": 1140, "\ub7ab": 721, "\uc606": 809, "\ub0b1": 1218, "\ub053": 1106, "\ub2f7": 890, "\uae54": 777, "k": 863, "\ubb58": 1203, "\uc539": 1264, "\ube75": 958, "\u25c7": 788, "\ub057": 915, "\uc274": 1206, "\uad49": 874, "\uc308": 1308, "\uc11e": 963, "\uc878": 647, "\uc595": 1475, "\ub214": 837, "\uc950": 928, "\uc369": 1145, "\uc78e": 1045, "\ud2f4": 850, "\ucfe8": 919, "r": 859, "e": 921, "s": 929, "h": 992, "\uc53b": 1061, "\ud034": 997, "\uc2e3": 1170, "\uc587": 1115, "\ub284": 1031, "\ud585": 1572, "\uad7d": 1086, "\uae45": 1337, "\ub95c": 1019, "\uba5c": 1034, "\uce75": 1313, "\ub80c": 590, "\uc999": 1214, "\uc100": 1359, "\uc19c": 1169, "\ucef5": 937, "\uad75": 1121, "\uc379": 1263, "\ub367": 523, "\uaf64": 1148, "\ubee3": 1449, "\uc8e0": 635, "\ub78f": 1486, "\ub560": 1545, "\uc9da": 1024, "\ub5c4": 1506, "p": 1025, "n": 1007, "\uacf1": 1093, "\ucda7": 1389, "\uac1b": 1587, "\ucc39": 1480, "\ub299": 1369, "\uc813": 1177, "\uaed1": 1256, "\ucdcc": 1334, "\uc2ad": 1606, "\ub6ab": 1026, "\ub9d9": 1259, "\ub154": 1144, "\uaef4": 849, "\uc090": 1165, "\ubccd": 1021, "\ubfcd": 1390, "\ub36e": 934, "\uba4d": 986, "\ub9e3": 1519, "\u2192": 1253, "\ub2d9": 1067, "\uaf42": 1243, "\ud284": 1785, "\ud22d": 1391, "\uba71": 1570, "\ucc59": 766, "\uaff0": 1323, "\uc22f": 1356, "\uc635": 867, "\ucea1": 1008, "\uc290": 1113, "\ub7ff": 1272, "\uce98": 1074, "\ud14d": 792, "\uc3dc": 1379, "\ube10": 1009, "\ubca4": 506, "\ud54d": 1299, "u": 1200, "d": 955, "i": 924, "\uc719": 1251, "\ub2fb": 1669, "\ucb10": 1438, "\ube84": 1533, "\uc2eb": 1070, "\uae61": 1333, "\ub738": 1238, "\ube57": 926, "\uad7c": 1645, "\uaf49": 1236, "\ucabc": 1172, "\ub52a": 1043, "\ub968": 1054, "f": 1568, "\ud6fc": 774, "w": 1367, "\uc19d": 1720, "\ub864": 816, "\uba64": 982, "\ucc48": 1364, "+": 1223, "Z": 1321, "\uc90d": 1220, "\ub429": 626, "\ud540": 743, "\uaecc": 1468, "\ubc49": 1358, "\uce89": 1303, "\uafe8": 1149, "\ud749": 889, "\uce94": 995, "\uc9ec": 1318, "\uca50": 1594, "\ud3fc": 783, "\ud3f0": 464, "\ub69d": 1027, "\uc0ad": 747, "\ub128": 1151, "\ub364": 999, "\uc81d": 715, "\uc96c": 1241, "\ud3f4": 687, "\ubf18": 1738, "\ub7a9": 943, "\ub9d1": 925, "\ub217": 1775, "\ub2e6": 1101, "\ud0ec": 1196, "\ub374": 898, "v": 1415, "\uc0cc": 978, "\ud0e0": 948, "\ud1b0": 1229, "\ub93c": 1300, "\uce84": 1120, "\ubb8c": 1517, "\ubc34": 947, "\ub8fd": 1384, "\ub3d4": 1231, "\ud1a4": 801, "\ucffc": 1199, "\ub158": 1425, "\ub7a0": 1233, "\ucfb0": 1727, "\ubafc": 1592, "\uaf3c": 735, "\u25c8": 1497, "\ub205": 1403, "\u25c6": 817, "@": 930, "\uce69": 1002, "\ub380": 1523, ";": 1512, "\ub72c": 1216, "j": 1221, "\u300c": 1397, "\u300d": 1393, "\ud2ac": 1285, "\ucfc4": 987, "\u738b": 1829, "\ub46c": 1014, "\uff5e": 1642, "\u25a0": 956, "\u8eca": 1890, "\ub2db": 1057, "\ub834": 612, "\ud018": 1114, "\uc92c": 722, "\u7f8e": 1436, "\uafe9": 1657, "\ubc1f": 899, "\ud5d0": 1186, "\ubed4": 1077, "*": 1298, "\ubfb0": 1348, "\uc954": 1289, "\uc234": 1715, "\ub7b4": 1202, "\ub2dd": 779, "\uc60c": 1342, "\ubed7": 1222, "\ubc38": 866, "\u3003": 1764, "\ucc14": 1160, "\uc90c": 1126, "\ub010": 1091, "\ub014": 1167, "\ud38c": 1096, "\uc7a4": 1625, "\u674e": 1745, "\ub1a8": 873, "Q": 1179, "\uc0c5": 1400, "\uaebd": 1640, "\ud0f1": 954, "\ub72f": 1156, "\ub7ac": 1098, "\u5317": 1564, "\uc7a3": 1139, "\uc270": 1406, "\uc98c": 760, "\uc37d": 1457, "\uc6c1": 1609, "\ub797": 1446, "\ub54b": 1842, "\ub315": 1526, "\ubcdc": 1728, "\ubeec": 1794, "\uc5e3": 1174, "\uc15c": 786, "\ub755": 1614, "\uc653": 1362, "\uc068": 1104, "\ubbac": 1163, "\ub9f5": 1082, "\u25cf": 1319, "\ud384": 1225, "\ub6f8": 1515, "\ud514": 974, "\uccc7": 1692, "\u65b0": 1544, "\ubc08": 1595, "\ud058": 1305, "\ubc40": 1281, "\ub819": 1386, "\ub461": 1324, "\uac13": 1154, "\uc6f0": 985, "\ud1a8": 1049, "\u7121": 1761, "\u5fc3": 1806, "\ud143": 1123, "\ubc9a": 1226, "\ub134": 1670, "\uc708": 881, "\ubdd4": 1107, "\ub304": 1040, "\uad7f": 1157, "\ubab9": 1407, "\u60c5": 1920, "\ubf50": 1173, "\u53cd": 1534, "\u5b78": 1891, "\u7530": 1899, "\u5c71": 1790, "\uca54": 1109, "\u5316": 1903, "z": 1730, "\u5357": 1900, "\u8ecd": 1694, "\ub194": 1176, "\ucad1": 1711, "\uc139": 994, "\u5c0d": 1491, "\uc3d8": 980, "\u5927": 1697, "\u97d3": 1725, "\u5916": 1932, "\uc6f9": 807, "\uaf80": 1081, "\u4e2d": 1520, "\u570b": 1747, "\ubb90": 1796, "\ud399": 1065, "\ub4c0": 988, "\u260e": 1269, "\uc250": 1063, "\ucf70": 1315, "\u5b50": 1864, "\uce04": 1312, "\ub0d1": 1888, "\ub2a0": 1131, "\uc5cc": 1413, "\ub463": 1712, "\ud1a1": 787, "\uc30c": 1547, "\ub810": 1246, "\ub371": 1261, "\u767c": 1687, "\uc58c": 1529, "\ud29c": 900, "\u793e": 1689, "\uc29b": 1620, "\ucc54": 1208, "\u9751": 1765, "\ub799": 732, "\ud6c5": 1713, "\uc7bd": 1811, "\ub5b4": 1388, "\uc0f7": 1143, "\uaebe": 1064, "\ub6f4": 1537, "\ubc99": 1376, "\u5973": 1843, "\ucef7": 1056, "\ud789": 1702, "\uccb8": 1339, "\ub524": 1278, "\ubee4": 1612, "\uc0db": 1453, "\uae6c": 1442, "\uc3f4": 1478, "\u4e09": 1797, "\u751f": 1766, "\ub310": 1119, "\uae7c": 1643, "\ud0f0": 1456, "\u884c": 1880, "\ud295": 1525, "\ud280": 940, "\uc1a5": 1280, "\uc597": 1428, "\ub818": 1244, "\uca0d": 1793, "\u91d1": 1674, "\ud1b1": 896, "\ud33b": 1483, "\uc82c": 1563, "\u6027": 1741, "\ucb49": 1194, "\uc6dc": 1467, "\uc634": 1175, "\uca4c": 1133, "\u00d7": 1927, "\uac2f": 1146, "\uc5f7": 1690, "\ubc85": 996, "\ud37d": 1599, "\uaf5d": 1508, "\uac94": 1191, "\ucf65": 1297, "\ucf78": 1835, "\ucf55": 1247, "\uad82": 1434, "\uc123": 1257, "\ubf40": 1260, "\ucc10": 1502, "\uc50c": 1267, "\ub544": 1644, "\ubea8": 1411, "\ub0c7": 1600, "\ubc0b": 1188, "\ub5b3": 1316, "\ub618": 1355, "\uba69": 1598, "\uc465": 1204, "\ud6d4": 1087, "\ud2f8": 1020, "\uafc7": 1349, "\uc0bf": 1265, "\ud391": 1224, "\uac07": 1178, "\ud3ab": 1249, "\ud47c": 1147, "\u6587": 1723, "\u25bc": 1522, "\uc73d": 1451, "\u25bd": 1735, "\ubcb3": 1338, "\uc3d9": 1416, "\ub11b": 1266, "\u5c0f": 1926, "\ud241": 1125, "\ud719": 1803, "\u65e5": 1623, "\u25a1": 1507, "\u4eba": 1673, "\ube61": 1335, "#": 1310, "\uc211": 1778, "\uc9e4": 1370, "\ub291": 1250, "\ud248": 1275, "\ube80": 1292, "\u6230": 1913, "\u975e": 1590, "\u6b63": 1833, "\u653f": 1850, "\u25b3": 666, "\ub525": 1290, "\u5bb6": 1718, "\ucd78": 1744, "\u696d": 1868, "\u524d": 1540, "\u9280": 1816, "\u6734": 1691, "\uc0d0": 1193, "\uad88": 1234, "\ub07d": 1228, "\ud338": 1284, "\u4e00": 1821, "\u5b89": 1714, "\u5f35": 1933, "\ud0a5": 1476, "\uafb9": 1499, "\ubdf4": 1763, "\uc231": 1340, "\ud799": 1242, "\uad18": 1569, "\u300a": 1553, "\ud0e4": 1352, "\u5167": 1923, "\u4eac": 1822, "\uc648": 1314, "\u5c55": 1916, "\uc74a": 1626, "\uc384": 1405, "\u795e": 1872, "\ud3c8": 1245, "\uc2f9": 1161, "\u4e0d": 1878, "\ub36b": 1559, "\u6c23": 1856, "\u5148": 1772, "\u91ce": 1709, "\u6cd5": 1881, "\uade4": 1279, "\ube54": 1181, "x": 1579, "\ub625": 1306, "\ud038": 1329, "\ucd10": 1618, "\ub381": 1917, "\ud2bf": 1375, "\uc9f1": 1291, "\uadc4": 1419, "\u6771": 1798, "\ud613": 1905, "\uad90": 1016, "\ub81b": 991, "\ucf67": 1099, "\ub188": 1211, "\u9053": 1762, "\u5168": 1824, "\u6d77": 1845, "\u798f": 1924, "\u5dde": 1636, "\ud188": 1409, "\u5929": 1869, "\u7537": 1909, "\ub515": 1377, "\uc7bf": 1557, "\ucb5d": 1886, "\uc575": 746, "\uc19f": 1029, "\u4e0a": 1858, "\u5730": 1940, "\ucf85": 1698, "\u9ad8": 1788, "\ub0c5": 1276, "\ud5d9": 1897, "\u9ee8": 1941, "\uae7d": 1921, "\u6bcd": 1942, "\ub10c": 1209, "\ub25c": 1366, "\ubb88": 1628, "\uc298": 1159, "\uc200": 1666, "_": 1602, "\ub0b5": 1417, "\ud401": 1387, "\ub754": 1353, "\ub5b5": 1928, "\uc21f": 1518, "\u6c11": 1892, "\u5bcc": 1883, "\ud168": 1450, "\ub365": 1326, "\ud54c": 1492, "\uaec4": 1455, "\uc660": 1464, "\uae41": 1322, "\uc641": 1445, "\ucf04": 1282, "\ud2cb": 1549, "\uad9c": 1554, "\ubcd0": 1530, "\ud515": 1834, "\ub234": 1127, "\uaf79": 1844, "\uc468": 1678, "\ud3c4": 1347, "\uadd3": 1510, "\uc9e2": 1832, "\uc705": 1639, "\ud2d4": 1494, "\u2605": 1616, "\uc5ce": 1213, "\ubfd4": 1328, "\ub2aa": 1354, "\ub138": 1295, "\ub55c": 1574, "\ub9cf": 1396, "\u2191": 1604, "\uc9ed": 1542, "\uc309": 1580, "\ubcf6": 1137, "\uba67": 1287, "\ub301": 1429, "\ubccf": 1667, "\ud234": 1232, "\ud649": 1336, "\uc136": 1830, "\uc63b": 1536, "\ub1fd": 1575, "\ub15c": 1749, "\uc0e8": 1571, "\uacd7": 1751, "\ud479": 1268, "\uaed0": 1684, "\ucad2": 1746, "\ub748": 1210, "\uceeb": 1373, "[": 414, "]": 492, "\ub700": 1847, "\ube90": 1532, "\ud3ad": 1466, "\ubf1b": 1566, "\ub9ec": 1638, "\ubf41": 1767, "\uadc8": 1752, "\uaf3f": 1585, "\uc9ca": 1431, "\u300e": 1567, "\u300f": 1573, "\ub528": 1851, "\ub3a0": 1548, "\u516c": 1865, "\uc4f1": 1596, "\ube7d": 1424, "\u5e73": 1737, "\ud6d7": 1422, "\ud711": 1866, "\uae4d": 1477, "\uc5e5": 1539, "\uc9e0": 1371, "\ubd59": 1444, "\ub314": 1345, "\ucc21": 1589, "\u820a": 1853, "\ud0b7": 970, "\ub775": 1817, "\uac85": 1668, "\ubed8": 1495, "\ub9f8": 1664, "\uc58f": 1433, "\uafcd": 1699, "\uc53d": 1317, "\ucff5": 1443, "\ub561": 1479, "\uc7e4": 1938, "\uce61": 1696, "\uc90f": 1610, "\ud141": 1402, "\ud6e4": 1469, "\ucee5": 1524, "\uac38": 1385, "\ucc1c": 1162, "\uc584": 1311, "\ucda5": 1341, "\uc69c": 1860, "\uce85": 1582, "\ub6a4": 1488, "\ub9f7": 1423, "\ud5f9": 1484, "\uc36c": 1331, "\ube7b": 1859, "\uae7b": 1631, "\ub383": 1907, "\uc605": 1381, "\ubc0c": 1392, "\uc0f9": 1414, "\uad2d": 1607, "\uacf6": 1361, "\uc3ed": 1688, "\ud03c": 1591, "\uac8a": 1779, "\uba84": 1418, "\u2299": 1873, "\ud0ed": 1271, "\u201c": 154, "\u2018": 288, "\u2019": 284, "\u201d": 152, "\u2015": 1420, "\u25a3": 1936, "\ubd4c": 1898, "\u9577": 1925, "\u5e02": 1799, "\u5834": 1839, "\ud31c": 1185, "\u4e59": 1914, "\uc651": 1511, "\u7684": 1943, "\u8207": 1758, "\u4f01": 1929, "\ubca1": 1283, "\u6c34": 1840, "\ucb50": 1808, "\uaf30": 1732, "\ud46f": 1786, "\u611b": 1855, "\uba53": 1807, "\ubd48": 1605, "\ucbd4": 1404, "\uc7c8": 1632, "\uc958": 1550, "\uacea": 1637, "\ud73c": 1876, "\uac2d": 1487, "\ubf55": 1309, "{": 1679, "}": 1685, "\uac54": 1884, "\ube64": 1660, "\u2500": 1706, "\uc538": 1731, "\uba4e": 1707, "\ubd50": 1750, "\uc0ec": 1543, "\ud390": 1906, "\ud000": 1460, "\ucad9": 1776, "\ub189": 1831, "\ucc27": 1782, "\uae70": 1624, "\ucf20": 1432, "\ucb48": 1521, "\uac8b": 1818, "\ube91": 1426, "\ubb3d": 1769, "\ubbc8": 1482, "\ud0c9": 1719, "\ubb44": 1083, "\u7fd2": 1791, "\ud79d": 1742, "\ube55": 1447, "`": 616, "\uc18e": 1621, "\ub5c0": 1514, "\uac09": 1562, "\ub527": 1320, "\ubbb4": 1634, "\ub4d0": 1627, "\ud1b3": 1722, "\u3008": 1801, "\u3009": 1812, "\uc887": 1458, "\ucf24": 1593, "\ucef9": 1736, "\u8aaa": 1944, "\ubb61": 1800, "\ub091": 1934, "\ubc09": 1650, "\uc530": 1672, "\uac17": 1777, "\ud301": 1293, "\uc42c": 1662, "\uc0dc": 1852, "\uc607": 1649, "\uc82f": 1235, "\uca84": 1633, "\ucc57": 1461, "\uc0af": 1904, "\ud3ff": 1792, "\ud0ef": 1671, "\uc2a5": 1836, "\ub11c": 1810, "\ud081": 1910, "\ud5f7": 1459, "\ucc4c": 1408, "\ub0d4": 1846, "\ub059": 1686, "\ub81d": 1768, "\uc7b0": 1695, "\ub31c": 1437, "\ud140": 951, "\uaf48": 1784, "\ub260": 1854, "\u89aa": 1704, "\u99ac": 1945, "\uc82d": 1682, "\ubc27": 1503, "\ud5f5": 1700, "\ud683": 1630, "\ub0d8": 1930, "\ubee5": 1516, "\uc7dd": 1773, "\uc1f3": 1546, "\ud5c9": 1809, "\uafc9": 1739, "\ucac4": 1325, "\uc7b4": 1894, "\ub11d": 1693, "\u300b": 1500, "\uc251": 1780, "\ub5cf": 1641, "\ub3db": 1601, "\ub2f3": 1535, "\uafce": 1613, "\ub5d0": 1465, "\ubd2c": 1889, "\ubf09": 1760, "\ub664": 1823, "\uc169": 1819, "\ub768": 1560, "\ub119": 1656, "\uc314": 1939, "\ud565": 1635, "\ubdf8": 1683, "\ucfe1": 1332, "\ud0b5": 1558, "\uc573": 1583, "\ud56b": 1089, "\ucb64": 1578, "\ub18b": 1895, "\ube73": 1774, "\ud17c": 1597, "\ud5e5": 1661, "\uc9f0": 1608, "\ub74c": 1652, "\uc388": 1781, "\ub4e6": 1653, "\ub5ab": 1826, "\ud57c": 1588, "\uce87": 1729, "\ud2a4": 1577, "\uca68": 1870, "\ub554": 1675, "\uac9f": 1395, "\uc29d": 1705, "\ud590": 1874, "\ud3a8": 1726, "\uceac": 1827, "\uc14d": 1877, "\uc733": 1541, "\ud651": 1862, "\uc14c": 1586, "\uc408": 1561, "\ud5f4": 1716, "\ucea5": 1676, "\uc069": 1759, "\ud15d": 1383, "\uc479": 1756, "\uc329": 1646, "|": 1454, "\u500d": 1937, "\ud15f": 1802, "\uc378": 1372, "\uaeeb": 1787, "\uc6e1": 1770, "\ub311": 1581, "\ucc1d": 1708, "\uafcb": 1412, "\ud667": 1556, "\u00b0": 1647, "\uc737": 1531, "\ucfe4": 1380, "\ucc60": 1710, "\u6545": 1344, "\uc54e": 1922, "\uc8e4": 1659, "\u8fd1": 1795, "\ud4f0": 1205, "\ub4c8": 1134, "\uc204": 1472, "\ub055": 1753, "\uc974": 1743, "\uc6cd": 1187, "\ud71c": 1603, "\uc83c": 1501, "\uc571": 682, "\u5cf6": 1879, "\ubb4d": 1703, "\ud144": 1665, "\ud330": 1401, "\uc6a4": 1814, "\ucf10": 1473, "\ud3a9": 1485, "\ub01c": 1740, "\uc258": 1513, "\u119e": 546, "\u25b2": 558, "\uc167": 1360, "\u3010": 1088, "\u3011": 1050, "\u25c0": 1180, "\u2501": 1882, "\uc0f5": 1058, "\ucc55": 1748, "\ucea3": 1368, "\ub844": 1505, "\ud31f": 1288, "\ucd28": 1481, "\uad0c": 1430, "\u00a9": 1551, "\u25b7": 1052, "\ubcb5": 1474, "\u0394": 1183, "\u1175": 1901, "\uc8cc": 1837, "\u00ae": 1902, "\uad63": 1629, "\u2022": 1398, "\u200b": 1885, "\u2219": 1330, "\ud004": 1258, "\ucac0": 1504, "\ud6d9": 1448, "\ucff0": 1733, "\u261e": 1084, "\u25a6": 1239, "\ucff1": 1721, "\u1100": 1296, "\u203b": 1555, "\uc8d7": 1838, "\\": 1378, "\u1107": 1915, "\u1109": 1887, "\u1102": 1538, "\ufffd": 1825, "\uba00": 1861, "\u2027": 1435, "\ud035": 1421, "\ud38d": 1622, "\uce28": 1771, "\uc20f": 1382, "\uc0e5": 1848, "\u110c": 1946, "\ud25c": 1757, "\ud2a0": 1493, "\u1103": 1681, "\u30fb": 1724, "\uac39": 1863, "\uc174": 1528, "\ud4f8": 1648, "\uac2c": 1875, "\u2013": 1754, "\uc698": 1565, "\ub01d": 1783, "\ud339": 1615, "\ud700": 1911, "\u0301": 1849, "\uc324": 1701, "\ud440": 1804, "\ud288": 1584, "\u110b": 1680, "\u03b1": 1947, "\ud045": 1935, "\uc1bd": 1908, "\uc5e1": 1677, "\ub135": 1789, "\ud4cc": 1857, "\ub584": 1871, "\u25ce": 1841, "\ucf74": 1658, "\u1105": 1948, "\uce5f": 1867, "\uc714": 1755, "\uc730": 1931, "\uc38c": 1717, "\u1106": 1912, "\u2661": 1734, "\u2502": 1527, "\uc0b5": 1896, "\uccb5": 1805, "\ub27c": 1813, "\ubc50": 1918, "\u2032": 1828, "\uc62d": 1820, "\ucd14": 1919, "\uc7c9": 1893, "__ETC__": 1949, "__PAD__": 1950}
--------------------------------------------------------------------------------
/pykospacing/resources/models/fingerprint.pb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/haven-jeon/PyKoSpacing/b32a889cbd10b006d2f4aba118f0cd5b677e2979/pykospacing/resources/models/fingerprint.pb
--------------------------------------------------------------------------------
/pykospacing/resources/models/saved_model.pb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/haven-jeon/PyKoSpacing/b32a889cbd10b006d2f4aba118f0cd5b677e2979/pykospacing/resources/models/saved_model.pb
--------------------------------------------------------------------------------
/pykospacing/resources/models/variables/variables.data-00000-of-00001:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/haven-jeon/PyKoSpacing/b32a889cbd10b006d2f4aba118f0cd5b677e2979/pykospacing/resources/models/variables/variables.data-00000-of-00001
--------------------------------------------------------------------------------
/pykospacing/resources/models/variables/variables.index:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/haven-jeon/PyKoSpacing/b32a889cbd10b006d2f4aba118f0cd5b677e2979/pykospacing/resources/models/variables/variables.index
--------------------------------------------------------------------------------
/requirements.txt:
--------------------------------------------------------------------------------
1 | tensorflow >= 2.16.2
2 | h5py >= 3.10.0
3 | argparse >= 1.1.0
4 |
--------------------------------------------------------------------------------
/setup.py:
--------------------------------------------------------------------------------
1 | from setuptools import setup
2 | import os, platform
3 |
4 | def requirements():
5 | if platform.system() == 'Darwin':
6 | return []
7 |
8 | def open_req(req_file):
9 | with open(os.path.join(os.path.dirname(os.path.abspath("__file__")), req_file)) as f:
10 | return f.read().splitlines()
11 |
12 | return open_req('requirements.txt')
13 |
14 | setup(name='pykospacing',
15 | python_requires='>=3.6',
16 | version=0.5,
17 | url='https://github.com/haven-jeon/PyKoSpacing',
18 | license='GPL-3',
19 | author='Heewon Jeon',
20 | author_email='madjakarta@gmail.com',
21 | description='Python package for automatic Korean word spacing.',
22 | packages=['pykospacing', ],
23 | long_description=open('README.md', encoding='utf-8').read(),
24 | zip_safe=False,
25 | include_package_data=True,
26 |
27 | install_requires=requirements(),
28 |
29 | entry_points={
30 | 'console_scripts': [
31 | 'pykos = pykospacing.pykos:main',
32 | ],
33 | },
34 | )
35 |
--------------------------------------------------------------------------------
/test.py:
--------------------------------------------------------------------------------
1 | from pykospacing import Spacing
2 | spacing = Spacing()
3 |
4 | blue_archive = """아즈사쨩이살인자가되는건싫어요...
5 | 그런어둡고우울한이야기,전싫어요
6 | 그게진실이라고,이세계의본질이라고해도,전싫어요!
7 | 저는좋아하는게있어요!
8 | 평범하고,별다른개성도없는저이지만....자신이좋아하는것에한해선절대로양보못해요!
9 | 우정으로고난을극복하여
10 | 노력이제대로보답받아서
11 | 힘든일은위로받고,친구들과서로위로해주고......!
12 | 괴로운일이있어도....누구나가최후엔,웃는얼굴이될수있는!
13 | 그런해피엔딩을전좋아해요!!
14 | 누가뭐라고말해도,몇번이고말해보이겠어요!
15 | 저희가그려나가는이야기는,저희가정하는거에요!
16 | 끝내거나하지않을거에요,앞으로도계속이어나갈거에요!
17 | 우리들의이야기......
18 | 우리들의,청춘의이야기를!!"""
19 |
20 | print(spacing("김형호영화시장분석가는'1987'의네이버영화정보네티즌10점평에서언급된단어들을지난해12월27일부터올해1월10일까지통계프로그램R과KoNLP패키지로텍스트마이닝하여분석했다."))
21 | print(spacing('귀밑에서턱까지잇따라난수염을구레나룻이라고한다.'))
22 |
23 | spacing = Spacing(rules=['구레나룻'])
24 |
25 | print(spacing('귀밑에서턱까지잇따라난수염을구레나룻이라고한다.'))
26 |
27 | hifumi_daisuki = ''
28 |
29 | for hifumi_word in blue_archive.split('\n'):
30 | hifumi_daisuki += spacing(hifumi_word) + '\n'
31 | print(hifumi_daisuki)
--------------------------------------------------------------------------------