# Natural Language Processing (NLP) (10%)

* [Development Life Cycle](#development-life-cycle) (開發生命周期)
* [Chinese text segmentation](#chinese-text-segmentation) (分詞)
* [Part-of-speech tagging (詞性標示)](#partofspeech-tagging-xing-shi)
* Named Entity Recognition (NER) (實體識別)
* Parsing (句法分析)
* Text-proofing (文字校對)
* [Text Classification (文本分類)](#text-classification-wen-ben-fen)
* Information retrieval (信息檢索)
* [Information extraction (信息抽取)](#information-extraction-xin-xi-chou-qu)
* Text summarization (文本摘要)
* [Question answering (問答系統)](#question-answering-da-xi)
* Natural language generation (自然語言生成)
* [Sentiment analysis (情感分析)](#sentiment-analysis-qing-gan-fen-xi)
* [Speech recognition (語音識別)](#speech-recognition-yin)
* [Text to speech (文本朗讀)](#text-to-speech-wen-ben-lang)
* Speech synthesis (語音合成)
* [Paper (論文)](#paper-wen)
*

## Development Life Cycle

| NLP 開發生命周期                                   |
| -------------------------------------------- |
| 理解問題                                         |
| 收集數據/語料                                      |
| 數據/語料分折                                      |
| Data pre-processing (數據預處理)                  |
| 特徵工程                                         |
| 決定使用的計算技術 (Rules base, machine learning ...) |
| 應用計算技術                                       |
| 測試和評估系統結果                                    |
| 優化調整參數                                       |
| 持續此過程直到得到滿意的結果                               |

## &#x20;Chinese Text Segmentation

### [jieba (結巴分詞)](https://asiabots.gitbook.io/learning/chinese-text-segmentation#jieba-ba)

## &#x20;Part-of-speech tagging (詞性標示)

## &#x20;Named Entity Recognition (NER) (實體識別)

### Reference

{% embed url="<http://zhuanlan.51cto.com/art/201705/540693.htm>" %}

#### 於 Conda run Stanford Corenlp&#x20;

{% embed url="<https://medium.com/@rnnnnn/%E4%BD%BF%E7%94%A8-stanford-corenlp-%E4%B8%AD%E6%96%87-py-1c234036875b>?" %}

## &#x20;Text Classification (文本分類)

### Sentence Similarity (句子相似度計算)

### REF

{% embed url="<https://juejin.im/post/5b237b45f265da59a90c11d6>" %}

<https://github.com/AIPractice/SentenceDistance>

#### Numpy Array Similarity

{% embed url="<https://blog.csdn.net/u012162613/article/details/42213883>" %}

{% code title="Code" %}

```python
#相似度计算,inA、inB都是行向量

import numpy as np
from numpy import linalg as la
 
#欧式距离
def euclidSimilar(inA,inB):
    return 1.0/(1.0+la.norm(inA-inB))
#皮尔逊相关系数
def pearsonSimilar(inA,inB):
    if len(inA)<3:
        return 1.0
    return 0.5+0.5*np.corrcoef(inA,inB,rowvar=0)[0][1]
#余弦相似度
def cosSimilar(inA,inB):
    inA=np.mat(inA)
    inB=np.mat(inB)
    num=float(inA*inB.T)
    denom=la.norm(inA)*la.norm(inB)
    return 0.5+0.5*(num/denom)
```

{% endcode %}

{% code title="Test" %}

```python
>>> inA=array([1,2,3])
>>> inB=array([2,4,6])
>>> euclidSimilar(inA,inB)
0.21089672205953397
>>> pearsonSimilar(inA,inB)
1.0
>>> cosSimilar(inA,inB)
1.0
```

{% endcode %}

#### <https://www.zhihu.com/question/29978268/answer/54399062>

作者：严昕\
链接：<https://www.zhihu.com/question/29978268/answer/456219359\\>
来源：知乎\
著作权归作者所有。商业转载请联系作者获得授权，非商业转载请注明出处。

从大类上分，计算句子相似度的方法可以分为两类：

1）无监督的方法，即不使用额外的标注数据，常用的方法有：

（1）对句子中所有词的word vector求平均，获得sentence embedding

（2）以每个词的tf-idf为权重，对所有词的word vector加权平均，获得sentence embedding

（3）以smooth inverse frequency\[1]（简称SIF)为权重，对所有词的word vector加权平均，最后从中减掉principal component，得到sentence embedding

（4）通过Word Mover’s Distance\[2]（简称WMD），直接度量句子之间的相似度

2）有监督的方法，需要额外的标注数据，常见的有监督任务有：

（1）分类任务，例如训练一个CNN的文本分类器\[3]，取最后一个hidden layer的输出作为sentence embedding，其实就是取分类器的前几层作为预训练的encoder

（2）sentence pair的等价性/等义性判定（\[4]\[5]），这种方法的好处是不仅可以得到sentence embedding，还可以直接学习到距离度量函数里的参数

#### SentenceDistance Example

<https://hk.saowen.com/a/b9c735db0ccf1984d71b9d381dca1de29a108c901272c4b9a38eaac0b4399a6b>

<https://github.com/AIPractice/SentenceDistance>

## &#x20;Information extraction (信息抽取)

## &#x20;Question answering (問答系統)

## Sentiment analysis (情感分析)

{% embed url="<https://gitlab.com/asiabots/wilson/sentiment-analysis>" %}

## &#x20;Speech recognition (語音識別)

## &#x20;Text to speech (文本朗讀)

## Reference

REF:

Sentiment Classification from Keras to the Browser

<https://medium.com/@alyafey22/sentiment-classification-from-keras-to-the-browser-7eda0d87cdc6>

## Parsing

![](https://2243942035-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-L9le-f14keouD-KFRhu%2F-LBcfHshVvQB9-Nw7lxu%2F-LBcfvLhaTxJcLZkcxEn%2Fimage.png?alt=media\&token=4ae77578-bb5c-43d9-8290-cc42f82eade5)

## Paper (論文)

### AAAI2019 | 騰訊AI Lab詳解自然語言處理領域三大研究方向及入選論文

{% embed url="<http://bangqu.com/L131bS.html?utm_source=dable>" %}
