forelegance
V2EX  ›  Python

re.split(pattern, text)的 pattern 是很长很长的 list,效率会很低吧,有什么好的方法

By forelegance at 2018 年 4 月 24 日 · 2874 次点击

现在又一个十几万个基因的名字,需要在一段文字中找到这些基因 Gene Symbol,然后从这个 Gene Symbol 两边切一刀,把这段文字切成 list

但是这个 pattern 就会操集长,想到用 re.split 来弄,但是 pattern 太长了,效率低

4 条回复  •  2018-04-25 02:58:33 +08:00
layorlayor
   1
layorlayor  
   2018 年 4 月 24 日
手写个 AC 自动机?
neosfung
   2
neosfung  
   2018 年 4 月 24 日 via iPhone
FlashText 了解一下?
bantao
   3
bantao  
   2018 年 4 月 24 日
flashtext 中文好用吗,是不是要先分个词
laqow
   4
laqow  
   2018 年 4 月 25 日 via Android
re 按行操作的话不会很长,python 自己的函数处理文字非常慢,按二进制读文字做匹配速度会快很多
推荐学习书目
› Learn Python the Hard Way
Python Sites
› PyPI - Python Package Index
› http://diveintopython.org/toc/index.html
› Pocoo
值得关注的项目
› PyPy
› Celery
› Jinja2
› Read the Docs
› gevent
› pyenv
› virtualenv
› Stackless Python
› Beautiful Soup
› 结巴中文分词
› Green Unicorn
› Sentry
› Shovel
› Pyflakes
› pytest
Python 编程
› pep8 Checker
Styles
› PEP 8
› Google Python Style Guide
› Code Style from The Hitchhiker's Guide
© 2026 V2EX · 33ms · 3.9.8.5