{"id":1098881,"date":"2025-01-08T15:25:15","date_gmt":"2025-01-08T07:25:15","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1098881.html"},"modified":"2025-01-08T15:25:17","modified_gmt":"2025-01-08T07:25:17","slug":"%e5%a6%82%e4%bd%95%e7%94%a8python%e8%bf%9b%e8%a1%8c%e6%96%87%e7%8c%ae%e8%ae%a1%e9%87%8f-2","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/1098881.html","title":{"rendered":"\u5982\u4f55\u7528python\u8fdb\u884c\u6587\u732e\u8ba1\u91cf"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25062843\/01048514-cbfb-462b-b5f7-be70f883c3b6.webp\" alt=\"\u5982\u4f55\u7528python\u8fdb\u884c\u6587\u732e\u8ba1\u91cf\" \/><\/p>\n<p><p> <strong>\u5982\u4f55\u7528Python\u8fdb\u884c\u6587\u732e\u8ba1\u91cf<\/strong><\/p>\n<\/p>\n<p><p><strong>Python\u8fdb\u884c\u6587\u732e\u8ba1\u91cf\u7684\u65b9\u6cd5\u5305\u62ec\uff1a\u6570\u636e\u91c7\u96c6\u3001\u6587\u672c\u9884\u5904\u7406\u3001\u6587\u672c\u5206\u6790\u3001\u53ef\u89c6\u5316\u3002<\/strong>\u672c\u6587\u5c06\u8be6\u7ec6\u9610\u8ff0\u5982\u4f55\u7528Python\u8fdb\u884c\u6587\u732e\u8ba1\u91cf\u5206\u6790\uff0c\u5e76\u4ecb\u7ecd\u5e38\u7528\u7684Python\u5e93\u548c\u5de5\u5177\uff0c\u4ee5\u5e2e\u52a9\u7814\u7a76\u8005\u9ad8\u6548\u5730\u5f00\u5c55\u6587\u732e\u8ba1\u91cf\u7814\u7a76\u3002<\/p>\n<\/p>\n<p><h3>\u4e00\u3001\u6570\u636e\u91c7\u96c6<\/h3>\n<\/p>\n<p><p>\u5728\u8fdb\u884c\u6587\u732e\u8ba1\u91cf\u5206\u6790\u4e4b\u524d\uff0c\u9996\u5148\u9700\u8981\u91c7\u96c6\u6587\u732e\u6570\u636e\u3002\u5e38\u7528\u7684\u6587\u732e\u6570\u636e\u6e90\u5305\u62ecGoogle Scholar\u3001PubMed\u3001Web of Science\u7b49\u3002Python\u63d0\u4f9b\u4e86\u591a\u79cd\u5de5\u5177\u548c\u5e93\u6765\u91c7\u96c6\u8fd9\u4e9b\u6570\u636e\u3002<\/p>\n<\/p>\n<p><h4>1. \u4f7f\u7528Selenium\u81ea\u52a8\u5316\u91c7\u96c6\u6570\u636e<\/h4>\n<\/p>\n<p><p>Selenium\u662f\u4e00\u4e2a\u81ea\u52a8\u5316\u6d4b\u8bd5\u5de5\u5177\uff0c\u53ef\u4ee5\u7528\u6765\u6a21\u62df\u6d4f\u89c8\u5668\u64cd\u4f5c\uff0c\u91c7\u96c6\u7f51\u9875\u6570\u636e\u3002\u901a\u8fc7Selenium\uff0c\u6211\u4eec\u53ef\u4ee5\u81ea\u52a8\u767b\u5f55\u6587\u732e\u6570\u636e\u5e93\u7f51\u7ad9\uff0c\u641c\u7d22\u5173\u952e\u8bcd\uff0c\u91c7\u96c6\u6587\u732e\u6570\u636e\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from selenium import webdriver<\/p>\n<p>from selenium.webdriver.common.keys import Keys<\/p>\n<h2><strong>\u8bbe\u7f6eSelenium WebDriver<\/strong><\/h2>\n<p>driver = webdriver.Chrome(executable_path=&#39;path_to_chromedriver&#39;)<\/p>\n<h2><strong>\u6253\u5f00\u6587\u732e\u6570\u636e\u5e93\u7f51\u7ad9<\/strong><\/h2>\n<p>driver.get(&#39;https:\/\/scholar.google.com&#39;)<\/p>\n<h2><strong>\u641c\u7d22\u5173\u952e\u8bcd<\/strong><\/h2>\n<p>search_box = driver.find_element_by_name(&#39;q&#39;)<\/p>\n<p>search_box.send_keys(&#39;machine learning&#39;)<\/p>\n<p>search_box.send_keys(Keys.RETURN)<\/p>\n<h2><strong>\u91c7\u96c6\u6587\u732e\u4fe1\u606f<\/strong><\/h2>\n<p>results = driver.find_elements_by_css_selector(&#39;div.gs_ri&#39;)<\/p>\n<p>for result in results:<\/p>\n<p>    title = result.find_element_by_css_selector(&#39;h3&#39;).text<\/p>\n<p>    authors = result.find_element_by_css_selector(&#39;div.gs_a&#39;).text<\/p>\n<p>    snippet = result.find_element_by_css_selector(&#39;div.gs_rs&#39;).text<\/p>\n<p>    print(f&#39;Title: {title}, Authors: {authors}, Snippet: {snippet}&#39;)<\/p>\n<h2><strong>\u5173\u95ed\u6d4f\u89c8\u5668<\/strong><\/h2>\n<p>driver.quit()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>2. \u4f7f\u7528API\u63a5\u53e3\u91c7\u96c6\u6570\u636e<\/h4>\n<\/p>\n<p><p>\u5f88\u591a\u6587\u732e\u6570\u636e\u5e93\u63d0\u4f9bAPI\u63a5\u53e3\uff0c\u5141\u8bb8\u7528\u6237\u901a\u8fc7\u7f16\u7a0b\u65b9\u5f0f\u83b7\u53d6\u6587\u732e\u6570\u636e\u3002\u4f8b\u5982\uff0cPubMed\u63d0\u4f9b\u4e86Entrez Programming Utilities (E-utilities)\uff0c\u53ef\u4ee5\u4f7f\u7528Python\u7684Biopython\u5e93\u6765\u8bbf\u95eePubMed API\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from Bio import Entrez<\/p>\n<h2><strong>\u8bbe\u7f6eEntrez em<a href=\"https:\/\/docs.pingcode.com\/blog\/59162.html\" target=\"_blank\">AI<\/a>l<\/strong><\/h2>\n<p>Entrez.email = &#39;your_email@example.com&#39;<\/p>\n<h2><strong>\u641c\u7d22\u5173\u952e\u8bcd<\/strong><\/h2>\n<p>search_term = &#39;machine learning&#39;<\/p>\n<p>handle = Entrez.esearch(db=&#39;pubmed&#39;, term=search_term, retmax=10)<\/p>\n<p>record = Entrez.read(handle)<\/p>\n<p>handle.close()<\/p>\n<h2><strong>\u83b7\u53d6\u6587\u732eID\u5217\u8868<\/strong><\/h2>\n<p>id_list = record[&#39;IdList&#39;]<\/p>\n<h2><strong>\u83b7\u53d6\u6587\u732e\u4fe1\u606f<\/strong><\/h2>\n<p>handle = Entrez.efetch(db=&#39;pubmed&#39;, id=id_list, rettype=&#39;abstract&#39;, retmode=&#39;text&#39;)<\/p>\n<p>abstracts = handle.read()<\/p>\n<p>handle.close()<\/p>\n<p>print(abstracts)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u4e8c\u3001\u6587\u672c\u9884\u5904\u7406<\/h3>\n<\/p>\n<p><p>\u83b7\u53d6\u5230\u6587\u732e\u6570\u636e\u540e\uff0c\u9700\u8981\u5bf9\u6587\u672c\u8fdb\u884c\u9884\u5904\u7406\uff0c\u4ee5\u4fbf\u540e\u7eed\u7684\u5206\u6790\u3002\u5e38\u89c1\u7684\u6587\u672c\u9884\u5904\u7406\u6b65\u9aa4\u5305\u62ec\u5206\u8bcd\u3001\u53bb\u9664\u505c\u7528\u8bcd\u3001\u8bcd\u5e72\u63d0\u53d6\u7b49\u3002<\/p>\n<\/p>\n<p><h4>1. \u5206\u8bcd\u548c\u53bb\u9664\u505c\u7528\u8bcd<\/h4>\n<\/p>\n<p><p>\u53ef\u4ee5\u4f7f\u7528NLTK\u5e93\u8fdb\u884c\u5206\u8bcd\u548c\u53bb\u9664\u505c\u7528\u8bcd\u3002NLTK\u63d0\u4f9b\u4e86\u4e30\u5bcc\u7684\u81ea\u7136\u8bed\u8a00\u5904\u7406\u5de5\u5177\u548c\u8d44\u6e90\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import nltk<\/p>\n<p>from nltk.corpus import stopwords<\/p>\n<p>from nltk.tokenize import word_tokenize<\/p>\n<h2><strong>\u4e0b\u8f7d\u505c\u7528\u8bcd<\/strong><\/h2>\n<p>nltk.download(&#39;stopwords&#39;)<\/p>\n<p>nltk.download(&#39;punkt&#39;)<\/p>\n<h2><strong>\u5206\u8bcd<\/strong><\/h2>\n<p>text = &#39;This is a sample text for text processing using NLTK.&#39;<\/p>\n<p>tokens = word_tokenize(text)<\/p>\n<h2><strong>\u53bb\u9664\u505c\u7528\u8bcd<\/strong><\/h2>\n<p>stop_words = set(stopwords.words(&#39;english&#39;))<\/p>\n<p>filtered_tokens = [word for word in tokens if word.lower() not in stop_words]<\/p>\n<p>print(filtered_tokens)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>2. \u8bcd\u5e72\u63d0\u53d6<\/h4>\n<\/p>\n<p><p>\u8bcd\u5e72\u63d0\u53d6\u662f\u5c06\u5355\u8bcd\u8fd8\u539f\u4e3a\u5176\u8bcd\u5e72\u5f62\u5f0f\uff0c\u51cf\u5c11\u8bcd\u5f62\u53d8\u5316\u5e26\u6765\u7684\u566a\u97f3\u3002\u53ef\u4ee5\u4f7f\u7528NLTK\u7684PorterStemmer\u8fdb\u884c\u8bcd\u5e72\u63d0\u53d6\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from nltk.stem import PorterStemmer<\/p>\n<h2><strong>\u8bcd\u5e72\u63d0\u53d6<\/strong><\/h2>\n<p>stemmer = PorterStemmer()<\/p>\n<p>stemmed_tokens = [stemmer.stem(word) for word in filtered_tokens]<\/p>\n<p>print(stemmed_tokens)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u4e09\u3001\u6587\u672c\u5206\u6790<\/h3>\n<\/p>\n<p><p>\u6587\u672c\u9884\u5904\u7406\u5b8c\u6210\u540e\uff0c\u53ef\u4ee5\u8fdb\u884c\u5404\u79cd\u6587\u672c\u5206\u6790\uff0c\u5305\u62ec\u8bcd\u9891\u7edf\u8ba1\u3001\u5171\u73b0\u5206\u6790\u3001\u4e3b\u9898\u5efa\u6a21\u7b49\u3002<\/p>\n<\/p>\n<p><h4>1. \u8bcd\u9891\u7edf\u8ba1<\/h4>\n<\/p>\n<p><p>\u8bcd\u9891\u7edf\u8ba1\u662f\u6700\u57fa\u672c\u7684\u6587\u672c\u5206\u6790\u65b9\u6cd5\uff0c\u53ef\u4ee5\u4f7f\u7528Python\u7684collections\u5e93\u6765\u7edf\u8ba1\u8bcd\u9891\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from collections import Counter<\/p>\n<h2><strong>\u8bcd\u9891\u7edf\u8ba1<\/strong><\/h2>\n<p>word_counts = Counter(stemmed_tokens)<\/p>\n<p>print(word_counts)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>2. \u5171\u73b0\u5206\u6790<\/h4>\n<\/p>\n<p><p>\u5171\u73b0\u5206\u6790\u662f\u7814\u7a76\u6587\u732e\u4e2d\u8bcd\u6c47\u6216\u4e3b\u9898\u4e4b\u95f4\u7684\u5171\u73b0\u5173\u7cfb\uff0c\u53ef\u4ee5\u4f7f\u7528NetworkX\u5e93\u6765\u6784\u5efa\u548c\u5206\u6790\u5171\u73b0\u7f51\u7edc\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import networkx as nx<\/p>\n<h2><strong>\u6784\u5efa\u5171\u73b0\u7f51\u7edc<\/strong><\/h2>\n<p>G = nx.Graph()<\/p>\n<h2><strong>\u6dfb\u52a0\u8282\u70b9\u548c\u8fb9<\/strong><\/h2>\n<p>for word1 in stemmed_tokens:<\/p>\n<p>    for word2 in stemmed_tokens:<\/p>\n<p>        if word1 != word2:<\/p>\n<p>            G.add_edge(word1, word2)<\/p>\n<h2><strong>\u53ef\u89c6\u5316\u5171\u73b0\u7f51\u7edc<\/strong><\/h2>\n<p>nx.draw(G, with_labels=True)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>3. \u4e3b\u9898\u5efa\u6a21<\/h4>\n<\/p>\n<p><p>\u4e3b\u9898\u5efa\u6a21\u662f\u4ece\u6587\u732e\u4e2d\u81ea\u52a8\u63d0\u53d6\u6f5c\u5728\u4e3b\u9898\u7684\u65b9\u6cd5\uff0c\u53ef\u4ee5\u4f7f\u7528Gensim\u5e93\u8fdb\u884cLDA\uff08Latent Dirichlet Allocation\uff09\u4e3b\u9898\u5efa\u6a21\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from gensim import corpora, models<\/p>\n<h2><strong>\u521b\u5efa\u8bcd\u5178<\/strong><\/h2>\n<p>dictionary = corpora.Dictionary([stemmed_tokens])<\/p>\n<h2><strong>\u521b\u5efa\u8bed\u6599\u5e93<\/strong><\/h2>\n<p>corpus = [dictionary.doc2bow(stemmed_tokens)]<\/p>\n<h2><strong>LDA\u4e3b\u9898\u5efa\u6a21<\/strong><\/h2>\n<p>lda_model = models.LdaModel(corpus, num_topics=3, id2word=dictionary, passes=15)<\/p>\n<h2><strong>\u6253\u5370\u4e3b\u9898<\/strong><\/h2>\n<p>for idx, topic in lda_model.print_topics(-1):<\/p>\n<p>    print(f&#39;Topic: {idx} \\nWords: {topic}&#39;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u56db\u3001\u53ef\u89c6\u5316<\/h3>\n<\/p>\n<p><p>\u6587\u672c\u5206\u6790\u7ed3\u679c\u53ef\u4ee5\u901a\u8fc7\u53ef\u89c6\u5316\u7684\u65b9\u5f0f\u5c55\u793a\uff0c\u4ee5\u4fbf\u66f4\u76f4\u89c2\u5730\u7406\u89e3\u548c\u89e3\u91ca\u6570\u636e\u3002\u5e38\u7528\u7684\u53ef\u89c6\u5316\u5de5\u5177\u5305\u62ecMatplotlib\u3001Seaborn\u3001WordCloud\u7b49\u3002<\/p>\n<\/p>\n<p><h4>1. \u8bcd\u4e91\u56fe<\/h4>\n<\/p>\n<p><p>\u8bcd\u4e91\u56fe\u662f\u5c55\u793a\u8bcd\u9891\u7684\u5e38\u7528\u65b9\u6cd5\uff0c\u53ef\u4ee5\u4f7f\u7528WordCloud\u5e93\u751f\u6210\u8bcd\u4e91\u56fe\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from wordcloud import WordCloud<\/p>\n<p>import matplotlib.pyplot as plt<\/p>\n<h2><strong>\u751f\u6210\u8bcd\u4e91\u56fe<\/strong><\/h2>\n<p>wordcloud = WordCloud(width=800, height=400, background_color=&#39;white&#39;).generate_from_frequencies(word_counts)<\/p>\n<h2><strong>\u663e\u793a\u8bcd\u4e91\u56fe<\/strong><\/h2>\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><\/code><\/pre>\n<\/p>\n<p><h4>2. \u8bcd\u9891\u67f1\u72b6\u56fe<\/h4>\n<\/p>\n<p><p>\u53ef\u4ee5\u4f7f\u7528Matplotlib\u548cSeaborn\u5e93\u7ed8\u5236\u8bcd\u9891\u67f1\u72b6\u56fe\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import seaborn as sns<\/p>\n<h2><strong>\u7ed8\u5236\u8bcd\u9891\u67f1\u72b6\u56fe<\/strong><\/h2>\n<p>word_freq = word_counts.most_common(10)<\/p>\n<p>words, frequencies = zip(*word_freq)<\/p>\n<p>plt.figure(figsize=(10, 5))<\/p>\n<p>sns.barplot(x=frequencies, y=words)<\/p>\n<p>plt.xlabel(&#39;Frequency&#39;)<\/p>\n<p>plt.ylabel(&#39;Words&#39;)<\/p>\n<p>plt.title(&#39;Top 10 Words by Frequency&#39;)<\/p>\n<p>plt.show()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>3. \u5171\u73b0\u7f51\u7edc\u56fe<\/h4>\n<\/p>\n<p><p>\u53ef\u4ee5\u4f7f\u7528NetworkX\u5e93\u7ed8\u5236\u5171\u73b0\u7f51\u7edc\u56fe\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">plt.figure(figsize=(10, 10))<\/p>\n<p>nx.draw(G, with_labels=True, node_size=50, node_color=&#39;skyblue&#39;, font_size=10, font_color=&#39;black&#39;, edge_color=&#39;gray&#39;)<\/p>\n<p>plt.title(&#39;Co-occurrence Network&#39;)<\/p>\n<p>plt.show()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u4e94\u3001\u6848\u4f8b\u5206\u6790<\/h3>\n<\/p>\n<p><p>\u4e3a\u4e86\u66f4\u597d\u5730\u7406\u89e3\u5982\u4f55\u7528Python\u8fdb\u884c\u6587\u732e\u8ba1\u91cf\u5206\u6790\uff0c\u6211\u4eec\u901a\u8fc7\u4e00\u4e2a\u5177\u4f53\u7684\u6848\u4f8b\u8fdb\u884c\u6f14\u793a\u3002\u5047\u8bbe\u6211\u4eec\u8981\u5206\u6790\u201c<a href=\"https:\/\/docs.pingcode.com\/ask\/59192.html\" target=\"_blank\">\u673a\u5668\u5b66\u4e60<\/a>\u201d\u9886\u57df\u7684\u6587\u732e\uff0c\u4e3b\u8981\u5173\u6ce8\u6587\u732e\u7684\u53d1\u8868\u8d8b\u52bf\u3001\u4e3b\u8981\u7814\u7a76\u4e3b\u9898\u548c\u7814\u7a76\u70ed\u70b9\u3002<\/p>\n<\/p>\n<p><h4>1. \u6570\u636e\u91c7\u96c6<\/h4>\n<\/p>\n<p><p>\u9996\u5148\uff0c\u901a\u8fc7Selenium\u91c7\u96c6Google Scholar\u4e0a\u7684\u201c\u673a\u5668\u5b66\u4e60\u201d\u76f8\u5173\u6587\u732e\u6570\u636e\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from selenium import webdriver<\/p>\n<p>from selenium.webdriver.common.keys import Keys<\/p>\n<h2><strong>\u8bbe\u7f6eSelenium WebDriver<\/strong><\/h2>\n<p>driver = webdriver.Chrome(executable_path=&#39;path_to_chromedriver&#39;)<\/p>\n<h2><strong>\u6253\u5f00Google Scholar<\/strong><\/h2>\n<p>driver.get(&#39;https:\/\/scholar.google.com&#39;)<\/p>\n<h2><strong>\u641c\u7d22\u5173\u952e\u8bcd<\/strong><\/h2>\n<p>search_box = driver.find_element_by_name(&#39;q&#39;)<\/p>\n<p>search_box.send_keys(&#39;machine learning&#39;)<\/p>\n<p>search_box.send_keys(Keys.RETURN)<\/p>\n<h2><strong>\u91c7\u96c6\u6587\u732e\u4fe1\u606f<\/strong><\/h2>\n<p>results = driver.find_elements_by_css_selector(&#39;div.gs_ri&#39;)<\/p>\n<p>papers = []<\/p>\n<p>for result in results:<\/p>\n<p>    title = result.find_element_by_css_selector(&#39;h3&#39;).text<\/p>\n<p>    authors = result.find_element_by_css_selector(&#39;div.gs_a&#39;).text<\/p>\n<p>    snippet = result.find_element_by_css_selector(&#39;div.gs_rs&#39;).text<\/p>\n<p>    papers.append({&#39;title&#39;: title, &#39;authors&#39;: authors, &#39;snippet&#39;: snippet})<\/p>\n<h2><strong>\u5173\u95ed\u6d4f\u89c8\u5668<\/strong><\/h2>\n<p>driver.quit()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>2. \u6587\u672c\u9884\u5904\u7406<\/h4>\n<\/p>\n<p><p>\u63a5\u4e0b\u6765\uff0c\u5bf9\u91c7\u96c6\u5230\u7684\u6587\u732e\u6570\u636e\u8fdb\u884c\u6587\u672c\u9884\u5904\u7406\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import nltk<\/p>\n<p>from nltk.corpus import stopwords<\/p>\n<p>from nltk.tokenize import word_tokenize<\/p>\n<p>from nltk.stem import PorterStemmer<\/p>\n<p>nltk.download(&#39;stopwords&#39;)<\/p>\n<p>nltk.download(&#39;punkt&#39;)<\/p>\n<h2><strong>\u5206\u8bcd\u548c\u53bb\u9664\u505c\u7528\u8bcd<\/strong><\/h2>\n<p>stop_words = set(stopwords.words(&#39;english&#39;))<\/p>\n<p>stemmer = PorterStemmer()<\/p>\n<p>all_tokens = []<\/p>\n<p>for paper in papers:<\/p>\n<p>    tokens = word_tokenize(paper[&#39;snippet&#39;])<\/p>\n<p>    filtered_tokens = [word for word in tokens if word.lower() not in stop_words]<\/p>\n<p>    stemmed_tokens = [stemmer.stem(word) for word in filtered_tokens]<\/p>\n<p>    all_tokens.extend(stemmed_tokens)<\/p>\n<p>print(all_tokens)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>3. \u6587\u672c\u5206\u6790<\/h4>\n<\/p>\n<p><p>\u8fdb\u884c\u8bcd\u9891\u7edf\u8ba1\u3001\u5171\u73b0\u5206\u6790\u548c\u4e3b\u9898\u5efa\u6a21\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from collections import Counter<\/p>\n<p>import networkx as nx<\/p>\n<p>from gensim import corpora, models<\/p>\n<h2><strong>\u8bcd\u9891\u7edf\u8ba1<\/strong><\/h2>\n<p>word_counts = Counter(all_tokens)<\/p>\n<p>print(word_counts)<\/p>\n<h2><strong>\u5171\u73b0\u5206\u6790<\/strong><\/h2>\n<p>G = nx.Graph()<\/p>\n<p>for word1 in all_tokens:<\/p>\n<p>    for word2 in all_tokens:<\/p>\n<p>        if word1 != word2:<\/p>\n<p>            G.add_edge(word1, word2)<\/p>\n<h2><strong>\u4e3b\u9898\u5efa\u6a21<\/strong><\/h2>\n<p>dictionary = corpora.Dictionary([all_tokens])<\/p>\n<p>corpus = [dictionary.doc2bow(all_tokens)]<\/p>\n<p>lda_model = models.LdaModel(corpus, num_topics=3, id2word=dictionary, passes=15)<\/p>\n<p>for idx, topic in lda_model.print_topics(-1):<\/p>\n<p>    print(f&#39;Topic: {idx} \\nWords: {topic}&#39;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>4. \u53ef\u89c6\u5316<\/h4>\n<\/p>\n<p><p>\u6700\u540e\uff0c\u901a\u8fc7\u8bcd\u4e91\u56fe\u3001\u8bcd\u9891\u67f1\u72b6\u56fe\u548c\u5171\u73b0\u7f51\u7edc\u56fe\u5c55\u793a\u5206\u6790\u7ed3\u679c\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from wordcloud import WordCloud<\/p>\n<p>import matplotlib.pyplot as plt<\/p>\n<p>import seaborn as sns<\/p>\n<h2><strong>\u8bcd\u4e91\u56fe<\/strong><\/h2>\n<p>wordcloud = WordCloud(width=800, height=400, background_color=&#39;white&#39;).generate_from_frequencies(word_counts)<\/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>\u8bcd\u9891\u67f1\u72b6\u56fe<\/strong><\/h2>\n<p>word_freq = word_counts.most_common(10)<\/p>\n<p>words, frequencies = zip(*word_freq)<\/p>\n<p>plt.figure(figsize=(10, 5))<\/p>\n<p>sns.barplot(x=frequencies, y=words)<\/p>\n<p>plt.xlabel(&#39;Frequency&#39;)<\/p>\n<p>plt.ylabel(&#39;Words&#39;)<\/p>\n<p>plt.title(&#39;Top 10 Words by Frequency&#39;)<\/p>\n<p>plt.show()<\/p>\n<h2><strong>\u5171\u73b0\u7f51\u7edc\u56fe<\/strong><\/h2>\n<p>plt.figure(figsize=(10, 10))<\/p>\n<p>nx.draw(G, with_labels=True, node_size=50, node_color=&#39;skyblue&#39;, font_size=10, font_color=&#39;black&#39;, edge_color=&#39;gray&#39;)<\/p>\n<p>plt.title(&#39;Co-occurrence Network&#39;)<\/p>\n<p>plt.show()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u603b\u7ed3<\/h3>\n<\/p>\n<p><p>\u901a\u8fc7\u672c\u6587\u7684\u4ecb\u7ecd\uff0c\u6211\u4eec\u8be6\u7ec6\u9610\u8ff0\u4e86\u5982\u4f55\u7528Python\u8fdb\u884c\u6587\u732e\u8ba1\u91cf\u5206\u6790\u7684\u6574\u4e2a\u6d41\u7a0b\uff0c\u5305\u62ec\u6570\u636e\u91c7\u96c6\u3001\u6587\u672c\u9884\u5904\u7406\u3001\u6587\u672c\u5206\u6790\u548c\u53ef\u89c6\u5316\u3002\u5229\u7528Python\u5f3a\u5927\u7684\u5e93\u548c\u5de5\u5177\uff0c\u6211\u4eec\u53ef\u4ee5\u9ad8\u6548\u5730\u91c7\u96c6\u548c\u5206\u6790\u6587\u732e\u6570\u636e\uff0c\u4ece\u800c\u6316\u6398\u6587\u732e\u4e2d\u7684\u6709\u4ef7\u503c\u4fe1\u606f\uff0c\u63ed\u793a\u7814\u7a76\u9886\u57df\u7684\u53d1\u5c55\u8d8b\u52bf\u548c\u70ed\u70b9\u3002\u5e0c\u671b\u672c\u6587\u80fd\u4e3a\u7814\u7a76\u8005\u63d0\u4f9b\u6709\u76ca\u7684\u53c2\u8003\uff0c\u52a9\u529b\u4ed6\u4eec\u5728\u6587\u732e\u8ba1\u91cf\u7814\u7a76\u4e2d\u53d6\u5f97\u66f4\u597d\u7684\u6210\u679c\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u6587\u732e\u8ba1\u91cf\u662f\u4ec0\u4e48\uff0c\u4e3a\u4ec0\u4e48\u8981\u4f7f\u7528Python\u8fdb\u884c\u6587\u732e\u8ba1\u91cf\u5206\u6790\uff1f<\/strong><br \/>\u6587\u732e\u8ba1\u91cf\u662f\u5bf9\u6587\u732e\u8fdb\u884c\u5b9a\u91cf\u5206\u6790\u7684\u5b66\u79d1\uff0c\u4e3b\u8981\u7528\u4e8e\u7814\u7a76\u6587\u732e\u7684\u751f\u4ea7\u3001\u4f20\u64ad\u53ca\u5176\u5f71\u54cd\u529b\u3002\u4f7f\u7528Python\u8fdb\u884c\u6587\u732e\u8ba1\u91cf\u5206\u6790\u7684\u539f\u56e0\u5728\u4e8e\u5176\u5f3a\u5927\u7684\u6570\u636e\u5904\u7406\u548c\u53ef\u89c6\u5316\u80fd\u529b\u3002Python\u63d0\u4f9b\u4e86\u4e30\u5bcc\u7684\u5e93\uff0c\u5982Pandas\u3001NumPy\u548cMatplotlib\uff0c\u80fd\u591f\u8f7b\u677e\u5904\u7406\u5927\u89c4\u6a21\u6587\u732e\u6570\u636e\uff0c\u8fdb\u884c\u7edf\u8ba1\u5206\u6790\u548c\u53ef\u89c6\u5316\u5c55\u793a\uff0c\u4ece\u800c\u5e2e\u52a9\u7814\u7a76\u4eba\u5458\u4e86\u89e3\u6587\u732e\u7684\u8d8b\u52bf\u548c\u6a21\u5f0f\u3002<\/p>\n<p><strong>\u5982\u4f55\u83b7\u53d6\u6587\u732e\u6570\u636e\u7528\u4e8e\u6587\u732e\u8ba1\u91cf\u5206\u6790\uff1f<\/strong><br \/>\u83b7\u53d6\u6587\u732e\u6570\u636e\u53ef\u4ee5\u901a\u8fc7\u591a\u79cd\u6e20\u9053\uff0c\u5305\u62ec\u5b66\u672f\u6570\u636e\u5e93\uff08\u5982Web of Science\u3001Scopus\u3001Google Scholar\u7b49\uff09\uff0c\u4ee5\u53ca\u5f00\u653e\u83b7\u53d6\u7684API\uff08\u5982CrossRef\u548cPubMed\uff09\u3002Python\u4e2d\u53ef\u4ee5\u4f7f\u7528Requests\u5e93\u6765\u6293\u53d6\u7f51\u9875\u6570\u636e\uff0c\u6216\u8005\u5229\u7528\u73b0\u6210\u7684\u5e93\u5982PySciHub\u3001pybliometrics\u7b49\u76f4\u63a5\u4ece\u6570\u636e\u5e93\u4e2d\u4e0b\u8f7d\u6587\u732e\u6570\u636e\u3002\u786e\u4fdd\u9075\u5faa\u5404\u5e73\u53f0\u7684\u4f7f\u7528\u653f\u7b56\uff0c\u5408\u6cd5\u83b7\u53d6\u6570\u636e\u3002<\/p>\n<p><strong>\u5728Python\u4e2d\u5982\u4f55\u8fdb\u884c\u6587\u732e\u8ba1\u91cf\u7684\u53ef\u89c6\u5316\uff1f<\/strong><br \/>\u5728Python\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528Matplotlib\u548cSeaborn\u7b49\u5e93\u8fdb\u884c\u6587\u732e\u8ba1\u91cf\u7684\u53ef\u89c6\u5316\u3002\u901a\u8fc7\u8fd9\u4e9b\u5e93\uff0c\u53ef\u4ee5\u521b\u5efa\u5404\u79cd\u7c7b\u578b\u7684\u56fe\u8868\uff0c\u5982\u67f1\u72b6\u56fe\u3001\u6298\u7ebf\u56fe\u548c\u70ed\u56fe\uff0c\u6765\u5c55\u793a\u6587\u732e\u7684\u5f15\u7528\u8d8b\u52bf\u3001\u5408\u4f5c\u7f51\u7edc\u548c\u4e3b\u9898\u5206\u5e03\u3002\u4f7f\u7528\u8fd9\u4e9b\u53ef\u89c6\u5316\u5de5\u5177\uff0c\u53ef\u4ee5\u66f4\u76f4\u89c2\u5730\u7406\u89e3\u6587\u732e\u6570\u636e\uff0c\u63ed\u793a\u6f5c\u5728\u7684\u7814\u7a76\u70ed\u70b9\u548c\u53d1\u5c55\u65b9\u5411\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u5982\u4f55\u7528Python\u8fdb\u884c\u6587\u732e\u8ba1\u91cf Python\u8fdb\u884c\u6587\u732e\u8ba1\u91cf\u7684\u65b9\u6cd5\u5305\u62ec\uff1a\u6570\u636e\u91c7\u96c6\u3001\u6587\u672c\u9884\u5904\u7406\u3001\u6587\u672c\u5206\u6790\u3001\u53ef\u89c6\u5316\u3002\u672c [&hellip;]","protected":false},"author":3,"featured_media":1098887,"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\/1098881"}],"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=1098881"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1098881\/revisions"}],"predecessor-version":[{"id":1098888,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1098881\/revisions\/1098888"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1098887"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1098881"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1098881"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1098881"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}