CoolFace
Apppublic

alpertml/TopicModelingForSummarization

sourceHugging Facecreativeml-openrail-mupdated 3y agoView on Hugging Face
0likes
nltk_utilities.py38 linesDownload Raw Back to src
1### Imports2import nltk3from nltk.tokenize import sent_tokenize4nltk.data.path.append("/nltk_data/")5 6 7class NltkSegmentizer:8    ##==========================================================================================================9    """10    Definition of attributes11    """12 13    ##==========================================================================================================14    """15    Function: __init__16    """17    def __init__(self):18        print("Initializing NltkSegmentizer object")19        nltk.download('punkt')20    ##==========================================================================================================21    """22    Function: segment_into_sentences23    """24    def segment_into_sentences(self, src_text="", _format=""):25        intermediate_result = None26 27        if isinstance(src_text, str):28            intermediate_result = sent_tokenize(src_text)29        elif isinstance(src_text, list):30            intermediate_result = list()31 32            for sent in src_text:33                intermediate_result.extend(sent_tokenize(sent))34 35        return intermediate_result36    ##==========================================================================================================37 38##==========================================================================================================