我试图检测可能由未知数量的语言组成的文本的语言.下面的代码给了我不同的语言作为答案 注意:我减少了审查,因为它是在帖子""不允许给出错误
print(detect(???? ????? ?????? ??????? ???? ??? ????? ??????))
print(detect(?????))
print(detect(Vi havde 2 perfekte dage i Legoland Malaysia))
print(detect(Wij hebben alleen gekozen voor het waterpark maar daar ben je vrijs snel doorheen. Super leuke glijbanen en overal ruimte om te zitten en te liggen. Misschien volgende keer een gecombineerd ticket kopen met ook toegang tot waterpark))
print(detect(This is a park thats just ok, nothing great to write home about. There is barely any shade, the weather is always really …
Run Code Online (Sandbox Code Playgroud) 我有以下数据
[[4, 'ABC'], [4, 'BCD'], [3, 'CDE'], [3, 'ABC'], [3, 'DEF'], [3, 'BCD'], [3, 'BCD'], [3, 'BCD']]
Run Code Online (Sandbox Code Playgroud)
我需要以下输出
[ABC, 2, 7]
[BCD, 4, 13]
[CDE, 1, 3]
[DEF, 1, 3]
Run Code Online (Sandbox Code Playgroud)
我需要将单词数量计为位置[1],并将位置为[0]的单词的数字相加.结果是
[Word, freq, sum of weight]
Run Code Online (Sandbox Code Playgroud)
我检查对列表中的对项的查找频率和查找python中的数字列表的频率分布,但它们无法解决我的问题.
我试过这个但没有成功
res = [[4, 'ABC'], [4, 'BCD'], [3, 'CDE'], [3, 'ABC'], [3, 'DEF'], [3, 'BCD'], [3, 'BCD'], [3, 'BCD']]
d = {}
for freq, label in res:
if label not in d:
d[label] = {}
inner_dict = d[label] …
Run Code Online (Sandbox Code Playgroud)