Regular Expressions, Text Normalization, and Edit Distance Note (SLP Ch02)

Normalizing text means converting it to a more convenient, standard form.

  • tokenization: separating out or tokenizing words from running text
  • lemmatization: words have the same root but different surface. Stemming refers to a simpler version of lemmatization in which just strip suffixes from the end of the word.
  • sentence segmentation

More

DataBase Foreign Data Wrapper

有时候我们需要将多个数据源的 DataBase 放在一个地方,最 Naive 的方法就是把其他 DataBase 的数据备份出来,再全部导入到一个 DataBase,但是这样比较麻烦,而且当数据库很大时也会比较耗时。这时候使用 FDW 就非常方便了。FDW 全称 Foreign Data Wrapper,这里有一些基本的介绍:Foreign data wrappers - PostgreSQL wiki,FDW 非常简单且效果不错,下面逐步介绍(基于 postgres)基本操作和注意事项。

More

Python 小白快速从入门到放弃:在开始前

说明:本教程只适用于之前没接触过编程然后又想学点编程知识的同学,他们的目的主要有两个:第一,解决日常工作中的一些重复劳动或者自己做一个好玩儿的小项目;第二,尝试一种新的思维或 ”面对世界“ 的方式。本教程将围绕这两个目的展开。

More

Information Extraction Note (SLP Ch18)

Recently, I wanted to build an information extraction system, so I searched for Google. However there were little Chinese articles, the quality was not so good as well. Fortunately, I found several English ones seemed well, and then the summary is here. The whole structure is based on my favorite NLP book Speech and Language Processing (use SLP instead below), also with some other materials in the reference.

Information extraction (IE), turns the unstructured information extraction information embedded in texts into structured data, for example for populating a relational database to enable further processing. Here is a figure of: Simple Pipeline Architecture for an Information Extraction System.

From: https://www.nltk.org/book/ch07.html

By the way, this book provides actionable steps, focusing on specific actions.

architecture

More

自然语言计算机形式分析的理论与方法笔记(Ch17)

第十七章:自然语言处理系统评测

测评的一般原则和方法

两种不同的测评方法:

  • 黑箱评测(外在评测):不关心 NLP 系统内部机制和组成结构,主要根据输入输出结果判断,有助于了解外在的总体性能。
  • 白箱评测(内在评测):对 NLP 内部机制分别分析,测评各组成部分性能,有助于了解内部组成部分的性能。

主要采用黑箱评测,“宽进严出”。

More

自然语言计算机形式分析的理论与方法笔记(Ch14)

第十四章:隐 Markov 模型

HMM 概述

Markov 链也就是加权自动机。HMM 增加了要求:

  • HMM 有一个观察符号的集合 O,这个集合中的符号不是从状态集合 Q 中的字母抽取的
  • HMM 中观察似然度函数 B 的值不只限于 1 或 0,概率 bi(ot) 可以取 0-1 之间的任何值

HMM 要求的参数如下:

  • 状态序列:Q = (q1, q2, …, qn)
  • 观察序列:O = (o1, o2, …, on)
  • 转换概率:A = (a01, a02, …, ann)
  • 观察似然度:B = bi(ot),表示从状态 i 生成观察值 ot 的概率
  • 初始状态概率分布:π,πi 是 HMM 在状态 i 开始时的概率
  • 接收状态:合法的接收状态集合

需要求解的是 A B π,因此一般使用 λ = {A, B, π} 来定义一个 HMM 模型,模型对外表现出来的是观察序列,状态序列不能直接观察到,被称为 “隐变量”。

三个基本问题:

  • 评估问题:给定观察序列 O 和模型 λ,如何计算由该模型产生该观察序列的概率 P(O|λ)
  • 解码问题:给定观察序列 O 和模型 λ,如何获取在某种意义下最优的状态序列 Q,一般使用 Viterbi 算法
  • 训练问题:如何选择或调整模型参数 λ,使得在该模型下产生观察序列 O 的概率 P(O|λ) 最大

More