V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
推荐学习书目
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
forelegance
V2EX  ›  Python

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

  •  
  •   forelegance · Apr 24, 2018 · 2484 views
    This topic created in 2925 days ago, the information mentioned may be changed or developed.

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

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

    4 replies    2018-04-25 02:58:33 +08:00
    layorlayor
        1
    layorlayor  
       Apr 24, 2018
    手写个 AC 自动机?
    neosfung
        2
    neosfung  
       Apr 24, 2018 via iPhone
    FlashText 了解一下?
    bantao
        3
    bantao  
       Apr 24, 2018
    flashtext 中文好用吗,是不是要先分个词
    laqow
        4
    laqow  
       Apr 25, 2018 via Android
    re 按行操作的话不会很长,python 自己的函数处理文字非常慢,按二进制读文字做匹配速度会快很多
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   6006 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 87ms · UTC 03:31 · PVG 11:31 · LAX 20:31 · JFK 23:31
    ♥ Do have faith in what you're doing.