Joke Collection Website - Public benefit messages - Segmentation extraction of short messages

Segmentation extraction of short messages

#-*-encoding: utf-8 -*-

Imported street fighter

Import jieba.posseg as pseg.

Import jieba.analyse

# jieba.load _ userdict ('userdict. txt') # jieba has a dict.txt thesaurus by default, but you can add your own entries according to your own needs.

Str 1 = "The common method to train networks that can be classified in n dimensions is to use polynomial logistic regression. “

Str2 = "You can try to modify the network architecture to accurately replicate the fully connected model."

Str3 = "The objective function of the model is to find the sum of cross entropy loss and all weight attenuation terms, and the return value of the loss () function is this value."

Seg _ list = jieba. cut(str 1, cut _ all = true)# full mode.

Print ("/". join(seg _ list))

result = pseg . cut(str 1)

Result 2 = jieba. cut(str 2)# exact mode

Result 3 = jieba.analyze.extract _ tags (str 3,4) # keyword extraction

Result4 = jieba.cut _ for _ search (str 3) # search engine mode

For w in the result:

Print (w.word, w.flag)

Print ("". Join (result 2))

Print ("". Join (result 3))

Print ("". Join (result 4))