skifts
Search for the most relevant documents containing words from the query.
query = ['A', 'B']
documents = [
['N', 'A', 'M'], # matching features: 'A'
['C', 'B', 'A'], # matching features: 'A', 'B'
['X', 'Y'] # no matching features
]
The search with return ['C', 'B', 'A'] and ['N', 'A', 'M'] in that
particular order.
It's not necessarily about text. Words are just any str instances. Documents
are unordered collections of these str. We search for documents considering
frequency, rarity and match accuracy.
Install
pip3 install git+https://github.com/rtmigo/skifts_py#egg=skifts
Use for full-text search
Finding documents that contain words from the query.
from skifts import SkiFts
# three documents, one per row
documents = [
["wait", "mister", "postman"],
["please", "mister", "postman", "look", "and", "see"],
["oh", "yes", "wait", "a", "minute", "mister", "postman"]
]
fts = SkiFts(documents)
# find and print the most relevant documents:
for doc_index in fts.search(['postman', 'wait']):
print(documents[doc_index])
Words inside the documents list are considered ready-made feature identifiers.
If your text needs preprocessing or stemming, this should be done separately.
The ranking takes into account the frequency of words in the document and the rarity of words in the corpus. The word order in the document and the distance between words do not matter.
Implementation details
The search uses the scikit-learn library, which ranks documents using tf-idf and cosine similarity.
See also
The gifts package implements the same search, but in pure Python with no binary dependencies.
Metadata
Release files for skifts 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| skifts-0.1.0.tar.gz | 4.7 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| skifts-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 10.0 kB
Release files / skifts-0.1.0.tar.gz
| Download URL | skifts-0.1.0.tar.gz |
|---|---|
| Size | 4.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
32017a958754ba25bc16d21225d49da427274edce59bbbb1c8370f630050f25c
|
|
BLAKE2b-256 checksum How to use checksums |
684f88cc233718a2de5b8e818aecbe469a75ddafcfa20e081da825a8973bc94a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.1
|
Release files / skifts-0.1.0-py3-none-any.whl
| Download URL | skifts-0.1.0-py3-none-any.whl |
|---|---|
| Size | 5.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
df539d5670da1b8fb520dee7c5c67d26895d47c0534c1857a4a124fecd26bbe5
|
|
BLAKE2b-256 checksum How to use checksums |
d53e1497648fa47969d8c8daee69309526fa78792b9d4a3016b41a0966eda03f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.1
|
Security for skifts 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.