Home  >  Q&A  >  body text

python - 如何从字符串中提取地区名字?

比如从‘在香港和纽约等地上市中国股票’这个字符串中提取出 美国,华尔街,香港,纽约这些地点名字?
**我是要从一本书当中提取出所有地点名称,所以看看大神们有没有好的建议和方式?
或者用到什么库呢?**

ringa_leeringa_lee2741 days ago1153

reply all(3)I'll reply

  • 高洛峰

    高洛峰2017-04-18 10:34:40

    I crawled a map website, downloaded all the place names in China, organized them into a txt, then opened it in python, converted it into a map list, and then traversed it, and it was ok.

    reply
    0
  • ringa_lee

    ringa_lee2017-04-18 10:34:40

    I think it is still a bit difficult to implement this, because some place names are unknown, but you can use an array to put some commonly used place names, and then use indexOf to see if they exist, but this method is too troublesome. I hope there will be better ones below. Methods.

    reply
    0
  • 阿神

    阿神2017-04-18 10:34:40

    You can find some third-party place name libraries. Then match the place names that appear in the book with the class library.

    reply
    0
  • Cancelreply