Skip to main content

A lightweight rule based tech content tagging module for Python

Project description

Tagging Module

A lightweight rule based tech content tagging module for Python

Class Overview

The TaggingService class is designed to provide a tagging service. It uses the tagging_system module to assign tags to content based on predefined rules. The tagging rules are specified in a YAML file.

You may directly use it from this repo or install via Pip.

pip install tagging-module

Constructor

__init__(self, rules_path: str = None)

The constructor initializes a TaggingService object.

Parameters

  • rules_path (optional): A string representing the path to the YAML file containing the tagging rules. If not provided, the default rules file path (tagging_module/config/rules.yml) is used.

Exceptions

  • FileNotFoundError: Raised if the provided rules_path is not a valid file path.

Example

from tagging_module.tagging_service import TaggingService

# Using the default rules file path
service = TaggingService()

# Providing a custom rules file path
service = TaggingService(rules_path="path/to/custom_rules.yml")

Methods

assign_tags(self, content: str) -> List[str]

This method assigns tags to the provided content based on the defined tagging rules.

Parameters

  • content: A string representing the content to be tagged.

Returns

A list of strings representing the assigned tags for the content.

Example

from tagging_module.tagging_service import TaggingService

# Assuming the rules file contains rules for tagging different types of content
service = TaggingService()

content = "This is a sample content."
tags = service.assign_tags(content)
print(tags)
# Output: ['sample', 'content']

Note: The output tags may vary based on the specific tagging rules defined in the rules file.

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

tagging_module-0.0.8.tar.gz (5.0 kB view hashes)

Uploaded Source

Built Distribution

tagging_module-0.0.8-py3-none-any.whl (5.6 kB view hashes)

Uploaded Python 3

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