Pageviews

Wednesday 16 September 2015

Profanity Editor Mini Project in Python

by Unknown  |  in Python at  Wednesday, September 16, 2015

Python is one of the most used functional programming language.Python has got many applications areas.We can build almost every type of application using Python.

What is Profanity Editor?

Profanity's meaning in English is obscene language word /curse word.For example,you used to write a large number of emails dailyto your Boss,so it is obvious that you may use curse words like shit,crap in your email also.Using of these words might get your job in trouble.In order to avoid this,there is Profanity Editor.

Profanity Checker tool by Google

Google has developed a Profanity checker tool which you can access here.You can type the word or a sentence after the = sign in the link.If there are profanity words in your sentence,the response will be true otherwise false.



Creating a Profanity Editor in Python:

import urllib 
def read_text():
    quotes = open("F:/Learn Python/text.txt")
    contents_of_file = quotes.read()
    #print the file contents
    print(contents_of_file)
    quotes.close()
    check_profanity(contents_of_file) 
def check_profanity(text_to_check):
   connection = urllib.urlopen("http://www.wdyl.com/profanity?q="+text_to_check)
   output = connection.read()
   connection.close()
   if "true" in output:
       print("Profanity Alert")
   elif "false" in output:
       print("This document has no words")
   else:
       print("Could not scan the document")
read_text()   

Since I have uploaded a text file from my PC,you can copy paste your email you want to write and you need not to read your email again,just run this program and check for profanity words.














0 comments:

Proudly Powered by Blogger.