{"id":1050128,"date":"2024-12-31T14:05:15","date_gmt":"2024-12-31T06:05:15","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1050128.html"},"modified":"2024-12-31T14:05:17","modified_gmt":"2024-12-31T06:05:17","slug":"python%e4%b8%ad%e5%a6%82%e4%bd%95%e5%ae%9e%e7%8e%b0%e6%90%9c%e7%b4%a2%e5%bc%95%e6%93%8e","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/1050128.html","title":{"rendered":"python\u4e2d\u5982\u4f55\u5b9e\u73b0\u641c\u7d22\u5f15\u64ce"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-docs.pingcode.com\/wp-content\/uploads\/2024\/12\/466ac42b-56f3-48c0-8a1f-5866962dc489.webp?x-oss-process=image\/auto-orient,1\/format,webp\" alt=\"python\u4e2d\u5982\u4f55\u5b9e\u73b0\u641c\u7d22\u5f15\u64ce\" \/><\/p>\n<p><p> <strong>Python\u4e2d\u5b9e\u73b0\u641c\u7d22\u5f15\u64ce\u7684\u65b9\u6cd5\u5305\u62ec\uff1a\u57fa\u4e8e\u6587\u672c\u7684\u641c\u7d22\u3001\u57fa\u4e8e\u6570\u636e\u5e93\u7684\u641c\u7d22\u3001\u57fa\u4e8e\u5012\u6392\u7d22\u5f15\u7684\u641c\u7d22\u3001\u4f7f\u7528\u73b0\u6709\u7684\u641c\u7d22\u5f15\u64ce\u5e93\uff08\u5982Whoosh\u3001Elasticsearch\uff09\u7b49\u3002<\/strong> \u5176\u4e2d\uff0c\u57fa\u4e8e\u5012\u6392\u7d22\u5f15\u7684\u641c\u7d22\u548c\u4f7f\u7528\u73b0\u6709\u7684\u641c\u7d22\u5f15\u64ce\u5e93\u662f\u6700\u5e38\u89c1\u548c\u6709\u6548\u7684\u65b9\u6cd5\u3002\u57fa\u4e8e\u5012\u6392\u7d22\u5f15\u7684\u641c\u7d22\u53ef\u4ee5\u5b9e\u73b0\u5feb\u901f\u7684\u5168\u6587\u68c0\u7d22\uff0c\u800c\u4f7f\u7528\u73b0\u6709\u7684\u641c\u7d22\u5f15\u64ce\u5e93\u53ef\u4ee5\u5229\u7528\u5176\u4f18\u5316\u7684\u7b97\u6cd5\u548c\u5f3a\u5927\u7684\u529f\u80fd\u6765\u5b9e\u73b0\u9ad8\u6548\u7684\u641c\u7d22\u3002<\/p>\n<\/p>\n<p><h3>\u4e00\u3001\u57fa\u4e8e\u6587\u672c\u7684\u641c\u7d22<\/h3>\n<\/p>\n<p><p>\u57fa\u4e8e\u6587\u672c\u7684\u641c\u7d22\u662f\u6700\u57fa\u672c\u7684\u641c\u7d22\u65b9\u5f0f\uff0c\u9002\u7528\u4e8e\u5c0f\u89c4\u6a21\u6570\u636e\u96c6\u3002\u5176\u4e3b\u8981\u601d\u60f3\u662f\u9010\u884c\u8bfb\u53d6\u6587\u4ef6\u5185\u5bb9\uff0c\u7136\u540e\u4f7f\u7528\u6b63\u5219\u8868\u8fbe\u5f0f\u6216\u5b57\u7b26\u4e32\u5339\u914d\u7684\u65b9\u6cd5\u67e5\u627e\u76ee\u6807\u5173\u952e\u8bcd\u3002<\/p>\n<\/p>\n<p><h4>1\u3001\u8bfb\u53d6\u6587\u4ef6\u5185\u5bb9<\/h4>\n<\/p>\n<p><p>\u9996\u5148\uff0c\u9700\u8981\u8bfb\u53d6\u5f85\u641c\u7d22\u7684\u6587\u4ef6\u5185\u5bb9\uff0c\u53ef\u4ee5\u4f7f\u7528Python\u5185\u7f6e\u7684<code>open<\/code>\u51fd\u6570\u8bfb\u53d6\u6587\u4ef6\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">def read_file(file_path):<\/p>\n<p>    with open(file_path, &#39;r&#39;, encoding=&#39;utf-8&#39;) as file:<\/p>\n<p>        content = file.read()<\/p>\n<p>    return content<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>2\u3001\u5b57\u7b26\u4e32\u5339\u914d<\/h4>\n<\/p>\n<p><p>\u4f7f\u7528Python\u7684\u5b57\u7b26\u4e32\u5339\u914d\u51fd\u6570\u67e5\u627e\u76ee\u6807\u5173\u952e\u8bcd\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">def simple_search(content, keyword):<\/p>\n<p>    return keyword in content<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>3\u3001\u6b63\u5219\u8868\u8fbe\u5f0f\u5339\u914d<\/h4>\n<\/p>\n<p><p>\u4f7f\u7528\u6b63\u5219\u8868\u8fbe\u5f0f\u8fdb\u884c\u66f4\u590d\u6742\u7684\u5339\u914d\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import re<\/p>\n<p>def regex_search(content, pattern):<\/p>\n<p>    return re.findall(pattern, content)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u4e8c\u3001\u57fa\u4e8e\u6570\u636e\u5e93\u7684\u641c\u7d22<\/h3>\n<\/p>\n<p><p>\u5bf9\u4e8e\u4e2d\u7b49\u89c4\u6a21\u7684\u6570\u636e\u96c6\uff0c\u53ef\u4ee5\u4f7f\u7528\u6570\u636e\u5e93\u8fdb\u884c\u641c\u7d22\u3002\u5e38\u89c1\u7684\u6570\u636e\u5e93\u6709MySQL\u3001PostgreSQL\u3001SQLite\u7b49\u3002<\/p>\n<\/p>\n<p><h4>1\u3001\u5efa\u7acb\u6570\u636e\u5e93<\/h4>\n<\/p>\n<p><p>\u9996\u5148\uff0c\u9700\u8981\u521b\u5efa\u6570\u636e\u5e93\u548c\u8868\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-sql\">CREATE TABLE documents (<\/p>\n<p>    id INT PRIMARY KEY,<\/p>\n<p>    content TEXT<\/p>\n<p>);<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>2\u3001\u63d2\u5165\u6570\u636e<\/h4>\n<\/p>\n<p><p>\u5c06\u6587\u4ef6\u5185\u5bb9\u63d2\u5165\u5230\u6570\u636e\u5e93\u4e2d\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import sqlite3<\/p>\n<p>def insert_data(db_path, data):<\/p>\n<p>    conn = sqlite3.connect(db_path)<\/p>\n<p>    cursor = conn.cursor()<\/p>\n<p>    cursor.executemany(&#39;INSERT INTO documents (id, content) VALUES (?, ?)&#39;, data)<\/p>\n<p>    conn.commit()<\/p>\n<p>    conn.close()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>3\u3001\u6267\u884c\u641c\u7d22<\/h4>\n<\/p>\n<p><p>\u4f7f\u7528SQL\u67e5\u8be2\u8fdb\u884c\u641c\u7d22\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">def search_db(db_path, keyword):<\/p>\n<p>    conn = sqlite3.connect(db_path)<\/p>\n<p>    cursor = conn.cursor()<\/p>\n<p>    cursor.execute(&#39;SELECT * FROM documents WHERE content LIKE ?&#39;, (&#39;%&#39; + keyword + &#39;%&#39;,))<\/p>\n<p>    results = cursor.fetchall()<\/p>\n<p>    conn.close()<\/p>\n<p>    return results<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u4e09\u3001\u57fa\u4e8e\u5012\u6392\u7d22\u5f15\u7684\u641c\u7d22<\/h3>\n<\/p>\n<p><p>\u5012\u6392\u7d22\u5f15\u662f\u4e00\u79cd\u9ad8\u6548\u7684\u5168\u6587\u68c0\u7d22\u65b9\u6cd5\u3002\u5176\u4e3b\u8981\u601d\u60f3\u662f\u5c06\u6bcf\u4e2a\u5173\u952e\u8bcd\u4e0e\u5305\u542b\u8be5\u5173\u952e\u8bcd\u7684\u6587\u6863\u5217\u8868\u5173\u8054\u8d77\u6765\uff0c\u4ece\u800c\u5b9e\u73b0\u5feb\u901f\u641c\u7d22\u3002<\/p>\n<\/p>\n<p><h4>1\u3001\u6784\u5efa\u5012\u6392\u7d22\u5f15<\/h4>\n<\/p>\n<p><p>\u9996\u5148\uff0c\u9700\u8981\u6784\u5efa\u5012\u6392\u7d22\u5f15\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from collections import defaultdict<\/p>\n<p>def build_inverted_index(docs):<\/p>\n<p>    inverted_index = defaultdict(list)<\/p>\n<p>    for doc_id, content in docs.items():<\/p>\n<p>        for word in content.split():<\/p>\n<p>            inverted_index[word].append(doc_id)<\/p>\n<p>    return inverted_index<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>2\u3001\u6267\u884c\u641c\u7d22<\/h4>\n<\/p>\n<p><p>\u4f7f\u7528\u5012\u6392\u7d22\u5f15\u8fdb\u884c\u641c\u7d22\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">def search_inverted_index(inverted_index, keyword):<\/p>\n<p>    return inverted_index.get(keyword, [])<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u56db\u3001\u4f7f\u7528\u73b0\u6709\u7684\u641c\u7d22\u5f15\u64ce\u5e93<\/h3>\n<\/p>\n<p><p>\u4f7f\u7528\u73b0\u6709\u7684\u641c\u7d22\u5f15\u64ce\u5e93\u53ef\u4ee5\u5927\u5927\u7b80\u5316\u641c\u7d22\u5f15\u64ce\u7684\u5b9e\u73b0\u8fc7\u7a0b\u3002\u5e38\u7528\u7684\u641c\u7d22\u5f15\u64ce\u5e93\u6709Whoosh\u548cElasticsearch\u3002<\/p>\n<\/p>\n<p><h4>1\u3001\u4f7f\u7528Whoosh<\/h4>\n<\/p>\n<p><p>Whoosh\u662f\u4e00\u4e2a\u7eafPython\u7f16\u5199\u7684\u641c\u7d22\u5f15\u64ce\u5e93\uff0c\u9002\u7528\u4e8e\u5c0f\u578b\u9879\u76ee\u3002<\/p>\n<\/p>\n<p><h5>\u5b89\u88c5Whoosh<\/h5>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install Whoosh<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h5>\u521b\u5efa\u7d22\u5f15<\/h5>\n<\/p>\n<p><pre><code class=\"language-python\">from whoosh.index import create_in<\/p>\n<p>from whoosh.fields import Schema, TEXT<\/p>\n<p>def create_index(index_dir, docs):<\/p>\n<p>    schema = Schema(id=TEXT(stored=True), content=TEXT)<\/p>\n<p>    if not os.path.exists(index_dir):<\/p>\n<p>        os.mkdir(index_dir)<\/p>\n<p>    ix = create_in(index_dir, schema)<\/p>\n<p>    writer = ix.writer()<\/p>\n<p>    for doc_id, content in docs.items():<\/p>\n<p>        writer.add_document(id=doc_id, content=content)<\/p>\n<p>    writer.commit()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h5>\u6267\u884c\u641c\u7d22<\/h5>\n<\/p>\n<p><pre><code class=\"language-python\">from whoosh.qparser import QueryParser<\/p>\n<p>def search_whoosh(index_dir, keyword):<\/p>\n<p>    ix = open_dir(index_dir)<\/p>\n<p>    with ix.searcher() as searcher:<\/p>\n<p>        query = QueryParser(&quot;content&quot;, ix.schema).parse(keyword)<\/p>\n<p>        results = searcher.search(query)<\/p>\n<p>        return [result[&#39;id&#39;] for result in results]<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>2\u3001\u4f7f\u7528Elasticsearch<\/h4>\n<\/p>\n<p><p>Elasticsearch\u662f\u4e00\u4e2a\u5206\u5e03\u5f0f\u641c\u7d22\u5f15\u64ce\uff0c\u9002\u7528\u4e8e\u5927\u89c4\u6a21\u6570\u636e\u96c6\u3002<\/p>\n<\/p>\n<p><h5>\u5b89\u88c5Elasticsearch<\/h5>\n<\/p>\n<p><p>\u9996\u5148\uff0c\u9700\u8981\u5b89\u88c5Elasticsearch\u5e76\u542f\u52a8\u670d\u52a1\u3002<\/p>\n<\/p>\n<p><h5>\u5b89\u88c5Elasticsearch Python\u5ba2\u6237\u7aef<\/h5>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install elasticsearch<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h5>\u521b\u5efa\u7d22\u5f15<\/h5>\n<\/p>\n<p><pre><code class=\"language-python\">from elasticsearch import Elasticsearch<\/p>\n<p>def create_index(es, index_name, docs):<\/p>\n<p>    es.indices.create(index=index_name, ignore=400)<\/p>\n<p>    for doc_id, content in docs.items():<\/p>\n<p>        es.index(index=index_name, id=doc_id, body={&#39;content&#39;: content})<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h5>\u6267\u884c\u641c\u7d22<\/h5>\n<\/p>\n<p><pre><code class=\"language-python\">def search_elasticsearch(es, index_name, keyword):<\/p>\n<p>    body = {<\/p>\n<p>        &quot;query&quot;: {<\/p>\n<p>            &quot;match&quot;: {<\/p>\n<p>                &quot;content&quot;: keyword<\/p>\n<p>            }<\/p>\n<p>        }<\/p>\n<p>    }<\/p>\n<p>    results = es.search(index=index_name, body=body)<\/p>\n<p>    return [hit[&#39;_id&#39;] for hit in results[&#39;hits&#39;][&#39;hits&#39;]]<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u4e94\u3001\u4f18\u5316\u641c\u7d22\u5f15\u64ce<\/h3>\n<\/p>\n<p><p>\u65e0\u8bba\u4f7f\u7528\u54ea\u79cd\u641c\u7d22\u65b9\u6cd5\uff0c\u90fd\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u51e0\u79cd\u65b9\u6cd5\u4f18\u5316\u641c\u7d22\u5f15\u64ce\u7684\u6027\u80fd\u3002<\/p>\n<\/p>\n<p><h4>1\u3001\u5efa\u7acb\u7d22\u5f15<\/h4>\n<\/p>\n<p><p>\u5efa\u7acb\u7d22\u5f15\u53ef\u4ee5\u5927\u5927\u63d0\u9ad8\u641c\u7d22\u901f\u5ea6\u3002\u5e38\u89c1\u7684\u7d22\u5f15\u7c7b\u578b\u6709\u5012\u6392\u7d22\u5f15\u3001B\u6811\u7d22\u5f15\u7b49\u3002<\/p>\n<\/p>\n<p><h4>2\u3001\u7f13\u5b58\u641c\u7d22\u7ed3\u679c<\/h4>\n<\/p>\n<p><p>\u5bf9\u4e8e\u9891\u7e41\u67e5\u8be2\u7684\u5173\u952e\u8bcd\uff0c\u53ef\u4ee5\u5c06\u641c\u7d22\u7ed3\u679c\u7f13\u5b58\u8d77\u6765\uff0c\u907f\u514d\u91cd\u590d\u8ba1\u7b97\u3002<\/p>\n<\/p>\n<p><h4>3\u3001\u5206\u8bcd\u5904\u7406<\/h4>\n<\/p>\n<p><p>\u5728\u8fdb\u884c\u641c\u7d22\u4e4b\u524d\uff0c\u53ef\u4ee5\u5bf9\u6587\u672c\u8fdb\u884c\u5206\u8bcd\u5904\u7406\uff0c\u5c06\u6587\u672c\u62c6\u5206\u6210\u5355\u72ec\u7684\u8bcd\u8bed\uff0c\u63d0\u9ad8\u641c\u7d22\u7684\u51c6\u786e\u6027\u3002<\/p>\n<\/p>\n<p><h4>4\u3001\u4f7f\u7528\u591a\u7ebf\u7a0b\u6216\u5f02\u6b65\u5904\u7406<\/h4>\n<\/p>\n<p><p>\u5bf9\u4e8e\u5927\u89c4\u6a21\u7684\u6570\u636e\u96c6\uff0c\u53ef\u4ee5\u4f7f\u7528\u591a\u7ebf\u7a0b\u6216\u5f02\u6b65\u5904\u7406\u7684\u65b9\u6cd5\uff0c\u63d0\u9ad8\u641c\u7d22\u5f15\u64ce\u7684\u54cd\u5e94\u901f\u5ea6\u3002<\/p>\n<\/p>\n<p><h3>\u603b\u7ed3<\/h3>\n<\/p>\n<p><p>\u672c\u6587\u4ecb\u7ecd\u4e86\u5728Python\u4e2d\u5b9e\u73b0\u641c\u7d22\u5f15\u64ce\u7684\u591a\u79cd\u65b9\u6cd5\uff0c\u5305\u62ec\u57fa\u4e8e\u6587\u672c\u7684\u641c\u7d22\u3001\u57fa\u4e8e\u6570\u636e\u5e93\u7684\u641c\u7d22\u3001\u57fa\u4e8e\u5012\u6392\u7d22\u5f15\u7684\u641c\u7d22\u3001\u4f7f\u7528\u73b0\u6709\u7684\u641c\u7d22\u5f15\u64ce\u5e93\u7b49\u3002\u6bcf\u79cd\u65b9\u6cd5\u90fd\u6709\u5176\u9002\u7528\u7684\u573a\u666f\u548c\u4f18\u7f3a\u70b9\uff0c\u5177\u4f53\u9009\u62e9\u54ea\u79cd\u65b9\u6cd5\u53d6\u51b3\u4e8e\u6570\u636e\u89c4\u6a21\u548c\u641c\u7d22\u9700\u6c42\u3002\u901a\u8fc7\u5408\u7406\u4f7f\u7528\u7d22\u5f15\u3001\u7f13\u5b58\u3001\u5206\u8bcd\u3001\u591a\u7ebf\u7a0b\u7b49\u4f18\u5316\u6280\u672f\uff0c\u53ef\u4ee5\u8fdb\u4e00\u6b65\u63d0\u9ad8\u641c\u7d22\u5f15\u64ce\u7684\u6027\u80fd\u3002\u5e0c\u671b\u672c\u6587\u5bf9\u5b9e\u73b0\u4e00\u4e2a\u9ad8\u6548\u7684\u641c\u7d22\u5f15\u64ce\u6709\u6240\u5e2e\u52a9\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u5728Python\u4e2d\u6784\u5efa\u4e00\u4e2a\u7b80\u5355\u7684\u641c\u7d22\u5f15\u64ce\uff1f<\/strong><br \/>\u6784\u5efa\u7b80\u5355\u7684\u641c\u7d22\u5f15\u64ce\u53ef\u4ee5\u901a\u8fc7\u51e0\u4e2a\u6b65\u9aa4\u5b9e\u73b0\u3002\u9996\u5148\uff0c\u60a8\u9700\u8981\u6536\u96c6\u6570\u636e\uff0c\u53ef\u4ee5\u4f7f\u7528\u722c\u866b\u6293\u53d6\u7f51\u9875\u5185\u5bb9\u3002\u63a5\u4e0b\u6765\uff0c\u4f7f\u7528\u6587\u672c\u5904\u7406\u5e93\uff08\u5982NLTK\u6216spaCy\uff09\u5bf9\u6293\u53d6\u7684\u6570\u636e\u8fdb\u884c\u6e05\u6d17\u548c\u5206\u8bcd\u3002\u7136\u540e\uff0c\u4f7f\u7528\u7d22\u5f15\u7b97\u6cd5\uff08\u5982\u5012\u6392\u7d22\u5f15\uff09\u6765\u5b58\u50a8\u548c\u5feb\u901f\u68c0\u7d22\u4fe1\u606f\u3002\u6700\u540e\uff0c\u60a8\u53ef\u4ee5\u5b9e\u73b0\u4e00\u4e2a\u67e5\u8be2\u63a5\u53e3\uff0c\u8ba9\u7528\u6237\u8f93\u5165\u5173\u952e\u8bcd\u5e76\u8fd4\u56de\u76f8\u5173\u7ed3\u679c\u3002<\/p>\n<p><strong>Python\u641c\u7d22\u5f15\u64ce\u7684\u6027\u80fd\u5982\u4f55\u4f18\u5316\uff1f<\/strong><br \/>\u4e3a\u4e86\u63d0\u5347Python\u641c\u7d22\u5f15\u64ce\u7684\u6027\u80fd\uff0c\u53ef\u4ee5\u8003\u8651\u4f7f\u7528\u591a\u7ebf\u7a0b\u6216\u5f02\u6b65\u7f16\u7a0b\u6765\u5904\u7406\u8bf7\u6c42\uff0c\u63d0\u9ad8\u54cd\u5e94\u901f\u5ea6\u3002\u540c\u65f6\uff0c\u9009\u62e9\u5408\u9002\u7684\u6570\u636e\u7ed3\u6784\uff08\u5982Trie\u6811\u6216BK\u6811\uff09\u6765\u4f18\u5316\u641c\u7d22\u7b97\u6cd5\u3002\u6b64\u5916\uff0c\u4f7f\u7528\u7f13\u5b58\u673a\u5236\uff08\u5982Redis\uff09\u6765\u5b58\u50a8\u9891\u7e41\u67e5\u8be2\u7684\u7ed3\u679c\uff0c\u80fd\u591f\u663e\u8457\u51cf\u5c11\u6570\u636e\u5e93\u8bbf\u95ee\u6b21\u6570\uff0c\u4ece\u800c\u63d0\u5347\u6574\u4f53\u6027\u80fd\u3002<\/p>\n<p><strong>\u5728Python\u4e2d\u5982\u4f55\u5904\u7406\u641c\u7d22\u5f15\u64ce\u4e2d\u7684\u81ea\u7136\u8bed\u8a00\u67e5\u8be2\uff1f<\/strong><br \/>\u5904\u7406\u81ea\u7136\u8bed\u8a00\u67e5\u8be2\u53ef\u4ee5\u901a\u8fc7\u81ea\u7136\u8bed\u8a00\u5904\u7406\u6280\u672f\u5b9e\u73b0\u3002\u4f7f\u7528\u5206\u8bcd\u548c\u8bcd\u6027\u6807\u6ce8\u53ef\u4ee5\u5e2e\u52a9\u7406\u89e3\u7528\u6237\u7684\u610f\u56fe\u3002\u60a8\u53ef\u4ee5\u4f7f\u7528TF-IDF\u6216Word2Vec\u7b49\u6a21\u578b\u6765\u8ba1\u7b97\u5173\u952e\u8bcd\u7684\u76f8\u5173\u6027\u3002\u7ed3\u5408\u4e0a\u4e0b\u6587\u7406\u89e3\u548c\u540c\u4e49\u8bcd\u6269\u5c55\uff0c\u53ef\u4ee5\u8fdb\u4e00\u6b65\u63d0\u5347\u641c\u7d22\u7ed3\u679c\u7684\u51c6\u786e\u6027\u3002\u6b64\u5916\uff0c\u5229\u7528<a href=\"https:\/\/docs.pingcode.com\/ask\/59192.html\" target=\"_blank\">\u673a\u5668\u5b66\u4e60<\/a>\u7b97\u6cd5\u8fdb\u884c\u67e5\u8be2\u610f\u56fe\u5206\u7c7b\uff0c\u4e5f\u80fd\u6539\u5584\u7528\u6237\u4f53\u9a8c\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"Python\u4e2d\u5b9e\u73b0\u641c\u7d22\u5f15\u64ce\u7684\u65b9\u6cd5\u5305\u62ec\uff1a\u57fa\u4e8e\u6587\u672c\u7684\u641c\u7d22\u3001\u57fa\u4e8e\u6570\u636e\u5e93\u7684\u641c\u7d22\u3001\u57fa\u4e8e\u5012\u6392\u7d22\u5f15\u7684\u641c\u7d22\u3001\u4f7f\u7528\u73b0\u6709\u7684\u641c\u7d22\u5f15\u64ce [&hellip;]","protected":false},"author":3,"featured_media":1050132,"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\/1050128"}],"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=1050128"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1050128\/revisions"}],"predecessor-version":[{"id":1050135,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1050128\/revisions\/1050135"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1050132"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1050128"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1050128"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1050128"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}