小编Abr*_*rar的帖子

python中的文本语言检测

我试图检测可能由未知数量的语言组成的文本的语言.下面的代码给了我不同的语言作为答案 注意:我减少了审查,因为它是在帖子""不允许给出错误

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)

python dataframe pandas

2
推荐指数
1
解决办法
5127
查看次数

如何计算单词的频率并在列表列表中添加单词的相关权重

我有以下数据

[[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)

python list frequency

0
推荐指数
1
解决办法
342
查看次数

标签 统计

python ×2

dataframe ×1

frequency ×1

list ×1

pandas ×1