{"id":1137493,"date":"2025-01-08T21:49:20","date_gmt":"2025-01-08T13:49:20","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1137493.html"},"modified":"2025-01-08T21:49:23","modified_gmt":"2025-01-08T13:49:23","slug":"python-%e5%a6%82%e4%bd%95%e4%bb%8e%e4%b8%80%e6%ae%b5%e4%b8%ad%e6%96%87%e4%b8%ad%e6%8f%90%e5%8f%96%e5%a7%93%e5%90%8d","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/1137493.html","title":{"rendered":"python \u5982\u4f55\u4ece\u4e00\u6bb5\u4e2d\u6587\u4e2d\u63d0\u53d6\u59d3\u540d"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25101315\/818083eb-f734-4181-bffb-e328f75e82fd.webp\" alt=\"python \u5982\u4f55\u4ece\u4e00\u6bb5\u4e2d\u6587\u4e2d\u63d0\u53d6\u59d3\u540d\" \/><\/p>\n<p><p> <strong>\u4ece\u4e00\u6bb5\u4e2d\u6587\u4e2d\u63d0\u53d6\u59d3\u540d\u7684\u65b9\u6cd5\u4e3b\u8981\u6709\uff1a\u81ea\u7136\u8bed\u8a00\u5904\u7406\uff08NLP\uff09\u6280\u672f\u3001\u547d\u540d\u5b9e\u4f53\u8bc6\u522b\uff08NER\uff09\u3001\u57fa\u4e8e\u89c4\u5219\u7684\u5339\u914d\u3001<a href=\"https:\/\/docs.pingcode.com\/ask\/59192.html\" target=\"_blank\">\u673a\u5668\u5b66\u4e60<\/a>\u6a21\u578b\u3002<\/strong>\u5176\u4e2d\uff0c\u547d\u540d\u5b9e\u4f53\u8bc6\u522b\uff08NER\uff09\u662f\u6700\u5e38\u7528\u7684\u65b9\u6cd5\u3002NER\u6280\u672f\u901a\u8fc7\u8bad\u7ec3\u6570\u636e\u96c6\uff0c\u53ef\u4ee5\u8bc6\u522b\u548c\u6807\u8bb0\u6587\u672c\u4e2d\u7684\u5b9e\u4f53\uff0c\u5982\u4eba\u540d\u3001\u5730\u540d\u3001\u7ec4\u7ec7\u540d\u7b49\u3002\u8fd9\u9879\u6280\u672f\u5728\u5904\u7406\u4e2d\u6587\u6587\u672c\u65f6\u5c24\u4e3a\u6709\u6548\uff0c\u56e0\u4e3a\u4e2d\u6587\u6587\u672c\u4e2d\u7684\u4eba\u540d\u5177\u6709\u4e30\u5bcc\u7684\u8bed\u4e49\u7279\u5f81\u3002\u4ee5\u4e0b\u6211\u4eec\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528Python\u4ece\u4e00\u6bb5\u4e2d\u6587\u4e2d\u63d0\u53d6\u59d3\u540d\u3002<\/p>\n<\/p>\n<p><h2>\u4e00\u3001\u81ea\u7136\u8bed\u8a00\u5904\u7406\uff08NLP\uff09\u6280\u672f<\/h2>\n<\/p>\n<p><p>\u81ea\u7136\u8bed\u8a00\u5904\u7406\uff08NLP\uff09\u662f<a href=\"https:\/\/docs.pingcode.com\/tag\/AI\" target=\"_blank\">\u4eba\u5de5\u667a\u80fd<\/a>\u7684\u4e00\u4e2a\u5206\u652f\uff0c\u4e3b\u8981\u6d89\u53ca\u4e0e\u8ba1\u7b97\u673a\u548c\u4eba\u7c7b\uff08\u81ea\u7136\uff09\u8bed\u8a00\u4e4b\u95f4\u7684\u4e92\u52a8\u3002NLP\u6280\u672f\u53ef\u4ee5\u5e2e\u52a9\u6211\u4eec\u7406\u89e3\u3001\u89e3\u91ca\u548c\u751f\u6210\u4eba\u7c7b\u8bed\u8a00\u3002\u5bf9\u4e8e\u4e2d\u6587\u59d3\u540d\u7684\u63d0\u53d6\uff0cNLP\u6280\u672f\u63d0\u4f9b\u4e86\u5f3a\u5927\u7684\u5de5\u5177\u548c\u5e93\uff0c\u5982jieba\u3001StanfordNLP\u548cSpacy\u7b49\u3002<\/p>\n<\/p>\n<p><h3>1. \u4f7f\u7528jieba\u8fdb\u884c\u5206\u8bcd\u548c\u63d0\u53d6<\/h3>\n<\/p>\n<p><p>jieba\u662f\u4e00\u4e2a\u975e\u5e38\u6d41\u884c\u7684\u4e2d\u6587\u5206\u8bcd\u5e93\uff0c\u5b83\u652f\u6301\u4e09\u79cd\u5206\u8bcd\u6a21\u5f0f\uff1a\u7cbe\u786e\u6a21\u5f0f\u3001\u5168\u6a21\u5f0f\u548c\u641c\u7d22\u5f15\u64ce\u6a21\u5f0f\u3002\u901a\u8fc7\u6dfb\u52a0\u81ea\u5b9a\u4e49\u8bcd\u5178\uff0c\u6211\u4eec\u53ef\u4ee5\u63d0\u9ad8\u5206\u8bcd\u7684\u51c6\u786e\u6027\uff0c\u4ece\u800c\u66f4\u597d\u5730\u63d0\u53d6\u51fa\u4eba\u540d\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import jieba<\/p>\n<h2><strong>\u6dfb\u52a0\u81ea\u5b9a\u4e49\u8bcd\u5178\uff0c\u53ef\u4ee5\u5305\u542b\u5e38\u89c1\u7684\u4eba\u540d<\/strong><\/h2>\n<p>jieba.load_userdict(&#39;userdict.txt&#39;)<\/p>\n<p>text = &quot;\u5f20\u4e09\u548c\u674e\u56db\u662f\u597d\u670b\u53cb\uff0c\u4ed6\u4eec\u7ecf\u5e38\u4e00\u8d77\u53bb\u6253\u7bee\u7403\u3002&quot;<\/p>\n<h2><strong>\u7cbe\u786e\u6a21\u5f0f\u5206\u8bcd<\/strong><\/h2>\n<p>words = jieba.lcut(text)<\/p>\n<h2><strong>\u8fc7\u6ee4\u4eba\u540d\uff08\u5047\u8bbe\u4eba\u540d\u5728\u81ea\u5b9a\u4e49\u8bcd\u5178\u4e2d\uff09<\/strong><\/h2>\n<p>names = [word for word in words if word in user_dict]<\/p>\n<p>print(names)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>2. \u4f7f\u7528StanfordNLP\u8fdb\u884c\u547d\u540d\u5b9e\u4f53\u8bc6\u522b<\/h3>\n<\/p>\n<p><p>StanfordNLP\u662f\u7531\u65af\u5766\u798f\u5927\u5b66\u5f00\u53d1\u7684\u81ea\u7136\u8bed\u8a00\u5904\u7406\u5e93\uff0c\u652f\u6301\u591a\u79cd\u8bed\u8a00\u7684\u89e3\u6790\u548c\u547d\u540d\u5b9e\u4f53\u8bc6\u522b\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import stanfordnlp<\/p>\n<h2><strong>\u4e0b\u8f7d\u4e2d\u6587\u6a21\u578b<\/strong><\/h2>\n<p>stanfordnlp.download(&#39;zh&#39;)<\/p>\n<h2><strong>\u521d\u59cb\u5316StanfordNLP<\/strong><\/h2>\n<p>nlp = stanfordnlp.Pipeline(lang=&#39;zh&#39;)<\/p>\n<p>text = &quot;\u5f20\u4e09\u548c\u674e\u56db\u662f\u597d\u670b\u53cb\uff0c\u4ed6\u4eec\u7ecf\u5e38\u4e00\u8d77\u53bb\u6253\u7bee\u7403\u3002&quot;<\/p>\n<h2><strong>\u5206\u6790\u6587\u672c<\/strong><\/h2>\n<p>doc = nlp(text)<\/p>\n<h2><strong>\u63d0\u53d6\u547d\u540d\u5b9e\u4f53<\/strong><\/h2>\n<p>for sentence in doc.sentences:<\/p>\n<p>    for entity in sentence.ents:<\/p>\n<p>        if entity.type == &#39;PERSON&#39;:<\/p>\n<p>            print(entity.text)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>3. \u4f7f\u7528Spacy\u8fdb\u884c\u547d\u540d\u5b9e\u4f53\u8bc6\u522b<\/h3>\n<\/p>\n<p><p>Spacy\u662f\u4e00\u4e2a\u5f00\u6e90\u7684\u81ea\u7136\u8bed\u8a00\u5904\u7406\u5e93\uff0c\u652f\u6301\u591a\u79cd\u8bed\u8a00\u7684\u89e3\u6790\u548c\u547d\u540d\u5b9e\u4f53\u8bc6\u522b\u3002\u5bf9\u4e8e\u4e2d\u6587\u6587\u672c\uff0c\u53ef\u4ee5\u7ed3\u5408\u4f7f\u7528<code>spacy<\/code>\u548c<code>zh_core_web_sm<\/code>\u6a21\u578b\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import spacy<\/p>\n<h2><strong>\u52a0\u8f7d\u4e2d\u6587\u6a21\u578b<\/strong><\/h2>\n<p>nlp = spacy.load(&#39;zh_core_web_sm&#39;)<\/p>\n<p>text = &quot;\u5f20\u4e09\u548c\u674e\u56db\u662f\u597d\u670b\u53cb\uff0c\u4ed6\u4eec\u7ecf\u5e38\u4e00\u8d77\u53bb\u6253\u7bee\u7403\u3002&quot;<\/p>\n<h2><strong>\u5206\u6790\u6587\u672c<\/strong><\/h2>\n<p>doc = nlp(text)<\/p>\n<h2><strong>\u63d0\u53d6\u547d\u540d\u5b9e\u4f53<\/strong><\/h2>\n<p>for ent in doc.ents:<\/p>\n<p>    if ent.label_ == &#39;PERSON&#39;:<\/p>\n<p>        print(ent.text)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h2>\u4e8c\u3001\u547d\u540d\u5b9e\u4f53\u8bc6\u522b\uff08NER\uff09<\/h2>\n<\/p>\n<p><p>\u547d\u540d\u5b9e\u4f53\u8bc6\u522b\uff08NER\uff09\u662f\u4e00\u79cd\u4fe1\u606f\u63d0\u53d6\u6280\u672f\uff0c\u7528\u4e8e\u8bc6\u522b\u548c\u5206\u7c7b\u6587\u672c\u4e2d\u7684\u5b9e\u4f53\uff0c\u5982\u4eba\u540d\u3001\u5730\u540d\u3001\u7ec4\u7ec7\u540d\u7b49\u3002\u5bf9\u4e8e\u4e2d\u6587\u59d3\u540d\u7684\u63d0\u53d6\uff0cNER\u6280\u672f\u5c24\u5176\u6709\u6548\u3002\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528\u73b0\u6210\u7684NER\u6a21\u578b\uff0c\u5982Hugging Face\u7684Transformers\u5e93\u3002<\/p>\n<\/p>\n<p><h3>1. \u4f7f\u7528Hugging Face\u7684Transformers\u5e93<\/h3>\n<\/p>\n<p><p>Hugging Face\u7684Transformers\u5e93\u63d0\u4f9b\u4e86\u591a\u79cd\u9884\u8bad\u7ec3\u6a21\u578b\uff0c\u53ef\u4ee5\u7528\u4e8e\u547d\u540d\u5b9e\u4f53\u8bc6\u522b\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from transformers import pipeline<\/p>\n<h2><strong>\u52a0\u8f7dNER\u6a21\u578b<\/strong><\/h2>\n<p>nlp = pipeline(&quot;ner&quot;, model=&quot;bert-base-chinese&quot;)<\/p>\n<p>text = &quot;\u5f20\u4e09\u548c\u674e\u56db\u662f\u597d\u670b\u53cb\uff0c\u4ed6\u4eec\u7ecf\u5e38\u4e00\u8d77\u53bb\u6253\u7bee\u7403\u3002&quot;<\/p>\n<h2><strong>\u63d0\u53d6\u547d\u540d\u5b9e\u4f53<\/strong><\/h2>\n<p>entities = nlp(text)<\/p>\n<h2><strong>\u8fc7\u6ee4\u4eba\u540d<\/strong><\/h2>\n<p>names = [entity[&#39;word&#39;] for entity in entities if entity[&#39;entity&#39;] == &#39;B-PER&#39;]<\/p>\n<p>print(names)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h2>\u4e09\u3001\u57fa\u4e8e\u89c4\u5219\u7684\u5339\u914d<\/h2>\n<\/p>\n<p><p>\u57fa\u4e8e\u89c4\u5219\u7684\u5339\u914d\u662f\u4e00\u79cd\u7b80\u5355\u4e14\u9ad8\u6548\u7684\u65b9\u6cd5\uff0c\u901a\u8fc7\u5b9a\u4e49\u4e00\u4e9b\u89c4\u5219\uff0c\u53ef\u4ee5\u5feb\u901f\u63d0\u53d6\u4e2d\u6587\u6587\u672c\u4e2d\u7684\u4eba\u540d\u3002\u8fd9\u79cd\u65b9\u6cd5\u9002\u7528\u4e8e\u6587\u672c\u683c\u5f0f\u56fa\u5b9a\u6216\u4eba\u540d\u5177\u6709\u7279\u5b9a\u7279\u5f81\u7684\u60c5\u51b5\u3002<\/p>\n<\/p>\n<p><h3>1. \u4f7f\u7528\u6b63\u5219\u8868\u8fbe\u5f0f\u8fdb\u884c\u5339\u914d<\/h3>\n<\/p>\n<p><pre><code class=\"language-python\">import re<\/p>\n<p>text = &quot;\u5f20\u4e09\u548c\u674e\u56db\u662f\u597d\u670b\u53cb\uff0c\u4ed6\u4eec\u7ecf\u5e38\u4e00\u8d77\u53bb\u6253\u7bee\u7403\u3002&quot;<\/p>\n<h2><strong>\u5b9a\u4e49\u4eba\u540d\u7684\u6b63\u5219\u8868\u8fbe\u5f0f<\/strong><\/h2>\n<p>pattern = re.compile(r&#39;\\b[\u5f20\u674e\u738b\u8d75]+[a-zA-Z]*\\b&#39;)<\/p>\n<h2><strong>\u63d0\u53d6\u4eba\u540d<\/strong><\/h2>\n<p>names = pattern.findall(text)<\/p>\n<p>print(names)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>2. \u4f7f\u7528\u5b9a\u4e49\u7684\u89c4\u5219\u8fdb\u884c\u5339\u914d<\/h3>\n<\/p>\n<p><p>\u6211\u4eec\u8fd8\u53ef\u4ee5\u901a\u8fc7\u5b9a\u4e49\u4e00\u7cfb\u5217\u89c4\u5219\u6765\u5339\u914d\u4eba\u540d\u3002\u4f8b\u5982\uff0c\u4e2d\u6587\u4eba\u540d\u901a\u5e38\u7531\u59d3\u548c\u540d\u7ec4\u6210\uff0c\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u8fd9\u79cd\u89c4\u5219\u6765\u63d0\u53d6\u4eba\u540d\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">def extract_names(text):<\/p>\n<p>    # \u5e38\u89c1\u7684\u4e2d\u6587\u59d3\u6c0f<\/p>\n<p>    surnames = [&#39;\u5f20&#39;, &#39;\u674e&#39;, &#39;\u738b&#39;, &#39;\u8d75&#39;, &#39;\u5218&#39;, &#39;\u9648&#39;, &#39;\u6768&#39;, &#39;\u9ec4&#39;, &#39;\u5434&#39;, &#39;\u5468&#39;]<\/p>\n<p>    names = []<\/p>\n<p>    words = text.split()<\/p>\n<p>    for word in words:<\/p>\n<p>        if len(word) == 2 or len(word) == 3:<\/p>\n<p>            if word[0] in surnames:<\/p>\n<p>                names.append(word)<\/p>\n<p>    return names<\/p>\n<p>text = &quot;\u5f20\u4e09\u548c\u674e\u56db\u662f\u597d\u670b\u53cb\uff0c\u4ed6\u4eec\u7ecf\u5e38\u4e00\u8d77\u53bb\u6253\u7bee\u7403\u3002&quot;<\/p>\n<p>names = extract_names(text)<\/p>\n<p>print(names)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h2>\u56db\u3001\u673a\u5668\u5b66\u4e60\u6a21\u578b<\/h2>\n<\/p>\n<p><p>\u673a\u5668\u5b66\u4e60\u6a21\u578b\u53ef\u4ee5\u901a\u8fc7\u8bad\u7ec3\u6570\u636e\u96c6\u6765\u63d0\u9ad8\u4e2d\u6587\u59d3\u540d\u63d0\u53d6\u7684\u51c6\u786e\u6027\u3002\u8fd9\u79cd\u65b9\u6cd5\u9700\u8981\u5927\u91cf\u7684\u6807\u6ce8\u6570\u636e\u548c\u8ba1\u7b97\u8d44\u6e90\uff0c\u4f46\u53ef\u4ee5\u63d0\u4f9b\u9ad8\u7cbe\u5ea6\u7684\u63d0\u53d6\u7ed3\u679c\u3002<\/p>\n<\/p>\n<p><h3>1. \u4f7f\u7528Scikit-learn\u8bad\u7ec3\u6a21\u578b<\/h3>\n<\/p>\n<p><p>\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528Scikit-learn\u5e93\u6765\u8bad\u7ec3\u4e00\u4e2a\u7b80\u5355\u7684\u5206\u7c7b\u6a21\u578b\uff0c\u7528\u4e8e\u8bc6\u522b\u4eba\u540d\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from sklearn.feature_extraction.text import CountVectorizer<\/p>\n<p>from sklearn.n<a href=\"https:\/\/docs.pingcode.com\/blog\/59162.html\" target=\"_blank\">AI<\/a>ve_bayes import MultinomialNB<\/p>\n<h2><strong>\u51c6\u5907\u8bad\u7ec3\u6570\u636e<\/strong><\/h2>\n<p>texts = [&quot;\u5f20\u4e09\u548c\u674e\u56db\u662f\u597d\u670b\u53cb&quot;, &quot;\u738b\u4e94\u548c\u8d75\u516d\u7ecf\u5e38\u4e00\u8d77\u6253\u7403&quot;, &quot;\u5218\u4e03\u548c\u9648\u516b\u662f\u540c\u4e8b&quot;]<\/p>\n<p>labels = [&quot;\u5f20\u4e09&quot;, &quot;\u674e\u56db&quot;, &quot;\u738b\u4e94&quot;, &quot;\u8d75\u516d&quot;, &quot;\u5218\u4e03&quot;, &quot;\u9648\u516b&quot;]<\/p>\n<h2><strong>\u5411\u91cf\u5316\u6587\u672c\u6570\u636e<\/strong><\/h2>\n<p>vectorizer = CountVectorizer()<\/p>\n<p>X = vectorizer.fit_transform(texts)<\/p>\n<h2><strong>\u8bad\u7ec3\u5206\u7c7b\u6a21\u578b<\/strong><\/h2>\n<p>model = MultinomialNB()<\/p>\n<p>model.fit(X, labels)<\/p>\n<h2><strong>\u9884\u6d4b\u65b0\u6587\u672c\u4e2d\u7684\u4eba\u540d<\/strong><\/h2>\n<p>new_text = [&quot;\u5f20\u4e09\u548c\u674e\u56db\u53bb\u516c\u56ed\u73a9&quot;]<\/p>\n<p>new_X = vectorizer.transform(new_text)<\/p>\n<p>predicted_names = model.predict(new_X)<\/p>\n<p>print(predicted_names)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>2. \u4f7f\u7528\u6df1\u5ea6\u5b66\u4e60\u6a21\u578b<\/h3>\n<\/p>\n<p><p>\u6df1\u5ea6\u5b66\u4e60\u6a21\u578b\uff0c\u5982LSTM\u3001BERT\u7b49\uff0c\u53ef\u4ee5\u901a\u8fc7\u5927\u89c4\u6a21\u8bad\u7ec3\u6570\u636e\u96c6\u6765\u63d0\u53d6\u4e2d\u6587\u6587\u672c\u4e2d\u7684\u4eba\u540d\u3002\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528Keras\u6216PyTorch\u7b49\u6df1\u5ea6\u5b66\u4e60\u6846\u67b6\u6765\u5b9e\u73b0\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import tensorflow as tf<\/p>\n<p>from tensorflow.keras.models import Sequential<\/p>\n<p>from tensorflow.keras.layers import LSTM, Dense, Embedding<\/p>\n<h2><strong>\u51c6\u5907\u8bad\u7ec3\u6570\u636e<\/strong><\/h2>\n<p>texts = [&quot;\u5f20\u4e09\u548c\u674e\u56db\u662f\u597d\u670b\u53cb&quot;, &quot;\u738b\u4e94\u548c\u8d75\u516d\u7ecf\u5e38\u4e00\u8d77\u6253\u7403&quot;, &quot;\u5218\u4e03\u548c\u9648\u516b\u662f\u540c\u4e8b&quot;]<\/p>\n<p>labels = [[1, 1, 0, 1, 1], [1, 1, 0, 1, 1], [1, 1, 0, 1, 1]]  # 1\u8868\u793a\u4eba\u540d\uff0c0\u8868\u793a\u975e\u4eba\u540d<\/p>\n<h2><strong>\u6784\u5efa\u6a21\u578b<\/strong><\/h2>\n<p>model = Sequential()<\/p>\n<p>model.add(Embedding(input_dim=1000, output_dim=64))<\/p>\n<p>model.add(LSTM(128))<\/p>\n<p>model.add(Dense(1, activation=&#39;sigmoid&#39;))<\/p>\n<h2><strong>\u7f16\u8bd1\u6a21\u578b<\/strong><\/h2>\n<p>model.compile(optimizer=&#39;adam&#39;, loss=&#39;binary_crossentropy&#39;, metrics=[&#39;accuracy&#39;])<\/p>\n<h2><strong>\u8bad\u7ec3\u6a21\u578b<\/strong><\/h2>\n<p>model.fit(texts, labels, epochs=10)<\/p>\n<h2><strong>\u9884\u6d4b\u65b0\u6587\u672c\u4e2d\u7684\u4eba\u540d<\/strong><\/h2>\n<p>new_text = [&quot;\u5f20\u4e09\u548c\u674e\u56db\u53bb\u516c\u56ed\u73a9&quot;]<\/p>\n<p>predicted_labels = model.predict(new_text)<\/p>\n<p>print(predicted_labels)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u901a\u8fc7\u4ee5\u4e0a\u51e0\u79cd\u65b9\u6cd5\uff0c\u6211\u4eec\u53ef\u4ee5\u4ece\u4e00\u6bb5\u4e2d\u6587\u6587\u672c\u4e2d\u6709\u6548\u5730\u63d0\u53d6\u51fa\u59d3\u540d\u3002\u6bcf\u79cd\u65b9\u6cd5\u90fd\u6709\u5176\u4f18\u7f3a\u70b9\uff0c\u9009\u62e9\u5408\u9002\u7684\u65b9\u6cd5\u53d6\u51b3\u4e8e\u5177\u4f53\u7684\u5e94\u7528\u573a\u666f\u548c\u6570\u636e\u7279\u70b9\u3002\u65e0\u8bba\u662f\u4f7f\u7528NLP\u6280\u672f\u3001NER\u6280\u672f\u3001\u57fa\u4e8e\u89c4\u5219\u7684\u5339\u914d\uff0c\u8fd8\u662f\u673a\u5668\u5b66\u4e60\u6a21\u578b\uff0c\u6bcf\u79cd\u65b9\u6cd5\u90fd\u53ef\u4ee5\u5728\u4e00\u5b9a\u7a0b\u5ea6\u4e0a\u63d0\u9ad8\u63d0\u53d6\u4e2d\u6587\u59d3\u540d\u7684\u51c6\u786e\u6027\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u5728Python\u4e2d\u8bc6\u522b\u4e2d\u6587\u59d3\u540d\uff1f<\/strong><br \/>\u5728Python\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528\u6b63\u5219\u8868\u8fbe\u5f0f\u548c\u81ea\u7136\u8bed\u8a00\u5904\u7406\u5e93\uff08\u5982jieba\uff09\u6765\u8bc6\u522b\u4e2d\u6587\u59d3\u540d\u3002\u901a\u8fc7\u5bf9\u6587\u672c\u8fdb\u884c\u5206\u8bcd\uff0c\u53ef\u4ee5\u63d0\u53d6\u51fa\u53ef\u80fd\u7684\u59d3\u540d\u90e8\u5206\u3002\u6b64\u5916\uff0c\u5229\u7528\u4e00\u4e9b\u59d3\u540d\u5e93\u8fdb\u884c\u5339\u914d\uff0c\u53ef\u4ee5\u63d0\u9ad8\u8bc6\u522b\u7684\u51c6\u786e\u6027\u3002<\/p>\n<p><strong>\u662f\u5426\u6709\u73b0\u6210\u7684\u5e93\u53ef\u4ee5\u5e2e\u52a9\u63d0\u53d6\u4e2d\u6587\u59d3\u540d\uff1f<\/strong><br \/>\u662f\u7684\uff0cPython\u4e2d\u6709\u4e00\u4e9b\u4e13\u95e8\u7528\u4e8e\u4e2d\u6587\u59d3\u540d\u8bc6\u522b\u7684\u5e93\uff0c\u5982<code>pyhanlp<\/code>\u548c<code>snownlp<\/code>\u3002\u8fd9\u4e9b\u5e93\u63d0\u4f9b\u4e86\u65b9\u4fbf\u7684\u63a5\u53e3\uff0c\u53ef\u4ee5\u5e2e\u52a9\u5f00\u53d1\u8005\u5feb\u901f\u5b9e\u73b0\u4e2d\u6587\u59d3\u540d\u7684\u63d0\u53d6\uff0c\u51cf\u5c11\u624b\u52a8\u7f16\u5199\u89c4\u5219\u7684\u5de5\u4f5c\u3002<\/p>\n<p><strong>\u5982\u4f55\u5904\u7406\u6587\u672c\u4e2d\u591a\u79cd\u683c\u5f0f\u7684\u59d3\u540d\uff1f<\/strong><br \/>\u5728\u5904\u7406\u5305\u542b\u591a\u79cd\u683c\u5f0f\u7684\u59d3\u540d\u65f6\uff0c\u53ef\u4ee5\u8003\u8651\u4f7f\u7528\u591a\u79cd\u6587\u672c\u5904\u7406\u6280\u672f\u3002\u5229\u7528\u6b63\u5219\u8868\u8fbe\u5f0f\u53ef\u4ee5\u6355\u6349\u4e0d\u540c\u7684\u59d3\u540d\u683c\u5f0f\uff0c\u4f8b\u5982\u201c\u59d3+\u540d\u201d\u3001\u201c\u540d+\u59d3\u201d\u6216\u201c\u5168\u540d\u201d\uff0c\u540c\u65f6\u7ed3\u5408\u5206\u8bcd\u548c\u4e0a\u4e0b\u6587\u5206\u6790\uff0c\u53ef\u4ee5\u66f4\u51c6\u786e\u5730\u8bc6\u522b\u51fa\u59d3\u540d\u3002<\/p>\n<p><strong>\u63d0\u53d6\u4e2d\u6587\u59d3\u540d\u65f6\u5982\u4f55\u63d0\u9ad8\u51c6\u786e\u7387\uff1f<\/strong><br \/>\u4e3a\u4e86\u63d0\u9ad8\u4e2d\u6587\u59d3\u540d\u63d0\u53d6\u7684\u51c6\u786e\u7387\uff0c\u53ef\u4ee5\u8003\u8651\u6784\u5efa\u4e00\u4e2a\u5305\u542b\u5e38\u89c1\u4e2d\u6587\u59d3\u540d\u7684\u5b57\u5178\uff0c\u7ed3\u5408\u4e0a\u4e0b\u6587\u4fe1\u606f\u8fdb\u884c\u9a8c\u8bc1\u3002\u540c\u65f6\uff0c\u4f7f\u7528\u673a\u5668\u5b66\u4e60\u6a21\u578b\u5bf9\u59d3\u540d\u8fdb\u884c\u8bad\u7ec3\uff0c\u4e5f\u80fd\u663e\u8457\u63d0\u5347\u63d0\u53d6\u6548\u679c\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u4ece\u4e00\u6bb5\u4e2d\u6587\u4e2d\u63d0\u53d6\u59d3\u540d\u7684\u65b9\u6cd5\u4e3b\u8981\u6709\uff1a\u81ea\u7136\u8bed\u8a00\u5904\u7406\uff08NLP\uff09\u6280\u672f\u3001\u547d\u540d\u5b9e\u4f53\u8bc6\u522b\uff08NER\uff09\u3001\u57fa\u4e8e\u89c4\u5219\u7684\u5339\u914d\u3001\u673a\u5668\u5b66\u4e60 [&hellip;]","protected":false},"author":3,"featured_media":1137496,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[37],"tags":[],"acf":[],"_links":{"self":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1137493"}],"collection":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/comments?post=1137493"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1137493\/revisions"}],"predecessor-version":[{"id":1137497,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1137493\/revisions\/1137497"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1137496"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1137493"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1137493"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1137493"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}