stride-align 0.6.0

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 (190) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +201 -0
  3. data/NOTICE +255 -0
  4. data/README.md +107 -0
  5. data/data/bmpm_data/gen_approx_any.txt +131 -0
  6. data/data/bmpm_data/gen_approx_arabic.txt +26 -0
  7. data/data/bmpm_data/gen_approx_common.txt +233 -0
  8. data/data/bmpm_data/gen_approx_cyrillic.txt +18 -0
  9. data/data/bmpm_data/gen_approx_czech.txt +18 -0
  10. data/data/bmpm_data/gen_approx_dutch.txt +18 -0
  11. data/data/bmpm_data/gen_approx_english.txt +47 -0
  12. data/data/bmpm_data/gen_approx_french.txt +25 -0
  13. data/data/bmpm_data/gen_approx_german.txt +73 -0
  14. data/data/bmpm_data/gen_approx_greek.txt +18 -0
  15. data/data/bmpm_data/gen_approx_greeklatin.txt +20 -0
  16. data/data/bmpm_data/gen_approx_hebrew.txt +18 -0
  17. data/data/bmpm_data/gen_approx_hungarian.txt +18 -0
  18. data/data/bmpm_data/gen_approx_italian.txt +18 -0
  19. data/data/bmpm_data/gen_approx_polish.txt +84 -0
  20. data/data/bmpm_data/gen_approx_portuguese.txt +18 -0
  21. data/data/bmpm_data/gen_approx_romanian.txt +18 -0
  22. data/data/bmpm_data/gen_approx_russian.txt +48 -0
  23. data/data/bmpm_data/gen_approx_spanish.txt +21 -0
  24. data/data/bmpm_data/gen_approx_turkish.txt +18 -0
  25. data/data/bmpm_data/gen_exact_any.txt +40 -0
  26. data/data/bmpm_data/gen_exact_approx_common.txt +79 -0
  27. data/data/bmpm_data/gen_exact_arabic.txt +18 -0
  28. data/data/bmpm_data/gen_exact_common.txt +32 -0
  29. data/data/bmpm_data/gen_exact_cyrillic.txt +18 -0
  30. data/data/bmpm_data/gen_exact_czech.txt +18 -0
  31. data/data/bmpm_data/gen_exact_dutch.txt +18 -0
  32. data/data/bmpm_data/gen_exact_english.txt +18 -0
  33. data/data/bmpm_data/gen_exact_french.txt +18 -0
  34. data/data/bmpm_data/gen_exact_german.txt +18 -0
  35. data/data/bmpm_data/gen_exact_greek.txt +18 -0
  36. data/data/bmpm_data/gen_exact_greeklatin.txt +18 -0
  37. data/data/bmpm_data/gen_exact_hebrew.txt +18 -0
  38. data/data/bmpm_data/gen_exact_hungarian.txt +18 -0
  39. data/data/bmpm_data/gen_exact_italian.txt +18 -0
  40. data/data/bmpm_data/gen_exact_polish.txt +23 -0
  41. data/data/bmpm_data/gen_exact_portuguese.txt +18 -0
  42. data/data/bmpm_data/gen_exact_romanian.txt +18 -0
  43. data/data/bmpm_data/gen_exact_russian.txt +19 -0
  44. data/data/bmpm_data/gen_exact_spanish.txt +19 -0
  45. data/data/bmpm_data/gen_exact_turkish.txt +18 -0
  46. data/data/bmpm_data/gen_hebrew_common.txt +113 -0
  47. data/data/bmpm_data/gen_lang.txt +295 -0
  48. data/data/bmpm_data/gen_languages.txt +36 -0
  49. data/data/bmpm_data/gen_rules_any.txt +367 -0
  50. data/data/bmpm_data/gen_rules_arabic.txt +76 -0
  51. data/data/bmpm_data/gen_rules_cyrillic.txt +99 -0
  52. data/data/bmpm_data/gen_rules_czech.txt +67 -0
  53. data/data/bmpm_data/gen_rules_dutch.txt +78 -0
  54. data/data/bmpm_data/gen_rules_english.txt +113 -0
  55. data/data/bmpm_data/gen_rules_french.txt +114 -0
  56. data/data/bmpm_data/gen_rules_german.txt +129 -0
  57. data/data/bmpm_data/gen_rules_greek.txt +97 -0
  58. data/data/bmpm_data/gen_rules_greeklatin.txt +118 -0
  59. data/data/bmpm_data/gen_rules_hebrew.txt +62 -0
  60. data/data/bmpm_data/gen_rules_hungarian.txt +83 -0
  61. data/data/bmpm_data/gen_rules_italian.txt +77 -0
  62. data/data/bmpm_data/gen_rules_polish.txt +185 -0
  63. data/data/bmpm_data/gen_rules_portuguese.txt +105 -0
  64. data/data/bmpm_data/gen_rules_romanian.txt +64 -0
  65. data/data/bmpm_data/gen_rules_russian.txt +142 -0
  66. data/data/bmpm_data/gen_rules_spanish.txt +85 -0
  67. data/data/bmpm_data/gen_rules_turkish.txt +50 -0
  68. data/data/keyboard_data/qwerty.npy +0 -0
  69. data/data/matrix_data/BLOSUM100 +31 -0
  70. data/data/matrix_data/BLOSUM30 +31 -0
  71. data/data/matrix_data/BLOSUM35 +31 -0
  72. data/data/matrix_data/BLOSUM40 +31 -0
  73. data/data/matrix_data/BLOSUM45 +25 -0
  74. data/data/matrix_data/BLOSUM50 +25 -0
  75. data/data/matrix_data/BLOSUM55 +31 -0
  76. data/data/matrix_data/BLOSUM60 +31 -0
  77. data/data/matrix_data/BLOSUM62 +25 -0
  78. data/data/matrix_data/BLOSUM65 +31 -0
  79. data/data/matrix_data/BLOSUM70 +31 -0
  80. data/data/matrix_data/BLOSUM75 +31 -0
  81. data/data/matrix_data/BLOSUM80 +25 -0
  82. data/data/matrix_data/BLOSUM85 +31 -0
  83. data/data/matrix_data/BLOSUM90 +25 -0
  84. data/data/matrix_data/NUC.4.4 +25 -0
  85. data/data/matrix_data/PAM10 +34 -0
  86. data/data/matrix_data/PAM100 +34 -0
  87. data/data/matrix_data/PAM110 +34 -0
  88. data/data/matrix_data/PAM120 +34 -0
  89. data/data/matrix_data/PAM130 +34 -0
  90. data/data/matrix_data/PAM140 +34 -0
  91. data/data/matrix_data/PAM150 +34 -0
  92. data/data/matrix_data/PAM160 +34 -0
  93. data/data/matrix_data/PAM170 +34 -0
  94. data/data/matrix_data/PAM180 +34 -0
  95. data/data/matrix_data/PAM190 +34 -0
  96. data/data/matrix_data/PAM20 +34 -0
  97. data/data/matrix_data/PAM200 +34 -0
  98. data/data/matrix_data/PAM210 +34 -0
  99. data/data/matrix_data/PAM220 +34 -0
  100. data/data/matrix_data/PAM230 +34 -0
  101. data/data/matrix_data/PAM240 +34 -0
  102. data/data/matrix_data/PAM250 +25 -0
  103. data/data/matrix_data/PAM260 +34 -0
  104. data/data/matrix_data/PAM270 +34 -0
  105. data/data/matrix_data/PAM280 +34 -0
  106. data/data/matrix_data/PAM290 +34 -0
  107. data/data/matrix_data/PAM30 +25 -0
  108. data/data/matrix_data/PAM300 +34 -0
  109. data/data/matrix_data/PAM310 +34 -0
  110. data/data/matrix_data/PAM320 +34 -0
  111. data/data/matrix_data/PAM330 +34 -0
  112. data/data/matrix_data/PAM340 +34 -0
  113. data/data/matrix_data/PAM350 +34 -0
  114. data/data/matrix_data/PAM360 +34 -0
  115. data/data/matrix_data/PAM370 +34 -0
  116. data/data/matrix_data/PAM380 +34 -0
  117. data/data/matrix_data/PAM390 +34 -0
  118. data/data/matrix_data/PAM40 +34 -0
  119. data/data/matrix_data/PAM400 +34 -0
  120. data/data/matrix_data/PAM410 +34 -0
  121. data/data/matrix_data/PAM420 +34 -0
  122. data/data/matrix_data/PAM430 +34 -0
  123. data/data/matrix_data/PAM440 +34 -0
  124. data/data/matrix_data/PAM450 +34 -0
  125. data/data/matrix_data/PAM460 +34 -0
  126. data/data/matrix_data/PAM470 +34 -0
  127. data/data/matrix_data/PAM480 +34 -0
  128. data/data/matrix_data/PAM490 +34 -0
  129. data/data/matrix_data/PAM50 +34 -0
  130. data/data/matrix_data/PAM500 +34 -0
  131. data/data/matrix_data/PAM60 +34 -0
  132. data/data/matrix_data/PAM70 +25 -0
  133. data/data/matrix_data/PAM80 +34 -0
  134. data/data/matrix_data/PAM90 +34 -0
  135. data/ext/stride_align/backend_avx2.cpp +2 -0
  136. data/ext/stride_align/backend_avx512bwvl.cpp +2 -0
  137. data/ext/stride_align/backend_generic.cpp +3 -0
  138. data/ext/stride_align/backend_impl.hpp +983 -0
  139. data/ext/stride_align/backend_lasx.cpp +2 -0
  140. data/ext/stride_align/backend_lsx.cpp +2 -0
  141. data/ext/stride_align/backend_neon.cpp +2 -0
  142. data/ext/stride_align/backend_rvv.cpp +2 -0
  143. data/ext/stride_align/backend_sse41.cpp +2 -0
  144. data/ext/stride_align/backend_sve.cpp +2 -0
  145. data/ext/stride_align/backend_sve2.cpp +2 -0
  146. data/ext/stride_align/backend_vsx.cpp +2 -0
  147. data/ext/stride_align/beider_morse_impl.cpp +5 -0
  148. data/ext/stride_align/cpu_detect.cpp +172 -0
  149. data/ext/stride_align/cpu_detect.hpp +6 -0
  150. data/ext/stride_align/extconf.rb +114 -0
  151. data/ext/stride_align/target_profile.hpp +82 -0
  152. data/ext/stride_align/vendor/beider_morse_impl.cpp +1467 -0
  153. data/ext/stride_align/vendor/stride_align/alignment.hpp +199 -0
  154. data/ext/stride_align/vendor/stride_align/batch.hpp +812 -0
  155. data/ext/stride_align/vendor/stride_align/beider_morse.hpp +121 -0
  156. data/ext/stride_align/vendor/stride_align/caverphone.hpp +222 -0
  157. data/ext/stride_align/vendor/stride_align/cologne_phonetic.hpp +202 -0
  158. data/ext/stride_align/vendor/stride_align/core.hpp +731 -0
  159. data/ext/stride_align/vendor/stride_align/daitch_mokotoff.hpp +631 -0
  160. data/ext/stride_align/vendor/stride_align/double_metaphone.hpp +796 -0
  161. data/ext/stride_align/vendor/stride_align/dtw.hpp +300 -0
  162. data/ext/stride_align/vendor/stride_align/encoded.hpp +235 -0
  163. data/ext/stride_align/vendor/stride_align/hamming.hpp +55 -0
  164. data/ext/stride_align/vendor/stride_align/indel.hpp +1200 -0
  165. data/ext/stride_align/vendor/stride_align/jaro.hpp +517 -0
  166. data/ext/stride_align/vendor/stride_align/lcs.hpp +159 -0
  167. data/ext/stride_align/vendor/stride_align/levenshtein.hpp +1247 -0
  168. data/ext/stride_align/vendor/stride_align/levenshtein_prepared.hpp +193 -0
  169. data/ext/stride_align/vendor/stride_align/match_rating.hpp +168 -0
  170. data/ext/stride_align/vendor/stride_align/metaphone.hpp +291 -0
  171. data/ext/stride_align/vendor/stride_align/ngram.hpp +176 -0
  172. data/ext/stride_align/vendor/stride_align/nysiis.hpp +199 -0
  173. data/ext/stride_align/vendor/stride_align/pairwise_alignment.hpp +465 -0
  174. data/ext/stride_align/vendor/stride_align/partial_ratio.hpp +486 -0
  175. data/ext/stride_align/vendor/stride_align/ratcliff_obershelp.hpp +101 -0
  176. data/ext/stride_align/vendor/stride_align/soundex.hpp +108 -0
  177. data/ext/stride_align/vendor/stride_align/token_ratios.hpp +445 -0
  178. data/ext/stride_align/vendor/stride_align/types.hpp +16 -0
  179. data/ext/stride_align/vendor/stride_align/utf8.hpp +512 -0
  180. data/ext/stride_align/vendor/stride_align/wratio.hpp +363 -0
  181. data/lib/stride_align/algorithms.rb +296 -0
  182. data/lib/stride_align/alignment_path.rb +217 -0
  183. data/lib/stride_align/backend.rb +47 -0
  184. data/lib/stride_align/batch.rb +705 -0
  185. data/lib/stride_align/core.rb +180 -0
  186. data/lib/stride_align/keyboard.rb +200 -0
  187. data/lib/stride_align/matrices.rb +403 -0
  188. data/lib/stride_align/version.rb +5 -0
  189. data/lib/stride_align.rb +87 -0
  190. metadata +231 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 88ccdf6bd96ab5ff0dadc902ecdcfc3c00126230f1ecadeb3e848e2353c75920
