<kbd id="afajh"><form id="afajh"></form></kbd>
<strong id="afajh"><dl id="afajh"></dl></strong>
    <del id="afajh"><form id="afajh"></form></del>
        1. <th id="afajh"><progress id="afajh"></progress></th>
          <b id="afajh"><abbr id="afajh"></abbr></b>
          <th id="afajh"><progress id="afajh"></progress></th>

          【NLP】競賽必備的NLP庫

          共 4683字,需瀏覽 10分鐘

           ·

          2020-09-29 04:23

          NLP必備的庫

          本周我們給大家整理了機(jī)器學(xué)習(xí)和競賽相關(guān)的NLP庫,方便大家進(jìn)行使用,建議收藏本文。


          jieba


          jieba是Python中的優(yōu)秀的中文分詞第三方庫,通過幾行代碼就可以完成中文句子的分詞。jieba的分詞精度和性能非常優(yōu)異,經(jīng)常用來進(jìn)行中文分詞的實(shí)驗(yàn)對比。此外jieba還可以很方便的自定義詞典,使用起來非常靈活。
          import jieba
          seg_list = jieba.cut("我來到北京清華大學(xué)", cut_all=True)print("Full Mode: " + "/ ".join(seg_list)) # 全模式# 【全模式】: 我/ 來到/ 北京/ 清華/ 清華大學(xué)/ 華大/ 大學(xué)seg_list = jieba.cut("我來到北京清華大學(xué)", cut_all=False)print("Default Mode: " + "/ ".join(seg_list)) # 精確模式# 【精確模式】: 我/ 來到/ 北京/ 清華大學(xué)
          seg_list = jieba.cut("他來到了網(wǎng)易杭研大廈") # 默認(rèn)是精確模式print(", ".join(seg_list))# 【新詞識別】:他, 來到, 了, 網(wǎng)易, 杭研, 大廈
          jieba項(xiàng)目主頁:https://github.com/fxsjy/jieba
          此外jieba分詞還有CPP版本,如果覺得性能不夠,可以嘗試CPP版本。


          spaCy

          spaCy是功能強(qiáng)化的NLP庫,可與深度學(xué)習(xí)框架一起運(yùn)行。spaCy提供了大多數(shù)NLP任務(wù)的標(biāo)準(zhǔn)功能(標(biāo)記化,PoS標(biāo)記,解析,命名實(shí)體識別)。spaCy與現(xiàn)有的深度學(xué)習(xí)框架接口可以一起使用,并預(yù)裝了常見的語言模型。

          import spacy
          # Load English tokenizer, tagger, parser, NER and word vectorsnlp = spacy.load("en_core_web_sm")
          # Process whole documentstext = ("When Sebastian Thrun started working on self-driving cars at " "Google in 2007, few people outside of the company took him " "seriously. “I can tell you very senior CEOs of major American " "car companies would shake my hand and turn away because I wasn’t " "worth talking to,” said Thrun, in an interview with Recode earlier " "this week.")doc = nlp(text)
          # Analyze syntaxprint("Noun phrases:", [chunk.text for chunk in doc.noun_chunks])print("Verbs:", [token.lemma_ for token in doc if token.pos_ == "VERB"])
          # Find named entities, phrases and conceptsfor entity in doc.ents: print(entity.text, entity.label_)

          spaCy項(xiàng)目主頁:https://spacy.io/


          Gensim

          是一個高效的自然語言處理Python庫,主要用于抽取文檔的語義主題(semantic topics)。Gensim的輸入是原始的、無結(jié)構(gòu)的數(shù)字文本(純文本),內(nèi)置的算法包括Word2Vec,F(xiàn)astText和LSA。
          from gensim.test.utils import common_texts, get_tmpfilefrom gensim.models import Word2Vec
          path = get_tmpfile("word2vec.model")model = Word2Vec(common_texts, size=100, window=5, min_count=1, workers=4)model.save("word2vec.model")
          Gensim項(xiàng)目官網(wǎng):https://radimrehurek.com/gensim/


          NLTK



          NLTK是一個免費(fèi)的,開源的,社區(qū)驅(qū)動的項(xiàng)目,提供了50多種語料庫和詞匯資源(如WordNet),還提供了一套用于分類,標(biāo)記化,詞干化,標(biāo)記,解析和語義推理的文本處理庫。
          import nltk>>> sentence = """At eight o'clock on Thursday morning... Arthur didn't feel very good.""">>> tokens = nltk.word_tokenize(sentence)>>> tokens['At', 'eight', "o'clock", 'on', 'Thursday', 'morning','Arthur', 'did', "n't", 'feel', 'very', 'good', '.']>>> tagged = nltk.pos_tag(tokens)>>> tagged[0:6][('At', 'IN'), ('eight', 'CD'), ("o'clock", 'JJ'), ('on', 'IN'),('Thursday', 'NNP'), ('morning', 'NN')]
          NLTK官網(wǎng):http://www.nltk.org/


          TextBlob

          TextBlob是一個用python編寫的開源的文本處理庫,它可以用來執(zhí)行很多自然語言處理的任務(wù),比如,詞性標(biāo)注、名詞性成分提取、情感分析、文本翻譯等。
          from textblob import TextBlob
          text = '''The titular threat of The Blob has always struck me as the ultimate moviemonster: an insatiably hungry, amoeba-like mass able to penetratevirtually any safeguard, capable of--as a doomed doctor chillinglydescribes it--"assimilating flesh on contact.Snide comparisons to gelatin be damned, it's a concept with the mostdevastating of potential consequences, not unlike the grey goo scenarioproposed by technological theorists fearful ofartificial intelligence run rampant.'''
          blob = TextBlob(text)blob.tags # [('The', 'DT'), ('titular', 'JJ'), # ('threat', 'NN'), ('of', 'IN'), ...]
          blob.noun_phrases # WordList(['titular threat', 'blob', # 'ultimate movie monster', # 'amoeba-like mass', ...])
          for sentence in blob.sentences: print(sentence.sentiment.polarity)# 0.060# -0.341

          TextBlob官網(wǎng):https://textblob.readthedocs.io/en/dev/


          CoreNLP

          Stanford CoreNLP是用處理自然語言的工具集合。它可以給出詞語的基本形式:詞性(它們是公司名、人名等,規(guī)范化日期,時間,和數(shù)字),根據(jù)短語和語法依賴來標(biāo)記句子的結(jié)構(gòu),發(fā)現(xiàn)實(shí)體之間的關(guān)系、情感以及人們所說的話等。
          CoreNLP提供了Java版本的服務(wù)器部署,也有python版本的調(diào)用,用途非常廣泛。在工業(yè)界和學(xué)術(shù)界都有廣泛的應(yīng)用。
          CoreNLP官網(wǎng):https://stanfordnlp.github.io/CoreNLP/

          AllenNLP

          AllenNLP 是由世界著名的艾倫人工智能實(shí)驗(yàn)室(Allen Institute for AI Lab)建立的 NLP 深度學(xué)習(xí)通用框架,不僅包含了最先進(jìn)的參考模型,可以進(jìn)行快速部署,而且支持多種任務(wù)和數(shù)據(jù)集。

          AllenNLP官網(wǎng):https://allennlp.org/

          TorchText

          TorchText是Pytorch下對NLP的支持庫,包含便利的數(shù)據(jù)處理實(shí)用程序,可在批量處理和準(zhǔn)備之前將其輸入到深度學(xué)習(xí)框架中。TorchText可以很方便加載訓(xùn)練數(shù)據(jù)、驗(yàn)證和測試數(shù)據(jù)集,來進(jìn)行標(biāo)記化、vocab構(gòu)造和創(chuàng)建迭代器,并構(gòu)建迭代器。

          TorchText官網(wǎng):https://github.com/pytorch/text

          Transformers

          Transformers是現(xiàn)如今最流行的庫,它實(shí)現(xiàn)了從 BERT 和 GPT-2 到 BART 和 Reformer 的各種轉(zhuǎn)換。huggingface 的代碼可讀性強(qiáng)和文檔也是清晰易讀。在官方github的存儲庫中,甚至通過不同的任務(wù)來組織 python 腳本,例如語言建模、文本生成、問題回答、多項(xiàng)選擇等。

          huggingface官網(wǎng):https://huggingface.co/


          OpenNMT

          OpenNMT 是用于機(jī)器翻譯和序列學(xué)習(xí)任務(wù)的便捷而強(qiáng)大的工具。其包含的高度可配置的模型和培訓(xùn)過程,讓它成為了一個非常簡單的框架。因其開源且簡單的特性,建議大家使用 OpenNMT 進(jìn)行各種類型的序列學(xué)習(xí)任務(wù)。

          OpenNMT官網(wǎng):https://opennmt.net/





          往期精彩回顧





          獲取一折本站知識星球優(yōu)惠券,復(fù)制鏈接直接打開:

          https://t.zsxq.com/662nyZF

          本站qq群704220115。

          加入微信群請掃碼進(jìn)群(如果是博士或者準(zhǔn)備讀博士請說明):

          瀏覽 78
          點(diǎn)贊
          評論
          收藏
          分享

          手機(jī)掃一掃分享

          分享
          舉報
          評論
          圖片
          表情
          推薦
          點(diǎn)贊
          評論
          收藏
          分享

          手機(jī)掃一掃分享

          分享
          舉報
          <kbd id="afajh"><form id="afajh"></form></kbd>
          <strong id="afajh"><dl id="afajh"></dl></strong>
            <del id="afajh"><form id="afajh"></form></del>
                1. <th id="afajh"><progress id="afajh"></progress></th>
                  <b id="afajh"><abbr id="afajh"></abbr></b>
                  <th id="afajh"><progress id="afajh"></progress></th>
                  婷婷五月综合在线 | 自慰精品| 亚洲精品操逼 | 91精品国产综合久久福利 | 任我操视频在线 |