簡體   English   中英

Python正則表達式和標記化

[英]Python regular expressions and tokenization

我有一個字符串“ABC一二三”。

我有一個任務是將這個字符串標記為[“ABC”,一,二,三],忽略句子末尾的句號。 我無法在句子結尾處刪除句號而不會干擾ABC的縮寫詞。

有沒有辦法讓我在句子結尾處刪除句點而不影響使用python正則表達式的首字母縮略詞?

word = re.compile(r'[A-Za-z.]*[A-Za-z]')
word.findall("A.B.C one two three.")    # => ['A.B.C', 'one', 'two', 'three']
line= "A.B.C one two three."
print line[:-1].split(' ')

可能也是這樣

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM