{"id":194591,"date":"2020-10-31T11:13:27","date_gmt":"2020-10-31T03:13:27","guid":{"rendered":"http:\/\/4563.org\/?p=194591"},"modified":"2020-10-31T11:13:27","modified_gmt":"2020-10-31T03:13:27","slug":"%e3%80%8c%e8%8b%b1%e6%96%87%e8%af%8d%e7%bb%84%e3%80%8d%e5%88%86%e8%af%8d%e9%97%ae%e9%a2%98","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=194591","title":{"rendered":"\u300c\u82f1\u6587\u8bcd\u7ec4\u300d\u5206\u8bcd\u95ee\u9898"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  \u300c\u82f1\u6587\u8bcd\u7ec4\u300d\u5206\u8bcd\u95ee\u9898               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : BarryLu <\/span>  <span><i><\/i> 5<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<p>\u4e4b\u524d\u5df2\u7ecf\u6709\u4e00\u4e2a\u63d0\u95ee\u4e86\uff1a https:\/\/www.v2ex.com\/t\/340752#reply13<\/p>\n<p>\u5173\u4e8e\u8fd9\u4e2a\u95ee\u9898\u641c\u7d22\u4e86\u633a\u4e45\u8fd8\u4e0d\u662f\u5f88\u660e\u767d\uff0c\u4e8e\u662f\u5f00\u4e86\u8fd9\u4e2a\u5e16\u5b50\u3002<\/p>\n<p>\u6211\u60f3\u505a\u82f1\u6587\u8bcd\u7ec4\u5206\u8bcd\uff08\u53ef\u80fd\u4e0d\u8fd9\u4e48\u53eb\uff09\uff0c\u6bd4\u5982 I love New York\uff0c\u6211\u5e0c\u671b\u5206\u8bcd\u51fa\u6765\u7684\u662f I \/ love \/ New York\uff0c\u800c\u4e0d\u662f\uff1aI \/ love \/ New \/ York \u3002New York \u5206\u5f00\u539f\u672c\u7684\u610f\u601d\u5c31\u53d8\u4e86\u3002<\/p>\n<p>\u4e2d\u6587\u5206\u8bcd\u6709\u975e\u5e38\u591a\u7684\u5de5\u5177\uff0c\u6bd4\u5982\u7ed3\u5df4\uff08 https:\/\/github.com\/fxsjy\/jieba \uff09\uff0c\u4f46\u662f\u627e\u82f1\u6587\u8bcd\u7ec4\u5206\u8bcd\u5de5\u5177\u5c31\u975e\u5e38\u96be\uff08\u6211\u751a\u81f3\u4e0d\u77e5\u9053\u7528\u4ec0\u4e48\u5355\u8bcd\u53bb\u641c\u7d22\uff0c\u6bd4\u5982\u662f Tokenizer \u3001Chunking \u3001\u8fd8\u662f text segmentation \uff09\uff0c\u8bf7\u95ee\u82f1\u6587\u6709\u6ca1\u6709\u6bd4\u8f83\u65b9\u4fbf\u53ef\u4ee5\u76f4\u63a5\u5206\u8bcd\u7684\u5de5\u5177\u3002<\/p>\n<p>\u6bd4\u5982\u65af\u5766\u798f\u7684 stanza \uff08 https:\/\/github.com\/stanfordnlp\/stanza \uff09 \u53ef\u4ee5\u7528\u4e8e\u5206\u8bcd\u3002\u4e2d\u6587\u5206\u8bcd\u7ed3\u679c\u6ca1\u95ee\u9898\uff0c\u4f46\u662f\u82f1\u6587\u53ea\u662f\u6309\u7167\u7a7a\u683c\u505a\u5206\u8bcd\u3002<\/p>\n<pre><code>text = \"\"\"\u82f1\u56fd\u9996\u76f8\u7ea6\u7ff0\u900a 6 \u65e5\u665a\u56e0\u75c5\u60c5\u6076\u5316\u3002\"\"\"  zh_nlp = stanza.Pipeline('zh') doc = zh_nlp(text)  for sent in doc.sentences:   print(\"Sentence\uff1a\" + sent.text) # \u65ad\u53e5   print(\"Tokenize\uff1a\" + ' '.join(token.text for token in sent.tokens)) # \u4e2d\u6587\u5206\u8bcd <\/code><\/pre>\n<p>\u5b83\u7684\u8f93\u51fa\u7ed3\u679c\u662f\u5206\u8bcd\u540e\u7684\u7ed3\u679c\uff0c\u8fd9\u6ca1\u95ee\u9898\uff1a<\/p>\n<pre><code>Tokenize\uff1a\u82f1\u56fd \u9996\u76f8 \u7ea6\u7ff0\u900a 6 \u65e5 \u665a\u56e0 \u75c5\u60c5 \u6076\u5316 \uff0c \u88ab \u8f6c\u5165 \u91cd\u75c7 \u76d1\u62a4 \u5ba4 \u6cbb\u7597 \u3002 <\/code><\/pre>\n<p>\u4f46\u662f\u82f1\u6587\u5206\u8bcd\uff1a<\/p>\n<pre><code>import stanza  nlp = stanza.Pipeline(lang='en', processors='tokenize', tokenize_no_ssplit=True) doc = nlp('This is a sentence.nnThis is a second. This is a third.') for i, sentence in enumerate(doc.sentences):     print(f'====== Sentence {i+1} tokens =======')     print(*[f'id: {token.id}ttext: {token.text}' for token in sentence.tokens], sep='n') <\/code><\/pre>\n<p>\u8f93\u51fa\u7ed3\u679c\u4e3a\uff1a<\/p>\n<pre><code>====== Sentence 1 tokens ======= id: (1,) text: This id: (2,) text: is id: (3,) text: a id: (4,) text: sentence id: (5,) text: . ====== Sentence 2 tokens ======= id: (1,) text: This id: (2,) text: is id: (3,) text: a id: (4,) text: second id: (5,) text: . id: (6,) text: This id: (7,) text: is id: (8,) text: a id: (9,) text: third id: (10,) text: . <\/code><\/pre>\n<\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>9<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"4216375\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : heiheidewo <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u81ea\u5df1\u5199\u4e00\u4e2a\u5427\uff0c\u4e00\u822c\u5206\u8bcd\u662f\u6309\u53cc\u5411\u6700\u957f\u5339\u914d\u6765\u7684\uff0c\u4f60\u628a New York \u5f53\u505a\u4e00\u4e2a\u8bcd\u5904\u7406\u5373\u53ef                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4216376\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : TimePPT <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u6ca1\u660e\u767d\uff0c\u4f60\u4e3e\u7684 stanza \u7528 en pipeline \u5206\u51fa\u6765\u54ea\u91cc\u4e0d\u5bf9\u5417\uff1f                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4216377\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : chizuo <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u53ef\u4ee5\u8bd5\u8bd5 nltk\/spacy \u8fd9\u7c7b\u5e93\uff0c\u4e00\u822c\u4ee5 word-level \u4e3a\u7ea7\u522b\u7684\u5206\u8bcd\uff0c\u5f88\u96be\u907f\u514d\u4f60\u8bf4\u7684\u8fd9\u4e2a\u95ee\u9898\u3002\u4f60\u53ef\u4ee5\u8bd5\u8bd5 sub-word level \u4ee5\u53ca\u7ed3\u5408 named entity \u3001pos_tag \u8fd9\u7c7b\u5224\u65ad<\/p>\n<p>\u4ee5 nlp tokenizer segmenter \u4e3a\u5173\u952e\u8bcd\u770b\u770b\u76f8\u5173\u8bba\u6587                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4216378\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : BarryLu <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @TimePPT \u60f3\u8bf4\u7684\u662f\uff0cStanza \u7684\u82f1\u6587\u5206\u8bcd\u53ea\u662f\u6309\u7167\u7a7a\u683c\u5206\u5f00\u7684\uff0c\u4f46\u662f\u4e2d\u6587\u662f \u201c\u771f\u6b63\u5206\u8bcd\u201d\u3002\u53e6\u5916\u6bd4\u5982 Tensorflow Keras \u7684\u82f1\u6587\u5206\u8bcd\uff08 Tokenizer \uff09\u4e5f\u53ea\u662f\u6309\u7167\u7a7a\u683c\u5206\u5f00\uff0c\u73b0\u6210\u7684\uff0c\u505a\u5230\u7c7b\u4f3c\u4e8e\u4e2d\u6587\u5206\u8bcd\u7684\u300c\u82f1\u6587\u5206\u8bcd\u300d\u5de5\u5177\uff0c\u6ca1\u627e\u5230\u3002\u3002\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4216379\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : BarryLu <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @heiheidewo \u81ea\u5df1\u5199                                                             <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4216380\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : TimePPT <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @BarryLu \u5f88\u96be\u505a\uff0cLS \u4e5f\u63d0\u5230\u4e86\uff0c\u901a\u8fc7 NER \u4e4b\u7c7b\u7684\u53ef\u4ee5\u505a\u5230\u4e00\u90e8\u5206\uff0c\u6216\u8005\u76f4\u63a5\u62ff\u8bcd\u5178\u5339\u914d\u3002\u4f46\u6ca1\u6cd5\u5b8c\u5168\u907f\u514d\u3002<br \/>\u53e6\u5916\uff0c\u5176\u5b9e\u4e2d\u6587\u5206\u8bcd\u9897\u7c92\u5ea6\u95ee\u9898\u66f4\u96be\uff0c\u6839\u636e\u4e1a\u52a1\u9700\u8981\u8981\u5fae\u8c03\u7684\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4216381\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : mxalbert1996 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u82f1\u6587\u91cc\u8fd9\u79cd\u60c5\u51b5\u672c\u6765\u5c31\u5f88\u5c11\uff0c\u5176\u4e2d\u5f88\u5927\u4e00\u90e8\u5206\u90fd\u662f\u4e13\u6709\u540d\u8bcd\uff0c\u5176\u5b9e\u6ca1\u592a\u5927\u5f71\u54cd\uff0c\u800c\u4e14\u73b0\u5728 NLP \u90fd\u662f RNN\uff0c\u80fd\u8bc6\u522b\u524d\u540e\u5173\u7cfb\uff0c\u5c31\u66f4\u65e0\u6240\u8c13\u4e86\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4216382\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : jhdxr <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u5176\u5b9e\u4f60\u8981\u7684\u5e76\u4e0d\u662f\u5206\u8bcd\uff0c\u6bd4\u5982 I want to have a cup of green apple juice.<br \/>\u5728\u4f60\u5b9a\u4e49\u7684\u300e\u5206\u8bcd\u300f\u4e2d\uff0cgreen apple juice \u662f\u4e00\u4e2a\u300e\u8bcd\u300f\u8fd8\u662f\u591a\u4e2a\u8bcd\uff1f<\/p>\n<p>\u5982\u679c\u4f60\u8ba4\u4e3a\u90a3\u662f\u4e00\u4e2a\u8bcd\uff0c\u90a3\u4f60\u53ef\u4ee5\u8003\u8651 syntax parsing<br \/>\u5982\u679c\u4f60\u8ba4\u4e3a\u90a3\u662f\u591a\u4e2a\u8bcd\uff0c\u90a3\u6211\u731c\u4f60\u60f3\u8981\u7684\u5176\u5b9e\u662f\u8bc6\u522b\u4e13\u6709\u540d\u8bcd\uff08\u8bf7\u5c1d\u8bd5\u5206\u8bcd\u4e2d\u6587\uff1a\u300e\u5357\u4eac\u5e02\u957f\u6c5f\u5927\u6865\u300f\uff09\uff0c\u53ef\u4ee5\u8003\u8651 NER\/NEM                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4216383\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : Merlini <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u8fd9\u79cd\u4e00\u822c\u662f\u9700\u8981\u77e5\u8bc6\u56fe\u8c31\u8f85\u52a9\u7684\uff0c\u6216\u8005\u5c31\u76f4\u63a5\u7528\u8bad\u7ec3\u597d\u7684 NER \u3002\u6bd4\u5982 Spacy \u7684 NER:<br \/>&#8220;`python<br \/>import spacy<\/p>\n<p>nlp = spacy.load(&#8220;en_core_web_sm&#8221;)<br \/>doc = nlp(&#8220;Apple is looking at buying U.K. startup for $1 billion&#8221;)<\/p>\n<p>for ent in doc.ents:<br \/> print(ent.text, ent.start_char, ent.end_char, ent.label_)<br \/>&#8220;`<\/p>\n<p>https:\/\/spacy.io\/usage\/linguistic-features#named-entities-101 <img decoding=\"async\" src=\"http:\/\/4563.org\/wp-content\/uploads\/2020\/11\/20201120_5fb7eca5a0bee.png\" rel=\"noreferrer\" alt=\"\u300c\u82f1\u6587\u8bcd\u7ec4\u300d\u5206\u8bcd\u95ee\u9898\"> <\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>\u300c\u82f1\u6587\u8bcd\u7ec4\u300d\u5206\u8bcd\u95ee\u9898 \u8cc7\u6df1\u5927\u4f6c :&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/194591"}],"collection":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=194591"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/194591\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=194591"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=194591"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=194591"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}