https://github.com/rixwew/darts-clone-python
Darts-clone python binding
https://github.com/rixwew/darts-clone-python
dart double-array-trie python trie
Last synced: 3 months ago
JSON representation
Darts-clone python binding
- Host: GitHub
- URL: https://github.com/rixwew/darts-clone-python
- Owner: rixwew
- License: apache-2.0
- Created: 2018-11-16T15:57:51.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2022-04-23T10:16:12.000Z (over 3 years ago)
- Last Synced: 2024-11-06T18:00:11.411Z (11 months ago)
- Topics: dart, double-array-trie, python, trie
- Language: Cython
- Size: 44.9 KB
- Stars: 20
- Watchers: 3
- Forks: 12
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# darts-clone-python
[Darts-clone](https://github.com/s-yata/darts-clone) binding for Python 3.x.
This repository provides Cython-based pip-installable package.## Installation
pip install dartsclone
## Usage
darts-clone-python is almost compatible with darts-clone.
```python
import dartsclonedarts = dartsclone.DoubleArray()
# build index
data = [b'apple', b'banana', b'orange']
values = [1, 3, 2]
darts.build(data, values=values)# exact match search
result = darts.exact_match_search('apple'.encode('utf-8'))
print(result) # [1, 5]# common prefix search
result = darts.common_prefix_search('apples'.encode('utf-8'), pair_type=False)
print(result) # [1]# save index
darts.save('sample.dic')# load index
darts.clear()
darts.open('sample.dic')# dump array data
array = darts.array()# load array data
darts.clear()
darts.set_array(array)```