首页 > 解决方案 > 句子标点返回 True-Spacy

问题描述

我正在使用熊猫编写包含句子的逗号以表现出色。

lists = [sent for sent in doc.sents if ',' in sent.string.lower()]

发现,我可以在 excel 中为它返回 True 或 False。

=ISNUMBER(SEARCH(",", A1))

我使用下面的代码来提取句子并将其列为 Excel 中的行

sentences = [sent.string.strip() for sent in doc.sents]

预计出炉:

Sentence                                 IS_comma_sent
This sentence contains no comma.         False
There is a , in this sentence.           True

关于如何在熊猫中做到这一点的任何建议。

标签: excelpandasspacy

解决方案


IIUC str.包含

df['Is_comma_sent']=df['Sentence'].str.contains(',')

推荐阅读