0

データのエンティティの結果を数えたいと思います。

これは私のDFです:

my_dict = {"customer_1": "Adidas é melhor do que Nike", "customer_2": "Até que Nike é bom", "customer_3": "Eu gosto do Google e da Microsoft"}

my_df = pd.DataFrame(list(my_dict.items()), columns = ['customer_id', 'review'])

print(my_df)

    customer_id   review
0   customer_1    Adidas é melhor do que Nike e Microsoft
1   customer_2    Até que Nike é bom
2   customer_3    Eu gosto do Google e da Microsoft

Polyglot のテキストを使用して、次のようなエンティティを識別しています。

# Create a new text object using Polyglot's Text class: txt
import polyglot
from polyglot.text import Text, Word

txt = Text(my_df['review'][2])

# Print each of the entities found
for ent in txt.entities:
    print(ent)

['Google']
['Microsoft']

(上記のように)括弧内に行番号を入力する代わりに、次のような結果を得たいと思います。

Entity    Count
Nike      2
Adidas    1
Google    1
Microsoft 2

これまでにこれを試しましたが、うまくいきませんでした:

for i in x_col['Texto_Abertura']:
    txt = Text(x_col['Texto_Abertura'][i])

# Print each of the entities found
    for ent in txt.entities:
        counter += ent
4

0 に答える 0