def detect(text):
k = 10 # koefficient
ru = 'абвгдежзиклмнопрстуфхцчщьыъэюя'
en = 'abcdefghijklmnopkrstuvwxyz'
cd = '[]{}()_=+/\\|@#$%^&*'
ru_c = 0 # c - chance
en_c = 0 # c - chance
cd_c = 0 # c - chance
max_cd_syms = 1 # syms - symbols
for s in str(text.casefold()): # str() for refuse some chance of exception
if s in ru:
ru_c += 1
continue
if s in en:
en_c += 1
cd_c += .5
continue
if s in cd:
cd_c += (max_cd_syms*len(text)//k)
continue
pass
#print(ru_c, en_c, cd_c) # debug
if ru_c > en_c and ru_c > cd_c:
return 'ru'
if en_c > ru_c and en_c > cd_c:
return 'en'
if cd_c > ru_c and cd_c > en_c:
return 'code'
return 'mixed'
#
text1 = '''Минобороны показало уничтожение высокоточным оружием артиллерийской батареи'''
text2 = '''O curse of marriage!
That we can call these delicate creatures ours,
And not their appetites! I had rather be a toad
And live upon the vapour of a dungeon
Than keep a corner in the thing I love
For others' uses.'''
text3 = '''_tabversion = '3.10'
_lr_method = 'LALR'
_lr_signature = 'amper apos back bux colon comma comment dog dot equ expl flex float ignore int lang lblc lfig lpar minus multilinecomment name newline percent plus rang rblc rfig rpar semi sharp slash star str tildeline : preptag\n | assign\n | func\n | cyclepreptag : sharp lblc name rblc\n | sharp lblc name colon name rblc\n | sharp lblc name colon int rblcassign : name equ expr\n | name equ namefunc : name lpar args rpar\n | name lpar rparexpr : intcycle : name lpar args rpar lfig rfigargs : name\n | expr\n | name comma args\n | expr comma args'
_lr_action_items = {'sharp':([0,],[6,]),'name':([0,8,9,10,20,21,23,],[7,11,12,15,24,15,15,]),'$end':([1,2,3,4,5,12,13,14,17,19,22,29,30,31,],[0,-1,-2,-3,-4,-9,-8,-12,-11,-5,-10,-6,-7,-13,]),'lblc':([6,],[8,]),'equ':([7,],[9,]),'lpar':([7,],[10,]),'int':([9,10,20,21,23,],[14,14,25,14,14,]),'rpar':([10,14,15,16,18,26,28,],[17,-12,-14,22,-15,-16,-17,]),'rblc':([11,24,25,],[19,29,30,]),'colon':([11,],[20,]),'comma':([14,15,18,],[-12,21,23,]),'lfig':([22,],[27,]),'rfig':([27,],[31,]),}
_lr_action = {}
for _k, _v in _lr_action_items.items():
for _x,_y in zip(_v[0],_v[1]):
if not _x in _lr_action: _lr_action[_x] = {}
_lr_action[_x][_k] = _y
del _lr_action_items
_lr_goto_items = {'line':([0,],[1,]),'preptag':([0,],[2,]),'assign':([0,],[3,]),'func':([0,],[4,]),'cycle':([0,],[5,]),'expr':([9,10,21,23,],[13,18,18,18,]),'args':([10,21,23,],[16,26,28,]),}
_lr_goto = {}
for _k, _v in _lr_goto_items.items():
for _x, _y in zip(_v[0], _v[1]):
if not _x in _lr_goto: _lr_goto[_x] = {}
_lr_goto[_x][_k] = _y
del _lr_goto_items
_lr_productions = [
("S' -> line","S'",1,None,None,None),
('line -> preptag','line',1,'p_line','lexyac.py',197),
('line -> assign','line',1,'p_line','lexyac.py',198),
('line -> func','line',1,'p_line','lexyac.py',199),
('line -> cycle','line',1,'p_line','lexyac.py',200),
('preptag -> sharp lblc name rblc','preptag',4,'p_preptag','lexyac.py',203),
('preptag -> sharp lblc name colon name rblc','preptag',6,'p_preptag','lexyac.py',204),
('preptag -> sharp lblc name colon int rblc','preptag',6,'p_preptag','lexyac.py',205),
('assign -> name equ expr','assign',3,'p_assign','lexyac.py',209),
('assign -> name equ name','assign',3,'p_assign','lexyac.py',210),
('func -> name lpar args rpar','func',4,'p_func','lexyac.py',214),
('func -> name lpar rpar','func',3,'p_func','lexyac.py',215),
('expr -> int','expr',1,'p_expr','lexyac.py',219),
('cycle -> name lpar args rpar lfig rfig','cycle',6,'p_cycle','lexyac.py',223),
('args -> name','args',1,'p_args','lexyac.py',227),
('args -> expr','args',1,'p_args','lexyac.py',228),
('args -> name comma args','args',3,'p_args','lexyac.py',229),
('args -> expr comma args','args',3,'p_args','lexyac.py',230),
]'''
#
print(detect(text1), detect(text2), detect(text3))
#
input()
Элементарно. Функция не идеальна, но если хотите полноценный ИИ для этих целей - напишите в комментах к ответу.