langidentify 1.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (151) hide show
  1. langidentify-1.0.0/LICENSE +201 -0
  2. langidentify-1.0.0/PKG-INFO +210 -0
  3. langidentify-1.0.0/README.md +187 -0
  4. langidentify-1.0.0/pyproject.toml +44 -0
  5. langidentify-1.0.0/setup.cfg +4 -0
  6. langidentify-1.0.0/src/langidentify/__init__.py +44 -0
  7. langidentify-1.0.0/src/langidentify/accent_remover.py +95 -0
  8. langidentify-1.0.0/src/langidentify/alphabet.py +222 -0
  9. langidentify-1.0.0/src/langidentify/detector.py +459 -0
  10. langidentify-1.0.0/src/langidentify/language.py +287 -0
  11. langidentify-1.0.0/src/langidentify/model.py +194 -0
  12. langidentify-1.0.0/src/langidentify/model_loader.py +607 -0
  13. langidentify-1.0.0/src/langidentify/models/__init__.py +0 -0
  14. langidentify-1.0.0/src/langidentify/models/full/__init__.py +0 -0
  15. langidentify-1.0.0/src/langidentify/models/lite/__init__.py +0 -0
  16. langidentify-1.0.0/src/langidentify/models/lite/ngrams-af.txt.gz +0 -0
  17. langidentify-1.0.0/src/langidentify/models/lite/ngrams-am.txt.gz +0 -0
  18. langidentify-1.0.0/src/langidentify/models/lite/ngrams-ar.txt.gz +0 -0
  19. langidentify-1.0.0/src/langidentify/models/lite/ngrams-az.txt.gz +0 -0
  20. langidentify-1.0.0/src/langidentify/models/lite/ngrams-be.txt.gz +0 -0
  21. langidentify-1.0.0/src/langidentify/models/lite/ngrams-bg.txt.gz +0 -0
  22. langidentify-1.0.0/src/langidentify/models/lite/ngrams-ca.txt.gz +0 -0
  23. langidentify-1.0.0/src/langidentify/models/lite/ngrams-cs.txt.gz +0 -0
  24. langidentify-1.0.0/src/langidentify/models/lite/ngrams-cy.txt.gz +0 -0
  25. langidentify-1.0.0/src/langidentify/models/lite/ngrams-da.txt.gz +0 -0
  26. langidentify-1.0.0/src/langidentify/models/lite/ngrams-de.txt.gz +0 -0
  27. langidentify-1.0.0/src/langidentify/models/lite/ngrams-en.txt.gz +0 -0
  28. langidentify-1.0.0/src/langidentify/models/lite/ngrams-eo.txt.gz +0 -0
  29. langidentify-1.0.0/src/langidentify/models/lite/ngrams-es.txt.gz +0 -0
  30. langidentify-1.0.0/src/langidentify/models/lite/ngrams-et.txt.gz +0 -0
  31. langidentify-1.0.0/src/langidentify/models/lite/ngrams-eu.txt.gz +0 -0
  32. langidentify-1.0.0/src/langidentify/models/lite/ngrams-fa.txt.gz +0 -0
  33. langidentify-1.0.0/src/langidentify/models/lite/ngrams-fi.txt.gz +0 -0
  34. langidentify-1.0.0/src/langidentify/models/lite/ngrams-fr.txt.gz +0 -0
  35. langidentify-1.0.0/src/langidentify/models/lite/ngrams-ga.txt.gz +0 -0
  36. langidentify-1.0.0/src/langidentify/models/lite/ngrams-hr.txt.gz +0 -0
  37. langidentify-1.0.0/src/langidentify/models/lite/ngrams-hu.txt.gz +0 -0
  38. langidentify-1.0.0/src/langidentify/models/lite/ngrams-id.txt.gz +0 -0
  39. langidentify-1.0.0/src/langidentify/models/lite/ngrams-is.txt.gz +0 -0
  40. langidentify-1.0.0/src/langidentify/models/lite/ngrams-it.txt.gz +0 -0
  41. langidentify-1.0.0/src/langidentify/models/lite/ngrams-la.txt.gz +0 -0
  42. langidentify-1.0.0/src/langidentify/models/lite/ngrams-lb.txt.gz +0 -0
  43. langidentify-1.0.0/src/langidentify/models/lite/ngrams-lg.txt.gz +0 -0
  44. langidentify-1.0.0/src/langidentify/models/lite/ngrams-lt.txt.gz +0 -0
  45. langidentify-1.0.0/src/langidentify/models/lite/ngrams-lv.txt.gz +0 -0
  46. langidentify-1.0.0/src/langidentify/models/lite/ngrams-mi.txt.gz +0 -0
  47. langidentify-1.0.0/src/langidentify/models/lite/ngrams-mk.txt.gz +0 -0
  48. langidentify-1.0.0/src/langidentify/models/lite/ngrams-mn.txt.gz +0 -0
  49. langidentify-1.0.0/src/langidentify/models/lite/ngrams-ms.txt.gz +0 -0
  50. langidentify-1.0.0/src/langidentify/models/lite/ngrams-nl.txt.gz +0 -0
  51. langidentify-1.0.0/src/langidentify/models/lite/ngrams-nn.txt.gz +0 -0
  52. langidentify-1.0.0/src/langidentify/models/lite/ngrams-no.txt.gz +0 -0
  53. langidentify-1.0.0/src/langidentify/models/lite/ngrams-om.txt.gz +0 -0
  54. langidentify-1.0.0/src/langidentify/models/lite/ngrams-pl.txt.gz +0 -0
  55. langidentify-1.0.0/src/langidentify/models/lite/ngrams-ps.txt.gz +0 -0
  56. langidentify-1.0.0/src/langidentify/models/lite/ngrams-pt.txt.gz +0 -0
  57. langidentify-1.0.0/src/langidentify/models/lite/ngrams-ro.txt.gz +0 -0
  58. langidentify-1.0.0/src/langidentify/models/lite/ngrams-ru.txt.gz +0 -0
  59. langidentify-1.0.0/src/langidentify/models/lite/ngrams-sk.txt.gz +0 -0
  60. langidentify-1.0.0/src/langidentify/models/lite/ngrams-sl.txt.gz +0 -0
  61. langidentify-1.0.0/src/langidentify/models/lite/ngrams-sn.txt.gz +0 -0
  62. langidentify-1.0.0/src/langidentify/models/lite/ngrams-so.txt.gz +0 -0
  63. langidentify-1.0.0/src/langidentify/models/lite/ngrams-sq.txt.gz +0 -0
  64. langidentify-1.0.0/src/langidentify/models/lite/ngrams-sr.txt.gz +0 -0
  65. langidentify-1.0.0/src/langidentify/models/lite/ngrams-st.txt.gz +0 -0
  66. langidentify-1.0.0/src/langidentify/models/lite/ngrams-sv.txt.gz +0 -0
  67. langidentify-1.0.0/src/langidentify/models/lite/ngrams-sw.txt.gz +0 -0
  68. langidentify-1.0.0/src/langidentify/models/lite/ngrams-ti.txt.gz +0 -0
  69. langidentify-1.0.0/src/langidentify/models/lite/ngrams-tl.txt.gz +0 -0
  70. langidentify-1.0.0/src/langidentify/models/lite/ngrams-tn.txt.gz +0 -0
  71. langidentify-1.0.0/src/langidentify/models/lite/ngrams-tr.txt.gz +0 -0
  72. langidentify-1.0.0/src/langidentify/models/lite/ngrams-ts.txt.gz +0 -0
  73. langidentify-1.0.0/src/langidentify/models/lite/ngrams-uk.txt.gz +0 -0
  74. langidentify-1.0.0/src/langidentify/models/lite/ngrams-ur.txt.gz +0 -0
  75. langidentify-1.0.0/src/langidentify/models/lite/ngrams-vi.txt.gz +0 -0
  76. langidentify-1.0.0/src/langidentify/models/lite/ngrams-xh.txt.gz +0 -0
  77. langidentify-1.0.0/src/langidentify/models/lite/ngrams-yo.txt.gz +0 -0
  78. langidentify-1.0.0/src/langidentify/models/lite/ngrams-zu.txt.gz +0 -0
  79. langidentify-1.0.0/src/langidentify/models/lite/skipwords.txt +67 -0
  80. langidentify-1.0.0/src/langidentify/models/lite/topwords-af.txt.gz +0 -0
  81. langidentify-1.0.0/src/langidentify/models/lite/topwords-am.txt.gz +0 -0
  82. langidentify-1.0.0/src/langidentify/models/lite/topwords-ar.txt.gz +0 -0
  83. langidentify-1.0.0/src/langidentify/models/lite/topwords-az.txt.gz +0 -0
  84. langidentify-1.0.0/src/langidentify/models/lite/topwords-be.txt.gz +0 -0
  85. langidentify-1.0.0/src/langidentify/models/lite/topwords-bg.txt.gz +0 -0
  86. langidentify-1.0.0/src/langidentify/models/lite/topwords-bs.txt.gz +0 -0
  87. langidentify-1.0.0/src/langidentify/models/lite/topwords-ca.txt.gz +0 -0
  88. langidentify-1.0.0/src/langidentify/models/lite/topwords-cs.txt.gz +0 -0
  89. langidentify-1.0.0/src/langidentify/models/lite/topwords-cy.txt.gz +0 -0
  90. langidentify-1.0.0/src/langidentify/models/lite/topwords-da.txt.gz +0 -0
  91. langidentify-1.0.0/src/langidentify/models/lite/topwords-de.txt.gz +0 -0
  92. langidentify-1.0.0/src/langidentify/models/lite/topwords-en.txt.gz +0 -0
  93. langidentify-1.0.0/src/langidentify/models/lite/topwords-eo.txt.gz +0 -0
  94. langidentify-1.0.0/src/langidentify/models/lite/topwords-es.txt.gz +0 -0
  95. langidentify-1.0.0/src/langidentify/models/lite/topwords-et.txt.gz +0 -0
  96. langidentify-1.0.0/src/langidentify/models/lite/topwords-eu.txt.gz +0 -0
  97. langidentify-1.0.0/src/langidentify/models/lite/topwords-fa.txt.gz +0 -0
  98. langidentify-1.0.0/src/langidentify/models/lite/topwords-fi.txt.gz +0 -0
  99. langidentify-1.0.0/src/langidentify/models/lite/topwords-fr.txt.gz +0 -0
  100. langidentify-1.0.0/src/langidentify/models/lite/topwords-ga.txt.gz +0 -0
  101. langidentify-1.0.0/src/langidentify/models/lite/topwords-hr.txt.gz +0 -0
  102. langidentify-1.0.0/src/langidentify/models/lite/topwords-hu.txt.gz +0 -0
  103. langidentify-1.0.0/src/langidentify/models/lite/topwords-id.txt.gz +0 -0
  104. langidentify-1.0.0/src/langidentify/models/lite/topwords-is.txt.gz +0 -0
  105. langidentify-1.0.0/src/langidentify/models/lite/topwords-it.txt.gz +0 -0
  106. langidentify-1.0.0/src/langidentify/models/lite/topwords-la.txt.gz +0 -0
  107. langidentify-1.0.0/src/langidentify/models/lite/topwords-lb.txt.gz +0 -0
  108. langidentify-1.0.0/src/langidentify/models/lite/topwords-lg.txt.gz +0 -0
  109. langidentify-1.0.0/src/langidentify/models/lite/topwords-lt.txt.gz +0 -0
  110. langidentify-1.0.0/src/langidentify/models/lite/topwords-lv.txt.gz +0 -0
  111. langidentify-1.0.0/src/langidentify/models/lite/topwords-mi.txt.gz +0 -0
  112. langidentify-1.0.0/src/langidentify/models/lite/topwords-mk.txt.gz +0 -0
  113. langidentify-1.0.0/src/langidentify/models/lite/topwords-mn.txt.gz +0 -0
  114. langidentify-1.0.0/src/langidentify/models/lite/topwords-ms.txt.gz +0 -0
  115. langidentify-1.0.0/src/langidentify/models/lite/topwords-nl.txt.gz +0 -0
  116. langidentify-1.0.0/src/langidentify/models/lite/topwords-nn.txt.gz +0 -0
  117. langidentify-1.0.0/src/langidentify/models/lite/topwords-no.txt.gz +0 -0
  118. langidentify-1.0.0/src/langidentify/models/lite/topwords-om.txt.gz +0 -0
  119. langidentify-1.0.0/src/langidentify/models/lite/topwords-pl.txt.gz +0 -0
  120. langidentify-1.0.0/src/langidentify/models/lite/topwords-ps.txt.gz +0 -0
  121. langidentify-1.0.0/src/langidentify/models/lite/topwords-pt.txt.gz +0 -0
  122. langidentify-1.0.0/src/langidentify/models/lite/topwords-ro.txt.gz +0 -0
  123. langidentify-1.0.0/src/langidentify/models/lite/topwords-ru.txt.gz +0 -0
  124. langidentify-1.0.0/src/langidentify/models/lite/topwords-sk.txt.gz +0 -0
  125. langidentify-1.0.0/src/langidentify/models/lite/topwords-sl.txt.gz +0 -0
  126. langidentify-1.0.0/src/langidentify/models/lite/topwords-sn.txt.gz +0 -0
  127. langidentify-1.0.0/src/langidentify/models/lite/topwords-so.txt.gz +0 -0
  128. langidentify-1.0.0/src/langidentify/models/lite/topwords-sq.txt.gz +0 -0
  129. langidentify-1.0.0/src/langidentify/models/lite/topwords-sr.txt.gz +0 -0
  130. langidentify-1.0.0/src/langidentify/models/lite/topwords-st.txt.gz +0 -0
  131. langidentify-1.0.0/src/langidentify/models/lite/topwords-sv.txt.gz +0 -0
  132. langidentify-1.0.0/src/langidentify/models/lite/topwords-sw.txt.gz +0 -0
  133. langidentify-1.0.0/src/langidentify/models/lite/topwords-ti.txt.gz +0 -0
  134. langidentify-1.0.0/src/langidentify/models/lite/topwords-tl.txt.gz +0 -0
  135. langidentify-1.0.0/src/langidentify/models/lite/topwords-tn.txt.gz +0 -0
  136. langidentify-1.0.0/src/langidentify/models/lite/topwords-tr.txt.gz +0 -0
  137. langidentify-1.0.0/src/langidentify/models/lite/topwords-ts.txt.gz +0 -0
  138. langidentify-1.0.0/src/langidentify/models/lite/topwords-uk.txt.gz +0 -0
  139. langidentify-1.0.0/src/langidentify/models/lite/topwords-ur.txt.gz +0 -0
  140. langidentify-1.0.0/src/langidentify/models/lite/topwords-vi.txt.gz +0 -0
  141. langidentify-1.0.0/src/langidentify/models/lite/topwords-xh.txt.gz +0 -0
  142. langidentify-1.0.0/src/langidentify/models/lite/topwords-yo.txt.gz +0 -0
  143. langidentify-1.0.0/src/langidentify/models/lite/topwords-zu.txt.gz +0 -0
  144. langidentify-1.0.0/src/langidentify/word_segmenter.py +119 -0
  145. langidentify-1.0.0/src/langidentify.egg-info/PKG-INFO +210 -0
  146. langidentify-1.0.0/src/langidentify.egg-info/SOURCES.txt +149 -0
  147. langidentify-1.0.0/src/langidentify.egg-info/dependency_links.txt +1 -0
  148. langidentify-1.0.0/src/langidentify.egg-info/requires.txt +7 -0
  149. langidentify-1.0.0/src/langidentify.egg-info/top_level.txt +1 -0
  150. langidentify-1.0.0/tests/test_detector.py +208 -0
  151. langidentify-1.0.0/tests/test_installed.py +113 -0
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either expressed or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,210 @@
1
+ Metadata-Version: 2.4
2
+ Name: langidentify
3
+ Version: 1.0.0
4
+ Summary: Fast, high-accuracy language detection for Python. Uses ngram classification augmented with a topwords signal for improved short-text accuracy. Supports 80+ languages.
5
+ Author-email: Jeremy Lilley <jeremy@jlilley.net>
6
+ License-Expression: Apache-2.0
7
+ Project-URL: Homepage, https://github.com/jlpka/langidentify
8
+ Project-URL: Repository, https://github.com/jlpka/langidentify
9
+ Keywords: language-detection,nlp,ngram,text-classification
10
+ Classifier: Development Status :: 5 - Production/Stable
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Topic :: Text Processing :: Linguistic
14
+ Requires-Python: >=3.9
15
+ Description-Content-Type: text/markdown
16
+ License-File: LICENSE
17
+ Requires-Dist: cjclassifier>=1.0.3
18
+ Provides-Extra: full
19
+ Requires-Dist: langidentify-full-model>=1.0.0; extra == "full"
20
+ Provides-Extra: dev
21
+ Requires-Dist: pytest>=7.0; extra == "dev"
22
+ Dynamic: license-file
23
+
24
+ # LangIdentify
25
+
26
+ A fast, lightweight language detection library for Python. LangIdentify detects
27
+ the language of text using a combination of ngram frequency analysis and
28
+ whole-word ("topwords") frequency signals, both trained on the Wikipedia corpus.
29
+ It supports 80+ languages across Latin, Cyrillic, Arabic, CJK, and many other
30
+ scripts, and runs entirely offline with no network calls.
31
+
32
+ Most language detection libraries rely solely on character ngram models. While
33
+ ngrams are an excellent primary signal, they struggle with short or ambiguous
34
+ text. LangIdentify augments ngram scoring with a topwords signal that identifies
35
+ common whole words from each language, giving it higher accuracy on short
36
+ sentences than other approaches -- even on two-word phrases.
37
+
38
+ ## Quick start
39
+
40
+ ### Install
41
+
42
+ ```bash
43
+ pip install langidentify
44
+ ```
45
+
46
+ For the full (higher accuracy) model:
47
+
48
+ ```bash
49
+ pip install "langidentify[full]"
50
+ ```
51
+
52
+ ### Basic usage
53
+
54
+ ```python
55
+ from langidentify import Detector, Model, Language
56
+
57
+ # Load the model for the languages you care about.
58
+ languages = Language.from_comma_separated("en,fr,de,es,it")
59
+ model = Model.load(languages)
60
+
61
+ # Create a detector (lightweight, not thread-safe -- use one per thread).
62
+ detector = Detector(model)
63
+
64
+ # Detect.
65
+ lang = detector.detect("Bonjour le monde")
66
+ print(lang) # Language.FRENCH
67
+ print(lang.iso_code) # fr
68
+ ```
69
+
70
+ ### Inspecting results
71
+
72
+ After detection, `detector.results` provides scoring details:
73
+
74
+ ```python
75
+ detector.detect("The quick brown fox")
76
+ results = detector.results
77
+ print(results.result) # Language.ENGLISH
78
+ print(results.gap) # confidence gap (0.0 = close, 1.0 = decisive)
79
+ ```
80
+
81
+ ### Incremental detection
82
+
83
+ For streaming or multi-part text:
84
+
85
+ ```python
86
+ detector.clear_scores()
87
+ detector.add_text("Bonjour")
88
+ detector.add_text(" le monde")
89
+ result = detector.compute_result() # Language.FRENCH
90
+ ```
91
+
92
+ ### Language boosts
93
+
94
+ When you have prior context (e.g. an HTTP Accept-Language header), you can bias
95
+ detection toward expected languages:
96
+
97
+ ```python
98
+ boosts = model.build_boost_array({Language.FRENCH: 0.08})
99
+ lang = detector.detect("message", boosts) # FRENCH
100
+ # Without the boost, "message" is ambiguous between English and French.
101
+ ```
102
+
103
+ ### Loading from a filesystem path
104
+
105
+ If you prefer to point directly at model data files instead of using the
106
+ bundled package data:
107
+
108
+ ```python
109
+ model = Model.load_from_path("/path/to/models/lite", languages)
110
+ ```
111
+
112
+ ## Choosing languages
113
+
114
+ **Configure only the languages you actually need.** Each additional language
115
+ increases loading time and memory usage. Closely related languages can
116
+ cross-detect on very short phrases -- for example, adding Luxembourgish when
117
+ you only need German may cause short German phrases to be misidentified.
118
+
119
+ Group aliases are supported for convenience:
120
+
121
+ | Alias | Languages |
122
+ |-------|-----------|
123
+ | `efigs` | English, French, Italian, German, Spanish |
124
+ | `efigsnp` | EFIGS + Dutch, Portuguese |
125
+ | `europe_west_common` | EFIGSNP + Nordic languages |
126
+ | `europe_common` | Western + Eastern European + Cyrillic |
127
+ | `cjk` | Chinese (Simplified/Traditional), Japanese, Korean |
128
+ | `latin_alphabet` | All Latin-script languages |
129
+ | `unique_alphabet` | Languages where the script implies the language (e.g. Thai, Greek) |
130
+
131
+ ```python
132
+ languages = Language.from_comma_separated("europe_west_common,cjk")
133
+ ```
134
+
135
+ ## Lite vs. full model
136
+
137
+ Both models are trained from the same Wikipedia data but cropped at different
138
+ probability floors:
139
+
140
+ | | Lite | Full |
141
+ |---|---|---|
142
+ | Log-probability floor | -12 | -15 |
143
+ | Disk size (all languages) | ~17 MB | ~89 MB |
144
+ | Best for | Most use cases | Maximum accuracy when memory is not a concern |
145
+
146
+ By default, `Model.load()` auto-discovers which model variant is available,
147
+ preferring the full model. To force a variant:
148
+
149
+ ```python
150
+ model = Model.load_lite(languages) # recommended default
151
+ model = Model.load_full(languages) # higher accuracy, more memory
152
+ ```
153
+
154
+ ### Getting the full model
155
+
156
+ The lite model is sufficient for most use cases. If you want the full model
157
+ for maximum accuracy, install the companion package:
158
+
159
+ ```bash
160
+ pip install "langidentify[full]"
161
+ ```
162
+
163
+ This installs the `langidentify-full-model` package, which provides the full
164
+ model data. Once installed, `Model.load()` will automatically prefer the full
165
+ model, or you can request it explicitly:
166
+
167
+ ```python
168
+ model = Model.load_full(languages)
169
+ ```
170
+
171
+ ## CJK detection
172
+
173
+ Chinese/Japanese disambiguation is handled by the
174
+ [cjclassifier](https://pypi.org/project/cjclassifier/) package, which is
175
+ installed automatically as a dependency. Korean uses the distinct Hangul script
176
+ and is identified by alphabet alone.
177
+
178
+ ## Thread safety
179
+
180
+ `Model` caches loaded data in a module-level dict protected by a lock.
181
+ `Detector` is lightweight to construct and intentionally **not thread-safe**.
182
+ For concurrent detection, use a separate instance per thread:
183
+
184
+ ```python
185
+ import threading
186
+
187
+ model = Model.load(languages) # shared, thread-safe
188
+
189
+ local = threading.local()
190
+
191
+ def get_detector():
192
+ if not hasattr(local, "detector"):
193
+ local.detector = Detector(model)
194
+ return local.detector
195
+
196
+ # In each thread:
197
+ lang = get_detector().detect(text)
198
+ ```
199
+
200
+ ## Requirements
201
+
202
+ - Python 3.9+
203
+ - [cjclassifier](https://pypi.org/project/cjclassifier/) (installed automatically)
204
+
205
+ ## License
206
+
207
+ Apache License 2.0 -- see [LICENSE](LICENSE).
208
+
209
+ The bundled models contain statistical parameters derived from Wikipedia text.
210
+ The models do not contain or reproduce Wikipedia text.
@@ -0,0 +1,187 @@
1
+ # LangIdentify
2
+
3
+ A fast, lightweight language detection library for Python. LangIdentify detects
4
+ the language of text using a combination of ngram frequency analysis and
5
+ whole-word ("topwords") frequency signals, both trained on the Wikipedia corpus.
6
+ It supports 80+ languages across Latin, Cyrillic, Arabic, CJK, and many other
7
+ scripts, and runs entirely offline with no network calls.
8
+
9
+ Most language detection libraries rely solely on character ngram models. While
10
+ ngrams are an excellent primary signal, they struggle with short or ambiguous
11
+ text. LangIdentify augments ngram scoring with a topwords signal that identifies
12
+ common whole words from each language, giving it higher accuracy on short
13
+ sentences than other approaches -- even on two-word phrases.
14
+
15
+ ## Quick start
16
+
17
+ ### Install
18
+
19
+ ```bash
20
+ pip install langidentify
21
+ ```
22
+
23
+ For the full (higher accuracy) model:
24
+
25
+ ```bash
26
+ pip install "langidentify[full]"
27
+ ```
28
+
29
+ ### Basic usage
30
+
31
+ ```python
32
+ from langidentify import Detector, Model, Language
33
+
34
+ # Load the model for the languages you care about.
35
+ languages = Language.from_comma_separated("en,fr,de,es,it")
36
+ model = Model.load(languages)
37
+
38
+ # Create a detector (lightweight, not thread-safe -- use one per thread).
39
+ detector = Detector(model)
40
+
41
+ # Detect.
42
+ lang = detector.detect("Bonjour le monde")
43
+ print(lang) # Language.FRENCH
44
+ print(lang.iso_code) # fr
45
+ ```
46
+
47
+ ### Inspecting results
48
+
49
+ After detection, `detector.results` provides scoring details:
50
+
51
+ ```python
52
+ detector.detect("The quick brown fox")
53
+ results = detector.results
54
+ print(results.result) # Language.ENGLISH
55
+ print(results.gap) # confidence gap (0.0 = close, 1.0 = decisive)
56
+ ```
57
+
58
+ ### Incremental detection
59
+
60
+ For streaming or multi-part text:
61
+
62
+ ```python
63
+ detector.clear_scores()
64
+ detector.add_text("Bonjour")
65
+ detector.add_text(" le monde")
66
+ result = detector.compute_result() # Language.FRENCH
67
+ ```
68
+
69
+ ### Language boosts
70
+
71
+ When you have prior context (e.g. an HTTP Accept-Language header), you can bias
72
+ detection toward expected languages:
73
+
74
+ ```python
75
+ boosts = model.build_boost_array({Language.FRENCH: 0.08})
76
+ lang = detector.detect("message", boosts) # FRENCH
77
+ # Without the boost, "message" is ambiguous between English and French.
78
+ ```
79
+
80
+ ### Loading from a filesystem path
81
+
82
+ If you prefer to point directly at model data files instead of using the
83
+ bundled package data:
84
+
85
+ ```python
86
+ model = Model.load_from_path("/path/to/models/lite", languages)
87
+ ```
88
+
89
+ ## Choosing languages
90
+
91
+ **Configure only the languages you actually need.** Each additional language
92
+ increases loading time and memory usage. Closely related languages can
93
+ cross-detect on very short phrases -- for example, adding Luxembourgish when
94
+ you only need German may cause short German phrases to be misidentified.
95
+
96
+ Group aliases are supported for convenience:
97
+
98
+ | Alias | Languages |
99
+ |-------|-----------|
100
+ | `efigs` | English, French, Italian, German, Spanish |
101
+ | `efigsnp` | EFIGS + Dutch, Portuguese |
102
+ | `europe_west_common` | EFIGSNP + Nordic languages |
103
+ | `europe_common` | Western + Eastern European + Cyrillic |
104
+ | `cjk` | Chinese (Simplified/Traditional), Japanese, Korean |
105
+ | `latin_alphabet` | All Latin-script languages |
106
+ | `unique_alphabet` | Languages where the script implies the language (e.g. Thai, Greek) |
107
+
108
+ ```python
109
+ languages = Language.from_comma_separated("europe_west_common,cjk")
110
+ ```
111
+
112
+ ## Lite vs. full model
113
+
114
+ Both models are trained from the same Wikipedia data but cropped at different
115
+ probability floors:
116
+
117
+ | | Lite | Full |
118
+ |---|---|---|
119
+ | Log-probability floor | -12 | -15 |
120
+ | Disk size (all languages) | ~17 MB | ~89 MB |
121
+ | Best for | Most use cases | Maximum accuracy when memory is not a concern |
122
+
123
+ By default, `Model.load()` auto-discovers which model variant is available,
124
+ preferring the full model. To force a variant:
125
+
126
+ ```python
127
+ model = Model.load_lite(languages) # recommended default
128
+ model = Model.load_full(languages) # higher accuracy, more memory
129
+ ```
130
+
131
+ ### Getting the full model
132
+
133
+ The lite model is sufficient for most use cases. If you want the full model
134
+ for maximum accuracy, install the companion package:
135
+
136
+ ```bash
137
+ pip install "langidentify[full]"
138
+ ```
139
+
140
+ This installs the `langidentify-full-model` package, which provides the full
141
+ model data. Once installed, `Model.load()` will automatically prefer the full
142
+ model, or you can request it explicitly:
143
+
144
+ ```python
145
+ model = Model.load_full(languages)
146
+ ```
147
+
148
+ ## CJK detection
149
+
150
+ Chinese/Japanese disambiguation is handled by the
151
+ [cjclassifier](https://pypi.org/project/cjclassifier/) package, which is
152
+ installed automatically as a dependency. Korean uses the distinct Hangul script
153
+ and is identified by alphabet alone.
154
+
155
+ ## Thread safety
156
+
157
+ `Model` caches loaded data in a module-level dict protected by a lock.
158
+ `Detector` is lightweight to construct and intentionally **not thread-safe**.
159
+ For concurrent detection, use a separate instance per thread:
160
+
161
+ ```python
162
+ import threading
163
+
164
+ model = Model.load(languages) # shared, thread-safe
165
+
166
+ local = threading.local()
167
+
168
+ def get_detector():
169
+ if not hasattr(local, "detector"):
170
+ local.detector = Detector(model)
171
+ return local.detector
172
+
173
+ # In each thread:
174
+ lang = get_detector().detect(text)
175
+ ```
176
+
177
+ ## Requirements
178
+
179
+ - Python 3.9+
180
+ - [cjclassifier](https://pypi.org/project/cjclassifier/) (installed automatically)
181
+
182
+ ## License
183
+
184
+ Apache License 2.0 -- see [LICENSE](LICENSE).
185
+
186
+ The bundled models contain statistical parameters derived from Wikipedia text.
187
+ The models do not contain or reproduce Wikipedia text.
@@ -0,0 +1,44 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68.0", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "langidentify"
7
+ version = "1.0.0"
8
+ description = "Fast, high-accuracy language detection for Python. Uses ngram classification augmented with a topwords signal for improved short-text accuracy. Supports 80+ languages."
9
+ readme = "README.md"
10
+ license = "Apache-2.0"
11
+ license-files = ["LICENSE"]
12
+ requires-python = ">=3.9"
13
+ authors = [
14
+ {name = "Jeremy Lilley", email = "jeremy@jlilley.net"},
15
+ ]
16
+ keywords = ["language-detection", "nlp", "ngram", "text-classification"]
17
+ classifiers = [
18
+ "Development Status :: 5 - Production/Stable",
19
+ "Intended Audience :: Developers",
20
+ "Programming Language :: Python :: 3",
21
+ "Topic :: Text Processing :: Linguistic",
22
+ ]
23
+ dependencies = [
24
+ "cjclassifier>=1.0.3",
25
+ ]
26
+
27
+ [project.optional-dependencies]
28
+ full = [
29
+ "langidentify-full-model>=1.0.0",
30
+ ]
31
+ dev = [
32
+ "pytest>=7.0",
33
+ ]
34
+
35
+ [project.urls]
36
+ Homepage = "https://github.com/jlpka/langidentify"
37
+ Repository = "https://github.com/jlpka/langidentify"
38
+
39
+ [tool.setuptools.packages.find]
40
+ where = ["src"]
41
+
42
+ [tool.setuptools.package-data]
43
+ "langidentify.models.lite" = ["*.txt.gz", "*.txt"]
44
+ "langidentify.models.full" = ["*.txt.gz", "*.txt"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,44 @@
1
+ # Copyright 2026 Jeremy Lilley (jeremy@jlilley.net)
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ """langidentify — fast language detection using n-gram and topword scoring.
16
+
17
+ Usage::
18
+
19
+ from langidentify import Detector, Model, Language
20
+
21
+ languages = Language.from_comma_separated("en,fr,de")
22
+ model = Model.load(languages)
23
+ detector = Detector(model)
24
+ lang = detector.detect("Bonjour le monde")
25
+ print(lang) # Language.FRENCH
26
+ """
27
+
28
+ from langidentify.alphabet import Alphabet
29
+ from langidentify.accent_remover import AccentRemover
30
+ from langidentify.detector import Detector, Results, Scores
31
+ from langidentify.language import Language
32
+ from langidentify.model import Model
33
+
34
+ __all__ = [
35
+ "Alphabet",
36
+ "AccentRemover",
37
+ "Detector",
38
+ "Language",
39
+ "Model",
40
+ "Results",
41
+ "Scores",
42
+ ]
43
+
44
+ __version__ = "1.0.0"