当前位置:网站首页>Address information parsing in one line of code

Address information parsing in one line of code

2022-07-07 00:53:00 Zhu Weijun

* The complete sample code and files of this article have been uploaded to my Github Warehouse https://github.com/CNFeffery/PythonPracticalSkills*

This is my article series 「「Python Practical secrets 」」 Of the 8 period , This series is based on the author's daily work Python Accumulated experience , Each issue brings you a simple skill that you can learn in a few minutes .

As the first in the series 8 period , What we are going to learn is : One line of code parses the address information .

In the process of daily data processing , Sometimes you get the complete address information , If you need to resolve the corresponding administrative unit names at all levels from the address information , There are many ways , The method to be introduced today can be implemented quickly with only one line of code .

First we need to install jionlp This very easy-to-use text preprocessing toolkit , Domestic image installation is recommended :

pip install jionlp -i https://pypi.douban.com/simple/

After installation , Just use its parse_location() The interface can resolve the address information , And has many different functions :

  • Basic provincial and urban information extraction
  • Street Town Township 、 Information extraction of village or neighborhood committee

By setting parameters town_village=True, You can also try to extract Street towns and townships 、 Information field of village or neighborhood committee information level :

  • Automatically complete the provincial and municipal information

If the address information is missing, it doesn't matter , In the absence of ambiguity ,parse_location() It will automatically associate and complete the relevant information :

besides ,parse_location() It also has the function of revising the old place name into a new place name 、 Custom administrative division dictionary and other functions , You can find it in its official documents https://github.com/dongrixinyu/JioNLP/wiki/Gadget- documentation # Address resolution Learn more about .


The end of this sharing , I'll see you next time ~

原网站

版权声明
本文为[Zhu Weijun]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/188/202207061703164737.html

随机推荐