美文网首页
冒犯语言检测器

冒犯语言检测器

作者: SmartDavid | 来源:发表于2017-03-12 21:27 被阅读0次

检测你书写的邮件有没有出现冒犯语言,实用简单。

import urllib.request

def read_text():
    quotes = open("F:\movie_quotes.txt")
    contents_of_file = quotes.read()
    #print(contents_of_file)
    quotes.close()
    check_profanity(contents_of_file)

def check_profanity(text_to_check):
    connection = urllib.request.urlopen("http://wdyl.com/profanity?q="+text_to_check)
    output = connection.read()
    #print(output)
    connection.close()
    if "true" in output:
        print("Profanity Alert!!")
    elif "false" in output:
        print("This document has no curse words!")
    else:
        print("Could not scan the document properly.")
    
read_text()

相关文章

网友评论

      本文标题:冒犯语言检测器

      本文链接:https://www.haomeiwen.com/subject/apyxnttx.html