Skip to main content

No project description provided

Project description

PDF and Web Content Query Package With FAISS And Cosine Similarity

License

This package provides functionality to process PDF files and web pages, allowing users to query their content using natural language processing techniques.

Table of Contents

Features

  • Process PDF files and answer queries about their content
  • Crawl web pages and answer queries about their content
  • Utilizes advanced embedding techniques for accurate content matching

Installation

To install this package, run:

pip install synapseai

Replace synapseai with the actual name of your package.

Usage

Processing a PDF

from synapseai import process_pdf

pdf_path = "path/to/your/document.pdf"
query = "What is the main topic of this document?"

results = process_pdf(pdf_path, query)

for chunk, similarity in results:
    print(f"Similarity: {similarity:.4f}")
    print(f"Chunk: {chunk[:200]}...")  # Print first 200 characters
    print("-" * 50)

Crawling and Querying a Web Page

To crawl a web page and query its content:

from synapseai import crawl_and_query

url = "https://example.com"
query = "What services does this website offer?"

results = crawl_and_query(url, query)

for chunk, similarity in results:
    print(f"Similarity: {similarity:.4f}")
    print(f"Chunk: {chunk[:200]}...")  # Print first 200 characters
    print("-" * 50)

How It Works

  • For PDFs: The package extracts text content from the file.
  • For Web Pages: It crawls the specified URL and extracts the text content.
  • The extracted text is split into manageable chunks.
  • The package uses HuggingFace's BGE embeddings to convert text chunks and the query into vector representations.
  • Cosine similarity is used to find the most relevant text chunks for the given query.
  • The top 5 most relevant chunks are returned along with their similarity scores.

License

This project is licensed under the MIT License - see the LICENSE file for details.

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

synapseai-0.5.1.tar.gz (4.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

SynapseAI-0.5.1-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

Details for the file synapseai-0.5.1.tar.gz.

File metadata

  • Download URL: synapseai-0.5.1.tar.gz
  • Upload date:
  • Size: 4.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.1

File hashes

Hashes for synapseai-0.5.1.tar.gz
Algorithm Hash digest
SHA256 0d8d9eaa4b00644c86098c42aab71dfee0527b305555127fa8a34e076d29b862
MD5 74cf7c12a50bdac8e0c0f601a76b9325
BLAKE2b-256 85b114421facf542d40d5783022e0968eeb2516821684ef59994d989a121ca43

See more details on using hashes here.

File details

Details for the file SynapseAI-0.5.1-py3-none-any.whl.

File metadata

  • Download URL: SynapseAI-0.5.1-py3-none-any.whl
  • Upload date:
  • Size: 6.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.1

File hashes

Hashes for SynapseAI-0.5.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4e4c4d27c5332635a2a059da918243284ddbacdab1d2409447fec5c943d70d65
MD5 5ff8012badf56e3a3ee4b59848f6a28a
BLAKE2b-256 59e2a1200350ea2010a4528e70e25c2a94183f0e357bafd1a831bb32adf002e0

See more details on using hashes here.

Supported by

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