Skip to content

Latest commit

 

History

11 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Argument Mining API

A FastAPI-based service for analyzing argumentative structures in text using state-of-the-art NLP models.

Python Version Test Status Coverage License

Features

  • Identification of argument components (claims, premises)
  • Analysis of argumentative relations
  • RESTful API with FastAPI
  • Powered by BERT and spaCy models
  • Comprehensive test suite

Requirements

  • Python 3.12.1 or higher
  • Hugging Face account and API token
  • CUDA-compatible GPU (optional, for faster inference)

Installation

  1. Clone the repository:
git clone https://github.com/Horizontal-Labs/pipeline
cd pipeline
  1. Create and activate a virtual environment:
python -m venv .venv
# On Windows:
.venv\Scripts\activate
# On Unix or MacOS:
source .venv/bin/activate
  1. Install dependencies:
pip install -r requirements.txt
  1. Download the spaCy model:
python -m spacy download en_core_web_lg
  1. Set up environment variables: Create a .env file in the project root with:
HF_TOKEN=your_huggingface_token_here

Usage

  1. Start the server:
python main.py
  1. The API will be available at http://localhost:8000

  2. Access the interactive API documentation:

  • Swagger UI: http://localhost:8000/docs
  • ReDoc: http://localhost:8000/redoc

Example API Request

import requests

response = requests.post(
    "http://localhost:8000/analyze",
    json={
        "text": "Global warming is a serious threat. Since temperatures are rising worldwide, we need to act now."
    }
)

print(response.json())

API Endpoints

POST /analyze

Analyzes text for argument components and relations.

Request body:

{
    "text": "string"
}

Response:

{
    "components": [
        {
            "text": "string",
            "type": "claim|premise|non-argument",
            "confidence": 0.95
        }
    ],
    "relations": [
        {
            "source_idx": 0,
            "target_idx": 1,
            "relation_type": "support|attack",
            "confidence": 0.8
        }
    ]
}

GET /health

Health check endpoint.

Response:

{
    "status": "healthy"
}

Project Structure

ArgumentMining/
├── app/
│   ├── __init__.py
│   ├── models.py      # Pydantic models
│   ├── routes.py      # API endpoints
│   └── services.py    # Core business logic
├── tests/
│   ├── __init__.py
│   ├── conftest.py
│   ├── test_api.py
│   ├── test_argument_mining.py
│   └── test_model.py
├── main.py            # Application entry point
├── requirements.txt
└── README.md

Testing

Run the test suite:

pytest

For test coverage report:

pytest --cov=. --cov-report=term-missing

Current test coverage: 93%

Development

  • The project uses FastAPI for the web framework
  • Models are loaded using the Hugging Face Transformers library
  • Argument component classification uses BERT
  • Sentence segmentation uses spaCy
  • Testing uses pytest with pytest-cov for coverage reporting

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Commit your changes
  4. Push to the branch
  5. Create a Pull Request

License

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

Acknowledgments

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages