惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

G
Google Developers Blog
S
SegmentFault 最新的问题
Jina AI
Jina AI
D
DataBreaches.Net
人人都是产品经理
人人都是产品经理
罗磊的独立博客
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
爱范儿
爱范儿
大猫的无限游戏
大猫的无限游戏
C
Check Point Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
WordPress大学
WordPress大学
博客园 - 三生石上(FineUI控件)
B
Blog
博客园 - 【当耐特】
博客园 - Franky
M
MIT News - Artificial intelligence
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
L
LangChain Blog
MyScale Blog
MyScale Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
博客园 - 叶小钗
Last Week in AI
Last Week in AI
Engineering at Meta
Engineering at Meta

博客园 - bigdog

安装PyTorch_1 Pandas上的Dataframe求差集 Linux 下安装NLTK的过程 Python函数返回多结果 Pandas下的Dataframe如何实现多条件筛选 如何安装pytorch Selenium 获取Select元素的选中值 安装MxNet Docker 的日常 Ubuntu上安装Docker Ubuntu华为云挂载新硬盘 Python读写大文件-将整行文字根据分号分行 Pandas中的DataFrame读取Mysql的方法 Pandas中的DataFrame读取Oracle的方法 Kettle 7.1 配置连接Oracle、Mysql、SqlServe的DLL文件准备 Nginx开启访问日志记录 Selenium chromeDriver 下载地址 在Linux上部署Nginx,反向代理tornado的WebSite Linux上安装Mysql
将英文缩写扩展成正常英文的方法
bigdog · 2021-04-09 · via 博客园 - bigdog
import re
class RegexpReplacer(object):

    def __init__(self):
        self.patterns = [
            (r"won\'t", "will not"),
            (r"can\'t", "can not"),
            (r"n\'t", " not"),
            (r"\'re", " are"),
            (r"\'s", " is"),
            (r"\'d", " would"),
            (r"\'ll", " will"),
            (r"\'t", " not"),
            (r"\'ve", " have"),
            (r"\'m", " am"),
            (r"CBA", "China Basketball Association")]

    def replace(self,text):
        s = text
        for(pattern,repl) in self.patterns:
            (s,count)=re.subn(pattern,repl,s)
        return s

调用方法:

replacer= RegexpReplacer()
str = replacer.replace("She must've gone to the market but she didn't go")
print(str)

Enjoy :)