MCPcopy Create free account
hub / github.com/subbarayudu-j/TheAlgorithms-Python / isEnglish

Function isEnglish

other/detecting_english_programmatically.py:38–50  ·  view source on GitHub ↗

>>> isEnglish('Hello World') True >>> isEnglish('llold HorWd') False

(message, wordPercentage = 20, letterPercentage = 85)

Source from the content-addressed store, hash-verified

36 return ''.join(lettersOnly)
37
38def isEnglish(message, wordPercentage = 20, letterPercentage = 85):
39 """
40 >>> isEnglish('Hello World')
41 True
42
43 >>> isEnglish('llold HorWd')
44 False
45 """
46 wordsMatch = getEnglishCount(message) * 100 >= wordPercentage
47 numLetters = len(removeNonLetters(message))
48 messageLettersPercentage = (float(numLetters) / len(message)) * 100
49 lettersMatch = messageLettersPercentage >= letterPercentage
50 return wordsMatch and lettersMatch
51
52
53import doctest

Callers

nothing calls this directly

Calls 2

getEnglishCountFunction · 0.85
removeNonLettersFunction · 0.85

Tested by

no test coverage detected