fm-index 1.0.1__cp314-cp314-manylinux_2_24_aarch64.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 +5 -0
- fm_index/__init__.pyi +32 -0
- fm_index/fm_index.cpython-314-aarch64-linux-gnu.so +0 -0
- fm_index/py.typed +0 -0
- fm_index-1.0.1.dist-info/METADATA +186 -0
- fm_index-1.0.1.dist-info/RECORD +8 -0
- fm_index-1.0.1.dist-info/WHEEL +4 -0
- fm_index-1.0.1.dist-info/licenses/LICENSE +7 -0
fm_index/__init__.py
ADDED
fm_index/__init__.pyi
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
from typing import 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 startswith(self, prefix: str) -> bool: ...
|
|
16
|
+
def endswith(self, suffix: str) -> bool: ...
|
|
17
|
+
|
|
18
|
+
class MultiFMIndex:
|
|
19
|
+
def __init__(self, data: Iterable[str]) -> MultiFMIndex: ...
|
|
20
|
+
def __len__(self) -> int: ...
|
|
21
|
+
def __contains__(self, pattern: str) -> bool: ...
|
|
22
|
+
def __str__(self) -> str: ...
|
|
23
|
+
def __repr__(self) -> str: ...
|
|
24
|
+
def __copy__(self) -> MultiFMIndex: ...
|
|
25
|
+
def __deepcopy__(self, memo) -> MultiFMIndex: ...
|
|
26
|
+
def item(self) -> list[str]: ...
|
|
27
|
+
def contains(self, pattern: str) -> bool: ...
|
|
28
|
+
def count_all(self, pattern: str) -> int: ...
|
|
29
|
+
def count(self, pattern: str) -> dict[int, int]: ...
|
|
30
|
+
def locate(self, pattern: str) -> dict[int, list[int]]: ...
|
|
31
|
+
def startswith(self, prefix: str) -> list[int]: ...
|
|
32
|
+
def endswith(self, suffix: str) -> list[int]: ...
|
|
Binary file
|
fm_index/py.typed
ADDED
|
File without changes
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: fm-index
|
|
3
|
+
Version: 1.0.1
|
|
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
|
+
[](https://github.com/math-hiyoko/fm-index/actions/workflows/CI.yml)
|
|
40
|
+
[](https://codecov.io/gh/math-hiyoko/fm-index)
|
|
41
|
+

|
|
42
|
+

|
|
43
|
+

|
|
44
|
+

|
|
45
|
+

|
|
46
|
+
[](https://pepy.tech/projects/fm-index)
|
|
47
|
+

|
|
48
|
+

|
|
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
|
+
## MultiFMIndex (Multiple Documents)
|
|
103
|
+
MultiFMIndex extends FMIndex to support multiple documents
|
|
104
|
+
while keeping query time independent of corpus size
|
|
105
|
+
|
|
106
|
+
### Construction Complexity
|
|
107
|
+
- Time / Space: `O(|''.join(data)| log σ)`
|
|
108
|
+
- σ = alphabet size (e.g. 2⁸ for UCS-1, 2¹⁶ for UCS-2).
|
|
109
|
+
|
|
110
|
+
```python
|
|
111
|
+
from fm_index import MultiFMIndex
|
|
112
|
+
|
|
113
|
+
documents = [
|
|
114
|
+
"政府はAI研究の支援を強化すると発表した。",
|
|
115
|
+
"政府は新たなデータ活用方針を発表した。",
|
|
116
|
+
"政府はサイバーセキュリティ対策を発表した。",
|
|
117
|
+
"専門家はAI検索技術の進化に注目している。",
|
|
118
|
+
"研究者は高速な検索アルゴリズムに注目している。",
|
|
119
|
+
"オープンソース界隈では全文検索ライブラリに注目している。"
|
|
120
|
+
]
|
|
121
|
+
|
|
122
|
+
mfm = MultiFMIndex(data=documents)
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
### Count Across All Documents
|
|
126
|
+
```python
|
|
127
|
+
mfm.count_all(pattern="検索")
|
|
128
|
+
# 3
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
### Count Per Document
|
|
132
|
+
```python
|
|
133
|
+
mfm.count(pattern="検索")
|
|
134
|
+
# {3: 1, 4: 1, 5: 1}
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
### Locate Per Document
|
|
138
|
+
```python
|
|
139
|
+
mfm.locate(pattern="検索")
|
|
140
|
+
# {5: [13], 4: [7], 3: [6]}
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
### Prefix / Suffix Search
|
|
144
|
+
```python
|
|
145
|
+
mfm.startswith(prefix="政府は")
|
|
146
|
+
mfm.endswith(suffix="注目している。")
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
## Development & Testing
|
|
150
|
+
|
|
151
|
+
### Run Tests
|
|
152
|
+
|
|
153
|
+
```bash
|
|
154
|
+
pip install -e ".[test]"
|
|
155
|
+
cargo test --all --release
|
|
156
|
+
pytest
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
## Formating
|
|
160
|
+
```bash
|
|
161
|
+
pip install -e ".[dev]"
|
|
162
|
+
cargo fmt --all
|
|
163
|
+
cargo clippy --all-targets --all-features
|
|
164
|
+
ruff format
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
## Generating Docs
|
|
168
|
+
```bash
|
|
169
|
+
pdoc fm_index \
|
|
170
|
+
--output-directory docs \
|
|
171
|
+
--no-search \
|
|
172
|
+
--no-show-source \
|
|
173
|
+
--docformat markdown \
|
|
174
|
+
--footer-text "© 2026 Koki Watanabe"
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
## References
|
|
178
|
+
|
|
179
|
+
- P. Ferragina and G. Manzini,
|
|
180
|
+
Opportunistic data structures with applications,
|
|
181
|
+
Proceedings 41st Annual Symposium on Foundations of Computer Science,
|
|
182
|
+
Redondo Beach, CA, USA,
|
|
183
|
+
2000,
|
|
184
|
+
pp. 390-398,
|
|
185
|
+
https://doi.org/10.1109/SFCS.2000.892127.
|
|
186
|
+
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
fm_index/__init__.py,sha256=lgghDqSWE4oRsMnOvEvjj96j9JKqKfVrm3iE-717vh0,115
|
|
2
|
+
fm_index/__init__.pyi,sha256=_o4dgdWwWNBFNXv0GmF81tsloAp21hTss0rEpXhODzU,1328
|
|
3
|
+
fm_index/fm_index.cpython-314-aarch64-linux-gnu.so,sha256=UYPXTHxmIvgpSpvpht1aooQpdQzXhl83QnLrMWU67XE,1006392
|
|
4
|
+
fm_index/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
5
|
+
fm_index-1.0.1.dist-info/METADATA,sha256=YTKrKtnXjziCO5d85_mfByRQhkBOnNYzTqzM2E5dEEA,5803
|
|
6
|
+
fm_index-1.0.1.dist-info/WHEEL,sha256=lCk6IB2rewLNoVMJgE92ShfVlrtIwG_M_ebHwCi6LNs,110
|
|
7
|
+
fm_index-1.0.1.dist-info/licenses/LICENSE,sha256=c4890hLIOBNdi11TX2JCtRlOakp867bppav4naMCh2s,1061
|
|
8
|
+
fm_index-1.0.1.dist-info/RECORD,,
|
|
@@ -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.
|