Category python-text-processing

Python blocks and gaps

Python Chunks and Gaps Chunking is the process of grouping similar words together based on their properties. In the following example, we create chunks by defining a grammar. This grammar suggests following a phrase order like noun, adjective, etc. when…

Python Text Translation

Python Text Translation Translating text from one language to another is increasingly common for websites catering to international audiences. The Python package that helps us achieve this is called translate. This package can be installed as follows. It provides translation…

Python Get Corpus

Getting a Corpus with Python A corpus is a collection of text documents. A collection is called a corpus. One well-known corpus is the Gutenberg Corpus, which contains approximately 25,000 free e-books and is hosted at In the following…

Python sort by row

Python Sorting by Line Often, we need to sort the contents of a file for analysis. For example, we might want to sort sentences written by different students alphabetically by their names. This involves sorting the first character of a…

Python text wrapping

Python Text Wrapping Text wrapping is necessary when text from a source is not formatted correctly for the available screen width. This can be achieved using the following package, which can be installed in our environment using the following command.…