Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

create a typo with python

import string
import random

new_phrase = []
words = phrase.split(' ')
for word in words:
    outcome = random.random()
    if outcome <= p:
        ix = random.choice(range(len(word)))
        new_word = ''.join([word[w] if w != ix else random.choice(string.ascii_letters) for w in range(len(word))])
        new_phrase.append(new_word)
    else:
        new_phrase.append(word)

new_phrase = ' '.join([w for w in new_phrase]) 
Comment

PREVIOUS NEXT
Code Example
Python :: oscillating fan 
Python :: python convert ftp timestamp to datetime 
Python :: come traferire file python 
Python :: specify dtype when creating array 
Python :: vitalik buterin age 
Python :: how to use Py-agender for projects 
Python :: install formio data python library 
Python :: if i[11] not in lst[i]: 
Python :: text input tkinter 
Python :: how to have framer read json timestamps 
Python :: sumx and ABS in power bi 
Python :: group your data columns by their data types 
Python :: Recursive Folder scan 
Python :: from flask_paginate import get_page_parameter 
Python :: python sqlobject declare connection 
Python :: how to delete a cell in jupyter notebook 
Python :: dividing counter object in python 
Python :: without using sum add item in list python 
Python :: compute the average age for each gender? * 
Python :: tyjacsav 
Python :: break up word in clomun pandas 
Python :: spacy text annotation dict comprehension 
Python :: streamlit altair 
Python :: Fancier Output Formatting in python 
Python :: https://practice.geeksforgeeks.org/problems/coin-change2448/1 
Python :: check substring frequency in a text python 
Python :: print function in python 
Python :: scatter plot points density color pandas 
Python :: check processing bar of loop in python 
Python :: geomertry 
ADD CONTENT
Topic
Content
Source link
Name
1+1 =