python包实现基于字符串匹配的实体消歧

disamb的Python项目详细描述


分解

https://img.shields.io/pypi/v/disamby.svghttps://img.shields.io/travis/verginer/disamby.svgDocumentation StatusUpdates

disamby是一个python包,用于执行基于fuzzy的实体消歧 字符串匹配。

它最适用于那些具有非常相似字符串的实体。 这种消歧算法很好地工作的情况的例子是 公司名称和地址,有排印、替换拼写或复合名称。 其他用例包括识别数据库中可能拼写错误的人。

该算法的工作原理是利用给定单词/令牌的信息量,基于 在整个弦乐语料库中观察到的频率。例如 公司名称的案例信息量不大,但是“所罗门”是,因为前者出现了 重复而第二次很少。

使用这些频率,算法计算给定的一对实例的相似程度 它们是,如果它们高于任意阈值,则它们连接在 “别名图”(即一个实体连接到另一个实体的有向网络 如果它足够相似)。以这种方式连接所有记录之后 返回强连接的实体集[2]。强连接手段 在这种情况下,存在从所有节点到组件内的所有节点的路径。

示例

在项目中使用分解:

import pandas as pd
import disamby.preprocessors as pre
form disamby import Disamby

# create a dataframe with the fields you intend to match on as columns
df = pd.DataFrame({
    'name':     ['Luca Georger',        'Luca Geroger',         'Adrian Sulzer'],
    'address':  ['Mira, 34, Augsburg',  'Miri, 34, Augsburg',   'Milano, 34']},
    index=      ['L1',                  'L2',                   'O1']
)

# define the pipeline to process the strings, note that the last step must return
# a tuple of strings
pipeline = [
    pre.normalize_whitespace,
    pre.remove_punctuation,
    lambda x: pre.trigram(x) + pre.split_words(x)  # any python function is allowed
]

# instantiate the disamby object, it applies the given pre-processing pipeline and
# computes their frequency.
dis = Disamby(df, pipeline)

# let disamby compute disambiguated sets. Node that a threshold must be given or it
# defaults to 0.
dis.disambiguated_sets(threshold=0.5)
[{'L2', 'L1'}, {'O1'}]  # output

# To check if the sets are accurate you can get the rows from the
# pandas dataframe like so:
df.loc[['L2', 'L1']]

安装

要安装disamby,请在终端中运行此命令:

$ pip install disamby

这是安装disamby的首选方法,因为它总是安装最新的稳定版本。 如果您没有安装pip,这个Python installation guide可以指导您 你完成了整个过程。

您也可以从源代码安装它,如下所示 可从Github repo下载要分解的源代码。 您可以克隆公共存储库:

$ git clone git://github.com/verginer/disamby

或者下载tarball

$ curl  -OL https://github.com/verginer/disamby/tarball/master

一旦您有了源代码的副本,就可以使用以下命令安装它:

$ python setup.py install

学分

我从“搜索引擎-一个 根据模糊标准进行匹配”作者:Thorsten Doherr,来自CISS[1]暑期学校,2017年

[1]http://www.euro-ciss.eu/ciss/home.html
[2]https://en.wikipedia.org/wiki/Strongly_connected_component

历史记录

0.2.3(2017-07-01)

  • 修复了破坏pypi显示的格式设置

0.2.2(2017-06-30)

  • 使用最少文档的工作版本
  • 使用多字段匹配
  • 自动执行从字符串预处理到 识别强连接组件

0.1.0(2017-06-24)

  • pypi上的第一个版本。

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
OSX中的macos Java编译问题   java有人能解释这个链表空指针异常吗?   javahive:如何计算时差   斐波那契练习中的java堆错误   java中带密钥的Caesar密码   java在一个jsp文件中创建多个表单。必须始终设置模型属性吗?   自定义注释中的Java int数组   java如何输出对象   java有没有办法在安卓应用程序代码中加载txt文件而不将其写入安卓设备?   JAVAutil。NoTouchElementException错误,扫描。下一个问题   java SpringBoot:REST endpint中@RequestParam参数的自定义验证   无getter/setter/toString/constructor的清晰代码的java Lombok替代方案   java xjc如何确定用于生成类的包?   eclipse如何获取当前选定安装的JRE的位置?   java为什么函数“display()”会自动放置在构造函数中   我在安卓应用程序上发送的图像的java黑色背景   java在异常处理结束并正确执行后,开关代码将在一个永无止境的循环中执行。   java图像处理程序中的多线程