Skip to content

Instantly share code, notes, and snippets.

@Abzol
Created March 1, 2017 22:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Abzol/1d3744c8cb4b745e66b3f286f6bc9ee0 to your computer and use it in GitHub Desktop.
Save Abzol/1d3744c8cb4b745e66b3f286f6bc9ee0 to your computer and use it in GitHub Desktop.
dumbest armenian checker
#!/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