句子标点返回True-Spacy

时间:2018-08-31 01:24:53

标签: excel pandas spacy

我正在用逗号编写包含要使用Excel的句子的逗号。

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

有关在熊猫中如何做的任何建议。

1 个答案:

答案 0 :(得分:1)

IIUC str.contains

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