4
+ data.tar.gz: a76d32796250ec94130ad285b7adc293387edcd8ae6bb3067b109ec9aedf664b
5
+ SHA512:
6
+ metadata.gz: c02fc4191b38e0fe898d33dc5f249bf7f6d8ce60b1003c213a793c434f8e8d2b1d2e862c9308395e52ec717ae4ef30f85987f4a2bc7af9f7711d450772ade69a
7
+ data.tar.gz: 856dc17733bf48743ce985438a6aadbab76a3d5c95aeb6050da51326d8e3f74ba8dbfd00b31bc3ef547c8c4760986121ecff926683f67c1593654eb65b33cfd5
data/LICENSE ADDED
@@ -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 express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
data/NOTICE ADDED
@@ -0,0 +1,255 @@
1
+ stride-align
2
+ Copyright 2025-2026 Adam DePrince
3
+
4
+ This product includes software developed by The Apache Software Foundation
5
+ (http://www.apache.org/).
6
+
7
+ ----------------------------------------------------------------------
8
+
9
+ Phonetic encoder ports
10
+ ======================
11
+
12
+ The following phonetic encoder implementations are derivative works of
13
+ Apache Commons Codec (https://commons.apache.org/proper/commons-codec/),
14
+ licensed under the Apache License, Version 2.0. The algorithmic
15
+ structure of the ports follows the corresponding Apache Commons Codec
16
+ classes; the C++ port is original code.
17
+
18
+ * include/stride_align/soundex.hpp
19
+ Reference: org.apache.commons.codec.language.Soundex
20
+
21
+ * include/stride_align/metaphone.hpp
22
+ Reference: org.apache.commons.codec.language.Metaphone
23
+
24
+ * include/stride_align/double_metaphone.hpp
25
+ Reference: org.apache.commons.codec.language.DoubleMetaphone
26
+
27
+ * include/stride_align/nysiis.hpp
28
+ Reference: org.apache.commons.codec.language.Nysiis
29
+
30
+ * include/stride_align/match_rating.hpp
31
+ Reference: org.apache.commons.codec.language.MatchRatingApproachEncoder
32
+
33
+ * include/stride_align/caverphone.hpp
34
+ Reference: org.apache.commons.codec.language.Caverphone2
35
+
36
+ * include/stride_align/cologne_phonetic.hpp
37
+ Reference: org.apache.commons.codec.language.ColognePhonetic
38
+
39
+ * include/stride_align/daitch_mokotoff.hpp
40
+ Reference: org.apache.commons.codec.language.DaitchMokotoffSoundex
41
+ The rule table is derived directly from the Apache Commons Codec
42
+ resource file ``dmrules.txt`` (see
43
+ ``docs/upstream/apache-commons-codec-dmrules.txt``).
44
+
45
+ * include/stride_align/beider_morse.hpp
46
+ src/cpp/beider_morse_impl.cpp
47
+ Reference: org.apache.commons.codec.language.bm.*
48
+ Stride-align ships the GENERIC name-type rules only. The vendored
49
+ rule files live in ``src/stride_align/bmpm_data/`` (loaded at
50
+ runtime via ``importlib.resources``); each file preserves its
51
+ original ASF Apache 2.0 header. The first-codepoint-bucket rule
52
+ lookup, predicate classifier, arena allocator, and parser in
53
+ ``beider_morse_impl.cpp`` are original C++.
54
+
55
+ Algorithmic structure and named test vectors of each encoder were
56
+ cross-checked against the canonical Apache Commons Codec test cases
57
+ during development. The third-party Python libraries listed in
58
+ ``[project.optional-dependencies].phonetic-compat`` — jellyfish
59
+ (MIT), the ``metaphone`` PyPI package (BSD), and pyphonetics (MIT) —
60
+ are available to downstream users who want their own cross-checks;
61
+ stride-align's own tests (``tests/test_phonetic.py``,
62
+ ``tests/test_beider_morse.py``) import only ``pytest`` and
63
+ ``stride_align`` and use hand-pinned expected values.
64
+
65
+ The separate ``tests/test_jellyfish_shim.py`` differential battery
66
+ imports Jellyfish when available because that module explicitly
67
+ targets Jellyfish API compatibility.
68
+
69
+ ----------------------------------------------------------------------
70
+
71
+ Algorithmic inspiration
72
+ =======================
73
+
74
+ The multi-word bit-parallel Indel / LCSseq kernel in
75
+ ``include/stride_align/indel.hpp`` (the ``indel_distance_k2_u8`` and
76
+ related K-specialised paths, plus the fused per-block recurrence in
77
+ ``indel_distance_multi_word_u8``) is informed by the architecture of
78
+ rapidfuzz-cpp (https://github.com/rapidfuzz/rapidfuzz-cpp,
79
+ licensed MIT, Max Bachmann and contributors). Specifically:
80
+
81
+ * The fused single-step Hyyrö per-block update
82
+ ``U = S & PEQ[c]; sum = addc64(S, U, carry);
83
+ S = sum | (S - U)`` — one fused expression per K block
84
+ rather than four separate K-sized passes — was adopted from
85
+ the rapidfuzz-cpp Indel / LCSseq design.
86
+ * The observation that the per-block ``S - U`` term needs no
87
+ borrow chain across blocks (the Hyyrö invariant ``U <= S``
88
+ bitwise) was likewise inherited from their implementation.
89
+ * Compile-time template specialisation of K = 1 through 8 paths
90
+ with a runtime ``switch`` dispatch on block count, so the
91
+ compiler sees N as a constant and pins state in registers
92
+ across the entire text loop.
93
+ * Stack-resident ``S[N]`` state for K <= 8 (no heap traffic per
94
+ call).
95
+ * The Ukkonen-style diagonal-band early-exit shape for the
96
+ ``score_cutoff`` path.
97
+
98
+ No source code, header comments, identifier names, file layouts,
99
+ struct field orderings, or close-paraphrased structural elements
100
+ were copied from rapidfuzz-cpp. The architectural ideas above were
101
+ extracted by a delegated investigation that reported back algorithm
102
+ structure in its own prose, while the code-authoring agent did not
103
+ read the rapidfuzz-cpp source. See
104
+ ``docs/phase-D-external-sources.md`` §3a and §4c for the full
105
+ provenance trail.
106
+
107
+ Striped SIMD alignment kernels
108
+ ==============================
109
+
110
+ The striped-profile layout and the lazy-F (Farrar-style) horizontal-gap
111
+ correction in stride-align's SIMD Smith-Waterman / Needleman-Wunsch kernels
112
+ (``src/cpp/backends/*.hpp``) are informed by the architecture of parasail
113
+ (https://github.com/jeffdaily/parasail), a BSD-3-Clause SIMD pairwise
114
+ alignment library by Jeff Daily. The striped inner-loop structure and the
115
+ lazy-F correction pass were studied from parasail's source for algorithmic
116
+ ideas; the kernels here are original C++ and no parasail source was copied.
117
+ The academic citation lives in the README "References" section:
118
+
119
+ Daily, Jeff. (2016). Parasail: SIMD C library for global, semi-global, and
120
+ local pairwise sequence alignments. BMC Bioinformatics, 17(1), 1-11.
121
+ doi:10.1186/s12859-016-0930-z
122
+
123
+ A consolidated source audit covering every phonetic encoder lives at
124
+ ``docs/phonetic-encoder-external-sources.md``. The BMPM-specific
125
+ audit (Apache Commons Codec rule data, vendored resources, explicit
126
+ GPL-port exclusions) lives at ``docs/bmpm-external-sources.md``.
127
+
128
+ ----------------------------------------------------------------------
129
+
130
+ Test oracles and compatibility references
131
+ =========================================
132
+
133
+ The third-party phonetic libraries listed under
134
+ ``[project.optional-dependencies].phonetic-compat`` are optional
135
+ cross-check oracles. ``metaphone`` and ``pyphonetics`` remain
136
+ test-time references only. Jellyfish is also the API and behavioural
137
+ reference for ``src/stride_align/jellyfish.py``; its compatibility
138
+ rule variants are adapted under the following MIT licence. TheFuzz
139
+ and RapidFuzz are the behavioural references for
140
+ ``src/stride_align/thefuzz/`` and its optional differential tests;
141
+ their compatibility conventions are adapted under the MIT licences
142
+ retained below.
143
+
144
+ Jellyfish compatibility facade
145
+ ==============================
146
+
147
+ The Jellyfish 1.2.1 compatibility rule variants in
148
+ ``src/stride_align/jellyfish.py`` are adapted from Jellyfish:
149
+ https://codeberg.org/jpt/jellyfish
150
+
151
+ MIT License
152
+
153
+ Copyright (c) 2015 James Turk
154
+
155
+ Permission is hereby granted, free of charge, to any person obtaining a copy
156
+ of this software and associated documentation files (the "Software"), to deal
157
+ in the Software without restriction, including without limitation the rights
158
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
159
+ copies of the Software, and to permit persons to whom the Software is
160
+ furnished to do so, subject to the following conditions:
161
+
162
+ The above copyright notice and this permission notice shall be included in all
163
+ copies or substantial portions of the Software.
164
+
165
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
166
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
167
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
168
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
169
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
170
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
171
+ SOFTWARE.
172
+
173
+ TheFuzz compatibility facade
174
+ ============================
175
+
176
+ The public adapter structure and legacy compatibility conventions in
177
+ ``src/stride_align/thefuzz/`` are adapted from TheFuzz 0.22.1:
178
+ https://github.com/seatgeek/thefuzz
179
+
180
+ MIT License
181
+
182
+ Copyright (c) 2014 SeatGeek
183
+
184
+ Permission is hereby granted, free of charge, to any person obtaining a copy
185
+ of this software and associated documentation files (the "Software"), to deal
186
+ in the Software without restriction, including without limitation the rights
187
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
188
+ copies of the Software, and to permit persons to whom the Software is
189
+ furnished to do so, subject to the following conditions:
190
+
191
+ The above copyright notice and this permission notice shall be included in all
192
+ copies or substantial portions of the Software.
193
+
194
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
195
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
196
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
197
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
198
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
199
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
200
+ SOFTWARE.
201
+
202
+ RapidFuzz sequence compatibility
203
+ ================================
204
+
205
+ The generic-sequence normalization, token-set arithmetic order, and
206
+ unrounded-score ranking conventions retained by the TheFuzz facade were
207
+ cross-checked against RapidFuzz 3.14.5's MIT-licensed Python implementation:
208
+ https://github.com/rapidfuzz/RapidFuzz
209
+
210
+ Copyright © 2020-present Max Bachmann
211
+ Copyright © 2011 Adam Cohen
212
+
213
+ Permission is hereby granted, free of charge, to any person obtaining
214
+ a copy of this software and associated documentation files (the
215
+ "Software"), to deal in the Software without restriction, including
216
+ without limitation the rights to use, copy, modify, merge, publish,
217
+ distribute, sublicense, and/or sell copies of the Software, and to
218
+ permit persons to whom the Software is furnished to do so, subject to
219
+ the following conditions:
220
+
221
+ The above copyright notice and this permission notice shall be
222
+ included in all copies or substantial portions of the Software.
223
+
224
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
225
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
226
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
227
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
228
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
229
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
230
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
231
+
232
+ ----------------------------------------------------------------------
233
+
234
+ Keyboard typo / confusion matrices (data)
235
+ =========================================
236
+
237
+ The optional keyboard substitution matrices — built by
238
+ ``tools/build_keyboard_matrices.py`` and loaded through the
239
+ ``stride_align.matrices.keyboard`` namespace — are derived, with the
240
+ authors' permission, from the Aalto University "136 Million Keystrokes"
241
+ dataset:
242
+
243
+ Vivek Dhakal, Anna Maria Feit, Per Ola Kristensson, Antti Oulasvirta.
244
+ "Observations on Typing from 136 Million Keystrokes." Proceedings of
245
+ the 2018 CHI Conference on Human Factors in Computing Systems
246
+ (CHI '18), 2018. https://doi.org/10.1145/3173574.3174220
247
+ Dataset: https://userinterfaces.aalto.fi/136Mkeystrokes/
248
+
249
+ stride-align bundles a small number of example keyboard substitution
250
+ matrices derived from this dataset. The dataset authors granted explicit
251
+ permission to build and publish these derived matrices under stride-align's
252
+ Apache-2.0 licence; only the derived matrices are distributed — the raw
253
+ keystroke data is not. Retain the citation above as attribution. See
254
+ docs/keyboard-matrix-external-sources.md for the provenance and the scope of
255
+ the permission.
data/README.md ADDED
@@ -0,0 +1,107 @@
1
+ # stride-align for Ruby
2
+
3
+ `stride-align` brings the complete public R binding surface to Ruby: Unicode
4
+ string distances and similarities, local and global alignment, batch search,
5
+ substitution matrices, keyboard-confusion matrices, phonetics, and Dynamic
6
+ Time Warping. The implementation is backed by the same header-only C++20 core.
7
+
8
+ ## Install
9
+
10
+ Build and install the gem from the repository root:
11
+
12
+ ```sh
13
+ bindings/ruby/build-package.sh
14
+ gem install dist/ruby/stride-align-0.6.0.gem
15
+ ```
16
+
17
+ Building requires Ruby development headers and a C++20 compiler. The resulting
18
+ gem contains its C++ headers, BMPM rules, BLOSUM/PAM catalog, and keyboard data;
19
+ it does not depend on Python, R, NumPy, or a binding-framework gem at runtime.
20
+
21
+ ## Import dispatch
22
+
23
+ Requiring the gem first imports the portable `_generic` extension, asks it for
24
+ the CPU-compatible backends packaged by the build, and then imports the best
25
+ one. Each backend is a separate Ruby extension, matching Python's import-based
26
+ dispatch model—unsupported instructions are never linked into the module that
27
+ performs CPU detection.
28
+
29
+ Source gems can build generic plus SSE4.1, AVX2, AVX-512 BW/VL, NEON, SVE,
30
+ SVE2, LSX, LASX, VSX, or RVV extensions when the host compiler supports them.
31
+ Pin a backend before `require` when benchmarking:
32
+
33
+ ```sh
34
+ STRIDE_ALIGN_RUBY_BACKEND=generic ruby benchmark.rb
35
+ STRIDE_ALIGN_RUBY_BACKEND=avx2 ruby benchmark.rb
36
+ ```
37
+
38
+ An unavailable or CPU-incompatible override raises `LoadError`. Inspect the
39
+ active dispatch with `StrideAlign.stride_backend` and
40
+ `StrideAlign.stride_available_backends`.
41
+
42
+ ## Use
43
+
44
+ ```ruby
45
+ require "stride_align"
46
+
47
+ StrideAlign.levenshtein_score("kitten", "sitting")
48
+ # => 3
49
+
50
+ StrideAlign.jaro_winkler_similarities(
51
+ "Martha", ["Martha", "Marhta", "Arthur", nil]
52
+ )
53
+
54
+ StrideAlign.cdist(
55
+ ["Martha", "Arthur"],
56
+ ["Martha", "Marhta", "Arthur"],
57
+ scorer: StrideAlign::Scorer::JARO_WINKLER
58
+ )
59
+
60
+ path = StrideAlign.smith_waterman_path("ACCGT", "CCG")
61
+ path.cigar # => "3="
62
+ path.aligned_query # => "CCG"
63
+
64
+ StrideAlign.smith_waterman_scores(
65
+ "HE", ["HE", "HH"], matrix: StrideAlign.blosum62
66
+ )
67
+ # => [13, 8]
68
+ ```
69
+
70
+ Pair functions accept either scalar strings or arrays. Equal-length arrays are
71
+ processed elementwise; a length-one side is broadcast. `nil` represents a
72
+ missing string and produces a missing score. Batch selection returns arrays of
73
+ hashes, `cdist` returns an array of rows, and source indices are zero-based.
74
+
75
+ The Ruby API covers every export in the R package:
76
+
77
+ - Levenshtein, OSA/Damerau, true Damerau-Levenshtein, Indel, Hamming, Jaro,
78
+ and Jaro-Winkler pair and batch forms
79
+ - Smith-Waterman and Needleman-Wunsch scores, normalized scores, linear and
80
+ affine gaps, traceback objects, CIGAR output, and prepared score facades
81
+ - top-k, best, `extract`, dense `cdist`, threshold filtering, global top-k,
82
+ and per-query top-k across all sixteen scorer IDs
83
+ - LCS, n-gram similarities, Ratcliff-Obershelp, token/partial ratios, WRatio,
84
+ and Monge-Elkan
85
+ - custom and NCBI-text substitution matrices, the complete BLOSUM/PAM
86
+ catalog, nucleotide/ASCII matrices, and keyboard-confusion helpers
87
+ - Soundex, Metaphone, NYSIIS, Match Rating, Caverphone, Cologne,
88
+ Daitch-Mokotoff, Double Metaphone, and Beider-Morse
89
+ - scalar and one-to-many Dynamic Time Warping
90
+
91
+ Ruby classes and hashes replace R's S3 objects and data frames. The Python
92
+ compatibility packages (`rapidfuzz`, `parasail`, `jellyfish`, and `thefuzz`)
93
+ remain Python-only.
94
+
95
+ ## Test
96
+
97
+ The test suite includes a live audit against the R `NAMESPACE`, so a newly
98
+ exported R API cannot silently be omitted from Ruby:
99
+
100
+ ```sh
101
+ bindings/ruby/build-package.sh /tmp/stride-align-ruby-dist
102
+ GEM_HOME=/tmp/stride-align-ruby-gems \
103
+ gem install --local --no-document \
104
+ /tmp/stride-align-ruby-dist/stride-align-0.6.0.gem
105
+ GEM_HOME=/tmp/stride-align-ruby-gems \
106
+ ruby bindings/ruby/test/test_stride_align.rb
107
+ ```