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 providedrules_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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for tagging_module-0.0.8-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d16060bf63d64f4c6289eb5b0d0b69e10d56ee832aa9e9ab9d42822f1480e768 |
|
MD5 | 6b254e76f78c32b8e928b268da91556a |
|
BLAKE2b-256 | c6a86a41c16afede71e9bec1e009137c40dfb9ffdb81d2c203dd4c3d19d2db7d |