fm-index 1.1.0__cp314-cp314-win_amd64.whl

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.
fm_index/__init__.py ADDED
@@ -0,0 +1,5 @@
1
+ from .fm_index import *
2
+
3
+ __doc__ = fm_index.__doc__
4
+ if hasattr(fm_index, "__all__"):
5
+ __all__ = fm_index.__all__
fm_index/__init__.pyi ADDED
@@ -0,0 +1,34 @@
1
+ from typing import Generator, Iterable
2
+
3
+ class FMIndex:
4
+ def __init__(self, data: str) -> FMIndex: ...
5
+ def __len__(self) -> int: ...
6
+ def __contains__(self, pattern: str) -> bool: ...
7
+ def __str__(self) -> str: ...
8
+ def __repr__(self) -> str: ...
9
+ def __copy__(self) -> FMIndex: ...
10
+ def __deepcopy__(self, memo) -> FMIndex: ...
11
+ def item(self) -> str: ...
12
+ def contains(self, pattern: str) -> bool: ...
13
+ def count(self, pattern: str) -> int: ...
14
+ def locate(self, pattern: str) -> list[int]: ...
15
+ def iter_locate(self, pattern: str) -> Generator[int, None, None]: ...
16
+ def startswith(self, prefix: str) -> bool: ...
17
+ def endswith(self, suffix: str) -> bool: ...
18
+
19
+ class MultiFMIndex:
20
+ def __init__(self, data: Iterable[str]) -> MultiFMIndex: ...
21
+ def __len__(self) -> int: ...
22
+ def __contains__(self, pattern: str) -> bool: ...
23
+ def __str__(self) -> str: ...
24
+ def __repr__(self) -> str: ...
25
+ def __copy__(self) -> MultiFMIndex: ...
26
+ def __deepcopy__(self, memo) -> MultiFMIndex: ...
27
+ def item(self) -> list[str]: ...
28
+ def contains(self, pattern: str) -> bool: ...
29
+ def count_all(self, pattern: str) -> int: ...
30
+ def count(self, pattern: str) -> dict[int, int]: ...
31
+ def locate(self, pattern: str) -> dict[int, list[int]]: ...
32
+ def iter_locate(self, pattern: str) -> Generator[tuple[int, int], None, None]: ...
33
+ def startswith(self, prefix: str) -> list[int]: ...
34
+ def endswith(self, suffix: str) -> list[int]: ...
Binary file
fm_index/py.typed ADDED
File without changes
@@ -0,0 +1,210 @@
1
+ Metadata-Version: 2.4
2
+ Name: fm-index
3
+ Version: 1.1.0
4
+ Classifier: Intended Audience :: Developers
5
+ Classifier: Intended Audience :: Science/Research
6
+ Classifier: Intended Audience :: Information Technology
7
+ Classifier: License :: OSI Approved :: MIT License
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: Programming Language :: Python :: 3.9
10
+ Classifier: Programming Language :: Python :: 3.10
11
+ Classifier: Programming Language :: Python :: 3.11
12
+ Classifier: Programming Language :: Python :: 3.12
13
+ Classifier: Programming Language :: Python :: 3.13
14
+ Classifier: Programming Language :: Python :: 3.14
15
+ Classifier: Programming Language :: Python :: Implementation :: CPython
16
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
17
+ Classifier: Topic :: Scientific/Engineering :: Information Analysis
18
+ Classifier: Topic :: Text Processing :: Indexing
19
+ Classifier: Typing :: Typed
20
+ Requires-Dist: pdoc>=16.0 ; extra == 'dev'
21
+ Requires-Dist: ruff>=0.14 ; extra == 'dev'
22
+ Requires-Dist: numpy>=2.0.2 ; extra == 'test'
23
+ Requires-Dist: pytest>=7.0 ; extra == 'test'
24
+ Requires-Dist: pytest-benchmark>=4.0 ; extra == 'test'
25
+ Provides-Extra: dev
26
+ Provides-Extra: test
27
+ License-File: LICENSE
28
+ Summary: High-performance FM-index powered by Rust, enabling fast substring search and count/locate queries.
29
+ Keywords: fm-index,full-text index,compressed index,substring search,pattern matching,succinct,information retrieval
30
+ Author: Koki Watanabe
31
+ Requires-Python: >=3.9
32
+ Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
33
+ Project-URL: documentation, https://math-hiyoko.github.io/fm-index
34
+ Project-URL: homepage, https://github.com/math-hiyoko/fm-index
35
+ Project-URL: repository, https://github.com/math-hiyoko/fm-index
36
+
37
+ # FM Index
38
+
39
+ [![CI](https://github.com/math-hiyoko/fm-index/actions/workflows/CI.yml/badge.svg)](https://github.com/math-hiyoko/fm-index/actions/workflows/CI.yml)
40
+ [![codecov](https://codecov.io/gh/math-hiyoko/fm-index/graph/badge.svg?token=37GS49DHDH)](https://codecov.io/gh/math-hiyoko/fm-index)
41
+ ![PyPI - Version](https://img.shields.io/pypi/v/fm-index)
42
+ ![PyPI - License](https://img.shields.io/pypi/l/fm-index)
43
+ ![PyPI - PythonVersion](https://img.shields.io/pypi/pyversions/fm-index)
44
+ ![PyPI - Implementation](https://img.shields.io/pypi/implementation/fm-index)
45
+ ![PyPI - Types](https://img.shields.io/pypi/types/fm-index)
46
+ [![PyPI Downloads](https://static.pepy.tech/personalized-badge/fm-index?period=total&units=INTERNATIONAL_SYSTEM&left_color=GRAY&right_color=GREEN&left_text=PyPI%20downloads)](https://pepy.tech/projects/fm-index)
47
+ ![PyPI - Format](https://img.shields.io/pypi/format/fm-index)
48
+ ![Rust](https://img.shields.io/badge/powered%20by-Rust-orange)
49
+
50
+
51
+ High-performance FM-index implementation powered by Rust,
52
+ designed for fast substring search on large texts and collections
53
+
54
+ - PyPI: https://pypi.org/project/fm-index
55
+ - Document: https://math-hiyoko.github.io/fm-index
56
+ - Repository: https://github.com/math-hiyoko/fm-index
57
+
58
+ ## Features:
59
+ - Fast count / locate substring queries
60
+ - Supports single text and multiple documents
61
+
62
+ ## Installation
63
+ ```bash
64
+ pip install fm-index
65
+ ```
66
+
67
+ ## FMIndex (Single Document)
68
+ ### What is FMIndex?
69
+ FMIndex builds a compressed index over a single string,
70
+ allowing fast substring search without scanning the original data.
71
+
72
+ ### Construction Complexity
73
+ - Time / Space: `O(|data| log σ)`
74
+ - σ = alphabet size (e.g. 2⁸ for UCS-1, 2¹⁶ for UCS-2).
75
+
76
+ #### Example
77
+
78
+ ```python
79
+ from fm_index import FMIndex
80
+
81
+ genome = "ACGTACGTTGACCTGACTGACTGACTGACGATCGATCGATCGATCGATCG"
82
+ fm = FMIndex(data=genome)
83
+ ```
84
+
85
+ ### Count Substring Occurrences
86
+ Counts how many times a pattern appears.
87
+ Time complexity is independent of data size.
88
+
89
+ ```python
90
+ fm.count(pattern="GACTGACT")
91
+ # 2
92
+ ```
93
+
94
+ ### Locate Substring Positions
95
+ Returns all starting offsets where the pattern occurs.
96
+
97
+ ```python
98
+ fm.locate(pattern="GACTGACT")
99
+ # [18, 14]
100
+ ```
101
+
102
+ ### Iterative Locate (Streaming)
103
+ For large result sets, iter_locate provides a memory-efficient
104
+ iterator interface that yields positions lazily.
105
+
106
+ ```python
107
+ for pos in fm.iter_locate(pattern="GACTGACT"):
108
+ print(pos)
109
+ # 18
110
+ # 14
111
+ ```
112
+
113
+ - Same results as locate
114
+ - Does not allocate a result list
115
+ - Suitable for streaming and early termination
116
+
117
+ ## MultiFMIndex (Multiple Documents)
118
+ MultiFMIndex extends FMIndex to support multiple documents
119
+ while keeping query time independent of corpus size
120
+
121
+ ### Construction Complexity
122
+ - Time / Space: `O(|''.join(data)| log σ)`
123
+ - σ = alphabet size (e.g. 2⁸ for UCS-1, 2¹⁶ for UCS-2).
124
+
125
+ ```python
126
+ from fm_index import MultiFMIndex
127
+
128
+ documents = [
129
+ "政府はAI研究の支援を強化すると発表した。",
130
+ "政府は新たなデータ活用方針を発表した。",
131
+ "政府はサイバーセキュリティ対策を発表した。",
132
+ "専門家はAI検索技術の進化に注目している。",
133
+ "研究者は高速な検索アルゴリズムに注目している。",
134
+ "オープンソース界隈では全文検索ライブラリに注目している。"
135
+ ]
136
+
137
+ mfm = MultiFMIndex(data=documents)
138
+ ```
139
+
140
+ ### Count Across All Documents
141
+ ```python
142
+ mfm.count_all(pattern="検索")
143
+ # 3
144
+ ```
145
+
146
+ ### Count Per Document
147
+ ```python
148
+ mfm.count(pattern="検索")
149
+ # {3: 1, 4: 1, 5: 1}
150
+ ```
151
+
152
+ ### Locate Per Document
153
+ ```python
154
+ mfm.locate(pattern="検索")
155
+ # {5: [13], 4: [7], 3: [6]}
156
+ ```
157
+
158
+ ### Iterative Locate (Streaming)
159
+ ```python
160
+ for doc_id, pos in mfm.iter_locate(pattern="検索"):
161
+ print(doc_id, pos)
162
+ # 4 7
163
+ # 5 13
164
+ # 3 6
165
+ ```
166
+
167
+ ### Prefix / Suffix Search
168
+ ```python
169
+ mfm.startswith(prefix="政府は")
170
+ mfm.endswith(suffix="注目している。")
171
+ ```
172
+
173
+ ## Development & Testing
174
+
175
+ ### Run Tests
176
+
177
+ ```bash
178
+ pip install -e ".[test]"
179
+ cargo test --all --release
180
+ pytest
181
+ ```
182
+
183
+ ## Formating
184
+ ```bash
185
+ pip install -e ".[dev]"
186
+ cargo fmt --all
187
+ cargo clippy --all-targets --all-features
188
+ ruff format
189
+ ```
190
+
191
+ ## Generating Docs
192
+ ```bash
193
+ pdoc fm_index \
194
+ --output-directory docs \
195
+ --no-search \
196
+ --no-show-source \
197
+ --docformat markdown \
198
+ --footer-text "© 2026 Koki Watanabe"
199
+ ```
200
+
201
+ ## References
202
+
203
+ - P. Ferragina and G. Manzini,
204
+ Opportunistic data structures with applications,
205
+ Proceedings 41st Annual Symposium on Foundations of Computer Science,
206
+ Redondo Beach, CA, USA,
207
+ 2000,
208
+ pp. 390-398,
209
+ https://doi.org/10.1109/SFCS.2000.892127.
210
+
@@ -0,0 +1,8 @@
1
+ fm_index\__init__.py,sha256=lgghDqSWE4oRsMnOvEvjj96j9JKqKfVrm3iE-717vh0,115
2
+ fm_index\__init__.pyi,sha256=rjIl2YsTkYKRzXAuxTl6eXOSER9-1s4rfTZWyJAs1wg,1535
3
+ fm_index\fm_index.cp314-win_amd64.pyd,sha256=o8ejjS4ahILMOqzvhM0nZca8qdDV0qTJ77CYmEtOZ9Q,615424
4
+ fm_index\py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
+ fm_index-1.1.0.dist-info\METADATA,sha256=44a6d9SkW8W0jbsVZQ03fuq8_qhmM-E7-TyLY7iqFXs,6470
6
+ fm_index-1.1.0.dist-info\WHEEL,sha256=ayLmrmZ44O5LJq4S5WaN6_jWyaqVIHcR47-f_n_2YKM,97
7
+ fm_index-1.1.0.dist-info\licenses\LICENSE,sha256=QoVaJZaoPrIBEtTEzrKazrD1PrLIf4ra8jRhKqwDFgM,1068
8
+ fm_index-1.1.0.dist-info\RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: maturin (1.11.4)
3
+ Root-Is-Purelib: false
4
+ Tag: cp314-cp314-win_amd64
@@ -0,0 +1,7 @@
1
+ Copyright 2026 Koki Watanabe
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.