Created
March 1, 2017 22:31
-
-
Save Abzol/1d3744c8cb4b745e66b3f286f6bc9ee0 to your computer and use it in GitHub Desktop.
dumbest armenian checker
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import re, sys | |
if __name__ == "__main__": | |
r_a = re.compile("[\u0531-\u058F]") | |
r_e = re.compile("[A-Za-z]") | |
fn = sys.argv[1] | |
try: | |
with open(fn, "r") as f: | |
a = 0 | |
e = 0 | |
for line in f: | |
a += len(re.findall(r_a, line)) | |
e += len(re.findall(r_e, line)) | |
if (a > e): | |
print(fn + " is likely Armenian.") | |
elif (e > a): | |
print(fn + " is likely English.") | |
else: | |
print("For " + fn + ", we can't tell.") | |
except IsADirectoryError: | |
pass |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment