Skip to main content

Simple Text similarity python

Project description

pykosinus

pykosinus is an open-source Python library for text similarity search scoring. It provides a fast and memory-efficient way to calculate cosine similarity scores, making it suitable for various text similarity applications. The library is designed to be user-friendly and encourages contributions from the community.

Installation

To install pykosinus, make sure you have Python 3.8.17 or higher installed. Then, you can install the library using pip:

pip install pykosinus

Usage

To use pykosinus in your Python project, you can follow these steps:

  • Import the necessary modules and classes:
from pykosinus import Content
from pykosinus.lib.scoring import CosineSimilarity
  • Create an instance of the CosineSimilarity class, providing the collection name as a parameter:
similarity = CosineSimilarity(collection_name)
  • Set the contents to be searched using the push_contents method, passing a list of Content objects:
contents = [
    Content(
        content="Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
        identifier="blog-1",
        section="blog_title",
    ),
    Content(
        content="Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.",
        identifier="blog-2",
        section="blog_title",
    ),
    Content(
        content="Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris.",
        identifier="blog-3",
        section="blog_title",
    ),
    # Add more contents as needed
]
similarity.push_contents(contents)
  • Initialize the similarity search by calling the initialize method:
similarity.initialize()
  • Perform a similarity search by calling the search method, providing a keyword and an optional threshold:
results = similarity.search(keyword="search keyword", threshold=0.2)
  • The search method returns a list of ScoringResult objects, which contain the relevant information about the search results. You can access the properties of each result, such as identifier, content, section, similar, and score.
for result in results:
    print(
        result.identifier, result.content, result.section, result.similar, result.score
    )

Contributing

pykosinus welcomes contributions from the community. If you would like to contribute to the library, please follow these steps:

  • Fork the pykosinus repository on GitHub.
  • Create a new branch for your feature or bug fix.
  • Make your changes and commit them with descriptive commit messages.
  • Push your changes to your forked repository.
  • Submit a pull request to the master pykosinus repository, explaining the changes you have made.

Versioning

pykosinus is currently in version 0.0.2. We encourage continuous development and contributions from other contributors to improve and expand the library.

License

pykosinus is released under the MIT License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pykosinus-0.0.2.tar.gz (8.8 kB view details)

Uploaded Source

Built Distribution

pykosinus-0.0.2-py3-none-any.whl (7.3 kB view details)

Uploaded Python 3

File details

Details for the file pykosinus-0.0.2.tar.gz.

File metadata

  • Download URL: pykosinus-0.0.2.tar.gz
  • Upload date:
  • Size: 8.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.9.6 readme-renderer/40.0 requests/2.28.2 requests-toolbelt/1.0.0 urllib3/1.26.15 tqdm/4.65.0 importlib-metadata/6.7.0 keyring/24.2.0 rfc3986/2.0.0 colorama/0.4.6 CPython/3.11.5

File hashes

Hashes for pykosinus-0.0.2.tar.gz
Algorithm Hash digest
SHA256 3e36c8f9334b96b6a7b47b4bea539d43c1368baeb3d760afcd4d9da1b48867ed
MD5 c1163ef378f877af257f95ac8f394a58
BLAKE2b-256 0f7468d8905afcdd36b479e9befd512b860bd686d6950e8cd867c8a3ca5e9ec6

See more details on using hashes here.

File details

Details for the file pykosinus-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: pykosinus-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 7.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.9.6 readme-renderer/40.0 requests/2.28.2 requests-toolbelt/1.0.0 urllib3/1.26.15 tqdm/4.65.0 importlib-metadata/6.7.0 keyring/24.2.0 rfc3986/2.0.0 colorama/0.4.6 CPython/3.11.5

File hashes

Hashes for pykosinus-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 3605bee9d395db543a338912a7104c5aacdc6d5442bd40b54d9c2ffdbef27e44
MD5 3c587f7d70978545df165cebb768021a
BLAKE2b-256 85f168dceeb81e4dafc09cefc4b409c404873bc9cef0108aa6cf5f66d2feade1

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page