Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

text splitter for nlp

def text_splitter(t):
    t = re.sub(r'[^ws]','',text)
    data = pd.DataFrame(columns=['text','output'])
    for i in range(len(t.split())):
        text = ' '.join(t.split()[0:i+1])
        temp_text = ' '.join(t.split()[i+1:])
        for k in range(len(temp_text.split())):
            output = ' '.join(temp_text.split()[:k+1])
    #         print(text,'----',output)
            data = data.append({'text':text, 'output':output}, ignore_index=True)
    return data
  
  
  
  
t = 'How do I reset a password in windows'
text_splitter(t)

text	output
0	How	do
1	How	do I
2	How	do I reset
3	How	do I reset a
4	How	do I reset a password
5	How	do I reset a password in
6	How	do I reset a password in windows
7	How do	I
8	How do	I reset
9	How do	I reset a
10	How do	I reset a password
11	How do	I reset a password in
12	How do	I reset a password in windows
13	How do I	reset
14	How do I	reset a
15	How do I	reset a password
16	How do I	reset a password in
17	How do I	reset a password in windows
18	How do I reset	a
19	How do I reset	a password
20	How do I reset	a password in
21	How do I reset	a password in windows
22	How do I reset a	password
23	How do I reset a	password in
24	How do I reset a	password in windows
25	How do I reset a password	in
26	How do I reset a password	in windows
27	How do I reset a password in	windows
Comment

PREVIOUS NEXT
Code Example
Python :: youtube view bot python code pastebin 
Python :: django wht post save signal not firing 
Python :: successful=true for number in range (3) print ("Attempt") if successful: print ("Successful") breal 
Python :: how to use python-socker.io with fast api 
Python :: Flask migration method, see the artcle for more info 
Python :: python indexing 
Python :: remove cooldown discord python 
Python :: new line in jupyter notebook markdown 
Python :: python convert comma separated list of number to float 
Python :: how to make an infinite loop in python 
Python :: dictionary changed size during iteration after pop function 
Python :: python which packages depend on package 
Python :: workbook select sheet python 
Python :: run all jupyter notebooks in project folder 
Python :: first n lis tpython 
Python :: how to check for non-datetime value in python 
Python :: struct is not defined python 
Python :: box detection 
Python :: python zip function 
Python :: pytest runtimeerror: no application found. either work inside a view function or push an application context 
Python :: open tkinter and cli 
Python :: crop image using opencv with height and width 
Python :: torch.unsqueeze 
Python :: Exception Type with except block: 
Python :: datetime german format python 
Python :: import cv2 illegal instruction (core dumped) 
Python :: next function with inherited list python 
Python :: get user id discord.py 
Python :: empty python file 
Python :: python select random number from list 
ADD CONTENT
Topic
Content
Source link
Name
6+6 =