Documentation/Core
TextHighlighter
The TextHighlighter module provides functionality to highlight specific keywords in text, supporting both single-word and multi-word highlighting with customizable markers.
Info: This documentation provides interactive code views for each method. Click on a function name to view its implementation.
Module Overview
Data class
NgramData
A data class to store n-gram processing results containing:
word_list: List of extracted words that form the n-gramsplit_kw_list: List of lists containing the split keywords for processing
Constructor
Parameters:
max_ngram_size(int): Maximum size of n-grams to consider for highlightinghighlight_pre(str, optional): Text to insert before highlighted terms (default:<kw>)highlight_post(str, optional): Text to insert after highlighted terms (default:</kw>)
Core Methods
Helper Methods
Usage Example
Dependencies
The TextHighlighter module relies on:
re: For regular expression operations in text processinglogging: For error handling and reportingdataclasses: For defining theNgramDatadataclasstyping: For type annotations