{"id":1092392,"date":"2025-01-08T14:20:42","date_gmt":"2025-01-08T06:20:42","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1092392.html"},"modified":"2025-01-08T14:20:44","modified_gmt":"2025-01-08T06:20:44","slug":"python%e6%95%b0%e6%8d%ae%e5%88%86%e6%9e%90%e5%a6%82%e4%bd%95%e5%ae%9e%e7%8e%b0%e8%af%8d%e9%a2%91%e7%bb%9f%e8%ae%a1-2","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/1092392.html","title":{"rendered":"python\u6570\u636e\u5206\u6790\u5982\u4f55\u5b9e\u73b0\u8bcd\u9891\u7edf\u8ba1"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/24205443\/2a6c4ee0-d528-4baf-950a-6c2cf525259c.webp\" alt=\"python\u6570\u636e\u5206\u6790\u5982\u4f55\u5b9e\u73b0\u8bcd\u9891\u7edf\u8ba1\" \/><\/p>\n<p><p> <strong>\u5b9e\u73b0Python\u6570\u636e\u5206\u6790\u7684\u8bcd\u9891\u7edf\u8ba1\uff0c\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u51e0\u4e2a\u5173\u952e\u6b65\u9aa4\u6765\u5b8c\u6210\uff1a\u6570\u636e\u9884\u5904\u7406\u3001\u5206\u8bcd\u5904\u7406\u3001\u7edf\u8ba1\u8bcd\u9891\u3001\u7ed3\u679c\u53ef\u89c6\u5316\u3002<\/strong> \u5176\u4e2d\uff0c\u6570\u636e\u9884\u5904\u7406\u662f\u57fa\u7840\uff0c\u5b83\u51b3\u5b9a\u4e86\u540e\u7eed\u6b65\u9aa4\u7684\u51c6\u786e\u6027\u4e0e\u6709\u6548\u6027\u3002\u4e0b\u9762\u8be6\u7ec6\u63cf\u8ff0\u6570\u636e\u9884\u5904\u7406\u7684\u8fc7\u7a0b\u3002<\/p>\n<\/p>\n<p><p><strong>\u6570\u636e\u9884\u5904\u7406<\/strong>\u662f\u8bcd\u9891\u7edf\u8ba1\u7684\u7b2c\u4e00\u6b65\uff0c\u6d89\u53ca\u6e05\u6d17\u548c\u89c4\u8303\u5316\u6587\u672c\u6570\u636e\u3002\u6587\u672c\u6570\u636e\u901a\u5e38\u5305\u542b\u591a\u4f59\u7684\u7a7a\u683c\u3001\u6807\u70b9\u7b26\u53f7\u3001\u7279\u6b8a\u5b57\u7b26\u548c\u5927\u5c0f\u5199\u4e0d\u4e00\u81f4\u7b49\u95ee\u9898\u3002\u901a\u8fc7\u5bf9\u6570\u636e\u8fdb\u884c\u6e05\u6d17\uff0c\u5220\u9664\u591a\u4f59\u5143\u7d20\uff0c\u7edf\u4e00\u5927\u5c0f\u5199\uff0c\u53ef\u4ee5\u63d0\u9ad8\u8bcd\u9891\u7edf\u8ba1\u7684\u51c6\u786e\u6027\u3002\u4f8b\u5982\uff0c\u53ef\u4ee5\u4f7f\u7528\u6b63\u5219\u8868\u8fbe\u5f0f\uff08Regex\uff09\u6765\u53bb\u9664\u6807\u70b9\u7b26\u53f7\u548c\u7279\u6b8a\u5b57\u7b26\uff0c\u4f7f\u7528Python\u5185\u7f6e\u7684\u5b57\u7b26\u4e32\u64cd\u4f5c\u51fd\u6570\u6765\u5904\u7406\u7a7a\u683c\u548c\u5927\u5c0f\u5199\u3002<\/p>\n<\/p>\n<hr>\n<p><h3>\u4e00\u3001\u6570\u636e\u9884\u5904\u7406<\/h3>\n<\/p>\n<p><p>\u6570\u636e\u9884\u5904\u7406\u662f\u6587\u672c\u5206\u6790\u7684\u5173\u952e\u6b65\u9aa4\uff0c\u76f4\u63a5\u5f71\u54cd\u540e\u7eed\u7684\u8bcd\u9891\u7edf\u8ba1\u7ed3\u679c\u3002\u5728\u6b64\u6b65\u9aa4\u4e2d\uff0c\u6211\u4eec\u9700\u8981\u5bf9\u6587\u672c\u6570\u636e\u8fdb\u884c\u6e05\u6d17\u548c\u89c4\u8303\u5316\u5904\u7406\u3002<\/p>\n<\/p>\n<p><h4>1\u3001\u6e05\u6d17\u6570\u636e<\/h4>\n<\/p>\n<p><p>\u6e05\u6d17\u6570\u636e\u662f\u4e3a\u4e86\u53bb\u9664\u6587\u672c\u4e2d\u7684\u566a\u97f3\u6570\u636e\uff0c\u8fd9\u4e9b\u6570\u636e\u5305\u62ec\u6807\u70b9\u7b26\u53f7\u3001\u7279\u6b8a\u5b57\u7b26\u3001\u591a\u4f59\u7684\u7a7a\u683c\u548c\u6362\u884c\u7b26\u7b49\u3002\u53ef\u4ee5\u4f7f\u7528\u6b63\u5219\u8868\u8fbe\u5f0f\uff08Regex\uff09\u8fdb\u884c\u6e05\u6d17\u3002<\/p>\n<\/p>\n<p><p>\u4f8b\u5982\uff0c\u4ee5\u4e0b\u4ee3\u7801\u5c55\u793a\u4e86\u5982\u4f55\u4f7f\u7528\u6b63\u5219\u8868\u8fbe\u5f0f\u53bb\u9664\u6587\u672c\u4e2d\u7684\u6807\u70b9\u7b26\u53f7\u548c\u7279\u6b8a\u5b57\u7b26\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import re<\/p>\n<p>def clean_text(text):<\/p>\n<p>    # \u79fb\u9664\u6807\u70b9\u7b26\u53f7\u548c\u7279\u6b8a\u5b57\u7b26<\/p>\n<p>    text = re.sub(r&#39;[^\\w\\s]&#39;, &#39;&#39;, text)<\/p>\n<p>    # \u79fb\u9664\u591a\u4f59\u7684\u7a7a\u683c<\/p>\n<p>    text = re.sub(r&#39;\\s+&#39;, &#39; &#39;, text)<\/p>\n<p>    return text.strip()<\/p>\n<p>text = &quot;Hello, world! This is a sample text with, punctuation.&quot;<\/p>\n<p>cleaned_text = clean_text(text)<\/p>\n<p>print(cleaned_text)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>2\u3001\u89c4\u8303\u5316\u5904\u7406<\/h4>\n<\/p>\n<p><p>\u89c4\u8303\u5316\u5904\u7406\u4e3b\u8981\u662f\u5c06\u6587\u672c\u4e2d\u7684\u5b57\u7b26\u7edf\u4e00\u4e3a\u5c0f\u5199\u6216\u5927\u5199\uff0c\u786e\u4fdd\u540c\u4e00\u4e2a\u8bcd\u5728\u7edf\u8ba1\u65f6\u4e0d\u4f1a\u56e0\u4e3a\u5927\u5c0f\u5199\u4e0d\u540c\u800c\u88ab\u5206\u5f00\u7edf\u8ba1\u3002<\/p>\n<\/p>\n<p><p>\u4f8b\u5982\uff0c\u4ee5\u4e0b\u4ee3\u7801\u5c55\u793a\u4e86\u5982\u4f55\u5c06\u6587\u672c\u5168\u90e8\u8f6c\u6362\u4e3a\u5c0f\u5199\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">def normalize_text(text):<\/p>\n<p>    return text.lower()<\/p>\n<p>normalized_text = normalize_text(cleaned_text)<\/p>\n<p>print(normalized_text)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u4e8c\u3001\u5206\u8bcd\u5904\u7406<\/h3>\n<\/p>\n<p><p>\u5206\u8bcd\u662f\u5c06\u6587\u672c\u5206\u5272\u6210\u4e00\u4e2a\u4e2a\u5355\u8bcd\u6216\u8bcd\u7ec4\u7684\u8fc7\u7a0b\uff0c\u662f\u8bcd\u9891\u7edf\u8ba1\u7684\u57fa\u7840\u3002\u4e0d\u540c\u8bed\u8a00\u7684\u5206\u8bcd\u65b9\u5f0f\u4e0d\u540c\uff0cPython\u4e2d\u5e38\u7528\u7684\u5206\u8bcd\u5e93\u6709<code>nltk<\/code>\u548c<code>jieba<\/code>\u3002<\/p>\n<\/p>\n<p><h4>1\u3001\u4f7f\u7528nltk\u8fdb\u884c\u5206\u8bcd<\/h4>\n<\/p>\n<p><p><code>nltk<\/code>\uff08Natural Language Toolkit\uff09\u662fPython\u4e2d\u5e38\u7528\u7684\u81ea\u7136\u8bed\u8a00\u5904\u7406\u5e93\uff0c\u9002\u7528\u4e8e\u82f1\u6587\u6587\u672c\u7684\u5206\u8bcd\u5904\u7406\u3002<\/p>\n<\/p>\n<p><p>\u4ee5\u4e0b\u4ee3\u7801\u5c55\u793a\u4e86\u5982\u4f55\u4f7f\u7528<code>nltk<\/code>\u8fdb\u884c\u82f1\u6587\u6587\u672c\u7684\u5206\u8bcd\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import nltk<\/p>\n<p>nltk.download(&#39;punkt&#39;)<\/p>\n<p>from nltk.tokenize import word_tokenize<\/p>\n<p>def tokenize_text(text):<\/p>\n<p>    return word_tokenize(text)<\/p>\n<p>tokens = tokenize_text(normalized_text)<\/p>\n<p>print(tokens)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>2\u3001\u4f7f\u7528jieba\u8fdb\u884c\u5206\u8bcd<\/h4>\n<\/p>\n<p><p><code>jieba<\/code>\u662fPython\u4e2d\u5e38\u7528\u7684\u4e2d\u6587\u5206\u8bcd\u5e93\uff0c\u9002\u7528\u4e8e\u4e2d\u6587\u6587\u672c\u7684\u5206\u8bcd\u5904\u7406\u3002<\/p>\n<\/p>\n<p><p>\u4ee5\u4e0b\u4ee3\u7801\u5c55\u793a\u4e86\u5982\u4f55\u4f7f\u7528<code>jieba<\/code>\u8fdb\u884c\u4e2d\u6587\u6587\u672c\u7684\u5206\u8bcd\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import jieba<\/p>\n<p>def tokenize_text_cn(text):<\/p>\n<p>    return list(jieba.cut(text))<\/p>\n<p>text_cn = &quot;\u8fd9\u662f\u4e00\u4e2a\u4e2d\u6587\u5206\u8bcd\u7684\u793a\u4f8b\u6587\u672c\u3002&quot;<\/p>\n<p>tokens_cn = tokenize_text_cn(text_cn)<\/p>\n<p>print(tokens_cn)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u4e09\u3001\u7edf\u8ba1\u8bcd\u9891<\/h3>\n<\/p>\n<p><p>\u5728\u5b8c\u6210\u5206\u8bcd\u4e4b\u540e\uff0c\u63a5\u4e0b\u6765\u5c31\u662f\u7edf\u8ba1\u6bcf\u4e2a\u8bcd\u51fa\u73b0\u7684\u9891\u7387\u3002\u53ef\u4ee5\u4f7f\u7528Python\u7684<code>collections.Counter<\/code>\u7c7b\u6765\u5b8c\u6210\u8bcd\u9891\u7edf\u8ba1\u3002<\/p>\n<\/p>\n<p><h4>1\u3001\u4f7f\u7528Counter\u7edf\u8ba1\u8bcd\u9891<\/h4>\n<\/p>\n<p><p>\u4ee5\u4e0b\u4ee3\u7801\u5c55\u793a\u4e86\u5982\u4f55\u4f7f\u7528<code>Counter<\/code>\u7edf\u8ba1\u8bcd\u9891\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from collections import Counter<\/p>\n<p>def count_word_frequency(tokens):<\/p>\n<p>    return Counter(tokens)<\/p>\n<p>word_freq = count_word_frequency(tokens)<\/p>\n<p>print(word_freq)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>2\u3001\u7edf\u8ba1\u4e2d\u6587\u8bcd\u9891<\/h4>\n<\/p>\n<p><p>\u540c\u6837\u7684\u65b9\u6cd5\u4e5f\u9002\u7528\u4e8e\u4e2d\u6587\u6587\u672c\u7684\u8bcd\u9891\u7edf\u8ba1\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">word_freq_cn = count_word_frequency(tokens_cn)<\/p>\n<p>print(word_freq_cn)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u56db\u3001\u7ed3\u679c\u53ef\u89c6\u5316<\/h3>\n<\/p>\n<p><p>\u4e3a\u4e86\u66f4\u76f4\u89c2\u5730\u5c55\u793a\u8bcd\u9891\u7edf\u8ba1\u7ed3\u679c\uff0c\u53ef\u4ee5\u4f7f\u7528\u53ef\u89c6\u5316\u5de5\u5177\u8fdb\u884c\u5c55\u793a\u3002Python\u4e2d\u5e38\u7528\u7684\u53ef\u89c6\u5316\u5e93\u6709<code>matplotlib<\/code>\u548c<code>wordcloud<\/code>\u3002<\/p>\n<\/p>\n<p><h4>1\u3001\u4f7f\u7528matplotlib\u7ed8\u5236\u8bcd\u9891\u76f4\u65b9\u56fe<\/h4>\n<\/p>\n<p><p>\u4ee5\u4e0b\u4ee3\u7801\u5c55\u793a\u4e86\u5982\u4f55\u4f7f\u7528<code>matplotlib<\/code>\u7ed8\u5236\u8bcd\u9891\u76f4\u65b9\u56fe\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import matplotlib.pyplot as plt<\/p>\n<p>def plot_word_frequency(word_freq):<\/p>\n<p>    words = list(word_freq.keys())<\/p>\n<p>    frequencies = list(word_freq.values())<\/p>\n<p>    plt.figure(figsize=(10, 5))<\/p>\n<p>    plt.bar(words, frequencies)<\/p>\n<p>    plt.xlabel(&#39;Words&#39;)<\/p>\n<p>    plt.ylabel(&#39;Frequency&#39;)<\/p>\n<p>    plt.title(&#39;Word Frequency&#39;)<\/p>\n<p>    plt.show()<\/p>\n<p>plot_word_frequency(word_freq)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>2\u3001\u4f7f\u7528wordcloud\u7ed8\u5236\u8bcd\u4e91<\/h4>\n<\/p>\n<p><p>\u8bcd\u4e91\u662f\u4e00\u79cd\u76f4\u89c2\u5c55\u793a\u8bcd\u9891\u7684\u56fe\u5f62\u65b9\u6cd5\uff0c\u53ef\u4ee5\u4f7f\u7528<code>wordcloud<\/code>\u5e93\u751f\u6210\u8bcd\u4e91\u3002<\/p>\n<\/p>\n<p><p>\u4ee5\u4e0b\u4ee3\u7801\u5c55\u793a\u4e86\u5982\u4f55\u4f7f\u7528<code>wordcloud<\/code>\u751f\u6210\u8bcd\u4e91\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from wordcloud import WordCloud<\/p>\n<p>def generate_wordcloud(word_freq):<\/p>\n<p>    wordcloud = WordCloud(width=800, height=400, background_color=&#39;white&#39;).generate_from_frequencies(word_freq)<\/p>\n<p>    plt.figure(figsize=(10, 5))<\/p>\n<p>    plt.imshow(wordcloud, interpolation=&#39;bilinear&#39;)<\/p>\n<p>    plt.axis(&#39;off&#39;)<\/p>\n<p>    plt.show()<\/p>\n<p>generate_wordcloud(word_freq)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u4e94\u3001\u7efc\u5408\u5e94\u7528\u5b9e\u4f8b<\/h3>\n<\/p>\n<p><p>\u6700\u540e\uff0c\u901a\u8fc7\u4e00\u4e2a\u7efc\u5408\u5e94\u7528\u5b9e\u4f8b\u6765\u5c55\u793a\u5982\u4f55\u5c06\u4e0a\u8ff0\u6b65\u9aa4\u7ed3\u5408\u8d77\u6765\uff0c\u5b8c\u6210\u6570\u636e\u9884\u5904\u7406\u3001\u5206\u8bcd\u3001\u8bcd\u9891\u7edf\u8ba1\u548c\u7ed3\u679c\u53ef\u89c6\u5316\u3002<\/p>\n<\/p>\n<p><h4>1\u3001\u7efc\u5408\u4ee3\u7801\u5b9e\u4f8b<\/h4>\n<\/p>\n<p><p>\u4ee5\u4e0b\u4ee3\u7801\u5c55\u793a\u4e86\u4e00\u4e2a\u7efc\u5408\u5e94\u7528\u5b9e\u4f8b\uff0c\u4ece\u6570\u636e\u9884\u5904\u7406\u5230\u7ed3\u679c\u53ef\u89c6\u5316\u7684\u5168\u8fc7\u7a0b\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import re<\/p>\n<p>import nltk<\/p>\n<p>import jieba<\/p>\n<p>import matplotlib.pyplot as plt<\/p>\n<p>from collections import Counter<\/p>\n<p>from wordcloud import WordCloud<\/p>\n<p>def clean_text(text):<\/p>\n<p>    text = re.sub(r&#39;[^\\w\\s]&#39;, &#39;&#39;, text)<\/p>\n<p>    text = re.sub(r&#39;\\s+&#39;, &#39; &#39;, text)<\/p>\n<p>    return text.strip()<\/p>\n<p>def normalize_text(text):<\/p>\n<p>    return text.lower()<\/p>\n<p>def tokenize_text(text):<\/p>\n<p>    return word_tokenize(text)<\/p>\n<p>def tokenize_text_cn(text):<\/p>\n<p>    return list(jieba.cut(text))<\/p>\n<p>def count_word_frequency(tokens):<\/p>\n<p>    return Counter(tokens)<\/p>\n<p>def plot_word_frequency(word_freq):<\/p>\n<p>    words = list(word_freq.keys())<\/p>\n<p>    frequencies = list(word_freq.values())<\/p>\n<p>    plt.figure(figsize=(10, 5))<\/p>\n<p>    plt.bar(words, frequencies)<\/p>\n<p>    plt.xlabel(&#39;Words&#39;)<\/p>\n<p>    plt.ylabel(&#39;Frequency&#39;)<\/p>\n<p>    plt.title(&#39;Word Frequency&#39;)<\/p>\n<p>    plt.show()<\/p>\n<p>def generate_wordcloud(word_freq):<\/p>\n<p>    wordcloud = WordCloud(width=800, height=400, background_color=&#39;white&#39;).generate_from_frequencies(word_freq)<\/p>\n<p>    plt.figure(figsize=(10, 5))<\/p>\n<p>    plt.imshow(wordcloud, interpolation=&#39;bilinear&#39;)<\/p>\n<p>    plt.axis(&#39;off&#39;)<\/p>\n<p>    plt.show()<\/p>\n<h2><strong>\u793a\u4f8b\u6587\u672c<\/strong><\/h2>\n<p>text = &quot;Hello, world! This is a sample text with, punctuation.&quot;<\/p>\n<h2><strong>\u6570\u636e\u9884\u5904\u7406<\/strong><\/h2>\n<p>cleaned_text = clean_text(text)<\/p>\n<p>normalized_text = normalize_text(cleaned_text)<\/p>\n<h2><strong>\u5206\u8bcd\u5904\u7406<\/strong><\/h2>\n<p>tokens = tokenize_text(normalized_text)<\/p>\n<h2><strong>\u8bcd\u9891\u7edf\u8ba1<\/strong><\/h2>\n<p>word_freq = count_word_frequency(tokens)<\/p>\n<h2><strong>\u7ed3\u679c\u53ef\u89c6\u5316<\/strong><\/h2>\n<p>plot_word_frequency(word_freq)<\/p>\n<p>generate_wordcloud(word_freq)<\/p>\n<h2><strong>\u4e2d\u6587\u6587\u672c\u793a\u4f8b<\/strong><\/h2>\n<p>text_cn = &quot;\u8fd9\u662f\u4e00\u4e2a\u4e2d\u6587\u5206\u8bcd\u7684\u793a\u4f8b\u6587\u672c\u3002&quot;<\/p>\n<h2><strong>\u6570\u636e\u9884\u5904\u7406<\/strong><\/h2>\n<p>cleaned_text_cn = clean_text(text_cn)<\/p>\n<h2><strong>\u5206\u8bcd\u5904\u7406<\/strong><\/h2>\n<p>tokens_cn = tokenize_text_cn(cleaned_text_cn)<\/p>\n<h2><strong>\u8bcd\u9891\u7edf\u8ba1<\/strong><\/h2>\n<p>word_freq_cn = count_word_frequency(tokens_cn)<\/p>\n<h2><strong>\u7ed3\u679c\u53ef\u89c6\u5316<\/strong><\/h2>\n<p>plot_word_frequency(word_freq_cn)<\/p>\n<p>generate_wordcloud(word_freq_cn)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u901a\u8fc7\u4ee5\u4e0a\u6b65\u9aa4\u548c\u4ee3\u7801\u5b9e\u4f8b\uff0c\u6211\u4eec\u53ef\u4ee5\u5b8c\u6210\u4ece\u6570\u636e\u9884\u5904\u7406\u5230\u8bcd\u9891\u7edf\u8ba1\uff0c\u518d\u5230\u7ed3\u679c\u53ef\u89c6\u5316\u7684\u5168\u8fc7\u7a0b\u3002\u8fd9\u4e9b\u6b65\u9aa4\u5728\u5b9e\u9645\u7684\u6587\u672c\u5206\u6790\u548c\u81ea\u7136\u8bed\u8a00\u5904\u7406\u4efb\u52a1\u4e2d\u662f\u975e\u5e38\u91cd\u8981\u7684\uff0c\u80fd\u591f\u5e2e\u52a9\u6211\u4eec\u66f4\u597d\u5730\u7406\u89e3\u548c\u5206\u6790\u6587\u672c\u6570\u636e\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u4f7f\u7528Python\u8fdb\u884c\u8bcd\u9891\u7edf\u8ba1\uff1f<\/strong><br \/>\u8fdb\u884c\u8bcd\u9891\u7edf\u8ba1\u7684\u57fa\u672c\u6b65\u9aa4\u5305\u62ec\u6587\u672c\u9884\u5904\u7406\u3001\u5206\u8bcd\u3001\u7edf\u8ba1\u8bcd\u9891\u548c\u53ef\u89c6\u5316\u3002\u9996\u5148\uff0c\u4f7f\u7528Python\u7684\u6587\u672c\u5904\u7406\u5e93\uff08\u5982NLTK\u6216spaCy\uff09\u8fdb\u884c\u6587\u672c\u6e05\u6d17\uff0c\u7136\u540e\u5229\u7528Counter\u7c7b\u6216pandas\u5e93\u6765\u7edf\u8ba1\u6bcf\u4e2a\u8bcd\u51fa\u73b0\u7684\u6b21\u6570\u3002\u6700\u540e\uff0c\u53ef\u4ee5\u4f7f\u7528matplotlib\u6216seaborn\u5e93\u6765\u53ef\u89c6\u5316\u8bcd\u9891\u5206\u5e03\u3002<\/p>\n<p><strong>\u5728Python\u4e2d\u6709\u54ea\u4e9b\u5e93\u53ef\u4ee5\u5e2e\u52a9\u8fdb\u884c\u8bcd\u9891\u7edf\u8ba1\uff1f<\/strong><br \/>Python\u63d0\u4f9b\u4e86\u591a\u4e2a\u5f3a\u5927\u7684\u5e93\u6765\u5b9e\u73b0\u8bcd\u9891\u7edf\u8ba1\u3002\u5e38\u7528\u7684\u6709NLTK\uff08\u81ea\u7136\u8bed\u8a00\u5de5\u5177\u5305\uff09\u3001spaCy\uff08\u7528\u4e8e\u9ad8\u7ea7\u81ea\u7136\u8bed\u8a00\u5904\u7406\uff09\u3001collections\u4e2d\u7684Counter\u7c7b\uff08\u7528\u4e8e\u7b80\u5355\u7684\u8ba1\u6570\uff09\uff0c\u4ee5\u53capandas\uff08\u7528\u4e8e\u6570\u636e\u5206\u6790\uff09\u3002\u8fd9\u4e9b\u5e93\u7684\u529f\u80fd\u5404\u6709\u4fa7\u91cd\uff0c\u9009\u62e9\u5408\u9002\u7684\u5de5\u5177\u53ef\u4ee5\u5927\u5927\u7b80\u5316\u8bcd\u9891\u7edf\u8ba1\u7684\u8fc7\u7a0b\u3002<\/p>\n<p><strong>\u5982\u4f55\u5904\u7406\u6587\u672c\u6570\u636e\u4e2d\u7684\u505c\u7528\u8bcd\u4ee5\u63d0\u9ad8\u8bcd\u9891\u7edf\u8ba1\u7684\u51c6\u786e\u6027\uff1f<\/strong><br \/>\u505c\u7528\u8bcd\u662f\u6307\u5728\u6587\u672c\u5206\u6790\u4e2d\u9891\u7e41\u51fa\u73b0\u4f46\u5bf9\u5206\u6790\u6ca1\u6709\u5b9e\u9645\u610f\u4e49\u7684\u8bcd\u6c47\uff0c\u5982\u201c\u7684\u201d\u3001\u201c\u662f\u201d\u7b49\u3002\u4e3a\u4e86\u63d0\u9ad8\u8bcd\u9891\u7edf\u8ba1\u7684\u51c6\u786e\u6027\uff0c\u53ef\u4ee5\u4f7f\u7528NLTK\u6216spaCy\u63d0\u4f9b\u7684\u505c\u7528\u8bcd\u5217\u8868\uff0c\u8fc7\u6ee4\u6389\u8fd9\u4e9b\u8bcd\u6c47\u3002\u8fd9\u6837\u53ef\u4ee5\u786e\u4fdd\u7edf\u8ba1\u7ed3\u679c\u66f4\u5177\u4ee3\u8868\u6027\uff0c\u7a81\u51fa\u91cd\u8981\u8bcd\u6c47\u7684\u9891\u7387\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u5b9e\u73b0Python\u6570\u636e\u5206\u6790\u7684\u8bcd\u9891\u7edf\u8ba1\uff0c\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u51e0\u4e2a\u5173\u952e\u6b65\u9aa4\u6765\u5b8c\u6210\uff1a\u6570\u636e\u9884\u5904\u7406\u3001\u5206\u8bcd\u5904\u7406\u3001\u7edf\u8ba1\u8bcd\u9891\u3001\u7ed3\u679c\u53ef\u89c6\u5316 [&hellip;]","protected":false},"author":3,"featured_media":1092407,"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\/1092392"}],"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=1092392"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1092392\/revisions"}],"predecessor-version":[{"id":1092410,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1092392\/revisions\/1092410"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1092407"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1092392"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1092392"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1092392"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}