Answers for "split string in txt to words python"

0

read a file and split the words python

f = open("yourfile.txt", "r")

content = f.read()
words = content.split()

f.close()
Posted by: Guest on August-05-2021
1

python split string to sentences

import spacy
nlp = spacy.load('en_core_web_sm') # Load the English Model

string1 = "This is the first sentence. This is the second sentence. This is the third sentence."
doc = nlp(string1)

list(doc.sents)
    
 # Output: ["This is the first sentence.", "This is the second sentence.", "This is the third sentence."]
Posted by: Guest on November-22-2021

Python Answers by Framework

Browse Popular Code Answers by Language