This Python code snippet demonstrates how to split a given raw text into sentences using DeepL's private API. It utilizes reverse engineering techniques to access DeepL's advanced natural language processing (NLP) features.
- Python 3.x
-
Clone the repository:
git clone https://github.com/devtonic-net/NLPSplitSentencesDeepLAPI.git
-
Navigate to the project directory:
cd NLPSplitSentencesDeepLAPI
-
Create a new virtual environment:
python3 -m venv venv
-
Activate the virtual environment:
For Windows:
venv\Scripts\activate
For Unix or Linux:
source venv/bin/activate
-
Install the required dependencies:
pip install -r requirements.txt
-
Create a text file called
my_text.txt
. This file should contain the text you need to split into sentences. -
In
main.py
, call thesplit_sentences()
function, passing the raw text as the argument:text = get_text("my_text.txt") sentences = split_sentences(text) for index, sentence in enumerate(sentences, start=1): print(f"{index}. {sentence}")
This will split the raw text into sentences using DeepL's private API and print them with their respective indices.