Iterate over all of the entities of txt, using ent as your iterator variable. Check whether the entity contains "Márquez

动态 未结 0 191
小小草
小小草 LV1 2023年9月23日 23:40 发表
# Initialize the count variable: count count = 0 # Iterate over all the entities for ent in txt.entities: # Check whether the entity contains 'Márquez' or 'Gabo' if 'Márquez' in ent or 'Gabo' in ent: # Increment count count += 1 # Print count print(count) # Calculate the percentage of entities that refer to "Gabo": percentage percentage = count / len(txt.entities) print(percentage)
收藏(0)  分享
相关标签: 智能问答
问题没解决?让AI助手帮你作答 AI助手
0个回复
  • 消灭零回复