Metadata-Version: 2.4
Name: semantic-title-generator
Version: 0.1.1
Summary: Generate concise titles and keywords from long documents via Google’s Gemini API.
Project-URL: Homepage, https://github.com/yourusername/semantic-title-generator
Project-URL: Issues, https://github.com/yourusername/semantic-title-generator/issues
Author-email: Ali Mnp <ali.mnp.uni@gmail.com>
License: MIT License
        
        Copyright (c) 2025 Ali Mnp
        
        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:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        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.
License-File: LICENSE
Keywords: chunking,gemini,keywords,nlp,summarization,title-generation
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Text Processing :: Linguistic
Requires-Python: >=3.8
Requires-Dist: beautifulsoup4>=4.12.0
Requires-Dist: google-generativeai>=0.7.0
Requires-Dist: lxml>=4.9.0
Requires-Dist: packaging>=21.3
Requires-Dist: pypdf2>=3.0.0
Requires-Dist: python-docx>=1.0.0
Description-Content-Type: text/markdown

# Semantic Title Generator

Generate concise titles and keywords from long documents using Google’s Gemini API.  This library chunks long input texts, summarizes each chunk, aggregates the summaries with a hierarchical map‑reduce approach, then produces a final title and a list of keywords.

## Features

- Supports plain text, PDF, DOCX and HTML inputs.
- Uses configurable chunk sizes with overlap to preserve context across boundaries.
- Summarises text hierarchically to handle long inputs efficiently.
- Generates a title and a list of keywords in one API call.
- Flexible configuration of the Gemini model and temperature.
- Comes with a command‑line interface (CLI) for quick use.

## Installation

Install the package from PyPI (replace `<version>` with the latest release):

```bash
pip install semantic-title-generator
```

Alternatively, clone the repository and install locally:

```bash
git clone https://github.com/yourusername/semantic-title-generator.git
cd semantic-title-generator
pip install .
```

## Usage

### Python API

Import the helper function `Semantic_title_generator` to quickly produce a title and keywords.  You will need a Gemini API key with access to the specified model.

```python
from semantic_title_generator import Semantic_title_generator

title, keywords = Semantic_title_generator(
    path_document="path/to/file.pdf",  # can also be a raw text string
    Gemini_API_KEY="YOUR_GEMINI_API_KEY",
    model="gemini-2.5-pro",    # or another supported model like "gemini-1.5-flash"
    chunkSize=512,              # number of words per chunk (default 512)
    temperature=0.3             # sampling temperature (default 0.3)
)

print("Title:", title)
print("Keywords:", keywords)
```

### Command‑line interface

After installation the package exposes a CLI entry point `stg`.  You can call it on a file or raw text.  Set your API key via the `--api_key` argument or the `GEMINI_API_KEY` environment variable.

```bash
export GEMINI_API_KEY="YOUR_GEMINI_API_KEY"

# generate a title and keywords for a PDF
stg path/to/document.pdf --model gemini-2.5-pro --chunk 512

# generate for a plain text file and override the temperature
stg path/to/text.txt --temperature 0.2
```

Use `stg --help` to see all options.

## License

This project is licensed under the MIT License.  See the [LICENSE](LICENSE) file for details.
