donglian7879 2019-03-07 17:27
浏览 240
已采纳

正则表达式在点号|分号处分割,但忽略URL

I'm trying to parse and match a lot of legal text, splitting it all up into individual sentences. I have the following regex which would work for just a few lines of easy text just fine:

[^\.\!\?\;
]*[\.\!\?\;
](\s+)

! and ? or pretty irrelvant here but . and ; as separators are quite common in the texts I'm trying to work with. The problem is that the above regex is just finding those delimiters followed by a space character. The following text for example would not be properly matched:

Member State law or pursuant to contract with a health professional and subject to the conditions and safeguards referred to in paragraph 3; processing is necessary for reasons of public interest in the area of public health, such as protecting against serious cross-border threats to health or ensuring high standards comparison tool at https://ec.europa.eu/ploteus/en/compare Adopted 7 comparable procedures (e. g. certifications/audits), and registered as required by the Member State. of quality and safety of health care and of medicinal products or medical devices, on the basis of Union or Member State law, which provides for suitable and specific measures to safeguard the rights and freedoms of the data subject, in particular professional secrecy; processing is...

the following entire section:

processing is necessary for reasons of public interest in the area of public health, such as protecting against serious cross-border threats to health or ensuring high standards comparison tool at https://ec.europa.

would not be matched at all.

Any help in improving the above regex would be greatly appreciated!

Thanks

  • 写回答

1条回答 默认 最新

  • dongshan4549 2019-03-08 17:55
    关注

    I think the name of what you want is a sentence tokenizer. For Go, I can recommend one library: github.com/jdkato/prose, it should do the job like a charm.

    Personally, I never used. Good luck!

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)