UNPKG

@mhg/blog

Version:
17 lines 320 kB
<!DOCTYPE html><html lang="zh-Hans"><head hexo-theme="https://github.com/volantis-x/hexo-theme-volantis/#6.8.2"><meta name="generator" content="Hexo 8.1.2"><meta name="Volantis" content="6.8.2"><meta charset="utf-8"><meta name="robots" content="index,follow, max-image-preview:large"><link rel="canonical" href="https://blog.mhuig.top/p/175a1706/"><meta http-equiv="x-dns-prefetch-control" content="on"><link rel="dns-prefetch" href="https://static.mhuig.top"><link rel="preconnect" href="https://static.mhuig.top" crossorigin><link rel="dns-prefetch" href="https://cdnjs.cloudflare.com"><link rel="preconnect" href="https://cdnjs.cloudflare.com" crossorigin><meta name="renderer" content="webkit"><meta name="force-rendering" content="webkit"><meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1"><meta name="HandheldFriendly" content="True"><meta name="mobile-web-app-capable" content="yes"><meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=5"><meta content="black-translucent" name="apple-mobile-web-app-status-bar-style"><meta content="telephone=no" name="format-detection"><script>function regSW(e){"localhost"!=window.location.hostname&&"serviceWorker"in navigator&&navigator.serviceWorker.register(`${e}`).then(function(e){"localhost"==window.location.hostname&&(e.onupdatefound=function(){var r=e.installing;r.onstatechange=function(){switch(r.state){case"installed":navigator.serviceWorker.controller?console.log("Updated Service Worker."):console.log("Service Worker Success!");break;case"redundant":console.log("The installing service worker became redundant.")}}})}).catch(function(e){console.error("Error during service worker registration:",e),"undefined"==typeof swinstallretry&&(swinstallretry=1,regSW("/vue.js"))})}"serviceWorker"in navigator&&Object.freeze(navigator.serviceWorker),regSW("/vue.js")</script><link rel="apple-touch-icon" sizes="180x180" href="/lib/favicon/apple-touch-icon.png"><link rel="icon" type="image/png" sizes="32x32" href="/lib/favicon/favicon-32x32.png"><link rel="icon" type="image/png" sizes="192x192" href="/lib/favicon/android-chrome-192x192.png"><link rel="icon" type="image/png" sizes="144x144" href="/lib/favicon/android-chrome-144x144.png"><link rel="icon" type="image/png" sizes="16x16" href="/lib/favicon/favicon-16x16.png"><link rel="manifest" href="/lib/favicon/site.webmanifest"><link rel="mask-icon" href="/lib/favicon/safari-pinned-tab.svg" color="#5bbad5"><meta name="apple-mobile-web-app-title" content="MHuiG Magicland"><meta name="apple-mobile-web-app-status-bar-style" content="black"><meta name="application-name" content="MHuiG Magicland"><meta name="msapplication-TileColor" content="#87ceeb"><meta name="msapplication-TileImage" content="/lib/favicon/mstile-144x144.png"><meta name="theme-color" content="#87ceeb" media="(prefers-color-scheme: light)"><meta name="theme-color" content="#21232f" media="(prefers-color-scheme: dark)"><link href="/opensearch.xml" rel="search" title="MHuiG Magicland" type="application/opensearchdescription+xml"><link rel="sitemap" type="application/xml" title="MHuiG Blog Site Map" href="https://blog.mhuig.top/sitemap.xml"><link rel="author" href="https://mhuig.top"><meta name="author" content="MHuiG"><meta name="creator" content="MHuiG"><link rel="archives" href="https://blog.mhuig.top/archives/"><meta http-equiv="Content-Security-Policy" content="frame-src 'self' https://giscus.app https://bilibili.com https://player.bilibili.com https://www.bilibili.com https://*.bilibili.com;"><link rel="preload" href="/css/style.css" as="style"><link rel="preload" href="https://static.mhuig.top/npm/volantis-static@0.0.1761982841160/media/fonts/VarelaRound/VarelaRound-Regular.ttf" as="font" type="font/ttf" crossorigin="anonymous"><link rel="preload" href="https://static.mhuig.top/npm/volantis-static@0.0.1761982841160/media/fonts/VarelaRound/VarelaRound-Regular.ttf" as="font" type="font/ttf" crossorigin="anonymous"><link rel="alternate" href="/atom.xml" title="Magicland" type="application/atom+xml"><link rel="alternate" href="/rss2.xml" title="Magicland" type="application/rss+xml"><title>尝试在博客中添加简易文章推荐功能 - Magicland</title><meta name="keywords" content="数据挖掘, 推荐系统,MHuiG, @MHuiG, Blog, 博客, Magicland, 魔法世界"><meta desc name="description" content="详解在静态博客中利用TF-IDF算法实现文章推荐功能的过程,包括文本分词、词频-逆文档频率计算、向量空间模型构建及余弦相似度匹配,解决传统标签推荐依赖人工标注的局限,提供技术实现思路。 - MHuiG - Magicland"><meta property="og:type" content="article"><meta property="og:title" content="尝试在博客中添加简易文章推荐功能"><meta property="og:url" content="https://blog.mhuig.top/p/175a1706/"><meta property="og:site_name" content="Magicland"><meta property="og:description" content="详解在静态博客中利用TF-IDF算法实现文章推荐功能的过程,包括文本分词、词频-逆文档频率计算、向量空间模型构建及余弦相似度匹配,解决传统标签推荐依赖人工标注的局限,提供技术实现思路。"><meta property="og:locale"><meta property="og:image" content="https://blog.mhuig.top/lib/favicon/android-chrome-192x192.png"><meta property="article:published_time" content="2022-09-15T11:13:00.000Z"><meta property="article:modified_time" content="2025-11-20T10:26:00.000Z"><meta property="article:author" content="MHuiG"><meta property="article:tag" content="推荐系统"><meta name="twitter:card" content="summary"><meta name="twitter:image" content="https://blog.mhuig.top/lib/favicon/android-chrome-192x192.png"><meta name="twitter:creator" content="@iMHuiG"><meta name="twitter:site" content="@iMHuiG"><style>#safearea{display:none}.post-story+.post-story{content-visibility:auto;contain-intrinsic-size:10px 500px}:root{--blur-px:12px;--blur-bg:var(--bg-a50);--blur-sat:300%}#u-search{display:-webkit-box;display:-moz-box;display:none;position:fixed;top:0;left:0;width:100%;height:100%;padding:60px 20px;z-index:1001}@media screen and (max-width:680px){#u-search{padding:0}}.l_header{position:fixed;z-index:1000;top:0;width:100%;height:64px;background:var(--color-card);box-shadow:0 1px 2px 0 rgba(0,0,0,.1);-webkit-box-shadow:0 1px 2px 0 rgba(0,0,0,.1)}.l_header.auto{transition:opacity .4s ease;-webkit-transition:opacity .4s ease;-khtml-transition:opacity 0.4s ease;-moz-transition:opacity .4s ease;-o-transition:opacity .4s ease;-ms-transition:opacity .4s ease;visibility:hidden}.l_header.auto.show{opacity:1!important;-webkit-opacity:1!important;-moz-opacity:1!important;visibility:visible}.l_header .container{margin-left:16px;margin-right:16px}.l_header #wrapper{height:100%;user-select:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none}.l_header #wrapper .nav-main,.l_header #wrapper .nav-sub{display:-webkit-box;display:-moz-box;display:-ms-flexbox;display:-webkit-flex;display:flex;display:flex;flex-wrap:nowrap;-webkit-flex-wrap:nowrap;-khtml-flex-wrap:nowrap;-moz-flex-wrap:nowrap;-o-flex-wrap:nowrap;-ms-flex-wrap:nowrap;justify-content:space-between;-webkit-justify-content:space-between;-khtml-justify-content:space-between;-moz-justify-content:space-between;-o-justify-content:space-between;-ms-justify-content:space-between;align-items:center}.l_header #wrapper .nav-main{transition:all .28s ease;-webkit-transition:all .28s ease;-khtml-transition:all 0.28s ease;-moz-transition:all .28s ease;-o-transition:all .28s ease;-ms-transition:all .28s ease}.l_header #wrapper.sub .nav-main{transform:translateY(-64px);-webkit-transform:translateY(-64px);-khtml-transform:translateY(-64px);-moz-transform:translateY(-64px);-o-transform:translateY(-64px);-ms-transform:translateY(-64px)}.l_header #wrapper .nav-sub{transition:all .28s ease;-webkit-transition:all .28s ease;-khtml-transition:all 0.28s ease;-moz-transition:all .28s ease;-o-transition:all .28s ease;-ms-transition:all .28s ease;opacity:0;-webkit-opacity:0;-moz-opacity:0;height:64px;width:calc(100% - 2 * 16px);position:absolute}.l_header #wrapper .nav-sub ::-webkit-scrollbar{display:-webkit-box;display:-moz-box;display:none}@media screen and (min-width:2048px){.l_header #wrapper .nav-sub{max-width:55vw;margin:auto}}.l_header #wrapper.sub .nav-sub{opacity:1;-webkit-opacity:1;-moz-opacity:1}.l_header #wrapper .title{position:relative;color:var(--color-text);padding-left:24px;max-height:64px}.l_header #wrapper .nav-main .title{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;flex-shrink:0;line-height:64px;padding:0 24px;font-size:1.25rem;font-family:"Varela Round",system-ui,"PingFang SC","Microsoft YaHei","Source Han Sans SC","Noto Sans SC",Helvetica,Arial,sans-serif,Helvetica,monospace}.l_header #wrapper .nav-main .title img{height:64px}.l_header .nav-sub{max-width:1080px;margin:auto}.l_header .nav-sub .title{font-weight:700;font-family:"Varela Round",system-ui,"PingFang SC","Microsoft YaHei","Source Han Sans SC","Noto Sans SC",Helvetica,Arial,sans-serif,Menlo,Monaco,monospace,sans-serif;line-height:1.2;max-height:64px;white-space:normal;flex-shrink:1}.l_header .switcher{display:-webkit-box;display:-moz-box;display:none;line-height:64px;align-items:center}.l_header .switcher .s-toc{display:-webkit-box;display:-moz-box;display:none}@media screen and (max-width:768px){.l_header .switcher .s-toc{display:-webkit-box;display:-moz-box;display:-ms-flexbox;display:-webkit-flex;display:flex;display:flex}}.l_header .switcher>li{height:48px;transition:all .28s ease;-webkit-transition:all .28s ease;-khtml-transition:all 0.28s ease;-moz-transition:all .28s ease;-o-transition:all .28s ease;-ms-transition:all .28s ease;margin:2px}@media screen and (max-width:500px){.l_header .switcher>li{margin:0 1px;height:48px}}.l_header .switcher>li>a{display:-webkit-box;display:-moz-box;display:-ms-flexbox;display:-webkit-flex;display:flex;display:flex;justify-content:center;-webkit-justify-content:center;-khtml-justify-content:center;-moz-justify-content:center;-o-justify-content:center;-ms-justify-content:center;align-items:center;width:48px;height:48px;padding:.85em 1.1em;border-radius:100px;-webkit-border-radius:100px;border:none;transition:all .28s ease;-webkit-transition:all .28s ease;-khtml-transition:all 0.28s ease;-moz-transition:all .28s ease;-o-transition:all .28s ease;-ms-transition:all .28s ease;color:var(--theme)}.l_header .switcher>li>a:hover{border:none}.l_header .switcher>li>a.active,.l_header .switcher>li>a:active{border:none;background:var(--color-site-bg)}@media screen and (max-width:500px){.l_header .switcher>li>a{width:36px;height:48px}}.l_header .nav-sub .switcher{display:-webkit-box;display:-moz-box;display:-ms-flexbox;display:-webkit-flex;display:flex;display:flex}.l_header .m_search{display:-webkit-box;display:-moz-box;display:-ms-flexbox;display:-webkit-flex;display:flex;display:flex;height:64px;width:240px;transition:all .28s ease;-webkit-transition:all .28s ease;-khtml-transition:all 0.28s ease;-moz-transition:all .28s ease;-o-transition:all .28s ease;-ms-transition:all .28s ease}@media screen and (max-width:1024px){.l_header .m_search{width:44px;min-width:44px}.l_header .m_search input::placeholder{opacity:0;-webkit-opacity:0;-moz-opacity:0}.l_header .m_search:hover{width:240px}.l_header .m_search:hover input::placeholder{opacity:1;-webkit-opacity:1;-moz-opacity:1}}@media screen and (min-width:500px){.l_header .m_search:hover .input{width:100%}.l_header .m_search:hover .input::placeholder{opacity:1;-webkit-opacity:1;-moz-opacity:1}}@media screen and (max-width:500px){.l_header .m_search{min-width:0}.l_header .m_search input::placeholder{opacity:1;-webkit-opacity:1;-moz-opacity:1}}.l_header .m_search .form{position:relative;display:-webkit-box;display:-moz-box;display:-ms-flexbox;display:-webkit-flex;display:flex;display:flex;width:100%;align-items:center}.l_header .m_search .icon{position:absolute;width:36px;left:5px;color:var(--color-meta)}@media screen and (max-width:500px){.l_header .m_search .icon{display:-webkit-box;display:-moz-box;display:none}}.l_header .m_search .input{display:-webkit-box;display:-moz-box;display:block;padding-top:8px;padding-bottom:8px;line-height:1.3;width:100%;color:var(--color-text);background:var(--color-card-darken2);box-shadow:none;-webkit-box-shadow:none;box-sizing:border-box;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;padding-left:40px;font-size:.875rem;border-radius:8px;-webkit-border-radius:8px;border:none;transition:all .28s ease;-webkit-transition:all .28s ease;-khtml-transition:all 0.28s ease;-moz-transition:all .28s ease;-o-transition:all .28s ease;-ms-transition:all .28s ease}@media screen and (min-width:500px){.l_header .m_search .input:focus{box-shadow:0 4px 8px 0 rgba(0,0,0,.1);-webkit-box-shadow:0 4px 8px 0 rgba(0,0,0,.1)}}@media screen and (max-width:500px){.l_header .m_search .input{background:var(--color-block);padding-left:8px;border:none}.l_header .m_search .input:focus,.l_header .m_search .input:hover{border:none}}@media (max-width:500px){.l_header .m_search{left:0;width:0;overflow:hidden;position:absolute;background:var(--color-card-lighten5);transition:all .28s ease;-webkit-transition:all .28s ease;-khtml-transition:all 0.28s ease;-moz-transition:all .28s ease;-o-transition:all .28s ease;-ms-transition:all .28s ease}.l_header .m_search .input{border-radius:32px;-webkit-border-radius:32px;margin-left:16px;padding-left:16px}.l_header.z_search-open .m_search{width:100%}.l_header.z_search-open .m_search .input{width:calc(100% - 120px)}}ul.m-pc>li>a{color:inherit;border-bottom:2px solid transparent}ul.m-pc>li>a.active,ul.m-pc>li>a:active{border-bottom:2px solid var(--theme)}ul.list-v li:hover>ul.list-v,ul.m-pc li:hover>ul.list-v{display:-webkit-box;display:-moz-box;display:block}ul.nav-list-h{display:-webkit-box;display:-moz-box;display:-ms-flexbox;display:-webkit-flex;display:flex;display:flex;align-items:stretch}ul.nav-list-h>li{position:relative;justify-content:center;-webkit-justify-content:center;-khtml-justify-content:center;-moz-justify-content:center;-o-justify-content:center;-ms-justify-content:center;height:100%;line-height:2.4;border-radius:4px;-webkit-border-radius:4px}ul.nav-list-h>li>a{-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;font-weight:600}ul.list-v{z-index:1;display:-webkit-box;display:-moz-box;display:none;position:absolute;background:var(--color-card);box-shadow:0 2px 4px 0 rgba(0,0,0,.08),0 4px 8px 0 rgba(0,0,0,.08),0 8px 16px 0 rgba(0,0,0,.08);-webkit-box-shadow:0 2px 4px 0 rgba(0,0,0,.08),0 4px 8px 0 rgba(0,0,0,.08),0 8px 16px 0 rgba(0,0,0,.08);margin-top:-6px;border-radius:4px;-webkit-border-radius:4px;padding:8px 0}ul.list-v.show{display:-webkit-box;display:-moz-box;display:block}ul.list-v hr{margin-top:8px;margin-bottom:8px}ul.list-v>li{white-space:nowrap;word-break:keep-all}ul.list-v>li.header{font-size:.78125rem;font-weight:700;line-height:2em;color:var(--color-meta);margin:8px 16px 4px}ul.list-v>li.header i{margin-right:8px}ul.list-v>li ul{margin-left:0;display:-webkit-box;display:-moz-box;display:none;margin-top:-40px}ul.list-v .aplayer-container{min-height:64px;padding:6px 16px}ul.list-v>li>a{transition:all .28s ease;-webkit-transition:all .28s ease;-khtml-transition:all 0.28s ease;-moz-transition:all .28s ease;-o-transition:all .28s ease;-ms-transition:all .28s ease;display:-webkit-box;display:-moz-box;display:block;color:var(--color-list);font-size:.875rem;font-weight:700;line-height:36px;padding:0 20px 0 16px;text-overflow:ellipsis;margin:0 4px;border-radius:4px;-webkit-border-radius:4px}@media screen and (max-width:1024px){ul.list-v>li>a{line-height:40px}}ul.list-v>li>a>i{margin-right:8px}ul.list-v>li>a.active,ul.list-v>li>a:active{color:var(--color-list-hl)}ul.list-v>li>a:hover{color:var(--color-list-hl);background:var(--color-site-bg)}.l_header .menu>ul>li>a{display:-webkit-box;display:-moz-box;display:block;padding:0 8px}.l_header .menu>ul>li>a>i{margin-right:4px}.l_header ul.nav-list-h>li{color:var(--color-list);line-height:64px}.l_header ul.nav-list-h>li>a{max-height:64px;overflow:hidden;color:inherit}.l_header ul.nav-list-h>li>a.active,.l_header ul.nav-list-h>li>a:active{color:var(--theme)}.l_header ul.nav-list-h>li:hover>a{color:var(--color-list-hl)}.l_header ul.nav-list-h>li i.music{animation:rotate-effect 1.5s linear infinite;-webkit-animation:rotate-effect 1.5s linear infinite;-khtml-animation:rotate-effect 1.5s linear infinite;-moz-animation:rotate-effect 1.5s linear infinite;-o-animation:rotate-effect 1.5s linear infinite;-ms-animation:rotate-effect 1.5s linear infinite}@-moz-keyframes rotate-effect{0%{transform:rotate(0);-webkit-transform:rotate(0);-khtml-transform:rotate(0);-moz-transform:rotate(0);-o-transform:rotate(0);-ms-transform:rotate(0)}25%{transform:rotate(90deg);-webkit-transform:rotate(90deg);-khtml-transform:rotate(90deg);-moz-transform:rotate(90deg);-o-transform:rotate(90deg);-ms-transform:rotate(90deg)}50%{transform:rotate(180deg);-webkit-transform:rotate(180deg);-khtml-transform:rotate(180deg);-moz-transform:rotate(180deg);-o-transform:rotate(180deg);-ms-transform:rotate(180deg)}75%{transform:rotate(270deg);-webkit-transform:rotate(270deg);-khtml-transform:rotate(270deg);-moz-transform:rotate(270deg);-o-transform:rotate(270deg);-ms-transform:rotate(270deg)}100%{transform:rotate(360deg);-webkit-transform:rotate(360deg);-khtml-transform:rotate(360deg);-moz-transform:rotate(360deg);-o-transform:rotate(360deg);-ms-transform:rotate(360deg)}}@-webkit-keyframes rotate-effect{0%{transform:rotate(0);-webkit-transform:rotate(0);-khtml-transform:rotate(0);-moz-transform:rotate(0);-o-transform:rotate(0);-ms-transform:rotate(0)}25%{transform:rotate(90deg);-webkit-transform:rotate(90deg);-khtml-transform:rotate(90deg);-moz-transform:rotate(90deg);-o-transform:rotate(90deg);-ms-transform:rotate(90deg)}50%{transform:rotate(180deg);-webkit-transform:rotate(180deg);-khtml-transform:rotate(180deg);-moz-transform:rotate(180deg);-o-transform:rotate(180deg);-ms-transform:rotate(180deg)}75%{transform:rotate(270deg);-webkit-transform:rotate(270deg);-khtml-transform:rotate(270deg);-moz-transform:rotate(270deg);-o-transform:rotate(270deg);-ms-transform:rotate(270deg)}100%{transform:rotate(360deg);-webkit-transform:rotate(360deg);-khtml-transform:rotate(360deg);-moz-transform:rotate(360deg);-o-transform:rotate(360deg);-ms-transform:rotate(360deg)}}@-o-keyframes rotate-effect{0%{transform:rotate(0);-webkit-transform:rotate(0);-khtml-transform:rotate(0);-moz-transform:rotate(0);-o-transform:rotate(0);-ms-transform:rotate(0)}25%{transform:rotate(90deg);-webkit-transform:rotate(90deg);-khtml-transform:rotate(90deg);-moz-transform:rotate(90deg);-o-transform:rotate(90deg);-ms-transform:rotate(90deg)}50%{transform:rotate(180deg);-webkit-transform:rotate(180deg);-khtml-transform:rotate(180deg);-moz-transform:rotate(180deg);-o-transform:rotate(180deg);-ms-transform:rotate(180deg)}75%{transform:rotate(270deg);-webkit-transform:rotate(270deg);-khtml-transform:rotate(270deg);-moz-transform:rotate(270deg);-o-transform:rotate(270deg);-ms-transform:rotate(270deg)}100%{transform:rotate(360deg);-webkit-transform:rotate(360deg);-khtml-transform:rotate(360deg);-moz-transform:rotate(360deg);-o-transform:rotate(360deg);-ms-transform:rotate(360deg)}}@keyframes rotate-effect{0%{transform:rotate(0);-webkit-transform:rotate(0);-khtml-transform:rotate(0);-moz-transform:rotate(0);-o-transform:rotate(0);-ms-transform:rotate(0)}25%{transform:rotate(90deg);-webkit-transform:rotate(90deg);-khtml-transform:rotate(90deg);-moz-transform:rotate(90deg);-o-transform:rotate(90deg);-ms-transform:rotate(90deg)}50%{transform:rotate(180deg);-webkit-transform:rotate(180deg);-khtml-transform:rotate(180deg);-moz-transform:rotate(180deg);-o-transform:rotate(180deg);-ms-transform:rotate(180deg)}75%{transform:rotate(270deg);-webkit-transform:rotate(270deg);-khtml-transform:rotate(270deg);-moz-transform:rotate(270deg);-o-transform:rotate(270deg);-ms-transform:rotate(270deg)}100%{transform:rotate(360deg);-webkit-transform:rotate(360deg);-khtml-transform:rotate(360deg);-moz-transform:rotate(360deg);-o-transform:rotate(360deg);-ms-transform:rotate(360deg)}}.menu-phone li ul.list-v{right:calc(100% - .5 * 16px)}.menu-phone li ul.list-v ul{right:calc(100% - .5 * 16px)}#wrapper{max-width:1080px;margin:auto}@media screen and (min-width:2048px){#wrapper{max-width:55vw}}#wrapper .menu{-webkit-box-flex:1;-moz-box-flex:1;-webkit-flex:1 1;-ms-flex:1 1;flex:1 1;margin:0 16px 0 0}#wrapper .menu .list-v ul{left:calc(100% - .5 * 16px)}.menu-phone{display:-webkit-box;display:-moz-box;display:none;margin-top:16px;right:8px;transition:all .28s ease;-webkit-transition:all .28s ease;-khtml-transition:all 0.28s ease;-moz-transition:all .28s ease;-o-transition:all .28s ease;-ms-transition:all .28s ease}.menu-phone ul{right:calc(100% - .5 * 16px)}@media screen and (max-width:500px){.menu-phone{display:-webkit-box;display:-moz-box;display:block}}.l_header{max-width:65vw;left:calc((100% - 65vw) * .5);border-bottom-left-radius:8px;border-bottom-right-radius:8px}@media screen and (max-width:2048px){.l_header{max-width:1112px;left:calc((100% - 1112px) * .5)}}@media screen and (max-width:1112px){.l_header{left:0;border-radius:0;-webkit-border-radius:0;max-width:100%}}@media screen and (max-width:500px){.l_header .container{margin-left:0;margin-right:0}.l_header #wrapper .nav-main .title{padding-left:16px;padding-right:16px}.l_header #wrapper .nav-sub{width:100%}.l_header #wrapper .nav-sub .title{overflow-y:scroll;margin-top:2px;padding:8px 16px}.l_header #wrapper .switcher{display:-webkit-box;display:-moz-box;display:-ms-flexbox;display:-webkit-flex;display:flex;display:flex;margin-right:8px}.l_header .menu{display:-webkit-box;display:-moz-box;display:none}}@media screen and (max-width:500px){.list-v li{max-width:270px}}@font-face{font-family:'Varela Round';src:url("https://static.mhuig.top/npm/volantis-static@0.0.1761982841160/media/fonts/VarelaRound/VarelaRound-Regular.ttf");font-weight:'normal';font-style:'normal';font-display:swap}@font-face{font-family:'Varela Round';src:url("https://static.mhuig.top/npm/volantis-static@0.0.1761982841160/media/fonts/VarelaRound/VarelaRound-Regular.ttf");font-weight:'normal';font-style:'normal';font-display:swap}@media (prefers-color-scheme:dark){:root{--color-mode:'dark'}:root:not([color-scheme]){--color-site-body:#121212;--color-read-bkg:#21232f;--color-read-post:#252d38;--color-site-bg:#21232f;--color-site-inner:#efefef;--color-site-footer:#666;--color-card:#252d38;--color-text:rgba(238,238,238,0.871);--color-block:rgba(68,68,68,0.65);--color-codeblock:#444;--color-inlinecode:#d56d28;--color-h1:rgba(255,255,255,0.871);--color-h2:rgba(255,255,255,0.871);--color-h3:rgba(255,255,255,0.6);--color-h4:rgba(255,255,255,0.6);--color-h5:rgba(255,255,255,0.6);--color-h6:rgba(255,255,255,0.6);--color-p:rgba(217,217,217,0.871);--color-list:rgba(217,217,217,0.871);--color-list-hl:#4dabf5;--color-meta:rgba(191,191,191,0.871);--color-link:rgba(191,191,191,0.871);--color-copyright-bkg:#21252b;--link-color:#e4e4e4;--color-text-a10:rgba(238,238,238,0.1);--color-text-a50:rgba(238,238,238,0.5);--color-text-a60:rgba(238,238,238,0.6);--color-text-a70:rgba(238,238,238,0.7);--color-text-a80:rgba(238,238,238,0.8);--color-text-a85:rgba(238,238,238,0.85);--color-text-a90:rgba(238,238,238,0.9);--color-card-a50:rgba(37,45,56,0.5);--color-card-a60:rgba(37,45,56,0.6);--color-card-a70:rgba(37,45,56,0.7);--color-card-a80:rgba(37,45,56,0.8);--color-card-a90:rgba(37,45,56,0.9);--color-card-darken2:#212832;--color-card-lighten5:#2f3947;--color-p-a20:rgba(217,217,217,0.2);--color-p-a70:rgba(217,217,217,0.7);--color-p-a75:rgba(217,217,217,0.75);--color-block-lighten3:rgba(76,76,76,0.65);--color-block-darken2:rgba(63,63,63,0.65);--color-mix60-p-card:rgba(133,137,142,0.922);--color-codeblock-darken6:#353535;--color-mix75-theme-text:rgba(74,167,241,0.968);--color-mix90-block-text:rgba(93,93,93,0.672)}:root:not([color-scheme]) img{filter:brightness(70%)!important}:root:not([color-scheme]) .blur{background:rgba(33,35,47,.9)!important}:root:not([color-scheme]) .white-box.blur{background:rgba(37,45,56,.9)!important}:root:not([color-scheme]) .nav-main .u-search-input{background:var(--color-card)!important}:root:not([color-scheme]) #l_main .article .prev-next>a{background:var(--color-block)!important}:root:not([color-scheme]) #l_main .article .prev-next>a:hover{background:var(--color-site-bg)!important}:root:not([color-scheme]) .article blockquote{background:var(--color-block)!important}:root:not([color-scheme]) .article-title a{color:var(--color-h1)!important}:root:not([color-scheme]) #u-search .modal,:root:not([color-scheme]) #u-search .modal-body,:root:not([color-scheme]) #u-search .modal-header{background:var(--color-card)!important}:root:not([color-scheme]) #u-search .modal-body .modal-results .result:hover{background:var(--color-block)!important}:root:not([color-scheme]) .u-search-input:hover{background:var(--color-block)!important}:root:not([color-scheme]) .u-search-input:focus{background:var(--color-site-body)!important}}[color-scheme=dark]{--color-site-body:#121212;--color-read-bkg:#21232f;--color-read-post:#252d38;--color-site-bg:#21232f;--color-site-inner:#efefef;--color-site-footer:#666;--color-card:#252d38;--color-text:rgba(238,238,238,0.871);--color-block:rgba(68,68,68,0.65);--color-codeblock:#444;--color-inlinecode:#d56d28;--color-h1:rgba(255,255,255,0.871);--color-h2:rgba(255,255,255,0.871);--color-h3:rgba(255,255,255,0.6);--color-h4:rgba(255,255,255,0.6);--color-h5:rgba(255,255,255,0.6);--color-h6:rgba(255,255,255,0.6);--color-p:rgba(217,217,217,0.871);--color-list:rgba(217,217,217,0.871);--color-list-hl:#4dabf5;--color-meta:rgba(191,191,191,0.871);--color-link:rgba(191,191,191,0.871);--color-copyright-bkg:#21252b;--link-color:#e4e4e4;--color-text-a10:rgba(238,238,238,0.1);--color-text-a50:rgba(238,238,238,0.5);--color-text-a60:rgba(238,238,238,0.6);--color-text-a70:rgba(238,238,238,0.7);--color-text-a80:rgba(238,238,238,0.8);--color-text-a85:rgba(238,238,238,0.85);--color-text-a90:rgba(238,238,238,0.9);--color-card-a50:rgba(37,45,56,0.5);--color-card-a60:rgba(37,45,56,0.6);--color-card-a70:rgba(37,45,56,0.7);--color-card-a80:rgba(37,45,56,0.8);--color-card-a90:rgba(37,45,56,0.9);--color-card-darken2:#212832;--color-card-lighten5:#2f3947;--color-p-a20:rgba(217,217,217,0.2);--color-p-a70:rgba(217,217,217,0.7);--color-p-a75:rgba(217,217,217,0.75);--color-block-lighten3:rgba(76,76,76,0.65);--color-block-darken2:rgba(63,63,63,0.65);--color-mix60-p-card:rgba(133,137,142,0.922);--color-codeblock-darken6:#353535;--color-mix75-theme-text:rgba(74,167,241,0.968);--color-mix90-block-text:rgba(93,93,93,0.672)}[color-scheme=dark] img{filter:brightness(70%)!important}[color-scheme=dark] .blur{background:rgba(33,35,47,.9)!important}[color-scheme=dark] .white-box.blur{background:rgba(37,45,56,.9)!important}[color-scheme=dark] .nav-main .u-search-input{background:var(--color-card)!important}[color-scheme=dark] #l_main .article .prev-next>a{background:var(--color-block)!important}[color-scheme=dark] #l_main .article .prev-next>a:hover{background:var(--color-site-bg)!important}[color-scheme=dark] .article blockquote{background:var(--color-block)!important}[color-scheme=dark] .article-title a{color:var(--color-h1)!important}[color-scheme=dark] #u-search .modal,[color-scheme=dark] #u-search .modal-body,[color-scheme=dark] #u-search .modal-header{background:var(--color-card)!important}[color-scheme=dark] #u-search .modal-body .modal-results .result:hover{background:var(--color-block)!important}[color-scheme=dark] .u-search-input:hover{background:var(--color-block)!important}[color-scheme=dark] .u-search-input:focus{background:var(--color-site-body)!important}@media screen and (max-width:500px){[color-scheme=dark] .l_header .m_search{background:var(--color-site-bg)!important}}#l_cover{min-height:64px}.cover-wrapper{top:0;left:0;max-width:100%;height:100vh;display:-webkit-box;display:-moz-box;display:-ms-flexbox;display:-webkit-flex;display:flex;display:flex;flex-wrap:nowrap;-webkit-flex-wrap:nowrap;-khtml-flex-wrap:nowrap;-moz-flex-wrap:nowrap;-o-flex-wrap:nowrap;-ms-flex-wrap:nowrap;-webkit-box-direction:normal;-moz-box-direction:normal;-webkit-box-orient:vertical;-moz-box-orient:vertical;-webkit-flex-direction:column;-ms-flex-direction:column;flex-direction:column;align-items:center;align-self:center;align-content:center;color:var(--color-site-inner);padding:0 16px;user-select:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;position:relative;overflow:hidden;margin-bottom:-100px}.cover-wrapper .cover-bg{position:absolute;width:100%;height:100%;background-position:center;background-size:cover;-webkit-background-size:cover;-moz-background-size:cover}.cover-wrapper .cover-bg.lazyload:not(.loaded){opacity:0;-webkit-opacity:0;-moz-opacity:0}.cover-wrapper .cover-bg.lazyload.loaded{animation-delay:0s;animation-duration:.5s;animation-fill-mode:forwards;animation-timing-function:ease-out;animation-name:fadeIn}@-moz-keyframes fadeIn{0%{opacity:0;-webkit-opacity:0;-moz-opacity:0;filter:blur(12px);transform:scale(1.02);-webkit-transform:scale(1.02);-khtml-transform:scale(1.02);-moz-transform:scale(1.02);-o-transform:scale(1.02);-ms-transform:scale(1.02)}100%{opacity:1;-webkit-opacity:1;-moz-opacity:1}}@-webkit-keyframes fadeIn{0%{opacity:0;-webkit-opacity:0;-moz-opacity:0;filter:blur(12px);transform:scale(1.02);-webkit-transform:scale(1.02);-khtml-transform:scale(1.02);-moz-transform:scale(1.02);-o-transform:scale(1.02);-ms-transform:scale(1.02)}100%{opacity:1;-webkit-opacity:1;-moz-opacity:1}}@-o-keyframes fadeIn{0%{opacity:0;-webkit-opacity:0;-moz-opacity:0;filter:blur(12px);transform:scale(1.02);-webkit-transform:scale(1.02);-khtml-transform:scale(1.02);-moz-transform:scale(1.02);-o-transform:scale(1.02);-ms-transform:scale(1.02)}100%{opacity:1;-webkit-opacity:1;-moz-opacity:1}}@keyframes fadeIn{0%{opacity:0;-webkit-opacity:0;-moz-opacity:0;filter:blur(12px);transform:scale(1.02);-webkit-transform:scale(1.02);-khtml-transform:scale(1.02);-moz-transform:scale(1.02);-o-transform:scale(1.02);-ms-transform:scale(1.02)}100%{opacity:1;-webkit-opacity:1;-moz-opacity:1}}.cover-wrapper .cover-body{z-index:1;position:relative;width:100%;height:100%}.cover-wrapper#full{height:calc(100vh + 100px);padding-bottom:100px}.cover-wrapper#half{max-height:640px;min-height:400px;height:calc(36vh - 64px + 200px)}.cover-wrapper #scroll-down{width:100%;height:64px;position:absolute;bottom:100px;text-align:center;cursor:pointer}.cover-wrapper #scroll-down .scroll-down-effects{color:#fff;font-size:24px;line-height:64px;position:absolute;width:24px;left:calc(50% - 12px);text-shadow:0 1px 2px rgba(0,0,0,.1);animation:scroll-down-effect 1.5s infinite;-webkit-animation:scroll-down-effect 1.5s infinite;-khtml-animation:scroll-down-effect 1.5s infinite;-moz-animation:scroll-down-effect 1.5s infinite;-o-animation:scroll-down-effect 1.5s infinite;-ms-animation:scroll-down-effect 1.5s infinite}@-moz-keyframes scroll-down-effect{0%{top:0;opacity:1;-webkit-opacity:1;-moz-opacity:1}50%{top:-16px;opacity:.4;-webkit-opacity:0.4;-moz-opacity:0.4}100%{top:0;opacity:1;-webkit-opacity:1;-moz-opacity:1}}@-webkit-keyframes scroll-down-effect{0%{top:0;opacity:1;-webkit-opacity:1;-moz-opacity:1}50%{top:-16px;opacity:.4;-webkit-opacity:0.4;-moz-opacity:0.4}100%{top:0;opacity:1;-webkit-opacity:1;-moz-opacity:1}}@-o-keyframes scroll-down-effect{0%{top:0;opacity:1;-webkit-opacity:1;-moz-opacity:1}50%{top:-16px;opacity:.4;-webkit-opacity:0.4;-moz-opacity:0.4}100%{top:0;opacity:1;-webkit-opacity:1;-moz-opacity:1}}@keyframes scroll-down-effect{0%{top:0;opacity:1;-webkit-opacity:1;-moz-opacity:1}50%{top:-16px;opacity:.4;-webkit-opacity:0.4;-moz-opacity:0.4}100%{top:0;opacity:1;-webkit-opacity:1;-moz-opacity:1}}.cover-wrapper .cover-body{margin-top:64px;margin-bottom:100px}.cover-wrapper .cover-body,.cover-wrapper .cover-body .bottom,.cover-wrapper .cover-body .top{display:-webkit-box;display:-moz-box;display:-ms-flexbox;display:-webkit-flex;display:flex;display:flex;-webkit-box-direction:normal;-moz-box-direction:normal;-webkit-box-orient:vertical;-moz-box-orient:vertical;-webkit-flex-direction:column;-ms-flex-direction:column;flex-direction:column;align-items:center;justify-content:center;-webkit-justify-content:center;-khtml-justify-content:center;-moz-justify-content:center;-o-justify-content:center;-ms-justify-content:center;max-width:100%}.cover-wrapper .cover-body .bottom{margin-top:32px}.cover-wrapper .cover-body .title{font-family:"Varela Round",system-ui,"PingFang SC","Microsoft YaHei","Source Han Sans SC","Noto Sans SC",Helvetica,Arial,sans-serif,Helvetica,monospace;font-size:3.125rem;line-height:1.2;text-shadow:0 1px 2px rgba(0,0,0,.1)}.cover-wrapper .cover-body .subtitle{font-size:20px}.cover-wrapper .cover-body .logo{max-height:120px;max-width:calc(100% - 4 * 16px)}@media screen and (min-height:1024px){.cover-wrapper .cover-body .title{font-size:3rem}.cover-wrapper .cover-body .subtitle{font-size:1.05rem}.cover-wrapper .cover-body .logo{max-height:150px}}.cover-wrapper .cover-body .m_search{position:relative;max-width:calc(100% - 16px);width:320px;vertical-align:middle}.cover-wrapper .cover-body .m_search .form{position:relative;display:-webkit-box;display:-moz-box;display:block;width:100%}.cover-wrapper .cover-body .m_search .icon,.cover-wrapper .cover-body .m_search .input{transition:all .28s ease;-webkit-transition:all .28s ease;-khtml-transition:all 0.28s ease;-moz-transition:all .28s ease;-o-transition:all .28s ease;-ms-transition:all .28s ease}.cover-wrapper .cover-body .m_search .icon{position:absolute;display:-webkit-box;display:-moz-box;display:block;line-height:2.5rem;width:32px;top:0;left:5px;color:var(--color-p-a75)}.cover-wrapper .cover-body .m_search .input{display:-webkit-box;display:-moz-box;display:block;height:2.5rem;width:100%;box-shadow:none;-webkit-box-shadow:none;box-sizing:border-box;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;font-size:.875rem;-webkit-appearance:none;padding-left:36px;border-radius:1.4rem;-webkit-border-radius:1.4rem;background:var(--color-card-a60);backdrop-filter:blur(10px);border:none;color:var(--color-text)}@media screen and (max-width:500px){.cover-wrapper .cover-body .m_search .input{padding-left:36px}}.cover-wrapper .cover-body .m_search .input:hover{background:var(--color-card-a80)}.cover-wrapper .cover-body .m_search .input:focus{background:var(--color-card)}.cover-wrapper .list-h{display:-webkit-box;display:-moz-box;display:-ms-flexbox;display:-webkit-flex;display:flex;display:flex;-webkit-box-direction:normal;-moz-box-direction:normal;-webkit-box-orient:horizontal;-moz-box-orient:horizontal;-webkit-flex-direction:row;-ms-flex-direction:row;flex-direction:row;flex-wrap:wrap;-webkit-flex-wrap:wrap;-khtml-flex-wrap:wrap;-moz-flex-wrap:wrap;-o-flex-wrap:wrap;-ms-flex-wrap:wrap;align-items:stretch;border-radius:4px;-webkit-border-radius:4px;user-select:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none}.cover-wrapper .list-h a{-webkit-box-flex:1;-moz-box-flex:1;-webkit-flex:1 0;-ms-flex:1 0;flex:1 0;display:-webkit-box;display:-moz-box;display:-ms-flexbox;display:-webkit-flex;display:flex;display:flex;font-weight:600}.cover-wrapper .list-h a img{display:-webkit-box;display:-moz-box;display:block;border-radius:2px;-webkit-border-radius:2px;margin:4px;min-width:40px;max-width:44px}@media screen and (max-width:768px){.cover-wrapper .list-h a img{min-width:36px;max-width:40px}}@media screen and (max-width:500px){.cover-wrapper .list-h a img{margin:2px 4px;min-width:32px;max-width:36px}}@media screen and (max-width:375px){.cover-wrapper .list-h a img{min-width:28px;max-width:32px}}.cover-wrapper{max-width:100%}.cover-wrapper.search .bottom .menu{margin-top:16px}.cover-wrapper.search .bottom .menu .list-h a{white-space:nowrap;-webkit-box-direction:normal;-moz-box-direction:normal;-webkit-box-orient:horizontal;-moz-box-orient:horizontal;-webkit-flex-direction:row;-ms-flex-direction:row;flex-direction:row;align-items:baseline;padding:2px;margin:4px;color:var(--color-site-inner);opacity:.75;-webkit-opacity:0.75;-moz-opacity:0.75;text-shadow:0 1px 2px rgba(0,0,0,.05);border-bottom:2px solid transparent}.cover-wrapper.search .bottom .menu .list-h a i{margin-right:4px}.cover-wrapper.search .bottom .menu .list-h a p{font-size:.9375rem}.cover-wrapper.search .bottom .menu .list-h a.active,.cover-wrapper.search .bottom .menu .list-h a:active,.cover-wrapper.search .bottom .menu .list-h a:hover{opacity:1;-webkit-opacity:1;-moz-opacity:1;border-bottom:2px solid var(--color-site-inner)}.cover-wrapper.dock .menu,.cover-wrapper.featured .menu,.cover-wrapper.focus .menu{border-radius:6px;-webkit-border-radius:6px}.cover-wrapper.dock .menu .list-h a,.cover-wrapper.featured .menu .list-h a,.cover-wrapper.focus .menu .list-h a{-webkit-box-direction:normal;-moz-box-direction:normal;-webkit-box-orient:vertical;-moz-box-orient:vertical;-webkit-flex-direction:column;-ms-flex-direction:column;flex-direction:column;align-items:center;padding:12px;line-height:24px;border-radius:4px;-webkit-border-radius:4px;border-bottom:none;text-align:center;align-content:flex-end;color:var(--color-text-a70);font-size:1.5rem}@media screen and (max-width:500px){.cover-wrapper.dock .menu .list-h a,.cover-wrapper.featured .menu .list-h a,.cover-wrapper.focus .menu .list-h a{padding:12px 8px}}.cover-wrapper.dock .menu .list-h a i,.cover-wrapper.featured .menu .list-h a i,.cover-wrapper.focus .menu .list-h a i{margin:8px}.cover-wrapper.dock .menu .list-h a p,.cover-wrapper.featured .menu .list-h a p,.cover-wrapper.focus .menu .list-h a p{font-size:.875rem}.cover-wrapper.dock .menu .list-h a.active,.cover-wrapper.featured .menu .list-h a.active,.cover-wrapper.focus .menu .list-h a.active{background:var(--color-card);backdrop-filter:none}.cover-wrapper.dock .menu .list-h a.active i,.cover-wrapper.dock .menu .list-h a.active i+p,.cover-wrapper.featured .menu .list-h a.active i,.cover-wrapper.featured .menu .list-h a.active i+p,.cover-wrapper.focus .menu .list-h a.active i,.cover-wrapper.focus .menu .list-h a.active i+p{color:var(--theme)}.cover-wrapper.dock .menu .list-h a.active img+p,.cover-wrapper.featured .menu .list-h a.active img+p,.cover-wrapper.focus .menu .list-h a.active img+p{color:var(--color-text)}.cover-wrapper.dock .menu .list-h a:hover,.cover-wrapper.featured .menu .list-h a:hover,.cover-wrapper.focus .menu .list-h a:hover{background:var(--color-card)}.cover-wrapper.featured .menu .list-h{margin:-2px}.cover-wrapper.featured .menu .list-h a{margin:2px;background:var(--color-card-a50)}@supports (backdrop-filter:blur(20px)){.cover-wrapper.featured .menu .list-h a{background:var(--color-card-a50);backdrop-filter:saturate(200%) blur(20px)}}:root{--hue:206.57142857142856deg;--sat:89.74358974358974%;--light:54.11764705882353%;--alpha:1;--theme:hsla(var(--hue) var(--sat) var(--light) / 1);--theme-a10:hsla(var(--hue) var(--sat) var(--light) / 0.1);--theme-a20:hsla(var(--hue) var(--sat) var(--light) / 0.2);--theme-a30:hsla(var(--hue) var(--sat) var(--light) / 0.3);--theme-a50:hsla(var(--hue) var(--sat) var(--light) / 0.5);--theme-a90:hsla(var(--hue) var(--sat) var(--light) / 0.9);--accent:#ff5722;--link:hsla(206.57142857142856deg 89.74358974358974% 54.11764705882353% / 1);--link-a20:hsla(206.57142857142856deg 89.74358974358974% 54.11764705882353% / 0.2);--background:hsla(210deg 20% 98% / 1);--card:#fff;--bg-a20:hsla(210deg 0% 100% / 0.2);--bg-a50:hsla(210deg 0% 100% / 0.5);--bg-a60:hsla(210deg 0% 100% / 0.6);--bg-a75:hsla(210deg 0% 100% / 0.75);--bg-a100:hsla(210deg 0% 100% / 1);--text:hsla(210deg 0% 0% / 1);--text-reverse:hsla(210deg 0% 100% / 1);--text-p1:hsla(210deg 0% 0% / 0.8);--text-p2:hsla(210deg 0% 0% / 0.7);--text-p3:hsla(210deg 0% 0% / 0.5);--text-p4:hsla(210deg 0% 0% / 0.4);--text-meta:hsla(210deg 0% 0% / 0.2);--text-code:hsla(210deg 0% 0% / 0.9);--text-a10:hsla(210deg 0% 0% / 0.1);--text-a20:hsla(210deg 0% 0% / 0.2);--block:hsla(210deg 50% 12% / 0.04);--block-border:hsla(210deg 50% 12% / 0.06)}@media (prefers-color-scheme:dark){:root{--background:hsla(210deg 8% 12% / 1);--card:hsla(210deg 10% 24% / 1);--bg-a20:hsla(210deg 0% 0% / 0.2);--bg-a50:hsla(210deg 0% 0% / 0.5);--bg-a60:hsla(210deg 0% 0% / 0.6);--bg-a75:hsla(210deg 0% 0% / 0.75);--bg-a100:hsla(210deg 0% 0% / 1);--text:hsla(210deg 0% 100% / 1);--text-reverse:hsla(210deg 0% 0% / 1);--text-p1:hsla(210deg 0% 100% / 0.8);--text-p2:hsla(210deg 0% 100% / 0.7);--text-p3:hsla(210deg 0% 100% / 0.5);--text-p4:hsla(210deg 0% 100% / 0.4);--text-meta:hsla(210deg 0% 100% / 0.2);--text-code:hsla(210deg 0% 100% / 0.9);--text-a10:hsla(210deg 0% 100% / 0.1);--text-a20:hsla(210deg 0% 100% / 0.2);--block:hsla(210deg 24% 72% / 0.08);--block-border:hsla(210deg 24% 72% / 0.12);--text-code:hsla(20 75 60 / 1)}}@media screen and (prefers-color-scheme:dark) and (max-width:667px){:root{--background:#000}}:root[color-scheme=light]{--background:hsla(210deg 20% 98% / 1);--card:#fff;--bg-a20:hsla(210deg 0% 100% / 0.2);--bg-a50:hsla(210deg 0% 100% / 0.5);--bg-a60:hsla(210deg 0% 100% / 0.6);--bg-a75:hsla(210deg 0% 100% / 0.75);--bg-a100:hsla(210deg 0% 100% / 1);--text:hsla(210deg 0% 0% / 1);--text-reverse:hsla(210deg 0% 100% / 1);--text-p1:hsla(210deg 0% 0% / 0.8);--text-p2:hsla(210deg 0% 0% / 0.7);--text-p3:hsla(210deg 0% 0% / 0.5);--text-p4:hsla(210deg 0% 0% / 0.4);--text-meta:hsla(210deg 0% 0% / 0.2);--text-code:hsla(210deg 0% 0% / 0.9);--text-a10:hsla(210deg 0% 0% / 0.1);--text-a20:hsla(210deg 0% 0% / 0.2);--block:hsla(210deg 50% 12% / 0.04);--block-border:hsla(210deg 50% 12% / 0.06)}:root[color-scheme=dark]{--background:hsla(210deg 8% 12% / 1);--card:hsla(210deg 10% 24% / 1);--bg-a20:hsla(210deg 0% 0% / 0.2);--bg-a50:hsla(210deg 0% 0% / 0.5);--bg-a60:hsla(210deg 0% 0% / 0.6);--bg-a75:hsla(210deg 0% 0% / 0.75);--bg-a100:hsla(210deg 0% 0% / 1);--text:hsla(210deg 0% 100% / 1);--text-reverse:hsla(210deg 0% 0% / 1);--text-p1:hsla(210deg 0% 100% / 0.8);--text-p2:hsla(210deg 0% 100% / 0.7);--text-p3:hsla(210deg 0% 100% / 0.5);--text-p4:hsla(210deg 0% 100% / 0.4);--text-meta:hsla(210deg 0% 100% / 0.2);--text-code:hsla(210deg 0% 100% / 0.9);--text-a10:hsla(210deg 0% 100% / 0.1);--text-a20:hsla(210deg 0% 100% / 0.2);--block:hsla(210deg 24% 72% / 0.08);--block-border:hsla(210deg 24% 72% / 0.12);--text-code:hsla(20 75 60 / 1)}@media screen and (max-width:667px){:root[color-scheme=dark]{--background:#000}}:root{--color-site-body:#87ceeb;--color-site-bg:#87ceeb;--color-site-inner:#555;--color-site-footer:#666;--color-card:#fff;--color-text:#444;--color-block:#f6f6f6;--color-inlinecode:#d56d28;--color-codeblock:#fff7ea;--color-h1:#3a3a3a;--color-h2:#3a3a3a;--color-h3:#333;--color-h4:#444;--color-h5:#555;--color-h6:#666;--color-p:#444;--color-list:#666;--color-list-hl:#1a78c2;--color-meta:#888;--color-read-bkg:#e0d8c8;--color-read-post:#f8f1e2;--color-copyright-bkg:#f5f5f5;--link-color:#00323c;--color-text-a10:rgba(68,68,68,0.1);--color-text-a50:rgba(68,68,68,0.5);--color-text-a60:rgba(68,68,68,0.6);--color-text-a70:rgba(68,68,68,0.7);--color-text-a80:rgba(68,68,68,0.8);--color-text-a85:rgba(68,68,68,0.85);--color-text-a90:rgba(68,68,68,0.9);--color-card-a50:rgba(255,255,255,0.5);--color-card-a60:rgba(255,255,255,0.6);--color-card-a70:rgba(255,255,255,0.7);--color-card-a80:rgba(255,255,255,0.8);--color-card-a90:rgba(255,255,255,0.9);--color-card-darken2:#fafafa;--color-card-lighten5:#fff;--color-p-a20:rgba(68,68,68,0.2);--color-p-a70:rgba(68,68,68,0.7);--color-p-a75:rgba(68,68,68,0.75);--color-block-lighten3:#fefefe;--color-block-darken2:#f1f1f1;--color-mix60-p-card:#8e8e8e;--color-codeblock-darken6:#ffebcb;--color-mix75-theme-text:#2981c7;--color-mix90-block-text:#e4e4e4}:root{text-autospace:normal}*{box-sizing:border-box;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;outline:0;margin:0;padding:0}::-webkit-scrollbar{height:4px;width:4px}::-webkit-scrollbar-track-piece{background:0 0}::-webkit-scrollbar-thumb{background:var(--theme);cursor:pointer;border-radius:2px;-webkit-border-radius:2px}::-webkit-scrollbar-thumb:hover{background:var(--accent)}html{color:var(--color-text);width:100%;height:100%;font-family:"Varela Round",system-ui,"PingFang SC","Microsoft YaHei","Source Han Sans SC","Noto Sans SC",Helvetica,Arial,sans-serif,Menlo,Monaco,monospace,sans-serif;font-size:16px}html>::-webkit-scrollbar{height:4px;width:4px}html>::-webkit-scrollbar-track-piece{background:0 0}html>::-webkit-scrollbar-thumb{background:var(--theme);cursor:pointer;border-radius:2px;-webkit-border-radius:2px}html>::-webkit-scrollbar-thumb:hover{background:var(--accent)}body{background-color:var(--color-site-body);text-rendering:optimizelegibility;-webkit-tap-highlight-color:transparent;line-height:1.6;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%}body.modal-active{overflow:hidden}@media screen and (max-width:680px){body.modal-active{position:fixed;top:0;right:0;bottom:0;left:0}}a{color:var(--link);cursor:pointer;text-decoration:none;transition:all .28s ease;-webkit-transition:all .28s ease;-khtml-transition:all 0.28s ease;-moz-transition:all .28s ease;-o-transition:all .28s ease;-ms-transition:all .28s ease}a:hover{color:var(--accent)}a:active,a:hover{outline:0}ol,ul{padding-left:0}ol li,ul li{list-style:none}header{display:-webkit-box;display:-moz-box;display:block}img{border:0;background:0 0;max-width:100%}svg:not(:root){overflow:hidden}hr{-moz-box-sizing:content-box;box-sizing:content-box;-webkit-box-sizing:content-box;-moz-box-sizing:content-box;height:0;border:0;border-radius:1px;-webkit-border-radius:1px;border-bottom:1px solid rgba(68,68,68,.1)}button,input{color:inherit;font:inherit;margin:0;background:0 0;border:none}button{overflow:visible;text-transform:none;-webkit-appearance:button;cursor:pointer}@supports (backdrop-filter:blur(20px)){.blur{background:var(--color-card-a90)!important;backdrop-filter:saturate(200%) blur(20px)}}.shadow{box-shadow:0 1px 2px 0 rgba(0,0,0,.1);-webkit-box-shadow:0 1px 2px 0 rgba(0,0,0,.1)}.shadow.floatable{transition:all .28s ease;-webkit-transition:all .28s ease;-khtml-transition:all 0.28s ease;-moz-transition:all .28s ease;-o-transition:all .28s ease;-ms-transition:all .28s ease}.shadow.floatable:hover{box-shadow:0 2px 4px 0 rgba(0,0,0,.1),0 4px 8px 0 rgba(0,0,0,.1),0 8px 16px 0 rgba(0,0,0,.1);-webkit-box-shadow:0 2px 4px 0 rgba(0,0,0,.1),0 4px 8px 0 rgba(0,0,0,.1),0 8px 16px 0 rgba(0,0,0,.1)}@media screen and (prefers-color-scheme:dark) and (max-width:500px){.l_header .m_search{background:var(--color-site-bg)!important}}.zh-dash{font-family:"PingFang SC","Microsoft YaHei","Noto Sans SC","Source Han Sans SC",sans-serif;white-space:nowrap}mjx-container{padding:0 0!important}mjx-container:not([display=true]){padding:4px 2px 4px 6px!important}mjx-container[jax=SVG]{direction:ltr}mjx-container[jax=SVG]>svg{overflow:visible}mjx-container[jax=SVG][display=true]{display:-webkit-box;display:-moz-box;display:block;text-align:center;margin:1em 0}mjx-container[jax=SVG][justify=left]{text-align:left}mjx-container[jax=SVG][justify=right]{text-align:right}g[data-mml-node=merror]>g{fill:#f00;stroke:#f00}g[data-mml-node=merror]>rect[data-background]{fill:#ff0;stroke:none}g[data-mml-node=mtable]>line[data-line]{stroke-width:70px;fill:none}g[data-mml-node=mtable]>rect[data-frame]{stroke-width:70px;fill:none}g[data-mml-node=mtable]>.mjx-dashed{stroke-dasharray:140}g[data-mml-node=mtable]>.mjx-dotted{stroke-linecap:round;stroke-dasharray:0,140}g[data-mml-node=mtable]>svg{overflow:visible}[jax=SVG] mjx-tool{display:-webkit-box;display:-moz-box;display:inline-block;position:relative;width:0;height:0}[jax=SVG] mjx-tool>mjx-tip{position:absolute;top:0;left:0}mjx-tool>mjx-tip{display:-webkit-box;display:-moz-box;display:inline-block;padding:.2em;border:1px solid #888;font-size:70%;background-color:#f8f8f8;color:#000;box-shadow:2px 2px 5px #aaa;-webkit-box-shadow:2px 2px 5px #aaa}g[data-mml-node=maction][data-toggle]{cursor:pointer}mjx-status{display:-webkit-box;display:-moz-box;display:block;position:fixed;left:1em;bottom:1em;min-width:25%;padding:.2em .4em;border:1px solid #888;font-size:90%;background-color:#f8f8f8;color:#000}foreignObject[data-mjx-xml]{font-family:initial;line-height:normal;overflow:visible}.MathJax path{stroke-width:3}mjx-container[display=true]{overflow:auto hidden}mjx-container[display=true]+br{display:-webkit-box;display:-moz-box;display:none}.fa-brands.color-github,.fa-duotone.color-github,.fa-light.color-github,.fa-regular.color-github,.fa-solid.color-github,.fa-thin.color-github,.fa.color-github,.fad.color-github,.fal.color-github,.far.color-github,.fas.color-github,.iziToast>.iziToast-body .iziToast-icon.color-github{color:#000}.fa-brands.color-friends,.fa-duotone.color-friends,.fa-light.color-friends,.fa-regular.color-friends,.fa-solid.color-friends,.fa-thin.color-friends,.fa.color-friends,.fad.color-friends,.fal.color-friends,.far.color-friends,.fas.color-friends,.iziToast>.iziToast-body .iziToast-icon.color-friends{color:#d31ee9}.fa-brands.color-about,.fa-duotone.color-about,.fa-light.color-about,.fa-regular.color-about,.fa-solid.color-about,.fa-thin.color-about,.fa.color-about,.fad.color-about,.fal.color-about,.far.color-about,.fas.color-about,.iziToast>.iziToast-body .iziToast-icon.color-about{color:#0095ff}.fa-brands.color-travellings,.fa-duotone.color-travellings,.fa-light.color-travellings,.fa-regular.color-travellings,.fa-solid.color-travellings,.fa-thin.color-travellings,.fa.color-travellings,.fad.color-travellings,.fal.color-travellings,.far.color-travellings,.fas.color-travellings,.iziToast>.iziToast-body .iziToast-icon.color-travellings{color:#734ae6}.cover-wrapper .cover-body .subtitle{font-size:.875rem}</style><link rel="stylesheet" href="/css/style.css" media="print" onload='this.media="all",this.onload=null'><noscript><link rel="stylesheet" href="/css/style.css"></noscript><script>let userColorScheme=localStorage.getItem("color-scheme");userColorScheme&&document.documentElement.setAttribute("color-scheme",userColorScheme)</script><script>window.MSInputMethodContext&&document.documentMode&&document.write('<style>html{overflow-x: hidden !important;overflow-y: hidden !important;}.kill-ie{text-align:center;height: 100%;margin-top: 15%;margin-bottom: 5500%;}.kill-t{font-size: 2rem;}.kill-c{font-size: 1.2rem;}#l_header,#l_body{display: none;}</style><div class="kill-ie"><span class="kill-t"><b>抱歉,您的浏览器无法访问本站</b></span><br/><span class="kill-c">微软已经于2016年终止了对 Internet Explorer (IE) 10 及更早版本的支持,<br/>继续使用存在极大的安全隐患,请使用当代主流的浏览器进行访问。</span><br/><a target="_blank" rel="noopener" href="https://blogs.windows.com/windowsexperience/2021/05/19/the-future-of-internet-explorer-on-windows-10-is-in-microsoft-edge/"><strong>了解详情 ></strong></a></div>')</script><noscript><style>html{overflow-x:hidden!important;overflow-y:hidden!important}.kill-noscript{text-align:center;height:100%;margin-top:15%;margin-bottom:5500%}.kill-t{font-size:2rem}.kill-c{font-size:1.2rem}#l_body,#l_header{display:none}</style><div class="kill-noscript"> <span class="kill-t"><b>抱歉,您的浏览器无法访问本站</b></span><br> <span class="kill-c">本页面需要浏览器支持(启用)JavaScript</span><br> <a target="_blank" rel="external nofollow noopener noreferrer" href="https://www.baidu.com/s?wd=启用JavaScript"><strong>了解详情 ></strong></a></div></noscript><script>!function(){const e=new WeakMap,t=new Proxy({},{get(o,n){const l=e.get(t);return l?.[n]},set(o,n,l){e.has(t)||e.set(t,Object.create(null));return e.get(t)[n]=l,!0},deleteProperty(o,n){const l=e.get(t);return!(!l||!Object.prototype.hasOwnProperty.call(l,n))&&(delete l[n],0===Object.keys(l).length&&e.delete(t),!0)},ownKeys(o){const n=e.get(t);return n?Object.keys(n):[]},getOwnPropertyDescriptor(o,n){const l=e.get(t);if(l&&Object.prototype.hasOwnProperty.call(l,n))return{value:l[n],writable:!0,enumerable:!0,configurable:!0}}});Object.defineProperty(window,"volantis",{value:t,writable:!0,configurable:!0,enumerable:!0})}(),volantis.dom={},volantis.simpleTextHash=e=>{let t=5381;for(let o=0;o<e.length;o++)t=(t<<5)+t+e.charCodeAt(o),t&=t;return t.toString(16).padStart(8,"0")},volantis.getFunctionHash=e=>{const t=e.toString();return volantis.simpleTextHash(t)},volantis.EventListener={list:[],remove(){this.list.forEach(e=>{e.ele.removeEventListener(e.type,e.f,!1)}),this.list=[]}};class VolantisEventListener{constructor(e,t,o){this.type=e,this.f=t,this.ele=o}}class VolantisDom{constructor(e){return this._ele=e||document.createElement("div"),new Proxy(this,{get:(e,t)=>void 0!==e[t]?e[t]:void 0!==e._ele[t]?"function"==typeof e._ele[t]?e._ele[t].bind(e._ele):e._ele[t]:void 0,set:(e,t,o)=>void 0!==e._ele[t]?(e._ele[t]=o,!0):(e[t]=o,!0)})}find(e){const t=this._ele.querySelector(e);return t?new VolantisDom(t):null}hasClass(e){return this._ele.classList.contains(e)}addClass(e){return"string"!=typeof e||e.split(" ").forEach(e=>{e&&this._ele.classList.add(e)}),this}removeClass(e){return"string"!=typeof e||e.split(" ").forEach(e=>{e&&this._ele.classList.remove(e)}),this}toggleClass(e){return"string"!=typeof e||e.split(" ").forEach(e=>{e&&this._ele.classList.toggle(e)}),this}on(e,t,o=!0){return"function"!=typeof t||(this._ele.addEventListener(e,t,!1),o&&volantis.EventListener.list.push(new VolantisEventListener(e,t,this._ele))),this}click(e,t){return this.on("click",e,t)}scroll(e,t){return this.on("scroll",e,t)}html(e){return void 0===e?this._ele.innerHTML:(this._ele.innerHTML=e,this)}hide(){return this._ele.classList.remove("show"),this._ele.style.removeProperty("display"),this}show(){return this._ele.classList.add("show"),this._ele.style.removeProperty("display"),this}}volantis.dom.$=e=>e?e instanceof VolantisDom?e:e instanceof NodeList||e instanceof HTMLCollection?Array.from(e).map(e=>new VolantisDom(e)):e instanceof Node?new VolantisDom(e):null:null;class RunItem{constructor(){this.list=[]}start(){this.list.forEach(e=>e.run())}push(e,t,o=!0){if("function"!=typeof e)return;let n=e;o&&(n=()=>{volantis.requestAnimationFrame(e)}),t=t||volantis.getFunctionHash(e);const l=this.list.findIndex(e=>e.name===t);-1===l?this.list.push(new TaskItem(n,t)):this.list[l]=new TaskItem(n,t)}remove(e){"string"==typeof e&&(this.list=this.list.filter(t=>t.name!==e))}}class TaskItem{constructor(e,t){this.name=t||volantis.getFunctionHash(e),this.fn=e}run(){try{this.fn()}catch(e){console.error(`Error executing task ${this.name}:`,e)}}}function errorImgAvatar(e){e.src=volantis.GLOBAL_CONFIG.default.avatar,e.srcset=volantis.GLOBAL_CONFIG.default.avatar,e.onerror=null}function errorImgCover(e){e.src=volantis.GLOBAL_CONFIG.default.cover,e.srcset=volantis.GLOBAL_CONFIG.default.cover,e.onerror=null}volantis.pjax={},volantis.pjax.method={complete:new RunItem,error:new RunItem,send:new RunItem},volantis.pjax=Object.assign(volantis.pjax,{push:volantis.pjax.method.complete.push.bind(volantis.pjax.method.complete),error:volantis.pjax.method.error.push.bind(volantis.pjax.method.error),send:volantis.pjax.method.send.push.bind(volantis.pjax.method.send)}),volantis.rightmenu={},volantis.rightmenu.method={handle:new RunItem},volantis.rightmenu=Object.assign(volantis.rightmenu,{handle:volantis.rightmenu.method.handle.push.bind(volantis.rightmenu.method.handle)}),volantis.dark={},volantis.dark.method={toggle:new RunItem},volantis.dark=Object.assign(volantis.dark,{push:volantis.dark.method.toggle.push.bind(volantis.dark.method.toggle)}),volantis.js=(e,t)=>new Promise((o,n)=>{setTimeout(function(){var l;if(document.querySelector(`script[src="${l=e,l.replace(/[#".'()[\]]/g,"\\$&")}"]`))return void o();const i=document.createElement("script");i.src=e;if(i.onload=()=>{"function"==typeof t&&t(),o()},i.onerror=()=>n(new Error(`Failed to load script: ${e}`)),t&&"object"==typeof t&&!Array.isArray(t))for(const e in t)t.hasOwnProperty(e)&&("onload"===e?i.onload=()=>{t[e](),o()}:"pjax"===e?(i.setAttribute("pjax",""),i.setAttribute("data-pjax","")):!0===t[e]?i.setAttribute(e,""):i.setAttribute(e,t[e]));(document.head||document.documentElement).appendChild(i)})}),volantis.css=e=>new Promise((t,o)=>{setTimeout(function(){var n;if(document.querySelector(`link[href="${n=e,n.replace(/[#".'()[\]]/g,"\\$&")}"]`))return void t();const l=document.createElement("link");Object.assign(l,{rel:"stylesheet",href:e,onload:()=>t(),onerror:()=>o(new Error(`Failed to load CSS: ${e}`))}),document.head.appendChild(l)})}),volantis.import={jQuery:()=>"undefined"==typeof jQuery?volantis.js(volantis.GLOBAL_CONFIG.cdn.jquery):new Promise(e=>{e()})},volantis.throttle=(e,t=200)=>{let o=0;return function(...n){const l=Date.now();l-o>=t&&(e.apply(this,n),o=l)}},volantis.debounce=(e,t=200)=>{let o=null;return function(){o&&clearTimeout(o),o=setTimeout(()=>{e.apply(this,arguments),o=null},t)}},volantis.requestAnimationFrame=e=>(window.requestAnimationFrame||(window.requestAnimationFrame=window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||function(e){return window.setTimeout(e,1e3/60)}),window.requestAnimationFrame(e)),volantis.rafThrottle=e=>{let t=null;return(...o)=>{t||(t=volantis.requestAnimationFrame(()=>{e(...o),t=null}))}},volantis.layoutHelper=(e,t,o={})=>{const{clean:n=!1,pjax:l=!0}={...o},i=()=>{const o=document.createElement("div");o.innerHTML=t;const l=document.querySelector(`#layoutHelper-${e}`);l&&(n&&(l.innerHTML=""),l.append(o))};i(),l&&volantis.pjax.push(i,`layoutHelper-${e}`)},volantis.scroll={engine:new RunItem,unengine:new RunItem},volantis.scroll=Object.assign(volantis.scroll,{push:volantis.scroll.engine.push.bind(volantis.scroll.engine)}),volantis.scroll.getScrollTop=()=>{let e;return window.pageYOffset?e=window.pageYOffset:document.compatMode&&"BackCompat"!=document.compatMode?e=document.documentElement.scrollTop:document.body&&(e=document.body.scrollTop),e},volantis.scroll.scrollHeight=function(){return Math.max(document.body.scrollHeight,document.documentElement.scrollHeight)},volantis.scroll.offsetHeight=function(){return Math.min(document.body.offsetHeight,document.documentElement.offsetHeight,document.body.clientHeight,document.documentElement.clientHeight)},volantis.scroll.progress=function(){return volantis.scroll.getScrollTop()/(volantis.scroll.scrollHeight()-volantis.scroll.offsetHeight())},volantis.scroll.handleScrollEvents=()=>{volantis.scroll.lastScrollTop=volantis.scroll.getScrollTop(),volantis.requestAnimationFrame(function e(){const t=volantis.scroll.getScrollTop();volantis.scroll.lastScrollTop!==t?(volantis.scroll.del=t-volantis.scroll.lastScrollTop,volantis.scroll.lastScrollTop=t,volantis.scroll.unengine.list=[],volantis.scroll.engine.start()):volantis.scroll.unengine.start(),volantis.requestAnimationFrame(e)})},volantis.scroll.handleScrollEvents(),volantis.scroll.ele=null,volantis.scroll.to=(e,t={})=>{e&&(volantis.scroll.ele=e,opt={top:e.getBoundingClientRect().top+document.documentElement.scrollTop,behavior:volantis.GLOBAL_CONFIG.scroll_behavior},"top"in t&&(opt.top=t.top),"behavior"in t&&(opt.behavior=t.behavior),"addTop"in t&&(opt.top+=t.addTop),"observerDic"in t||(t.observerDic=100),window.scrollTo(opt),t.observer&&setTimeout(()=>{volantis.scroll.ele==e&&volantis.scroll.unengine.push(()=>{let o=e.getBoundingClientRect().top;o>=-t.observerDic&&o<=t.observerDic||volantis.scroll.to(e,t),volantis.scroll.unengine.remove("unengineObserver")},"unengineObserver")},1e3))},volantis.cleanContentVisibility=()=>{document.querySelector(".post-story")&&(console.log("cleanContentVisibility"),document.querySelectorAll(".post-story").forEach(e=>{e.classList.remove("post-story")}))};const nativeSetTimeout=window.setTimeout,nativeSetInterval=window.setInterval,nativeClearTimeout=window.clearTimeout,nativeClearInterval=window.clearInterval;volantis.activeTimeout=[],volantis.activeInterval=[],window.setTimeout=function(e,t,...o){const n=nativeSetTimeout(function(...t){try{return e.apply(this,t)}finally{const e=volantis.activeTimeout.indexOf(n);-1!==e&&volantis.activeTimeout.splice(e,1)}},t,...o);return volantis.activeTimeout.push(n),n},window.setInterval=function(e,t,...o){const n=nativeSetInterval(e,t,...o);return volantis.activeInterval.push(n),n},window.clearTimeout=function(e){nativeClearTimeout(e);const t=volantis.activeTimeout.indexOf(e);-1!==t&&volantis.activeTimeout.splice(t,1)},window.clearInterval=function(e){nativeClearInterval(e);const t=volantis.activeInterval.indexOf(e);-1!==t&&volantis.activeInterval.splice(t,1)},volantis.getActiveInterval=function(){return[...volantis.activeInterval]},volantis.getActiveTimeout=function(){return[...volantis.activeTimeout]},volantis.clearAllTimers=function(){volantis.getActiveInterval().forEach(function(e){clearInterval(e)}),volantis.getActiveTimeout().forEach(function(e){clearTimeout(e)})},volantis.pjax.send(volantis.clearAllTimers,"clearAllTimers"),document.addEventListener("DOMContentLoaded",function(){volantis.dom.bodyAnchor=volantis.dom.$(document.getElementById("safearea")),volantis.dom.topBtn=volantis.dom.$(document.getElementById("s-top")),volantis.dom.wrapper=volantis.dom.$(document.getElementById("wrapper")),volantis.dom.coverAnchor=volantis.dom.$(document.querySelector("#l_cover .cover-wrapper")),volantis.dom.switcher=volantis.dom.$(document.querySelector("#l_header .switcher .s-search")),volantis.dom.header=volantis.dom.$(document.getElementById("l_header")),volantis.dom.search=volantis.dom.$(document.querySelector("#l_header .m_search")),volantis.dom.mPhoneList=volantis.dom.$(document.querySelectorAll("#l_header .m-phone .list-v"))})</script><script>volantis.debug=!1,volantis.GLOBAL_CONFIG={root:"/",debug:!1,default:{avatar:"https://static.mhuig.top/npm/volantis-static@0.0.1761982841160/media/placeholder/avatar/round/3442075.svg",link:"https://static.mhuig.top/npm/volantis-static@0.0.1761982841160/media/placeholder/link/8f277b4ee0ecd.svg",cover:"https://static.mhuig.top/npm/volantis-static@0.0.1761982841160/media/placeholder/cover/76b86c0226ffd.svg",image:"https://static.mhuig.top/npm/volantis-static@0.0.1761982841160/media/placeholder/image/2659360.svg",topic:"https://static.mhuig.top/gh/cdn-x/placeholder@1.0.12/image/10433048.png",project:"https://static.mhuig.top/gh/cdn-x/placeholder@1.0.12/image/2779789.png",banner:"https://gcore.jsdelivr.net/gh/cdn-x/placeholder@1.0.12/banner/books.jpg",loading:"https://api.iconify.design/eos-icons:three-dots-loading.svg?color=%231cd0fd",image_onerror:"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='2rem' height='2rem' viewBox='0 0 24 24'%3E%3C!-- Icon from Solar by 480 Design - https://creativecommons.org/licenses/by/4.0/ --%3E%3Cpath fill='%23F44336' d='M22 12.698c-.002 1.47-.013 2.718-.096 3.743c-.097 1.19-.296 2.184-.74 3.009a4.2 4.2 0 0 1-.73.983c-.833.833-1.893 1.21-3.237 1.39C15.884 22 14.2 22 12.053 22h-.106c-2.148 0-3.83 0-5.144-.177c-1.343-.18-2.404-.557-3.236-1.39c-.738-.738-1.12-1.656-1.322-2.795c-.2-1.12-.236-2.512-.243-4.241Q1.999 12.737 2 12v-.054c0-2.148 0-3.83.177-5.144c.18-1.343.557-2.404 1.39-3.236s1.893-1.21 3.236-1.39c1.168-.157 2.67-.175 4.499-.177a.697.697 0 1 1 0 1.396c-1.855.002-3.234.018-4.313.163c-1.189.16-1.906.464-2.436.994S3.72 5.8 3.56 6.99C3.397 8.2 3.395 9.788 3.395 12v.784l.932-.814a2.14 2.14 0 0 1 2.922.097l3.99 3.99a1.86 1.86 0 0 0 2.385.207l.278-.195a2.79 2.79 0 0 1 3.471.209l2.633 2.37c.265-.557.423-1.288.507-2.32c.079-.972.09-2.152.091-3.63a.698.698 0 0 1 1.396 0' opacity='.5'/%3E%3Cpath fill='%23F44336' fill-rule='evenodd' d='M17.5 11c-2.121 0-3.182 0-3.841-.659S13 8.621 13 6.5s0-3.182.659-3.841S15.379 2 17.5 2s3.182 0 3.841.659S22 4.379 22 6.5s0 3.182-.659 3.841S19.621 11 17.5 11m-1.47-7.03a.75.75 0 1 0-1.06 1.06l1.47 1.47l-1.47 1.47a.75.75 0 0 0 1.06 1.06l1.47-1.47l1.47 1.47a.75.75 0 1 0 1.06-1.06L18.56 6.5l1.47-1.47a.75.75 0 0 0-1.06-1.06L17.5 5.44z' clip-rule='evenodd'/%3E%3C/svg%3E"},lastupdate:new Date(1787014577137),scroll_behavior:"smooth",cdn:{jquery:"https://static.mhuig.top/npm/jquery@3.7.1/dist/jquery.min.js",izitoast_css:"https://static.mhuig.top/npm/izitoast@1.4.0/dist/css/iziToast.min.css",izitoast_js:"https://static.mhuig.top/npm/izitoast@1.4.0/dist/js/iziToast.min.js",fancybox_css:"https://static.mhuig.top/npm/@fancyapps/ui@5.0.36/dist/fancybox/fancybox.css",fancybox_js:"https://static.mhuig.top/npm/@fancyapps/ui@5.0.36/dist/fancybox/fancybox.umd.js"},sidebar:{webinfo:{lastupd:{enable:!1,friendlyShow:!0},runtime:{data:"2019/08/19",unit:"天"}}},plugins:{message:{enable:!1,icon:{default:"fa-solid fa-info-circle light-blue",quection:"fa-solid fa-question-circle light-blue"},time:{default:5e3,quection:2e4},position:"topRight",transitionIn:"bounceInLeft",transitionOut:"fadeOutRight",titleColor:"var(--color-text)",messageColor:"var(--color-text)",backgroundColor:"var(--color-card)",zindex:2147483647,copyright:{enable:!0,title:"知识共享许可协议",message:"请遵守 CC BY-NC-SA 4.0 协议。",icon:"far fa-copyright light-blue"},aplayer:{enable:!0,play:"fa-solid fa-play",pause:"fa-solid fa-pause"},rightmenu:{enable:!0,notice:!0}},aplayer:{id:1480000098,enable:!0}},tag_plugins:{chat:{api:"https://siteinfo.listentothewind.cn/api/v1"}},search:{dataPath:"/content.json"},languages:{search:{hits_empty:"找不到您查询的内容:${query}",hits_stats:"找到 ${hits} 条结果,用时 ${time} 毫秒",normal:"输入关键词搜索",hits_found:"找到 ${totalResults} 个相关结果",history:"搜索历史",no_history:"暂无搜索历史",clear_history:"清除历史",filter_all:"全部",filter_posts:"文章",filter_pages:"页面",filter_tags:"标签",searching:"搜索中...",placeholder:"搜索文章、标签或分类...",label_posts:"文章",label_pages:"页面",label_tags:"标签"},search:{no_title:"无标题",config_invalid:"搜索配置无效,请检查设置。"}}}</script><script type="application/ld+json">[{"@context":"http://schema.org","@type":"Organization","name":"MHuiG Magicland","url":"https://blog.mhuig.top/","logo":{"@type":"ImageObject","url":"/lib/favicon/android-chrome-192x192.png","width":192,"height":192}},{"@context":"http://schema.org","@type":"Person","name":"MHuiG","image":{"@type":"ImageObject","url":"/lib/favicon/android-chrome-192x192.png"},"url":"https://blog.mhuig.top/","sameAs":["https://github.com/MHuiG","https://twitter.com/iMHuiG","https://t.me/MHuiG","https://keybase.io/MHuiG"],"description":"「Be Yourself, Make a Difference.」"},{"@context":"http://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"item":{"@id":"https://blog.mhuig.top/","name":"Magicland"}},{"@type":"ListItem","position":2,"item":{"@id":"https://blog.mhuig.top/categories/数据挖掘/","name":"数据挖掘"}},{"@type":"ListItem","position":3,"item":{"@id":"https://blog.mhuig.top/p/175a1706/","name":"尝试在博客中添加简易文章推荐功能"}}]},{"@context":"http://schema.org","@type":"WebSite","name":"MHuiG Magicland","url":"https://blog.mhuig.top/","keywords":"MHuiG, @MHuiG, Blog, 博客, Magicland, 魔法世界","description":"宠辱不惊,看庭前花开花落;去留无意,望天上云卷云舒。「Be Yourself, Make a Difference.」 - Magic Island","author":{"@type":"Person","name":"MHuiG","image":{"@type":"ImageObject","url":"/lib/favicon/android-chrome-192x192.png"},"url":"https://blog.mhuig.top/","description":"「Be Yourself, Make a Difference.」"},"publisher":{"@type":"Organization","name":"MHuiG Magicland","url":"https://blog.mhuig.top/","logo":{"@type":"ImageObject","url":"/lib/favicon/android-chrome-192x192.png","width":192,"height":192}},"potentialAction":{"@type":"SearchAction","name":"CoCo | The Cat of MHuiG","target":{"@type":"EntryPoint","urlTemplate":"https://blog.mhuig.top/havefun/coco/?s={search_term_string}"},"query-input":"required name=search_term_string"}},{"@context":"http://schema.org","@type":"BlogPosting","headline":"尝试在博客中添加简易文章推荐功能","description":"详解在静态博客中利用TF-IDF算法实现文章推荐功能的过程,包括文本分词、词频-逆文档频率计算、向量空间模型构建及余弦相似度匹配,解决传统标签推荐依赖人工标注的局限,提供技术实现思路。","inLanguage":"zh-Hans","mainEntityOfPage":{"@type":"WebPage","@id":"https://blog.mhuig.top/p/175a1706/"},"author":{"@type":"Person","name":"MHuiG","image":{"@type":"ImageObject","url":"/lib/favicon/android-chrome-192x192.png"},"url":"https://blog.mhuig.top/"},"publisher":{"@type":"Organization","name":"MHuiG Magicland","logo":{"@type":"ImageObject","url":"/lib/favicon/android-chrome-192x192.png","width":192,"height":192}},"url":"https://blog.mhuig.top/p/175a1706/","wordCount":0,"datePublished":"2022-09-15T11:13:00.000Z","dateModified":"2025-11-20T10:26:00.000Z","articleSection":"数据挖掘","keywords":"推荐系统","image":{"@type":"ImageObject","url":"https://static.mhuig.top/npm/mhgoos@0.0.1663317354137/tf-idf.png","width":1024,"height":768}}]</script></head><body itemscope itemtype="http://schema.org/WebPage"><pjax></pjax><header itemscope itemtype="http://schema.org/WPHeader" id="l_header" class="l_header auto shadow floatable blur show" style="opacity:0"><div class="container"><div id="wrapper"><div class="nav-sub"><p class="title"></p><ul class="switcher nav-list-h m-phone" id="pjax-header-nav-list"><li><a id="s-comment" class="fa-solid fa-comments fa-fw" target="_self" title="comment"></a></li><li><a id="s-toc" class="s-toc fa-solid fa-list fa-fw" target="_self" title="toc"></a></li></ul></div><div class="nav-main"> <a class="title flat-box" target="_self" href="/">MHuiG</a><div class="menu navigation"><ul class="nav-list-h m-pc"><li><a class="menuitem flat-box faa-parent animated-hover" title="索引"><i class="fa-duotone fa-list-alt fa-fw"></i> 索引</a><ul class="list-v"><li><a class="menuitem flat-box faa-parent animated-hover" href="/notes/" title="便签" active-action="action-notes"><i class="fa-duotone fa-books fa-fw"></i> 便签</a></li><li><a class="menuitem flat-box faa-parent animated-hover" href="/categories/" title="分类" active-action="action-categories"><i class="fa-duotone fa-folder-open fa-fw"></i> 分类</a></li><li><a class="menuitem flat-box faa-parent animated-hover" href="/tags/" title="标签" active-action="action-tags"><i class="fa-duotone fa-tags fa-fw"></i> 标签</a></li><li><a class="menuitem flat-box faa-parent animated-hover" href="/archives/" title="归档" active-action="action-archives"><i class="fa-duotone fa-archive fa-fw"></i> 归档</a></li></ul></li><li><a class="menuitem flat-box faa-parent animated-hover" href="/pages/friends/" title="友链" active-action="action-pagesfriends"><i class="fa-duotone fa-link fa-fw"></i> 友链</a><ul class="list-v"><li><a class="menuitem flat-box faa-parent animated-hover" href="https://www.travellings.cn/go-by-clouds.html" title="Travelling" target="_blank" active-action="action-https:wwwtravellingscngo-by-cloudshtml" rel="external nofollow noopener noreferrer"><i class="fa-duotone fa-subway fa-fw"></i> Travelling</a></li></ul></li><li><a class="menuitem flat-box faa-parent animated-hover" href="/pages/about/" title="关于" active-action="action-pagesabout"><i class="fa-duotone fa-user-tie fa-fw"></i> 关于</a><ul class="list-v"><li><a class="menuitem flat-box faa-parent animated-hover" href="/pages/time-machine/" title="时光机" active-action="action-pagestime-machine"><i class="fa-duotone fa-clock fa-fw"></i> 时光机</a></li><li><a class="menuitem flat-box faa-parent animated-hover" target="_blank" rel="noopener" href="https://mhuig.top/privacy-policy/" title="隐私政策" active-action="action-https:mhuigtopprivacy-policy"><i class="fa-duotone fa-user-secret fa-fw"></i> 隐私政策</a></li></ul></li><li><a class="menuitem flat-box faa-parent animated-hover" title="更多"><i class="fa-duotone fa-fan fa-spin fa-fw"></i> 更多</a><ul class="list-v"><li><a class="menuitem flat-box faa-parent animated-hover" href="/pages/beer/" title="Sponsor" active-action="action-pagesbeer"><i class="fa-duotone fa-heart-square fa-fw"></i> Sponsor</a></li><hr><li><a class="menuitem flat-box faa-parent animated-hover" title="博客管理"><i class="fa-duotone fa-user-shield fa-fw"></i> 博客管理</a><ul class="list-v"><li><a class="menuitem flat-box header toggle-mode-btn"><i class="fa-duotone fa-bat fa-fw"></i> 暗黑模式</a></li><li></li><li><a class="menuitem flat-box faa-parent animated-hover" href="/pages/rss/" title="RSS订阅" active-action="action-pagesrss"><i class="fa-duotone fa-rss fa-fw"></i> RSS订阅</a></li><li><a class="menuitem flat-box faa-parent animated-hover" href="/sitemap.xml" title="站点地图" active-action="action-sitemapxml"><i class="fa-duotone fa-sitemap fa-fw"></i> 站点地图</a></li><li><a class="menuitem flat-box faa-parent animated-hover" target="_blank" rel="external nofollow noopener noreferrer" href="https://mhuig.instatus.com/" title="Monitors" active-action="action-https:mhuiginstatuscom"><i class="fa-duotone fa-telescope fa-fw"></i> Monitors</a></li><li><a class="menuitem flat-box faa-parent animated-hover" target="_blank" rel="external nofollow noopener noreferrer" href="https://ssl.mhuig.top/" title="SSL Status" active-action="action-https:sslmhuigtop"><i class="fa-brands fa-expeditedssl fa-fw"></i> SSL Status</a></li></ul></li><hr><li><a class="menuitem flat-box faa-parent animated-hover" title="工具箱"><i class="fa-duotone fa-tools fa-fw"></i> 工具箱</a><ul class="list-v"><li><a class="menuitem flat-box faa-parent animated-hover" target="_blank" rel="external nofollow noopener noreferrer" href="https://rssbox.mhuig.top/" title="RSS Box" active-action="action-https:rssboxmhuigtop"><i class="fa-duotone fa-conveyor-belt-boxes fa-fw"></i> RSS Box</a></li><li><a class="menuitem flat-box faa-parent animated-hover" href="/havefun/coco/" title="My Cat" active-action="action-havefuncoco"><i class="fa-duotone fa-cat fa-fw"></i> My Cat</a></li><li><a class="menuitem flat-box"><i class="fa-duotone fa-compact-disc fa-spin fa-fw music"></i> Music</a><ul class="list-v"><li><div class="aplayer-container"><div class="aplayer-local"></div></div></li></ul></li><li></li><li><a class="menuitem flat-box faa-parent animated-hover" href="/pages/talk/" title="碎言碎语" active-action="action-pagestalk"><i class="fa-duotone fa-comments fa-fw"></i> 碎言碎语</a></li></ul></li><hr><li><a class="menuitem flat-box faa-parent animated-hover" target="_blank" rel="external nofollow noopener noreferrer" href="https://github.com/MHuiG" title="GitHub" active-action="action-https:githubcomMHuiG"><i class="fa-brands fa-github fa-fw"></i> GitHub</a></li></ul></li></ul></div><div class="m_search"><form name="searchform" class="form u-search-form"><i class="icon fa-solid fa-search fa-fw"></i> <input type="text" class="input u-search-input" placeholder="Search..."></form></div><ul class="switcher nav-list-h m-phone"><li><a class="s-search fa-solid fa-search fa-fw" target="_self" title="search"></a></li><li><a class="s-menu fa-solid fa-bars fa-fw" target="_self" title="menu"></a><ul class="menu-phone list-v navigation white-box"><li><a class="menuitem flat-box faa-parent animated-hover" title="索引"><i class="fa-duotone fa-list-alt fa-fw"></i> 索引</a><ul class="list-v"><li><a class="menuitem flat-box faa-parent animated-hover" href="/notes/" title="便签" active-action="action-notes"><i class="fa-duotone fa-books fa-fw"></i> 便签</a></li><li><a class="menuitem flat-box faa-parent animated-hover" href="/categories/" title="分类" active-action="action-categories"><i class="fa-duotone fa-folder-open fa-fw"></i> 分类</a></li><li><a class="menuitem flat-box faa-parent animated-hover" href="/tags/" title="标签" active-action="action-tags"><i class="fa-duotone fa-tags fa-fw"></i> 标签</a></li><li><a class="menuitem flat-box faa-parent animated-hover" href="/archives/" title="归档" active-action="action-archives"><i class="fa-duotone fa-archive fa-fw"></i> 归档</a></li></ul></li><li><a class="menuitem flat-box faa-parent animated-hover" href="/pages/friends/" title="友链" active-action="action-pagesfriends"><i class="fa-duotone fa-link fa-fw"></i> 友链</a><ul class="list-v"><li><a class="menuitem flat-box faa-parent animated-hover" href="https://www.travellings.cn/go-by-clouds.html" title="Travelling" target="_blank" active-action="action-https:wwwtravellingscngo-by-cloudshtml" rel="external nofollow noopener noreferrer"><i class="fa-duotone fa-subway fa-fw"></i> Travelling</a></li></ul></li><li><a class="menuitem flat-box faa-parent animated-hover" href="/pages/about/" title="关于" active-action="action-pagesabout"><i class="fa-duotone fa-user-tie fa-fw"></i> 关于</a><ul class="list-v"><li><a class="menuitem flat-box faa-parent animated-hover" href="/pages/time-machine/" title="时光机" active-action="action-pagestime-machine"><i class="fa-duotone fa-clock fa-fw"></i> 时光机</a></li><li><a class="menuitem flat-box faa-parent animated-hover" target="_blank" rel="noopener" href="https://mhuig.top/privacy-policy/" title="隐私政策" active-action="action-https:mhuigtopprivacy-policy"><i class="fa-duotone fa-user-secret fa-fw"></i> 隐私政策</a></li></ul></li><li><a class="menuitem flat-box faa-parent animated-hover" title="更多"><i class="fa-duotone fa-fan fa-spin fa-fw"></i> 更多</a><ul class="list-v"><li><a class="menuitem flat-box faa-parent animated-hover" href="/pages/beer/" title="Sponsor" active-action="action-pagesbeer"><i class="fa-duotone fa-heart-square fa-fw"></i> Sponsor</a></li><hr><li><a class="menuitem flat-box faa-parent animated-hover" title="博客管理"><i class="fa-duotone fa-user-shield fa-fw"></i> 博客管理</a><ul class="list-v"><li><a class="menuitem flat-box header toggle-mode-btn"><i class="fa-duotone fa-bat fa-fw"></i> 暗黑模式</a></li><li></li><li><a class="menuitem flat-box faa-parent animated-hover" href="/pages/rss/" title="RSS订阅" active-action="action-pagesrss"><i class="fa-duotone fa-rss fa-fw"></i> RSS订阅</a></li><li><a class="menuitem flat-box faa-parent animated-hover" href="/sitemap.xml" title="站点地图" active-action="action-sitemapxml"><i class="fa-duotone fa-sitemap fa-fw"></i> 站点地图</a></li><li><a class="menuitem flat-box faa-parent animated-hover" target="_blank" rel="external nofollow noopener noreferrer" href="https://mhuig.instatus.com/" title="Monitors" active-action="action-https:mhuiginstatuscom"><i class="fa-duotone fa-telescope fa-fw"></i> Monitors</a></li><li><a class="menuitem flat-box faa-parent animated-hover" target="_blank" rel="external nofollow noopener noreferrer" href="https://ssl.mhuig.top/" title="SSL Status" active-action="action-https:sslmhuigtop"><i class="fa-brands fa-expeditedssl fa-fw"></i> SSL Status</a></li></ul></li><hr><li><a class="menuitem flat-box faa-parent animated-hover" title="工具箱"><i class="fa-duotone fa-tools fa-fw"></i> 工具箱</a><ul class="list-v"><li><a class="menuitem flat-box faa-parent animated-hover" target="_blank" rel="external nofollow noopener noreferrer" href="https://rssbox.mhuig.top/" title="RSS Box" active-action="action-https:rssboxmhuigtop"><i class="fa-duotone fa-conveyor-belt-boxes fa-fw"></i> RSS Box</a></li><li><a class="menuitem flat-box faa-parent animated-hover" href="/havefun/coco/" title="My Cat" active-action="action-havefuncoco"><i class="fa-duotone fa-cat fa-fw"></i> My Cat</a></li><li><a class="menuitem flat-box faa-parent animated-hover" href="/pages/talk/" title="碎言碎语" active-action="action-pagestalk"><i class="fa-duotone fa-comments fa-fw"></i> 碎言碎语</a></li></ul></li><hr><li><a class="menuitem flat-box faa-parent animated-hover" target="_blank" rel="external nofollow noopener noreferrer" href="https://github.com/MHuiG" title="GitHub" active-action="action-https:githubcomMHuiG"><i class="fa-brands fa-github fa-fw"></i> GitHub</a></li></ul></li></ul></li></ul></div></div></div></header><div id="l_body"><div id="l_cover"><div id="none" class="cover-wrapper post featured" style="display:none"><div class="cover-bg lazyload placeholder" data-bg></div><div class="cover-body"><div class="top"><p class="title">Magicland</p><p class="subtitle">「看庭前花开花落,望天上云卷云舒」</p></div><div class="bottom"><div class="menu navigation"><div class="list-h"><a target="_blank" rel="external nofollow noopener noreferrer" href="https://github.com/MHuiG" active-action="action-https:githubcomMHuiG"><i class="fa-brands fa-github color-github fa-fw"></i><p>Github</p></a><a href="/pages/friends/" active-action="action-pagesfriends"><i class="fa-duotone fa-link color-friends fa-fw"></i><p>友链</p></a><a href="/pages/about/" active-action="action-pagesabout"><i class="fa-duotone fa-user-tie color-about fa-fw"></i><p>关于</p></a><a href="https://www.travellings.cn/go-by-clouds.html" target="_blank" active-action="action-https:wwwtravellingscngo-by-cloudshtml" rel="external nofollow noopener noreferrer"><i class="fa-duotone fa-subway color-travellings fa-fw"></i><p>Travelling</p></a></div></div></div></div><div id="scroll-down" style="display:none"><i class="fa fa-chevron-down scroll-down-effects"></i></div></div></div><div id="safearea"><div class="body-wrapper"><div id="l_main" class><article itemscope itemtype="http://schema.org/Article" class="article post white-box reveal md shadow floatable blur article-type-post" id="post" itemprop="blogPost"><link itemprop="mainEntityOfPage" href="https://blog.mhuig.top/p/175a1706/"><span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization"><meta itemprop="name" content="Magicland"></span><span hidden itemprop="post" itemscope itemtype="http://schema.org/CreativeWork"><meta itemprop="name" content="尝试在博客中添加简易文章推荐功能"><meta itemprop="description" content="详解在静态博客中利用TF-IDF算法实现文章推荐功能的过程,包括文本分词、词频-逆文档频率计算、向量空间模型构建及余弦相似度匹配,解决传统标签推荐依赖人工标注的局限,提供技术实现思路。"></span><div class="headimg-div"><div class="headimg-a"> <img itemprop="image" class="headimg lazyload" alt="尝试在博客中添加简易文章推荐功能" src="https://static.mhuig.top/npm/mhgoos@0.0.1663317354137/tf-idf.png" class="lazyload" data-srcset="https://static.mhuig.top/npm/mhgoos@0.0.1663317354137/tf-idf.png" srcset="data:image/gif;base64,R0lGODlhAQABAIAAAP///////yH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=="></div></div><div class="article-meta" id="top"><h1 class="hidden" itemprop="name headline"> 尝试在博客中添加简易文章推荐功能</h1><div class="new-meta-box"><div class="new-meta-item author" itemprop="author" itemscope itemtype="http://schema.org/Person"> <a itemprop="url" class="author" target="_blank" href="https://mhuig.top/" rel="nofollow noopener" alt="author"><img itemprop="image" src="/lib/avatar/avatar-16.webp" class="lazyload" data-srcset="/lib/avatar/avatar-16.webp" srcset="data:image/gif;base64,R0lGODlhAQABAIAAAP///////yH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==" alt="author"><p itemprop="name">MHuiG</p></a></div><div class="new-meta-item wordcount"><a class="notlink"><i class="fa-duotone fa-keyboard fa-fw" aria-hidden="true"></i><p>字数:2.7k 字</p></a></div><div class="new-meta-item readtime"><a class="notlink"><i class="fa-duotone fa-hourglass-half fa-fw" aria-hidden="true"></i><p>时长:10 分钟</p></a></div></div></div><div id="layoutHelper-page-plugins"></div><div id="post-body" itemprop="articleBody"><p>把文档转换成 “向量”,并且尝试用线性代数等数学工具来解决信息检索这类问题,至少可以追溯到 20 世纪 70 年代. 想到在 Hexo 这种静态博客系统,特别是 GitHub Page 这种 Serverless 服务中使用 Word2Vec 等深度学习方法似乎并不现实,所以这里使用的是一个非常简单经典的 TF-IDF 算法.</p><p>TF-IDF 算法原来是搜索引擎中的核心部分,谷歌百度已经使用 TF-IDF 作为内容排名因素很长一段时间.</p><p>现在的搜索引擎一般用如下的算法计算网站页面得分:score(页面得分) = TFIDF分 * x + 链接分 * y + 用户体验分 * z(其中x+y+z=100%),TFIDF分值百度大约占 40% 左右的权重,谷歌更是达到了50%.</p><p>这是百度的计算方法: score(页面得分) = 40%的内容质量相关性(TFIDF)+ 40% 的用户体验分 + 20% 的链接分(域名+外链).</p><p>搜索引擎使用 TF-IDF 来计算内容质量相关性,我们这边也可以用它来计算文章内容相关性,然后实现简易文章推荐功能。</p><p>当然也可以使用文章的 tags 标签最为推荐依据,但是这样过于依赖人工标注数据,顺便最近发现在 Hexo 中分类和标签只能在 <code>source/_posts</code> 文件夹中使用才能渲染出来。</p><div class="story post-story"><h2 id="构建向量空间模型"><a href="#构建向量空间模型" class="headerlink" title="构建向量空间模型"></a>构建向量空间模型</h2><p>将文档转化为向量来表示,这样文档与文档之间就可以定量的去度量他们之间的关系,挖掘文档之间的联系. 上面提到的 Word2Vec 是把单词转化为向量来表示,这样词与词之间就可以定量的去度量他们之间的关系,挖掘词之间的联系.</p><p>比如将词的维度降维到 2 维,用下图的词向量表示词:</p><p><img src="https://static.mhuig.top/npm/mhgoos@0.0.1663246894190/1.png" class="lazyload" data-srcset="https://static.mhuig.top/npm/mhgoos@0.0.1663246894190/1.png" srcset="data:image/gif;base64,R0lGODlhAQABAIAAAP///////yH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==" alt="单词转化为向量"></p><p><img src="https://static.mhuig.top/npm/mhgoos@0.0.1663284804787/2.png" class="lazyload" data-srcset="https://static.mhuig.top/npm/mhgoos@0.0.1663284804787/2.png" srcset="data:image/gif;base64,R0lGODlhAQABAIAAAP///////yH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==" alt="向量运算"></p><p><mjx-container class="MathJax" jax="SVG" overflow="overflow" display="true" width="full" style="min-width: 42.655ex;"><svg style="vertical-align: -1.157ex; min-width: 42.655ex;" xmlns="http://www.w3.org/2000/svg" width="100%" height="3.445ex" role="img" focusable="false" data-mjx-viewbox="0 -1011.4 18853.4 1522.8"><g stroke="currentColor" fill="currentColor" stroke-width="0" transform="scale(0.0181,-0.0181) translate(0, -1011.4)"><g data-mml-node="math" data-latex="\overrightarrow{King} - \overrightarrow{Man} + \overrightarrow{Woman} = \overrightarrow{Queen}"><g data-mml-node="mtable" data-latex="\overrightarrow{King} - \overrightarrow{Man} + \overrightarrow{Woman} = \overrightarrow{Queen}" transform="translate(2078,0) translate(-2078,0)"><g transform="translate(0 1011.4) matrix(1 0 0 -1 0 0) scale(55.25)"><svg data-table="true" preserveaspectratio="xMidYMid" viewbox="7348.7 -1011.4 1 1522.8"><g transform="matrix(1 0 0 -1 0 0)"><g data-mml-node="mlabeledtr" transform="translate(0,-261.4)"><g data-mml-node="mtd"><g data-mml-node="mover" data-latex="\overrightarrow{King}"><g data-mml-node="mrow" data-latex="King"><g data-mml-node="mi" data-latex="K"><path data-c="1D43E" d="M804 680C783 680 715 683 694 683C679 683 671 675 671 659C671 651 678 646 692 643C706 640 714 635 714 628C714 617 703 602 680 585L302 296L379 602C384 623 393 636 406 641C412 643 429 644 458 644C484 644 496 644 496 668C496 678 490 683 478 683L351 680L223 683C207 684 199 676 199 660C199 649 210 644 232 644C252 644 293 647 293 631C293 629 292 623 289 613L156 82C151 60 141 47 126 42C119 40 101 39 70 39C48 39 38 37 38 16C38 5 44 0 57 0L183 3L246 2C257 2 299 0 310 0C326 0 334 8 334 24C334 34 324 39 303 39C262 39 242 43 242 52C242 57 245 72 251 95L290 249L433 359L546 98C553 81 557 70 557 65C557 48 541 39 510 39C492 39 484 35 484 15C484 5 490 0 502 0C524 0 600 3 622 3C641 3 701 0 720 0C734 0 741 8 741 24C741 33 733 38 718 39C677 39 667 50 653 81L512 404C511 409 509 413 508 416L708 570C757 608 799 631 833 639C857 643 889 642 889 668C889 678 884 683 874 683C860 683 818 680 804 680Z"/></g><g data-mml-node="mi" data-latex="i" transform="translate(889,0)"><path data-c="1D456" d="M284 621C284 648 271 661 244 661C216 661 188 633 188 605C188 578 202 565 229 565C257 565 284 593 284 621M259 138C237 59 205 19 164 19C151 19 144 28 144 47C144 64 173 150 232 306C240 329 244 347 244 360C244 409 210 445 161 445C118 445 84 420 59 369C39 328 29 301 29 288C29 279 34 275 45 275C58 275 60 281 64 295C87 375 118 415 158 415C171 415 178 406 178 387C178 373 175 357 168 338C145 275 121 208 101 155C86 115 78 88 78 74C78 25 114-11 162-11C205-11 239 14 264 64C283 103 293 130 293 145C293 154 288 159 277 159C274 159 259 150 259 138Z"/></g><g data-mml-node="mi" data-latex="n" transform="translate(1234,0)"><path data-c="1D45B" d="M537 137C514 58 481 18 440 18C427 18 420 28 420 47C420 61 426 84 438 115C478 224 498 296 498 333C498 403 451 442 381 442C322 442 271 416 230 363C222 407 187 442 136 442C80 442 58 390 44 345C34 313 29 294 29 287C29 278 34 273 45 273C50 273 53 274 56 276C61 285 64 292 65 299C83 375 106 413 133 413C151 413 160 399 160 371C160 358 155 331 144 290L87 63C84 50 78 24 78 19C78-1 89-11 111-11C130-11 144-1 151 19C153 24 159 49 170 92L191 181L221 295C232 318 249 341 270 365C299 397 335 413 378 413C411 413 427 391 427 348C427 310 406 234 363 120C356 102 353 87 353 74C353 25 390-11 438-11C482-11 517 14 542 64C561 104 571 131 571 144C571 153 566 158 555 158C552 158 537 149 537 137Z"/></g><g data-mml-node="mi" data-latex="g" transform="translate(1834,0)"><path data-c="1D454" d="M15-141C15-184 60-205 150-205C197-205 241-193 280-170C324-144 351-109 362-66L471 373C473 383 474 389 474 392C474 412 463 422 442 422C420 422 406 410 399 387C377 424 347 442 310 442C246 442 189 410 140 346C95 286 72 223 72 158C72 71 123-3 207-3C246-3 282 14 315 47L285-71C256-140 211-175 148-175C122-175 100-173 82-169C103-158 113-141 113-118C113-93 99-80 72-80C40-80 15-109 15-141M356 392C376 371 386 351 386 331C386 330 385 325 383 318L336 129C330 106 313 82 286 60C259 38 233 27 210 27C170 27 150 56 150 114C150 169 184 291 204 327C235 384 270 412 311 412C329 412 344 405 356 392Z"/></g></g><g data-mml-node="mo" transform="translate(0,720.4)"><path data-c="2192" d="M496 234C503 237 507 243 507 250C507 257 503 263 496 266C448 282 403 316 362 368C334 403 315 444 306 491C303 504 296 510 283 510C267 510 259 502 259 485L260 483L260 482C277 395 321 326 393 274L0 274L0 226L393 226C321 174 277 105 260 18L260 17L259 15C259-2 267-10 283-10C296-10 303-4 306 9C315 56 334 97 362 132C403 184 448 218 496 234Z" transform="translate(1804,0)"/><svg width="1874" height="188" x="0" y="156" viewbox="468.5 156 1874 188"><path data-c="2190" d="M0 226L337 226L337 274L0 274Z" transform="scale(8.341,1)"/></svg></g></g><g data-mml-node="mo" data-latex="-" transform="translate(2533.2,0)"><path data-c="2212" d="M698 270L80 270C64 270 56 263 56 250C56 237 64 230 80 230L698 230C714 230 722 237 722 250C722 262 710 270 698 270Z"/></g><g data-mml-node="mover" data-latex="\overrightarrow{Man}" transform="translate(3533.4,0)"><g data-mml-node="mrow" data-latex="Man"><g data-mml-node="mi" data-latex="M"><path data-c="1D440" d="M594 16C594 5 600 0 613 0L736 3C759 4 840 0 859 0C874 0 882 8 882 24C882 34 872 39 851 39C810 39 790 43 790 52C790 55 792 62 795 75L927 602C932 623 942 636 955 641C961 643 979 644 1008 644C1033 644 1044 645 1044 668C1044 678 1034 683 1013 683L882 683C853 683 853 681 840 662L484 108L408 657C404 682 402 683 373 683L237 683C215 683 204 682 204 660C204 649 215 644 236 644C256 644 297 647 297 631C297 629 296 623 293 613L167 110C158 72 135 49 100 42C75 39 42 43 42 16C42 5 48 0 60 0C78 0 141 3 159 3C178 3 242 0 261 0C276 0 283 8 283 24C283 33 276 38 261 39C219 39 198 52 198 78C198 82 199 89 202 100L332 621L415 26C418 9 424 0 434 0C442 0 450 7 459 20L848 627L712 82C706 60 696 47 681 42C675 40 656 39 625 39C604 39 594 37 594 16Z"/></g><g data-mml-node="mi" data-latex="a" transform="translate(1044,0)"><path data-c="1D44E" d="M498 144C498 153 493 158 482 158C474 158 468 151 465 137C445 58 421 18 394 18C377 18 368 32 368 60C368 73 372 97 381 132L438 357C443 376 445 387 445 392C445 412 434 422 412 422C391 422 377 410 370 387C349 424 319 442 281 442C216 442 159 409 109 343C63 281 40 217 40 150C40 63 91-11 175-11C218-11 260 12 300 58C311 20 345-11 392-11C461-11 482 70 498 144M341 374C350 353 355 339 355 330C355 326 354 321 353 314L304 122C301 111 294 99 285 87C248 41 212 18 177 18C138 18 118 48 118 107C118 131 124 167 136 215C157 300 187 357 224 388C244 405 263 413 282 413C309 413 329 400 341 374Z"/></g><g data-mml-node="mi" data-latex="n" transform="translate(1573,0)"><path data-c="1D45B" d="M537 137C514 58 481 18 440 18C427 18 420 28 420 47C420 61 426 84 438 115C478 224 498 296 498 333C498 403 451 442 381 442C322 442 271 416 230 363C222 407 187 442 136 442C80 442 58 390 44 345C34 313 29 294 29 287C29 278 34 273 45 273C50 273 53 274 56 276C61 285 64 292 65 299C83 375 106 413 133 413C151 413 160 399 160 371C160 358 155 331 144 290L87 63C84 50 78 24 78 19C78-1 89-11 111-11C130-11 144-1 151 19C153 24 159 49 170 92L191 181L221 295C232 318 249 341 270 365C299 397 335 413 378 413C411 413 427 391 427 348C427 310 406 234 363 120C356 102 353 87 353 74C353 25 390-11 438-11C482-11 517 14 542 64C561 104 571 131 571 144C571 153 566 158 555 158C552 158 537 149 537 137Z"/></g></g><g data-mml-node="mo" transform="translate(0,719.4)"><path data-c="2192" d="M496 234C503 237 507 243 507 250C507 257 503 263 496 266C448 282 403 316 362 368C334 403 315 444 306 491C303 504 296 510 283 510C267 510 259 502 259 485L260 483L260 482C277 395 321 326 393 274L0 274L0 226L393 226C321 174 277 105 260 18L260 17L259 15C259-2 267-10 283-10C296-10 303-4 306 9C315 56 334 97 362 132C403 184 448 218 496 234Z" transform="translate(1666,0)"/><svg width="1736" height="188" x="0" y="156" viewbox="434 156 1736 188"><path data-c="2190" d="M0 226L337 226L337 274L0 274Z" transform="scale(7.727,1)"/></svg></g></g><g data-mml-node="mo" data-latex="+" transform="translate(5928.7,0)"><path data-c="2B" d="M698 274L413 274L413 559C413 575 405 583 389 583C373 583 365 575 365 559L365 274L80 274C64 274 56 266 56 250C56 234 64 226 80 226L365 226L365-59C365-75 373-83 389-83C405-83 413-75 413-59L413 226L698 226C714 226 722 234 722 250C722 263 711 274 698 274Z"/></g><g data-mml-node="mover" data-latex="\overrightarrow{Woman}" transform="translate(6928.9,0)"><g data-mml-node="mrow" data-latex="Woman"><g data-mml-node="mi" data-latex="W"><path data-c="1D44A" d="M956 680C937 680 872 683 853 683C838 683 830 675 830 660C830 650 836 645 848 644C885 643 903 632 903 610C903 604 899 594 891 579L629 125L594 602C590 638 614 644 659 644C680 644 690 652 690 668C690 678 684 683 671 683C649 683 572 680 550 680C531 680 465 683 446 683C431 683 423 675 423 659C423 649 432 644 451 644C482 644 498 637 499 623L505 548L261 125L225 613C222 638 264 644 296 644C313 644 321 652 321 668C321 678 315 683 303 683C281 683 203 680 181 680C162 680 96 683 77 683C62 683 55 675 55 660C55 649 65 644 84 644C126 644 130 642 132 612L177 7C178-12 185-22 197-22C210-20 215-17 223-2C224-1 224 0 224 1L509 494L545 7C546-12 553-22 565-22C575-22 584-15 592-1L918 562C945 611 964 639 1025 644C1043 646 1048 651 1048 668C1048 678 1043 683 1032 683C1018 683 970 680 956 680Z"/></g><g data-mml-node="mi" data-latex="o" transform="translate(1048,0)"><path data-c="1D45C" d="M308 442C239 442 176 412 122 353C68 294 41 229 41 159C41 63 106-11 202-11C272-11 334 19 388 78C442 137 469 201 469 272C469 369 405 442 308 442M389 310C389 287 384 255 374 213C353 130 319 73 272 42C248 26 225 18 203 18C149 18 121 65 121 122C121 180 155 288 178 324C216 383 259 413 307 413C361 413 389 367 389 310Z"/></g><g data-mml-node="mi" data-latex="m" transform="translate(1533,0)"><path data-c="1D45A" d="M657 442C596 442 543 412 498 353C489 412 451 442 383 442C324 442 273 416 231 363C223 407 188 442 137 442C96 442 66 409 45 344C34 312 29 293 29 287C29 278 34 273 45 273C50 273 53 274 56 276C61 285 64 292 66 299C84 375 107 413 134 413C152 413 161 399 161 371C161 358 156 331 145 290L88 63C84 51 79 25 79 19C79-1 90-11 111-11C131-11 145-1 152 19C153 24 160 49 171 92L192 181L222 295C233 318 250 341 272 365C301 397 337 413 380 413C413 413 429 391 429 348C429 335 424 308 414 267L387 153C380 124 364 64 356 32C355 25 354 21 354 19C354-1 365-11 387-11C398-11 406-8 413-1C428 14 429 21 435 48L494 285C497 298 511 321 535 353C565 393 605 413 654 413C687 413 703 391 703 348C703 309 683 236 642 129C633 106 629 87 629 74C629 25 666-11 714-11C759-11 793 14 818 64C838 104 848 131 848 144C848 153 843 158 832 158C825 157 818 148 813 137C791 58 759 18 716 18C703 18 696 28 696 47C696 62 702 84 714 115C755 222 775 295 775 333C775 404 728 442 657 442Z"/></g><g data-mml-node="mi" data-latex="a" transform="translate(2411,0)"><path data-c="1D44E" d="M498 144C498 153 493 158 482 158C474 158 468 151 465 137C445 58 421 18 394 18C377 18 368 32 368 60C368 73 372 97 381 132L438 357C443 376 445 387 445 392C445 412 434 422 412 422C391 422 377 410 370 387C349 424 319 442 281 442C216 442 159 409 109 343C63 281 40 217 40 150C40 63 91-11 175-11C218-11 260 12 300 58C311 20 345-11 392-11C461-11 482 70 498 144M341 374C350 353 355 339 355 330C355 326 354 321 353 314L304 122C301 111 294 99 285 87C248 41 212 18 177 18C138 18 118 48 118 107C118 131 124 167 136 215C157 300 187 357 224 388C244 405 263 413 282 413C309 413 329 400 341 374Z"/></g><g data-mml-node="mi" data-latex="n" transform="translate(2940,0)"><path data-c="1D45B" d="M537 137C514 58 481 18 440 18C427 18 420 28 420 47C420 61 426 84 438 115C478 224 498 296 498 333C498 403 451 442 381 442C322 442 271 416 230 363C222 407 187 442 136 442C80 442 58 390 44 345C34 313 29 294 29 287C29 278 34 273 45 273C50 273 53 274 56 276C61 285 64 292 65 299C83 375 106 413 133 413C151 413 160 399 160 371C160 358 155 331 144 290L87 63C84 50 78 24 78 19C78-1 89-11 111-11C130-11 144-1 151 19C153 24 159 49 170 92L191 181L221 295C232 318 249 341 270 365C299 397 335 413 378 413C411 413 427 391 427 348C427 310 406 234 363 120C356 102 353 87 353 74C353 25 390-11 438-11C482-11 517 14 542 64C561 104 571 131 571 144C571 153 566 158 555 158C552 158 537 149 537 137Z"/></g></g><g data-mml-node="mo" transform="translate(0,719.4)"><path data-c="2192" d="M496 234C503 237 507 243 507 250C507 257 503 263 496 266C448 282 403 316 362 368C334 403 315 444 306 491C303 504 296 510 283 510C267 510 259 502 259 485L260 483L260 482C277 395 321 326 393 274L0 274L0 226L393 226C321 174 277 105 260 18L260 17L259 15C259-2 267-10 283-10C296-10 303-4 306 9C315 56 334 97 362 132C403 184 448 218 496 234Z" transform="translate(3033,0)"/><svg width="3103" height="188" x="0" y="156" viewbox="775.8 156 3103 188"><path data-c="2190" d="M0 226L337 226L337 274L0 274Z" transform="scale(13.812,1)"/></svg></g></g><g data-mml-node="mo" data-latex="=" transform="translate(10746.7,0)"><path data-c="3D" d="M698 367L80 367C64 367 56 359 56 344C56 329 64 321 80 321L698 321C714 321 722 329 722 344C722 356 711 367 698 367M698 179L80 179C64 179 56 171 56 156C56 141 64 133 80 133L698 133C714 133 722 141 722 156C722 169 711 179 698 179Z"/></g><g data-mml-node="mover" data-latex="\overrightarrow{Queen}" transform="translate(11802.4,0)"><g data-mml-node="mrow" data-latex="Queen"><g data-mml-node="mi" data-latex="Q"><path data-c="1D444" d="M306-24C335-24 366-19 399-10C396-48 395-72 395-81C395-156 424-194 481-194C542-194 589-145 612-100C637-48 650-14 650 2C650 11 645 16 635 16C628 16 623 12 620 3C605-43 564-90 508-90C457-90 450-49 442 6C526 39 597 96 654 178C711 260 740 345 740 434C740 513 717 577 670 628C623 679 561 705 484 705C431 705 378 692 325 665C217 612 138 528 87 415C62 358 49 302 49 245C49 88 151-24 306-24M645 466C645 405 630 335 600 254C565 161 511 92 436 48C432 70 426 90 418 108C405 138 381 153 346 153C291 153 241 103 241 48C241 39 242 30 244 23C177 54 144 117 144 213C144 255 152 306 169 366C204 493 267 583 358 636C401 660 441 672 478 672C588 672 645 581 645 466M346 123C383 123 402 96 402 43C402 34 399 29 393 27C365 15 338 9 312 9C284 9 270 22 270 48C270 86 308 123 346 123Z"/></g><g data-mml-node="mi" data-latex="u" transform="translate(791,0)"><path data-c="1D462" d="M543 144C543 153 538 158 527 158C518 158 513 151 510 137C505 118 500 99 493 80C480 39 462 18 440 18C422 18 413 32 413 60C413 77 420 111 433 161L460 267C469 303 477 328 483 359L489 386C491 393 492 398 492 401C492 421 481 431 459 431C437 431 423 419 417 394L343 98C342 95 338 88 330 76C314 50 275 18 235 18C197 18 178 44 178 95C178 136 196 202 231 294C242 324 248 345 248 357C248 407 213 442 163 442C118 442 83 417 58 367C39 328 29 301 29 287C29 278 34 273 45 273C58 273 60 279 64 293C87 373 119 413 160 413C174 413 181 403 181 384C181 369 175 348 164 319C126 218 107 148 107 111C107 34 155-11 232-11C275-11 314 9 347 50C361 9 391-11 437-11C506-11 527 70 543 144Z"/></g><g data-mml-node="mi" data-latex="e" transform="translate(1363,0)"><path data-c="1D452" d="M124 129C124 153 129 186 139 227L188 227C253 227 303 235 339 250C372 264 394 284 405 309C412 326 415 342 415 355C415 410 363 442 307 442C268 442 229 432 190 412C113 372 46 281 46 171C46 69 105-11 204-11C257-11 304 2 345 27C379 48 404 69 420 90C427 99 430 106 430 109C430 120 425 126 414 126C409 126 404 122 398 114C365 70 324 42 277 30C246 22 223 18 206 18C149 18 124 72 124 129M375 355C375 289 311 256 182 256L147 256C166 322 194 366 232 387C262 404 287 413 307 413C343 413 375 391 375 355Z"/></g><g data-mml-node="mi" data-latex="e" transform="translate(1829,0)"><path data-c="1D452" d="M124 129C124 153 129 186 139 227L188 227C253 227 303 235 339 250C372 264 394 284 405 309C412 326 415 342 415 355C415 410 363 442 307 442C268 442 229 432 190 412C113 372 46 281 46 171C46 69 105-11 204-11C257-11 304 2 345 27C379 48 404 69 420 90C427 99 430 106 430 109C430 120 425 126 414 126C409 126 404 122 398 114C365 70 324 42 277 30C246 22 223 18 206 18C149 18 124 72 124 129M375 355C375 289 311 256 182 256L147 256C166 322 194 366 232 387C262 404 287 413 307 413C343 413 375 391 375 355Z"/></g><g data-mml-node="mi" data-latex="n" transform="translate(2295,0)"><path data-c="1D45B" d="M537 137C514 58 481 18 440 18C427 18 420 28 420 47C420 61 426 84 438 115C478 224 498 296 498 333C498 403 451 442 381 442C322 442 271 416 230 363C222 407 187 442 136 442C80 442 58 390 44 345C34 313 29 294 29 287C29 278 34 273 45 273C50 273 53 274 56 276C61 285 64 292 65 299C83 375 106 413 133 413C151 413 160 399 160 371C160 358 155 331 144 290L87 63C84 50 78 24 78 19C78-1 89-11 111-11C130-11 144-1 151 19C153 24 159 49 170 92L191 181L221 295C232 318 249 341 270 365C299 397 335 413 378 413C411 413 427 391 427 348C427 310 406 234 363 120C356 102 353 87 353 74C353 25 390-11 438-11C482-11 517 14 542 64C561 104 571 131 571 144C571 153 566 158 555 158C552 158 537 149 537 137Z"/></g></g><g data-mml-node="mo" transform="translate(0,741.4)"><path data-c="2192" d="M496 234C503 237 507 243 507 250C507 257 503 263 496 266C448 282 403 316 362 368C334 403 315 444 306 491C303 504 296 510 283 510C267 510 259 502 259 485L260 483L260 482C277 395 321 326 393 274L0 274L0 226L393 226C321 174 277 105 260 18L260 17L259 15C259-2 267-10 283-10C296-10 303-4 306 9C315 56 334 97 362 132C403 184 448 218 496 234Z" transform="translate(2388,0)"/><svg width="2458" height="188" x="0" y="156" viewbox="614.5 156 2458 188"><path data-c="2190" d="M0 226L337 226L337 274L0 274Z" transform="scale(10.941,1)"/></svg></g></g></g></g></g></svg><svg data-labels="true" preserveaspectratio="xMaxYMid" viewbox="1278 -1011.4 1 1522.8"><g data-labels="true" transform="matrix(1 0 0 -1 0 0)"><g data-mml-node="mtd" id="mjx-eqn:1" transform="translate(0,486.6)"><text data-id-align="true"/><g data-idbox="true" transform="translate(0,-748)"><g data-mml-node="mtext" data-latex="\text{(}"><path data-c="28" d="M318-248C327-248 332-243 332-234C332-231 330-227 327-223C275-183 233-117 202-26C175 53 161 131 161 208L161 292C161 369 175 447 202 526C233 617 275 683 327 723C330 726 332 730 332 734C332 743 327 748 318 748C317 748 314 747 311 745C251 699 201 631 160 540C121 453 101 371 101 292L101 208C101 129 121 47 160-40C201-131 251-199 311-245C314-247 317-248 318-248Z"/></g><g data-mml-node="mtext" data-latex="\text{1}" transform="translate(389,0)"><path data-c="31" d="M269 666C228 624 168 603 89 603L89 564C141 564 184 572 217 588L217 82C217 64 213 52 204 47C195 42 170 39 130 39L95 39L95 0C120 2 174 3 257 3C340 3 394 2 419 0L419 39L384 39C343 39 318 42 310 47C302 52 297 64 297 82L297 636C297 660 295 666 269 666Z"/></g><g data-mml-node="mtext" data-latex="\text{)}" transform="translate(889,0)"><path data-c="29" d="M78-245C138-199 188-131 229-40C268 47 288 129 288 208L288 292C288 371 268 453 229 540C188 631 138 699 78 745C75 747 72 748 71 748C62 748 57 743 57 734C57 730 59 726 62 723C114 683 156 617 187 526C214 447 228 369 228 292L228 208C228 131 214 53 187-26C156-117 114-183 62-223C59-227 57-231 57-234C57-243 62-248 71-248C72-248 75-247 78-245Z"/></g></g></g></g></svg></g></g></g></g></svg></mjx-container></p><p>似乎发现了什么不得了的事情。</p><p>对于自然语言书写的文本这种非结构化信息,从文本中抽取出的特征来量化来表示文本信息,构建向量空间模型,并基于数学模型的处理,将文本转换为机器可以理解的语言的方式是很重要的。</p></div><div class="story post-story"><h2 id="举个栗子"><a href="#举个栗子" class="headerlink" title="举个栗子"></a>举个栗子</h2><p>要实现文章推荐,就需要从一堆文章中找出一些内容相似的文章。基本思路就是,如果文章的关键词越相似,那么他们的内容就会越相似。</p><p>我们先从几个简单的句子着手。</p><figure class="highlight bash"><table><tbody><tr><td class="code"><pre><span class="line">句子A:我这里有苹果和西瓜。</span><br><span class="line"></span><br><span class="line">句子B:我喜欢吃西瓜,不喜欢吃苹果。</span><br><span class="line"></span><br><span class="line">句子C:我喜欢吃蔬菜。</span><br></pre></td></tr></tbody></table></figure></div><div class="story post-story"><h2 id="第一步:数据清洗"><a href="#第一步:数据清洗" class="headerlink" title="第一步:数据清洗"></a>第一步:数据清洗</h2><p>简单去除标点符号等干扰信息。</p><figure class="highlight bash"><table><tbody><tr><td class="code"><pre><span class="line">句子A: 我这里有苹果和西瓜</span><br><span class="line"></span><br><span class="line">句子B: 我喜欢吃西瓜 不喜欢吃苹果</span><br><span class="line"></span><br><span class="line">句子C: 我喜欢吃蔬菜</span><br></pre></td></tr></tbody></table></figure></div><div class="story post-story"><h2 id="第二步:分词"><a href="#第二步:分词" class="headerlink" title="第二步:分词"></a>第二步:分词</h2><p>使用分词工具进行分词。</p><figure class="highlight bash"><table><tbody><tr><td class="code"><pre><span class="line">句子A:</span><br><span class="line"></span><br><span class="line">[ <span class="string">'我'</span>, <span class="string">'这里'</span>, <span class="string">'有'</span>, <span class="string">'苹果'</span>, <span class="string">'和'</span>, <span class="string">'西瓜'</span> ]</span><br><span class="line"></span><br><span class="line">句子B:</span><br><span class="line">[</span><br><span class="line">  <span class="string">'我'</span>, <span class="string">'喜欢'</span>,</span><br><span class="line">  <span class="string">'吃'</span>, <span class="string">'西瓜'</span>,</span><br><span class="line">  <span class="string">'不'</span>, <span class="string">'喜欢'</span>,</span><br><span class="line">  <span class="string">'吃'</span>, <span class="string">'苹果'</span></span><br><span class="line">]</span><br><span class="line"></span><br><span class="line">句子C:</span><br><span class="line"></span><br><span class="line">[ <span class="string">'我'</span>, <span class="string">'喜欢'</span>, <span class="string">'吃'</span>, <span class="string">'蔬菜'</span> ]</span><br></pre></td></tr></tbody></table></figure></div><div class="story post-story"><h2 id="第三步:去重收集所有句子中所有的词"><a href="#第三步:去重收集所有句子中所有的词" class="headerlink" title="第三步:去重收集所有句子中所有的词"></a>第三步:去重收集所有句子中所有的词</h2><figure class="highlight bash"><table><tbody><tr><td class="code"><pre><span class="line">[</span><br><span class="line">  <span class="string">'我'</span>,   <span class="string">'这里'</span>, <span class="string">'有'</span>,</span><br><span class="line">  <span class="string">'苹果'</span>, <span class="string">'和'</span>,   <span class="string">'西瓜'</span>,</span><br><span class="line">  <span class="string">'喜欢'</span>, <span class="string">'吃'</span>,   <span class="string">'不'</span>,</span><br><span class="line">  <span class="string">'蔬菜'</span></span><br><span class="line">]</span><br></pre></td></tr></tbody></table></figure></div><div class="story post-story"><h2 id="第四步:计算词频"><a href="#第四步:计算词频" class="headerlink" title="第四步:计算词频"></a>第四步:计算词频</h2><p>词频背后的假设是文章的重要程度即文章的相关度与单词在文档中出现的次数成正比。文章的关键词应当比文章中的其他词出现的次数多。</p><p><mjx-container class="MathJax" jax="SVG" overflow="overflow" display="true" width="full" style="min-width: 49.146ex;"><svg style="vertical-align: -0.566ex; min-width: 49.146ex;" xmlns="http://www.w3.org/2000/svg" width="100%" height="2.262ex" role="img" focusable="false" data-mjx-viewbox="0 -750 21722.6 1000"><g stroke="currentColor" fill="currentColor" stroke-width="0" transform="scale(0.0181,-0.0181) translate(0, -750)"><g data-mml-node="math" data-latex="词频(TF) = 某个词在文章中出现的次数"><g data-mml-node="mtable" data-latex="词频(TF) = 某个词在文章中出现的次数" transform="translate(2078,0) translate(-2078,0)"><g transform="translate(0 750) matrix(1 0 0 -1 0 0) scale(55.25)"><svg data-table="true" preserveaspectratio="xMidYMid" viewbox="8783.3 -750 1 1000"><g transform="matrix(1 0 0 -1 0 0)"><g data-mml-node="mlabeledtr"><g data-mml-node="mtd"><g data-mml-node="mi" data-latex="词"><text data-variant="normal" transform="scale(1,-1)" font-size="884px" font-family="serif">词</text></g><g data-mml-node="mi" data-latex="频" transform="translate(1000,0)"><text data-variant="normal" transform="scale(1,-1)" font-size="884px" font-family="serif">频</text></g><g data-mml-node="mo" data-latex="(" transform="translate(2000,0)"><path data-c="28" d="M318-248C327-248 332-243 332-234C332-231 330-227 327-223C275-183 233-117 202-26C175 53 161 131 161 208L161 292C161 369 175 447 202 526C233 617 275 683 327 723C330 726 332 730 332 734C332 743 327 748 318 748C317 748 314 747 311 745C251 699 201 631 160 540C121 453 101 371 101 292L101 208C101 129 121 47 160-40C201-131 251-199 311-245C314-247 317-248 318-248Z"/></g><g data-mml-node="mi" data-latex="T" transform="translate(2389,0)"><path data-c="1D447" d="M344 631C344 628 343 621 340 611L208 83C204 68 200 59 197 55C188 44 154 39 94 39C63 39 49 42 49 16C49 5 56 0 69 0C120 0 192 4 235 3L317 2C331 2 386 0 403 0C420 0 428 8 428 24C428 34 416 39 391 39C339 39 309 41 300 46C297 48 295 52 295 58L430 603C433 617 436 626 439 629C443 635 467 638 511 638C566 638 604 634 623 625C642 616 652 595 652 561C652 543 649 517 644 483C642 475 641 469 641 464C641 453 646 447 657 447C666 447 672 456 675 473L702 645C703 650 704 656 704 662C704 672 694 677 673 677L125 677C99 677 97 674 89 655L30 481C27 472 25 466 24 462C24 452 29 447 40 447C48 447 55 455 60 470C85 543 110 588 133 607C159 628 209 638 282 638L321 638C332 638 344 639 344 631Z"/></g><g data-mml-node="mi" data-latex="F" transform="translate(3093,0)"><path data-c="1D439" d="M199 656C199 646 210 641 231 641C271 641 291 637 291 628C291 625 289 618 286 605L156 82C150 60 140 47 126 42C119 40 101 39 70 39C48 39 38 37 38 16C38 5 44 0 57 0L187 3L335 0C351 0 359 8 359 23C359 40 348 39 322 39C278 39 253 41 247 46C244 47 243 51 243 56L307 321L400 321C446 321 478 319 478 281C478 268 476 252 471 233C470 230 469 226 468 222C468 211 473 206 484 206C489 207 496 214 503 229L557 444C559 452 560 458 560 461C557 470 551 475 544 475C536 475 530 467 526 452C516 414 502 390 486 378C470 366 442 360 402 360L317 360L379 606C387 640 387 641 429 641L559 641C656 641 700 626 700 537C700 517 699 499 697 484C696 473 695 467 695 466C695 455 700 450 710 450C720 450 726 459 728 478L748 649C751 677 744 680 717 680L233 680C210 680 199 679 199 656Z"/></g><g data-mml-node="mo" data-latex=")" transform="translate(3844,0)"><path data-c="29" d="M78-245C138-199 188-131 229-40C268 47 288 129 288 208L288 292C288 371 268 453 229 540C188 631 138 699 78 745C75 747 72 748 71 748C62 748 57 743 57 734C57 730 59 726 62 723C114 683 156 617 187 526C214 447 228 369 228 292L228 208C228 131 214 53 187-26C156-117 114-183 62-223C59-227 57-231 57-234C57-243 62-248 71-248C72-248 75-247 78-245Z"/></g><g data-mml-node="mo" data-latex="=" transform="translate(4510.8,0)"><path data-c="3D" d="M698 367L80 367C64 367 56 359 56 344C56 329 64 321 80 321L698 321C714 321 722 329 722 344C722 356 711 367 698 367M698 179L80 179C64 179 56 171 56 156C56 141 64 133 80 133L698 133C714 133 722 141 722 156C722 169 711 179 698 179Z"/></g><g data-mml-node="mi" data-latex="某" transform="translate(5566.6,0)"><text data-variant="normal" transform="scale(1,-1)" font-size="884px" font-family="serif">某</text></g><g data-mml-node="mi" data-latex="个" transform="translate(6566.6,0)"><text data-variant="normal" transform="scale(1,-1)" font-size="884px" font-family="serif">个</text></g><g data-mml-node="mi" data-latex="词" transform="translate(7566.6,0)"><text data-variant="normal" transform="scale(1,-1)" font-size="884px" font-family="serif">词</text></g><g data-mml-node="mi" data-latex="在" transform="translate(8566.6,0)"><text data-variant="normal" transform="scale(1,-1)" font-size="884px" font-family="serif">在</text></g><g data-mml-node="mi" data-latex="文" transform="translate(9566.6,0)"><text data-variant="normal" transform="scale(1,-1)" font-size="884px" font-family="serif">文</text></g><g data-mml-node="mi" data-latex="章" transform="translate(10566.6,0)"><text data-variant="normal" transform="scale(1,-1)" font-size="884px" font-family="serif">章</text></g><g data-mml-node="mi" data-latex="中" transform="translate(11566.6,0)"><text data-variant="normal" transform="scale(1,-1)" font-size="884px" font-family="serif">中</text></g><g data-mml-node="mi" data-latex="出" transform="translate(12566.6,0)"><text data-variant="normal" transform="scale(1,-1)" font-size="884px" font-family="serif">出</text></g><g data-mml-node="mi" data-latex="现" transform="translate(13566.6,0)"><text data-variant="normal" transform="scale(1,-1)" font-size="884px" font-family="serif">现</text></g><g data-mml-node="mi" data-latex="的" transform="translate(14566.6,0)"><text data-variant="normal" transform="scale(1,-1)" font-size="884px" font-family="serif">的</text></g><g data-mml-node="mi" data-latex="次" transform="translate(15566.6,0)"><text data-variant="normal" transform="scale(1,-1)" font-size="884px" font-family="serif">次</text></g><g data-mml-node="mi" data-latex="数" transform="translate(16566.6,0)"><text data-variant="normal" transform="scale(1,-1)" font-size="884px" font-family="serif">数</text></g></g></g></g></svg><svg data-labels="true" preserveaspectratio="xMaxYMid" viewbox="1278 -750 1 1000"><g data-labels="true" transform="matrix(1 0 0 -1 0 0)"><g data-mml-node="mtd" id="mjx-eqn:2"><g data-mml-node="mtext" data-latex="\text{(}"><path data-c="28" d="M318-248C327-248 332-243 332-234C332-231 330-227 327-223C275-183 233-117 202-26C175 53 161 131 161 208L161 292C161 369 175 447 202 526C233 617 275 683 327 723C330 726 332 730 332 734C332 743 327 748 318 748C317 748 314 747 311 745C251 699 201 631 160 540C121 453 101 371 101 292L101 208C101 129 121 47 160-40C201-131 251-199 311-245C314-247 317-248 318-248Z"/></g><g data-mml-node="mtext" data-latex="\text{2}" transform="translate(389,0)"><path data-c="32" d="M237 666C186 666 143 648 106 612C69 576 50 534 50 483C50 449 75 424 106 424C136 424 161 450 161 480C161 513 137 536 105 536C102 536 100 536 98 535C117 584 161 627 224 627C306 627 352 556 352 470C352 403 318 331 250 255L62 43C49 28 50 29 50 0L421 0L450 180L417 180C409 129 402 100 396 91C391 86 361 84 306 84L139 84L236 179C304 243 390 312 419 365C439 400 449 435 449 470C449 588 357 666 237 666Z"/></g><g data-mml-node="mtext" data-latex="\text{)}" transform="translate(889,0)"><path data-c="29" d="M78-245C138-199 188-131 229-40C268 47 288 129 288 208L288 292C288 371 268 453 229 540C188 631 138 699 78 745C75 747 72 748 71 748C62 748 57 743 57 734C57 730 59 726 62 723C114 683 156 617 187 526C214 447 228 369 228 292L228 208C228 131 214 53 187-26C156-117 114-183 62-223C59-227 57-231 57-234C57-243 62-248 71-248C72-248 75-247 78-245Z"/></g></g></g></svg></g></g></g></g></svg></mjx-container></p><figure class="highlight bash"><table><tbody><tr><td class="code"><pre><span class="line">句子A:</span><br><span class="line"></span><br><span class="line">{</span><br><span class="line">  <span class="string">'我'</span>: 1,</span><br><span class="line">  <span class="string">'这里'</span>: 1,</span><br><span class="line">  <span class="string">'有'</span>: 1,</span><br><span class="line">  <span class="string">'苹果'</span>: 1,</span><br><span class="line">  <span class="string">'和'</span>: 1,</span><br><span class="line">  <span class="string">'西瓜'</span>: 1,</span><br><span class="line">  <span class="string">'喜欢'</span>: 0,</span><br><span class="line">  <span class="string">'吃'</span>: 0,</span><br><span class="line">  <span class="string">'不'</span>: 0,</span><br><span class="line">  <span class="string">'蔬菜'</span>: 0</span><br><span class="line">}</span><br><span class="line"></span><br><span class="line">句子B:</span><br><span class="line">{</span><br><span class="line">  <span class="string">'我'</span>: 1,</span><br><span class="line">  <span class="string">'这里'</span>: 0,</span><br><span class="line">  <span class="string">'有'</span>: 0,</span><br><span class="line">  <span class="string">'苹果'</span>: 1,</span><br><span class="line">  <span class="string">'和'</span>: 0,</span><br><span class="line">  <span class="string">'西瓜'</span>: 1,</span><br><span class="line">  <span class="string">'喜欢'</span>: 2,</span><br><span class="line">  <span class="string">'吃'</span>: 2,</span><br><span class="line">  <span class="string">'不'</span>: 1,</span><br><span class="line">  <span class="string">'蔬菜'</span>: 0</span><br><span class="line">}</span><br><span class="line"></span><br><span class="line">句子C:</span><br><span class="line"></span><br><span class="line">{</span><br><span class="line">  <span class="string">'我'</span>: 1,</span><br><span class="line">  <span class="string">'这里'</span>: 0,</span><br><span class="line">  <span class="string">'有'</span>: 0,</span><br><span class="line">  <span class="string">'苹果'</span>: 0,</span><br><span class="line">  <span class="string">'和'</span>: 0,</span><br><span class="line">  <span class="string">'西瓜'</span>: 0,</span><br><span class="line">  <span class="string">'喜欢'</span>: 1,</span><br><span class="line">  <span class="string">'吃'</span>: 1,</span><br><span class="line">  <span class="string">'不'</span>: 0,</span><br><span class="line">  <span class="string">'蔬菜'</span>: 1</span><br><span class="line">}</span><br></pre></td></tr></tbody></table></figure></div><div class="story post-story"><h2 id="第四步:词频标准化"><a href="#第四步:词频标准化" class="headerlink" title="第四步:词频标准化"></a>第四步:词频标准化</h2><p>文章的篇幅有长有短,为了便于不同文章的比较,进行"词频"标准化。词频标准化的目的是把所有的词频在同一维度上分析。</p><p>词频标准化有两种方案:</p><p>方案一:</p><p><mjx-container class="MathJax" jax="SVG" overflow="overflow" display="true" width="full" style="min-width: 50.142ex;"><svg style="vertical-align: -2.077ex; min-width: 50.142ex;" xmlns="http://www.w3.org/2000/svg" width="100%" height="5.285ex" role="img" focusable="false" data-mjx-viewbox="0 -1418 22162.6 2336"><g stroke="currentColor" fill="currentColor" stroke-width="0" transform="scale(0.0181,-0.0181) translate(0, -1418)"><g data-mml-node="math" data-latex="
词频(TF) = \frac{某个词在文章中出现的次数}{文章的总词数}
"><g data-mml-node="mtable" data-latex="词频(TF) = \frac{某个词在文章中出现的次数}{文章的总词数}" transform="translate(2078,0) translate(-2078,0)"><g transform="translate(0 1418) matrix(1 0 0 -1 0 0) scale(55.25)"><svg data-table="true" preserveaspectratio="xMidYMid" viewbox="9003.3 -1418 1 2336"><g transform="matrix(1 0 0 -1 0 0)"><g data-mml-node="mlabeledtr" transform="translate(0,-8)"><g data-mml-node="mtd"><g data-mml-node="mi" data-latex="词"><text data-variant="normal" transform="scale(1,-1)" font-size="884px" font-family="serif">词</text></g><g data-mml-node="mi" data-latex="频" transform="translate(1000,0)"><text data-variant="normal" transform="scale(1,-1)" font-size="884px" font-family="serif">频</text></g><g data-mml-node="mo" data-latex="(" transform="translate(2000,0)"><path data-c="28" d="M318-248C327-248 332-243 332-234C332-231 330-227 327-223C275-183 233-117 202-26C175 53 161 131 161 208L161 292C161 369 175 447 202 526C233 617 275 683 327 723C330 726 332 730 332 734C332 743 327 748 318 748C317 748 314 747 311 745C251 699 201 631 160 540C121 453 101 371 101 292L101 208C101 129 121 47 160-40C201-131 251-199 311-245C314-247 317-248 318-248Z"/></g><g data-mml-node="mi" data-latex="T" transform="translate(2389,0)"><path data-c="1D447" d="M344 631C344 628 343 621 340 611L208 83C204 68 200 59 197 55C188 44 154 39 94 39C63 39 49 42 49 16C49 5 56 0 69 0C120 0 192 4 235 3L317 2C331 2 386 0 403 0C420 0 428 8 428 24C428 34 416 39 391 39C339 39 309 41 300 46C297 48 295 52 295 58L430 603C433 617 436 626 439 629C443 635 467 638 511 638C566 638 604 634 623 625C642 616 652 595 652 561C652 543 649 517 644 483C642 475 641 469 641 464C641 453 646 447 657 447C666 447 672 456 675 473L702 645C703 650 704 656 704 662C704 672 694 677 673 677L125 677C99 677 97 674 89 655L30 481C27 472 25 466 24 462C24 452 29 447 40 447C48 447 55 455 60 470C85 543 110 588 133 607C159 628 209 638 282 638L321 638C332 638 344 639 344 631Z"/></g><g data-mml-node="mi" data-latex="F" transform="translate(3093,0)"><path data-c="1D439" d="M199 656C199 646 210 641 231 641C271 641 291 637 291 628C291 625 289 618 286 605L156 82C150 60 140 47 126 42C119 40 101 39 70 39C48 39 38 37 38 16C38 5 44 0 57 0L187 3L335 0C351 0 359 8 359 23C359 40 348 39 322 39C278 39 253 41 247 46C244 47 243 51 243 56L307 321L400 321C446 321 478 319 478 281C478 268 476 252 471 233C470 230 469 226 468 222C468 211 473 206 484 206C489 207 496 214 503 229L557 444C559 452 560 458 560 461C557 470 551 475 544 475C536 475 530 467 526 452C516 414 502 390 486 378C470 366 442 360 402 360L317 360L379 606C387 640 387 641 429 641L559 641C656 641 700 626 700 537C700 517 699 499 697 484C696 473 695 467 695 466C695 455 700 450 710 450C720 450 726 459 728 478L748 649C751 677 744 680 717 680L233 680C210 680 199 679 199 656Z"/></g><g data-mml-node="mo" data-latex=")" transform="translate(3844,0)"><path data-c="29" d="M78-245C138-199 188-131 229-40C268 47 288 129 288 208L288 292C288 371 268 453 229 540C188 631 138 699 78 745C75 747 72 748 71 748C62 748 57 743 57 734C57 730 59 726 62 723C114 683 156 617 187 526C214 447 228 369 228 292L228 208C228 131 214 53 187-26C156-117 114-183 62-223C59-227 57-231 57-234C57-243 62-248 71-248C72-248 75-247 78-245Z"/></g><g data-mml-node="mo" data-latex="=" transform="translate(4510.8,0)"><path data-c="3D" d="M698 367L80 367C64 367 56 359 56 344C56 329 64 321 80 321L698 321C714 321 722 329 722 344C722 356 711 367 698 367M698 179L80 179C64 179 56 171 56 156C56 141 64 133 80 133L698 133C714 133 722 141 722 156C722 169 711 179 698 179Z"/></g><g data-mml-node="mfrac" data-latex="\frac{某个词在文章中出现的次数}{文章的总词数}" transform="translate(5566.6,0)"><g data-mml-node="mrow" data-latex="某个词在文章中出现的次数" transform="translate(220,676)"><g data-mml-node="mi" data-latex="某"><text data-variant="normal" transform="scale(1,-1)" font-size="884px" font-family="serif">某</text></g><g data-mml-node="mi" data-latex="个" transform="translate(1000,0)"><text data-variant="normal" transform="scale(1,-1)" font-size="884px" font-family="serif">个</text></g><g data-mml-node="mi" data-latex="词" transform="translate(2000,0)"><text data-variant="normal" transform="scale(1,-1)" font-size="884px" font-family="serif">词</text></g><g data-mml-node="mi" data-latex="在" transform="translate(3000,0)"><text data-variant="normal" transform="scale(1,-1)" font-size="884px" font-family="serif">在</text></g><g data-mml-node="mi" data-latex="文" transform="translate(4000,0)"><text data-variant="normal" transform="scale(1,-1)" font-size="884px" font-family="serif">文</text></g><g data-mml-node="mi" data-latex="章" transform="translate(5000,0)"><text data-variant="normal" transform="scale(1,-1)" font-size="884px" font-family="serif">章</text></g><g data-mml-node="mi" data-latex="中" transform="translate(6000,0)"><text data-variant="normal" transform="scale(1,-1)" font-size="884px" font-family="serif">中</text></g><g data-mml-node="mi" data-latex="出" transform="translate(7000,0)"><text data-variant="normal" transform="scale(1,-1)" font-size="884px" font-family="serif">出</text></g><g data-mml-node="mi" data-latex="现" transform="translate(8000,0)"><text data-variant="normal" transform="scale(1,-1)" font-size="884px" font-family="serif">现</text></g><g data-mml-node="mi" data-latex="的" transform="translate(9000,0)"><text data-variant="normal" transform="scale(1,-1)" font-size="884px" font-family="serif">的</text></g><g data-mml-node="mi" data-latex="次" transform="translate(10000,0)"><text data-variant="normal" transform="scale(1,-1)" font-size="884px" font-family="serif">次</text></g><g data-mml-node="mi" data-latex="数" transform="translate(11000,0)"><text data-variant="normal" transform="scale(1,-1)" font-size="884px" font-family="serif">数</text></g></g><g data-mml-node="mrow" data-latex="文章的总词数" transform="translate(3220,-710)"><g data-mml-node="mi" data-latex="文"><text data-variant="normal" transform="scale(1,-1)" font-size="884px" font-family="serif">文</text></g><g data-mml-node="mi" data-latex="章" transform="translate(1000,0)"><text data-variant="normal" transform="scale(1,-1)" font-size="884px" font-family="serif">章</text></g><g data-mml-node="mi" data-latex="的" transform="translate(2000,0)"><text data-variant="normal" transform="scale(1,-1)" font-size="884px" font-family="serif">的</text></g><g data-mml-node="mi" data-latex="总" transform="translate(3000,0)"><text data-variant="normal" transform="scale(1,-1)" font-size="884px" font-family="serif">总</text></g><g data-mml-node="mi" data-latex="词" transform="translate(4000,0)"><text data-variant="normal" transform="scale(1,-1)" font-size="884px" font-family="serif">词</text></g><g data-mml-node="mi" data-latex="数" transform="translate(5000,0)"><text data-variant="normal" transform="scale(1,-1)" font-size="884px" font-family="serif">数</text></g></g><rect width="12200" height="60" x="120" y="220"/></g></g></g></g></svg><svg data-labels="true" preserveaspectratio="xMaxYMid" viewbox="1278 -1418 1 2336"><g data-labels="true" transform="matrix(1 0 0 -1 0 0)"><g data-mml-node="mtd" id="mjx-eqn:3" transform="translate(0,740)"><text data-id-align="true"/><g data-idbox="true" transform="translate(0,-748)"><g data-mml-node="mtext" data-latex="\text{(}"><path data-c="28" d="M318-248C327-248 332-243 332-234C332-231 330-227 327-223C275-183 233-117 202-26C175 53 161 131 161 208L161 292C161 369 175 447 202 526C233 617 275 683 327 723C330 726 332 730 332 734C332 743 327 748 318 748C317 748 314 747 311 745C251 699 201 631 160 540C121 453 101 371 101 292L101 208C101 129 121 47 160-40C201-131 251-199 311-245C314-247 317-248 318-248Z"/></g><g data-mml-node="mtext" data-latex="\text{3}" transform="translate(389,0)"><path data-c="33" d="M303 353C369 378 431 441 431 526C431 569 410 604 369 631C333 654 292 666 246 666C201 666 162 654 127 631C88 605 68 571 68 528C68 495 90 472 122 472C154 472 176 495 176 527C176 560 157 578 119 580C145 615 186 633 242 633C302 633 332 598 332 527C332 485 324 450 309 421C282 373 245 364 183 364C171 362 165 357 165 348C165 333 172 333 192 333L235 333C310 333 348 280 348 173C348 88 317 14 241 14C176 14 128 36 99 80C134 79 160 105 160 139C160 173 135 198 101 198C62 198 42 178 42 137C42 88 64 49 108 18C147-9 193-22 244-22C301-22 350-3 393 34C436 71 457 117 457 173C457 267 383 332 303 353Z"/></g><g data-mml-node="mtext" data-latex="\text{)}" transform="translate(889,0)"><path data-c="29" d="M78-245C138-199 188-131 229-40C268 47 288 129 288 208L288 292C288 371 268 453 229 540C188 631 138 699 78 745C75 747 72 748 71 748C62 748 57 743 57 734C57 730 59 726 62 723C114 683 156 617 187 526C214 447 228 369 228 292L228 208C228 131 214 53 187-26C156-117 114-183 62-223C59-227 57-231 57-234C57-243 62-248 71-248C72-248 75-247 78-245Z"/></g></g></g></g></svg></g></g></g></g></svg></mjx-container></p><p>方案二:</p><p><mjx-container class="MathJax" jax="SVG" overflow="overflow" display="true" width="full" style="min-width: 52.404ex;"><svg style="vertical-align: -2.077ex; min-width: 52.404ex;" xmlns="http://www.w3.org/2000/svg" width="100%" height="5.285ex" role="img" focusable="false" data-mjx-viewbox="0 -1418 23162.6 2336"><g stroke="currentColor" fill="currentColor" stroke-width="0" transform="scale(0.0181,-0.0181) translate(0, -1418)"><g data-mml-node="math" data-latex="
词频(TF) = \frac{某个词在文章中出现的次数}{该文出现最多的词出现的次数}
"><g data-mml-node="mtable" data-latex="词频(TF) = \frac{某个词在文章中出现的次数}{该文出现最多的词出现的次数}" transform="translate(2078,0) translate(-2078,0)"><g transform="translate(0 1418) matrix(1 0 0 -1 0 0) scale(55.25)"><svg data-table="true" preserveaspectratio="xMidYMid" viewbox="9503.3 -1418 1 2336"><g transform="matrix(1 0 0 -1 0 0)"><g data-mml-node="mlabeledtr" transform="translate(0,-8)"><g data-mml-node="mtd"><g data-mml-node="mi" data-latex="词"><text data-variant="normal" transform="scale(1,-1)" font-size="884px" font-family="serif">词</text></g><g data-mml-node="mi" data-latex="频" transform="translate(1000,0)"><text data-variant="normal" transform="scale(1,-1)" font-size="884px" font-family="serif">频</text></g><g data-mml-node="mo" data-latex="(" transform="translate(2000,0)"><path data-c="28" d="M318-248C327-248 332-243 332-234C332-231 330-227 327-223C275-183 233-117 202-26C175 53 161 131 161 208L161 292C161 369 175 447 202 526C233 617 275 683 327 723C330 726 332 730 332 734C332 743 327 748 318 748C317 748 314 747 311 745C251 699 201 631 160 540C121 453 101 371 101 292L101 208C101 129 121 47 160-40C201-131 251-199 311-245C314-247 317-248 318-248Z"/></g><g data-mml-node="mi" data-latex="T" transform="translate(2389,0)"><path data-c="1D447" d="M344 631C344 628 343 621 340 611L208 83C204 68 200 59 197 55C188 44 154 39 94 39C63 39 49 42 49 16C49 5 56 0 69 0C120 0 192 4 235 3L317 2C331 2 386 0 403 0C420 0 428 8 428 24C428 34 416 39 391 39C339 39 309 41 300 46C297 48 295 52 295 58L430 603C433 617 436 626 439 629C443 635 467 638 511 638C566 638 604 634 623 625C642 616 652 595 652 561C652 543 649 517 644 483C642 475 641 469 641 464C641 453 646 447 657 447C666 447 672 456 675 473L702 645C703 650 704 656 704 662C704 672 694 677 673 677L125 677C99 677 97 674 89 655L30 481C27 472 25 466 24 462C24 452 29 447 40 447C48 447 55 455 60 470C85 543 110 588 133 607C159 628 209 638 282 638L321 638C332 638 344 639 344 631Z"/></g><g data-mml-node="mi" data-latex="F" transform="translate(3093,0)"><path data-c="1D439" d="M199 656C199 646 210 641 231 641C271 641 291 637 291 628C291 625 289 618 286 605L156 82C150 60 140 47 126 42C119 40 101 39 70 39C48 39 38 37 38 16C38 5 44 0 57 0L187 3L335 0C351 0 359 8 359 23C359 40 348 39 322 39C278 39 253 41 247 46C244 47 243 51 243 56L307 321L400 321C446 321 478 319 478 281C478 268 476 252 471 233C470 230 469 226 468 222C468 211 473 206 484 206C489 207 496 214 503 229L557 444C559 452 560 458 560 461C557 470 551 475 544 475C536 475 530 467 526 452C516 414 502 390 486 378C470 366 442 360 402 360L317 360L379 606C387 640 387 641 429 641L559 641C656 641 700 626 700 537C700 517 699 499 697 484C696 473 695 467 695 466C695 455 700 450 710 450C720 450 726 459 728 478L748 649C751 677 744 680 717 680L233 680C210 680 199 679 199 656Z"/></g><g data-mml-node="mo" data-latex=")" transform="translate(3844,0)"><path data-c="29" d="M78-245C138-199 188-131 229-40C268 47 288 129 288 208L288 292C288 371 268 453 229 540C188 631 138 699 78 745C75 747 72 748 71 748C62 748 57 743 57 734C57 730 59 726 62 723C114 683 156 617 187 526C214 447 228 369 228 292L228 208C228 131 214 53 187-26C156-117 114-183 62-223C59-227 57-231 57-234C57-243 62-248 71-248C72-248 75-247 78-245Z"/></g><g data-mml-node="mo" data-latex="=" transform="translate(4510.8,0)"><path data-c="3D" d="M698 367L80 367C64 367 56 359 56 344C56 329 64 321 80 321L698 321C714 321 722 329 722 344C722 356 711 367 698 367M698 179L80 179C64 179 56 171 56 156C56 141 64 133 80 133L698 133C714 133 722 141 722 156C722 169 711 179 698 179Z"/></g><g data-mml-node="mfrac" data-latex="\frac{某个词在文章中出现的次数}{该文出现最多的词出现的次数}" transform="translate(5566.6,0)"><g data-mml-node="mrow" data-latex="某个词在文章中出现的次数" transform="translate(720,676)"><g data-mml-node="mi" data-latex="某"><text data-variant="normal" transform="scale(1,-1)" font-size="884px" font-family="serif">某</text></g><g data-mml-node="mi" data-latex="个" transform="translate(1000,0)"><text data-variant="normal" transform="scale(1,-1)" font-size="884px" font-family="serif">个</text></g><g data-mml-node="mi" data-latex="词" transform="translate(2000,0)"><text data-variant="normal" transform="scale(1,-1)" font-size="884px" font-family="serif">词</text></g><g data-mml-node="mi" data-latex="在" transform="translate(3000,0)"><text data-variant="normal" transform="scale(1,-1)" font-size="884px" font-family="serif">在</text></g><g data-mml-node="mi" data-latex="文" transform="translate(4000,0)"><text data-variant="normal" transform="scale(1,-1)" font-size="884px" font-family="serif">文</text></g><g data-mml-node="mi" data-latex="章" transform="translate(5000,0)"><text data-variant="normal" transform="scale(1,-1)" font-size="884px" font-family="serif">章</text></g><g data-mml-node="mi" data-latex="中" transform="translate(6000,0)"><text data-variant="normal" transform="scale(1,-1)" font-size="884px" font-family="serif">中</text></g><g data-mml-node="mi" data-latex="出" transform="translate(7000,0)"><text data-variant="normal" transform="scale(1,-1)" font-size="884px" font-family="serif">出</text></g><g data-mml-node="mi" data-latex="现" transform="translate(8000,0)"><text data-variant="normal" transform="scale(1,-1)" font-size="884px" font-family="serif">现</text></g><g data-mml-node="mi" data-latex="的" transform="translate(9000,0)"><text data-variant="normal" transform="scale(1,-1)" font-size="884px" font-family="serif">的</text></g><g data-mml-node="mi" data-latex="次" transform="translate(10000,0)"><text data-variant="normal" transform="scale(1,-1)" font-size="884px" font-family="serif">次</text></g><g data-mml-node="mi" data-latex="数" transform="translate(11000,0)"><text data-variant="normal" transform="scale(1,-1)" font-size="884px" font-family="serif">数</text></g></g><g data-mml-node="mrow" data-latex="该文出现最多的词出现的次数" transform="translate(220,-710)"><g data-mml-node="mi" data-latex="该"><text data-variant="normal" transform="scale(1,-1)" font-size="884px" font-family="serif">该</text></g><g data-mml-node="mi" data-latex="文" transform="translate(1000,0)"><text data-variant="normal" transform="scale(1,-1)" font-size="884px" font-family="serif">文</text></g><g data-mml-node="mi" data-latex="出" transform="translate(2000,0)"><text data-variant="normal" transform="scale(1,-1)" font-size="884px" font-family="serif">出</text></g><g data-mml-node="mi" data-latex="现" transform="translate(3000,0)"><text data-variant="normal" transform="scale(1,-1)" font-size="884px" font-family="serif">现</text></g><g data-mml-node="mi" data-latex="最" transform="translate(4000,0)"><text data-variant="normal" transform="scale(1,-1)" font-size="884px" font-family="serif">最</text></g><g data-mml-node="mi" data-latex="多" transform="translate(5000,0)"><text data-variant="normal" transform="scale(1,-1)" font-size="884px" font-family="serif">多</text></g><g data-mml-node="mi" data-latex="的" transform="translate(6000,0)"><text data-variant="normal" transform="scale(1,-1)" font-size="884px" font-family="serif">的</text></g><g data-mml-node="mi" data-latex="词" transform="translate(7000,0)"><text data-variant="normal" transform="scale(1,-1)" font-size="884px" font-family="serif">词</text></g><g data-mml-node="mi" data-latex="出" transform="translate(8000,0)"><text data-variant="normal" transform="scale(1,-1)" font-size="884px" font-family="serif">出</text></g><g data-mml-node="mi" data-latex="现" transform="translate(9000,0)"><text data-variant="normal" transform="scale(1,-1)" font-size="884px" font-family="serif">现</text></g><g data-mml-node="mi" data-latex="的" transform="translate(10000,0)"><text data-variant="normal" transform="scale(1,-1)" font-size="884px" font-family="serif">的</text></g><g data-mml-node="mi" data-latex="次" transform="translate(11000,0)"><text data-variant="normal" transform="scale(1,-1)" font-size="884px" font-family="serif">次</text></g><g data-mml-node="mi" data-latex="数" transform="translate(12000,0)"><text data-variant="normal" transform="scale(1,-1)" font-size="884px" font-family="serif">数</text></g></g><rect width="13200" height="60" x="120" y="220"/></g></g></g></g></svg><svg data-labels="true" preserveaspectratio="xMaxYMid" viewbox="1278 -1418 1 2336"><g data-labels="true" transform="matrix(1 0 0 -1 0 0)"><g data-mml-node="mtd" id="mjx-eqn:4" transform="translate(0,740)"><text data-id-align="true"/><g data-idbox="true" transform="translate(0,-748)"><g data-mml-node="mtext" data-latex="\text{(}"><path data-c="28" d="M318-248C327-248 332-243 332-234C332-231 330-227 327-223C275-183 233-117 202-26C175 53 161 131 161 208L161 292C161 369 175 447 202 526C233 617 275 683 327 723C330 726 332 730 332 734C332 743 327 748 318 748C317 748 314 747 311 745C251 699 201 631 160 540C121 453 101 371 101 292L101 208C101 129 121 47 160-40C201-131 251-199 311-245C314-247 317-248 318-248Z"/></g><g data-mml-node="mtext" data-latex="\text{4}" transform="translate(389,0)"><path data-c="34" d="M353 677C344 677 336 672 330 663L28 199L28 163L289 163L289 81C289 63 285 51 278 46C271 41 252 39 219 39L194 39L194 0C223 2 269 3 331 3C393 3 439 2 468 0L468 39L443 39C410 39 391 41 384 46C377 51 373 63 373 81L373 163L471 163L471 202L373 202L373 660C373 670 366 677 353 677M295 553L295 202L67 202Z"/></g><g data-mml-node="mtext" data-latex="\text{)}" transform="translate(889,0)"><path data-c="29" d="M78-245C138-199 188-131 229-40C268 47 288 129 288 208L288 292C288 371 268 453 229 540C188 631 138 699 78 745C75 747 72 748 71 748C62 748 57 743 57 734C57 730 59 726 62 723C114 683 156 617 187 526C214 447 228 369 228 292L228 208C228 131 214 53 187-26C156-117 114-183 62-223C59-227 57-231 57-234C57-243 62-248 71-248C72-248 75-247 78-245Z"/></g></g></g></g></svg></g></g></g></g></svg></mjx-container></p><p>一般情况下,第二个标准化方案更适用,因为能够使词频的值相对大点,便于分析。</p><p>有时候常常用 <mjx-container class="MathJax" jax="SVG" overflow="overflow"><svg style="vertical-align: -0.566ex;" xmlns="http://www.w3.org/2000/svg" width="1.131ex" height="2.262ex" role="img" focusable="false" viewbox="0 -750 500 1000"><g stroke="currentColor" fill="currentColor" stroke-width="0" transform="scale(1,-1)"><g data-mml-node="math" data-latex="1+\log(TF)"><g data-mml-node="mn" data-latex="1"><path data-c="31" d="M269 666C228 624 168 603 89 603L89 564C141 564 184 572 217 588L217 82C217 64 213 52 204 47C195 42 170 39 130 39L95 39L95 0C120 2 174 3 257 3C340 3 394 2 419 0L419 39L384 39C343 39 318 42 310 47C302 52 297 64 297 82L297 636C297 660 295 666 269 666Z"/></g></g></g></svg><mjx-break size="3"> </mjx-break><svg style="vertical-align: -0.566ex;" xmlns="http://www.w3.org/2000/svg" width="10.206ex" height="2.262ex" role="img" focusable="false" viewbox="0 -750 4511.2 1000"><g stroke="currentColor" fill="currentColor" stroke-width="0" transform="scale(1,-1)"><g data-mml-node="math" data-latex="1+\log(TF)"><g data-mml-node="mo" data-latex="+"><path data-c="2B" d="M698 274L413 274L413 559C413 575 405 583 389 583C373 583 365 575 365 559L365 274L80 274C64 274 56 266 56 250C56 234 64 226 80 226L365 226L365-59C365-75 373-83 389-83C405-83 413-75 413-59L413 226L698 226C714 226 722 234 722 250C722 263 711 274 698 274Z"/></g><g data-mml-node="mi" data-latex="\log" transform="translate(1000.2,0)"><path data-c="6C" d="M144 3L255 0L255 39C219 39 197 40 190 44C183 48 180 60 180 79L180 694L33 683L33 645C68 645 90 642 97 636C104 630 108 616 108 593L108 79C108 60 105 48 98 44C91 40 69 39 33 39L33 0Z"/><path data-c="6F" d="M249-11C311-11 363 11 406 55C449 99 471 152 471 214C471 277 450 332 408 378C366 424 313 448 250 448C187 448 135 424 92 378C49 332 28 277 28 214C28 152 49 99 92 55C135 11 188-11 249-11M250 21C202 21 166 42 141 85C125 113 117 159 117 222C117 283 125 327 140 355C164 398 200 419 249 419C296 419 332 398 357 357C374 329 382 284 382 222C382 106 348 21 250 21Z" transform="translate(278,0)"/><path data-c="67" d="M431 453C393 453 358 438 326 408C296 431 262 442 223 442C137 442 59 378 59 294C59 252 74 218 104 192C85 168 75 141 75 110C75 72 88 43 113 24C71 10 28-26 28-77C28-120 56-154 111-178C153-197 199-206 249-206C300-206 347-197 389-178C444-154 471-120 471-75C471-22 449 17 405 42C359 67 308 70 234 70C190 70 166 70 161 71C133 75 113 102 113 133C113 148 117 162 126 174C154 155 186 145 223 145C309 145 386 209 386 293C386 332 373 364 347 389C372 412 399 423 428 423C423 418 420 410 420 400C420 378 431 367 453 367C474 367 485 378 485 401C485 432 461 453 431 453M223 411C277 411 304 372 304 294C304 215 277 175 223 175C168 175 141 214 141 293C141 372 168 411 223 411M164 4L222 4C274 4 316 1 348-6C391-15 412-39 412-77C412-109 392-134 352-153C321-168 287-175 250-175C214-175 180-168 148-153C107-134 87-109 87-77C87-35 123 4 164 4Z" transform="translate(778,0)"/></g><g data-mml-node="mo" transform="translate(2278.2,0)"><path data-c="2061" d=""/></g><g data-mml-node="mo" data-latex="(" transform="translate(2278.2,0)"><path data-c="28" d="M318-248C327-248 332-243 332-234C332-231 330-227 327-223C275-183 233-117 202-26C175 53 161 131 161 208L161 292C161 369 175 447 202 526C233 617 275 683 327 723C330 726 332 730 332 734C332 743 327 748 318 748C317 748 314 747 311 745C251 699 201 631 160 540C121 453 101 371 101 292L101 208C101 129 121 47 160-40C201-131 251-199 311-245C314-247 317-248 318-248Z"/></g><g data-mml-node="mi" data-latex="T" transform="translate(2667.2,0)"><path data-c="1D447" d="M344 631C344 628 343 621 340 611L208 83C204 68 200 59 197 55C188 44 154 39 94 39C63 39 49 42 49 16C49 5 56 0 69 0C120 0 192 4 235 3L317 2C331 2 386 0 403 0C420 0 428 8 428 24C428 34 416 39 391 39C339 39 309 41 300 46C297 48 295 52 295 58L430 603C433 617 436 626 439 629C443 635 467 638 511 638C566 638 604 634 623 625C642 616 652 595 652 561C652 543 649 517 644 483C642 475 641 469 641 464C641 453 646 447 657 447C666 447 672 456 675 473L702 645C703 650 704 656 704 662C704 672 694 677 673 677L125 677C99 677 97 674 89 655L30 481C27 472 25 466 24 462C24 452 29 447 40 447C48 447 55 455 60 470C85 543 110 588 133 607C159 628 209 638 282 638L321 638C332 638 344 639 344 631Z"/></g><g data-mml-node="mi" data-latex="F" transform="translate(3371.2,0)"><path data-c="1D439" d="M199 656C199 646 210 641 231 641C271 641 291 637 291 628C291 625 289 618 286 605L156 82C150 60 140 47 126 42C119 40 101 39 70 39C48 39 38 37 38 16C38 5 44 0 57 0L187 3L335 0C351 0 359 8 359 23C359 40 348 39 322 39C278 39 253 41 247 46C244 47 243 51 243 56L307 321L400 321C446 321 478 319 478 281C478 268 476 252 471 233C470 230 469 226 468 222C468 211 473 206 484 206C489 207 496 214 503 229L557 444C559 452 560 458 560 461C557 470 551 475 544 475C536 475 530 467 526 452C516 414 502 390 486 378C470 366 442 360 402 360L317 360L379 606C387 640 387 641 429 641L559 641C656 641 700 626 700 537C700 517 699 499 697 484C696 473 695 467 695 466C695 455 700 450 710 450C720 450 726 459 728 478L748 649C751 677 744 680 717 680L233 680C210 680 199 679 199 656Z"/></g><g data-mml-node="mo" data-latex=")" transform="translate(4122.2,0)"><path data-c="29" d="M78-245C138-199 188-131 229-40C268 47 288 129 288 208L288 292C288 371 268 453 229 540C188 631 138 699 78 745C75 747 72 748 71 748C62 748 57 743 57 734C57 730 59 726 62 723C114 683 156 617 187 526C214 447 228 369 228 292L228 208C228 131 214 53 187-26C156-117 114-183 62-223C59-227 57-231 57-234C57-243 62-248 71-248C72-248 75-247 78-245Z"/></g></g></g></svg></mjx-container> 这个值来代替原来的 TF 取值。这样的计算保持了一个平衡,既有区分度,但也不至于完全线性增长。</p><p>这里使用比较简单的方案一作为栗子:</p><figure class="highlight bash"><table><tbody><tr><td class="code"><pre><span class="line">句子A:</span><br><span class="line"></span><br><span class="line">{</span><br><span class="line">  <span class="string">'我'</span>: 0.16666666666666666,</span><br><span class="line">  <span class="string">'这里'</span>: 0.16666666666666666,</span><br><span class="line">  <span class="string">'有'</span>: 0.16666666666666666,</span><br><span class="line">  <span class="string">'苹果'</span>: 0.16666666666666666,</span><br><span class="line">  <span class="string">'和'</span>: 0.16666666666666666,</span><br><span class="line">  <span class="string">'西瓜'</span>: 0.16666666666666666,</span><br><span class="line">  <span class="string">'喜欢'</span>: 0,</span><br><span class="line">  <span class="string">'吃'</span>: 0,</span><br><span class="line">  <span class="string">'不'</span>: 0,</span><br><span class="line">  <span class="string">'蔬菜'</span>: 0</span><br><span class="line">}</span><br><span class="line"></span><br><span class="line">句子B:</span><br><span class="line">{</span><br><span class="line">  <span class="string">'我'</span>: 0.125,</span><br><span class="line">  <span class="string">'这里'</span>: 0,</span><br><span class="line">  <span class="string">'有'</span>: 0,</span><br><span class="line">  <span class="string">'苹果'</span>: 0.125,</span><br><span class="line">  <span class="string">'和'</span>: 0,</span><br><span class="line">  <span class="string">'西瓜'</span>: 0.125,</span><br><span class="line">  <span class="string">'喜欢'</span>: 0.25,</span><br><span class="line">  <span class="string">'吃'</span>: 0.25,</span><br><span class="line">  <span class="string">'不'</span>: 0.125,</span><br><span class="line">  <span class="string">'蔬菜'</span>: 0</span><br><span class="line">}</span><br><span class="line"></span><br><span class="line">句子C:</span><br><span class="line"></span><br><span class="line">{</span><br><span class="line">  <span class="string">'我'</span>: 0.25,</span><br><span class="line">  <span class="string">'这里'</span>: 0,</span><br><span class="line">  <span class="string">'有'</span>: 0,</span><br><span class="line">  <span class="string">'苹果'</span>: 0,</span><br><span class="line">  <span class="string">'和'</span>: 0,</span><br><span class="line">  <span class="string">'西瓜'</span>: 0,</span><br><span class="line">  <span class="string">'喜欢'</span>: 0.25,</span><br><span class="line">  <span class="string">'吃'</span>: 0.25,</span><br><span class="line">  <span class="string">'不'</span>: 0,</span><br><span class="line">  <span class="string">'蔬菜'</span>: 0.25</span><br><span class="line">}</span><br></pre></td></tr></tbody></table></figure></div><div class="story post-story"><h2 id="第五步:计算逆文档频率"><a href="#第五步:计算逆文档频率" class="headerlink" title="第五步:计算逆文档频率"></a>第五步:计算逆文档频率</h2><p>仅有词频(TF)不能比较完整地描述文档的相关度。因为语言的因素,有一些单词可能会比较自然地在很多文档中反复出现,比如这里中的 “我”、“和” 等等。这些词大多起到了链接语句的作用,是保持语言连贯不可或缺的部分。</p><p>很明显,如果有太多文档都涵盖了某个单词,这个单词也就越不重要,或者说是这个单词就越没有信息量。因此,我们需要对词频(TF)的值进行修正,而 逆文档频率(IDF)的想法是用文档频率(DF)的倒数来进行修正。</p><p><mjx-container class="MathJax" jax="SVG" overflow="overflow" display="true" width="full" style="min-width: 57.833ex;"><svg style="vertical-align: -2.077ex; min-width: 57.833ex;" xmlns="http://www.w3.org/2000/svg" width="100%" height="5.285ex" role="img" focusable="false" data-mjx-viewbox="0 -1418 25562 2336"><g stroke="currentColor" fill="currentColor" stroke-width="0" transform="scale(0.0181,-0.0181) translate(0, -1418)"><g data-mml-node="math" data-latex="
逆文档频率(IDF) = \log(\frac{语料库的文档总数}{包含该词的文档数+1})
"><g data-mml-node="mtable" data-latex="逆文档频率(IDF) = \log(\frac{语料库的文档总数}{包含该词的文档数+1})" transform="translate(2078,0) translate(-2078,0)"><g transform="translate(0 1418) matrix(1 0 0 -1 0 0) scale(55.25)"><svg data-table="true" preserveaspectratio="xMidYMid" viewbox="10703 -1418 1 2336"><g transform="matrix(1 0 0 -1 0 0)"><g data-mml-node="mlabeledtr" transform="translate(0,-8)"><g data-mml-node="mtd"><g data-mml-node="mi" data-latex="逆"><text data-variant="normal" transform="scale(1,-1)" font-size="884px" font-family="serif">逆</text></g><g data-mml-node="mi" data-latex="文" transform="translate(1000,0)"><text data-variant="normal" transform="scale(1,-1)" font-size="884px" font-family="serif">文</text></g><g data-mml-node="mi" data-latex="档" transform="translate(2000,0)"><text data-variant="normal" transform="scale(1,-1)" font-size="884px" font-family="serif">档</text></g><g data-mml-node="mi" data-latex="频" transform="translate(3000,0)"><text data-variant="normal" transform="scale(1,-1)" font-size="884px" font-family="serif">频</text></g><g data-mml-node="mi" data-latex="率" transform="translate(4000,0)"><text data-variant="normal" transform="scale(1,-1)" font-size="884px" font-family="serif">率</text></g><g data-mml-node="mo" data-latex="(" transform="translate(5000,0)"><path data-c="28" d="M318-248C327-248 332-243 332-234C332-231 330-227 327-223C275-183 233-117 202-26C175 53 161 131 161 208L161 292C161 369 175 447 202 526C233 617 275 683 327 723C330 726 332 730 332 734C332 743 327 748 318 748C317 748 314 747 311 745C251 699 201 631 160 540C121 453 101 371 101 292L101 208C101 129 121 47 160-40C201-131 251-199 311-245C314-247 317-248 318-248Z"/></g><g data-mml-node="mi" data-latex="I" transform="translate(5389,0)"><path data-c="1D43C" d="M497 667C497 678 491 683 478 683L349 680L218 683C202 684 194 676 194 659C194 649 205 644 226 644C269 644 290 639 290 630C290 625 289 620 288 615L155 82C150 60 140 47 125 42C118 40 100 39 69 39C44 39 34 38 34 15C34 5 40 0 53 0L181 3L313 0C329-1 337 7 337 23C337 39 325 39 303 39C264 39 240 37 240 53C240 58 241 65 244 75L376 602C381 623 391 636 406 641C413 643 431 644 462 644C486 644 497 645 497 667Z"/></g><g data-mml-node="mi" data-latex="D" transform="translate(5886,0)"><path data-c="1D437" d="M567 683L235 683C212 683 201 682 201 660C201 649 212 644 234 644C254 644 294 647 294 631C294 629 293 623 290 613L158 82C153 60 143 47 128 42C121 40 103 39 72 39C50 39 40 37 40 16C40 5 51 0 72 0L399 0C467 0 532 20 595 61C702 130 804 265 804 429C804 577 713 683 567 683M710 466C710 353 659 216 607 149C550 76 475 39 381 39L270 39C259 39 252 39 248 40C242 40 239 42 239 45C239 47 241 54 244 67L379 610C388 643 387 644 429 644L535 644C647 644 710 578 710 466Z"/></g><g data-mml-node="mi" data-latex="F" transform="translate(6714,0)"><path data-c="1D439" d="M199 656C199 646 210 641 231 641C271 641 291 637 291 628C291 625 289 618 286 605L156 82C150 60 140 47 126 42C119 40 101 39 70 39C48 39 38 37 38 16C38 5 44 0 57 0L187 3L335 0C351 0 359 8 359 23C359 40 348 39 322 39C278 39 253 41 247 46C244 47 243 51 243 56L307 321L400 321C446 321 478 319 478 281C478 268 476 252 471 233C470 230 469 226 468 222C468 211 473 206 484 206C489 207 496 214 503 229L557 444C559 452 560 458 560 461C557 470 551 475 544 475C536 475 530 467 526 452C516 414 502 390 486 378C470 366 442 360 402 360L317 360L379 606C387 640 387 641 429 641L559 641C656 641 700 626 700 537C700 517 699 499 697 484C696 473 695 467 695 466C695 455 700 450 710 450C720 450 726 459 728 478L748 649C751 677 744 680 717 680L233 680C210 680 199 679 199 656Z"/></g><g data-mml-node="mo" data-latex=")" transform="translate(7465,0)"><path data-c="29" d="M78-245C138-199 188-131 229-40C268 47 288 129 288 208L288 292C288 371 268 453 229 540C188 631 138 699 78 745C75 747 72 748 71 748C62 748 57 743 57 734C57 730 59 726 62 723C114 683 156 617 187 526C214 447 228 369 228 292L228 208C228 131 214 53 187-26C156-117 114-183 62-223C59-227 57-231 57-234C57-243 62-248 71-248C72-248 75-247 78-245Z"/></g><g data-mml-node="mo" data-latex="=" transform="translate(8131.8,0)"><path data-c="3D" d="M698 367L80 367C64 367 56 359 56 344C56 329 64 321 80 321L698 321C714 321 722 329 722 344C722 356 711 367 698 367M698 179L80 179C64 179 56 171 56 156C56 141 64 133 80 133L698 133C714 133 722 141 722 156C722 169 711 179 698 179Z"/></g><g data-mml-node="mi" data-latex="\log" transform="translate(9187.6,0)"><path data-c="6C" d="M144 3L255 0L255 39C219 39 197 40 190 44C183 48 180 60 180 79L180 694L33 683L33 645C68 645 90 642 97 636C104 630 108 616 108 593L108 79C108 60 105 48 98 44C91 40 69 39 33 39L33 0Z"/><path data-c="6F" d="M249-11C311-11 363 11 406 55C449 99 471 152 471 214C471 277 450 332 408 378C366 424 313 448 250 448C187 448 135 424 92 378C49 332 28 277 28 214C28 152 49 99 92 55C135 11 188-11 249-11M250 21C202 21 166 42 141 85C125 113 117 159 117 222C117 283 125 327 140 355C164 398 200 419 249 419C296 419 332 398 357 357C374 329 382 284 382 222C382 106 348 21 250 21Z" transform="translate(278,0)"/><path data-c="67" d="M431 453C393 453 358 438 326 408C296 431 262 442 223 442C137 442 59 378 59 294C59 252 74 218 104 192C85 168 75 141 75 110C75 72 88 43 113 24C71 10 28-26 28-77C28-120 56-154 111-178C153-197 199-206 249-206C300-206 347-197 389-178C444-154 471-120 471-75C471-22 449 17 405 42C359 67 308 70 234 70C190 70 166 70 161 71C133 75 113 102 113 133C113 148 117 162 126 174C154 155 186 145 223 145C309 145 386 209 386 293C386 332 373 364 347 389C372 412 399 423 428 423C423 418 420 410 420 400C420 378 431 367 453 367C474 367 485 378 485 401C485 432 461 453 431 453M223 411C277 411 304 372 304 294C304 215 277 175 223 175C168 175 141 214 141 293C141 372 168 411 223 411M164 4L222 4C274 4 316 1 348-6C391-15 412-39 412-77C412-109 392-134 352-153C321-168 287-175 250-175C214-175 180-168 148-153C107-134 87-109 87-77C87-35 123 4 164 4Z" transform="translate(778,0)"/></g><g data-mml-node="mo" transform="translate(10465.6,0)"><path data-c="2061" d=""/></g><g data-mml-node="mo" data-latex="(" transform="translate(10465.6,0)"><path data-c="28" d="M318-248C327-248 332-243 332-234C332-231 330-227 327-223C275-183 233-117 202-26C175 53 161 131 161 208L161 292C161 369 175 447 202 526C233 617 275 683 327 723C330 726 332 730 332 734C332 743 327 748 318 748C317 748 314 747 311 745C251 699 201 631 160 540C121 453 101 371 101 292L101 208C101 129 121 47 160-40C201-131 251-199 311-245C314-247 317-248 318-248Z"/></g><g data-mml-node="mfrac" data-latex="\frac{语料库的文档总数}{包含该词的文档数+1}" transform="translate(10854.6,0)"><g data-mml-node="mrow" data-latex="语料库的文档总数" transform="translate(1081.2,676)"><g data-mml-node="mi" data-latex="语"><text data-variant="normal" transform="scale(1,-1)" font-size="884px" font-family="serif">语</text></g><g data-mml-node="mi" data-latex="料" transform="translate(1000,0)"><text data-variant="normal" transform="scale(1,-1)" font-size="884px" font-family="serif">料</text></g><g data-mml-node="mi" data-latex="库" transform="translate(2000,0)"><text data-variant="normal" transform="scale(1,-1)" font-size="884px" font-family="serif">库</text></g><g data-mml-node="mi" data-latex="的" transform="translate(3000,0)"><text data-variant="normal" transform="scale(1,-1)" font-size="884px" font-family="serif">的</text></g><g data-mml-node="mi" data-latex="文" transform="translate(4000,0)"><text data-variant="normal" transform="scale(1,-1)" font-size="884px" font-family="serif">文</text></g><g data-mml-node="mi" data-latex="档" transform="translate(5000,0)"><text data-variant="normal" transform="scale(1,-1)" font-size="884px" font-family="serif">档</text></g><g data-mml-node="mi" data-latex="总" transform="translate(6000,0)"><text data-variant="normal" transform="scale(1,-1)" font-size="884px" font-family="serif">总</text></g><g data-mml-node="mi" data-latex="数" transform="translate(7000,0)"><text data-variant="normal" transform="scale(1,-1)" font-size="884px" font-family="serif">数</text></g></g><g data-mml-node="mrow" data-latex="包含该词的文档数+1" transform="translate(220,-710)"><g data-mml-node="mi" data-latex="包"><text data-variant="normal" transform="scale(1,-1)" font-size="884px" font-family="serif">包</text></g><g data-mml-node="mi" data-latex="含" transform="translate(1000,0)"><text data-variant="normal" transform="scale(1,-1)" font-size="884px" font-family="serif">含</text></g><g data-mml-node="mi" data-latex="该" transform="translate(2000,0)"><text data-variant="normal" transform="scale(1,-1)" font-size="884px" font-family="serif">该</text></g><g data-mml-node="mi" data-latex="词" transform="translate(3000,0)"><text data-variant="normal" transform="scale(1,-1)" font-size="884px" font-family="serif">词</text></g><g data-mml-node="mi" data-latex="的" transform="translate(4000,0)"><text data-variant="normal" transform="scale(1,-1)" font-size="884px" font-family="serif">的</text></g><g data-mml-node="mi" data-latex="文" transform="translate(5000,0)"><text data-variant="normal" transform="scale(1,-1)" font-size="884px" font-family="serif">文</text></g><g data-mml-node="mi" data-latex="档" transform="translate(6000,0)"><text data-variant="normal" transform="scale(1,-1)" font-size="884px" font-family="serif">档</text></g><g data-mml-node="mi" data-latex="数" transform="translate(7000,0)"><text data-variant="normal" transform="scale(1,-1)" font-size="884px" font-family="serif">数</text></g><g data-mml-node="mo" data-latex="+" transform="translate(8222.2,0)"><path data-c="2B" d="M698 274L413 274L413 559C413 575 405 583 389 583C373 583 365 575 365 559L365 274L80 274C64 274 56 266 56 250C56 234 64 226 80 226L365 226L365-59C365-75 373-83 389-83C405-83 413-75 413-59L413 226L698 226C714 226 722 234 722 250C722 263 711 274 698 274Z"/></g><g data-mml-node="mn" data-latex="1" transform="translate(9222.4,0)"><path data-c="31" d="M269 666C228 624 168 603 89 603L89 564C141 564 184 572 217 588L217 82C217 64 213 52 204 47C195 42 170 39 130 39L95 39L95 0C120 2 174 3 257 3C340 3 394 2 419 0L419 39L384 39C343 39 318 42 310 47C302 52 297 64 297 82L297 636C297 660 295 666 269 666Z"/></g></g><rect width="9922.4" height="60" x="120" y="220"/></g><g data-mml-node="mo" data-latex=")" transform="translate(21017,0)"><path data-c="29" d="M78-245C138-199 188-131 229-40C268 47 288 129 288 208L288 292C288 371 268 453 229 540C188 631 138 699 78 745C75 747 72 748 71 748C62 748 57 743 57 734C57 730 59 726 62 723C114 683 156 617 187 526C214 447 228 369 228 292L228 208C228 131 214 53 187-26C156-117 114-183 62-223C59-227 57-231 57-234C57-243 62-248 71-248C72-248 75-247 78-245Z"/></g></g></g></g></svg><svg data-labels="true" preserveaspectratio="xMaxYMid" viewbox="1278 -1418 1 2336"><g data-labels="true" transform="matrix(1 0 0 -1 0 0)"><g data-mml-node="mtd" id="mjx-eqn:5" transform="translate(0,740)"><text data-id-align="true"/><g data-idbox="true" transform="translate(0,-748)"><g data-mml-node="mtext" data-latex="\text{(}"><path data-c="28" d="M318-248C327-248 332-243 332-234C332-231 330-227 327-223C275-183 233-117 202-26C175 53 161 131 161 208L161 292C161 369 175 447 202 526C233 617 275 683 327 723C330 726 332 730 332 734C332 743 327 748 318 748C317 748 314 747 311 745C251 699 201 631 160 540C121 453 101 371 101 292L101 208C101 129 121 47 160-40C201-131 251-199 311-245C314-247 317-248 318-248Z"/></g><g data-mml-node="mtext" data-latex="\text{5}" transform="translate(389,0)"><path data-c="35" d="M118 315C123 315 129 319 134 326C164 371 205 393 257 393C292 393 319 373 337 332C348 305 354 264 354 209C354 146 346 102 331 76C306 35 272 14 229 14C162 14 109 62 91 114C94 113 96 114 100 114C130 114 155 137 155 167C155 198 130 219 100 219C65 219 50 200 50 163C50 63 131-22 231-22C292-22 344 0 386 44C428 88 449 141 449 202C449 260 432 310 398 353C361 400 315 423 259 423C212 423 171 408 138 378L138 556C165 548 191 544 218 544C264 544 304 555 338 578C369 597 390 616 402 634C408 642 411 648 411 651C411 661 406 666 396 666C341 645 294 634 256 634C211 634 168 643 127 662C122 664 118 665 114 665C105 665 100 656 100 637L100 345C100 324 100 315 118 315Z"/></g><g data-mml-node="mtext" data-latex="\text{)}" transform="translate(889,0)"><path data-c="29" d="M78-245C138-199 188-131 229-40C268 47 288 129 288 208L288 292C288 371 268 453 229 540C188 631 138 699 78 745C75 747 72 748 71 748C62 748 57 743 57 734C57 730 59 726 62 723C114 683 156 617 187 526C214 447 228 369 228 292L228 208C228 131 214 53 187-26C156-117 114-183 62-223C59-227 57-231 57-234C57-243 62-248 71-248C72-248 75-247 78-245Z"/></g></g></g></g></svg></g></g></g></g></svg></mjx-container></p><p>如果一个词越常见,那么分母就越大,逆文档频率就越小越接近0。分母之所以要加1,是为了避免分母为0(即所有文档都不包含该词)。log表示对得到的值取对数。为什么要用log函数?log函数是单调递增,求log是为了归一化,保证逆文档频率不会过大。用 Log 进行变换,也是一个非线性增长的技巧,这样的计算保持了一个平衡,既有区分度,但也不至于完全线性增长。</p><figure class="highlight bash"><table><tbody><tr><td class="code"><pre><span class="line">句子A:</span><br><span class="line"></span><br><span class="line">{</span><br><span class="line">  <span class="string">'我'</span>: -0.2876820724517809,</span><br><span class="line">  <span class="string">'这里'</span>: 0.4054651081081644,</span><br><span class="line">  <span class="string">'有'</span>: 0.4054651081081644,</span><br><span class="line">  <span class="string">'苹果'</span>: 0,</span><br><span class="line">  <span class="string">'和'</span>: 0.4054651081081644,</span><br><span class="line">  <span class="string">'西瓜'</span>: 0,</span><br><span class="line">  <span class="string">'喜欢'</span>: 0,</span><br><span class="line">  <span class="string">'吃'</span>: 0,</span><br><span class="line">  <span class="string">'不'</span>: 0.4054651081081644,</span><br><span class="line">  <span class="string">'蔬菜'</span>: 0.4054651081081644</span><br><span class="line">}</span><br><span class="line"></span><br><span class="line">句子B:</span><br><span class="line">{</span><br><span class="line">  <span class="string">'我'</span>: -0.2876820724517809,</span><br><span class="line">  <span class="string">'这里'</span>: 0.4054651081081644,</span><br><span class="line">  <span class="string">'有'</span>: 0.4054651081081644,</span><br><span class="line">  <span class="string">'苹果'</span>: 0,</span><br><span class="line">  <span class="string">'和'</span>: 0.4054651081081644,</span><br><span class="line">  <span class="string">'西瓜'</span>: 0,</span><br><span class="line">  <span class="string">'喜欢'</span>: 0,</span><br><span class="line">  <span class="string">'吃'</span>: 0,</span><br><span class="line">  <span class="string">'不'</span>: 0.4054651081081644,</span><br><span class="line">  <span class="string">'蔬菜'</span>: 0.4054651081081644</span><br><span class="line">}</span><br><span class="line"></span><br><span class="line">句子C:</span><br><span class="line"></span><br><span class="line">{</span><br><span class="line">  <span class="string">'我'</span>: -0.2876820724517809,</span><br><span class="line">  <span class="string">'这里'</span>: 0.4054651081081644,</span><br><span class="line">  <span class="string">'有'</span>: 0.4054651081081644,</span><br><span class="line">  <span class="string">'苹果'</span>: 0,</span><br><span class="line">  <span class="string">'和'</span>: 0.4054651081081644,</span><br><span class="line">  <span class="string">'西瓜'</span>: 0,</span><br><span class="line">  <span class="string">'喜欢'</span>: 0,</span><br><span class="line">  <span class="string">'吃'</span>: 0,</span><br><span class="line">  <span class="string">'不'</span>: 0.4054651081081644,</span><br><span class="line">  <span class="string">'蔬菜'</span>: 0.4054651081081644</span><br><span class="line">}</span><br></pre></td></tr></tbody></table></figure></div><div class="story post-story"><h2 id="第六步:计算TF-IDF"><a href="#第六步:计算TF-IDF" class="headerlink" title="第六步:计算TF-IDF"></a>第六步:计算TF-IDF</h2><p><mjx-container class="MathJax" jax="SVG" overflow="overflow" display="true" width="full" style="min-width: 53.286ex;"><svg style="vertical-align: -0.566ex; min-width: 53.286ex;" xmlns="http://www.w3.org/2000/svg" width="100%" height="2.262ex" role="img" focusable="false" data-mjx-viewbox="0 -750 23552.4 1000"><g stroke="currentColor" fill="currentColor" stroke-width="0" transform="scale(0.0181,-0.0181) translate(0, -750)"><g data-mml-node="math" data-latex="
TF-IDF = 词频(TF) \times 逆文档频率(IDF)
"><g data-mml-node="mtable" data-latex="TF-IDF = 词频(TF) \times 逆文档频率(IDF)" transform="translate(2078,0) translate(-2078,0)"><g transform="translate(0 750) matrix(1 0 0 -1 0 0) scale(55.25)"><svg data-table="true" preserveaspectratio="xMidYMid" viewbox="9698.2 -750 1 1000"><g transform="matrix(1 0 0 -1 0 0)"><g data-mml-node="mlabeledtr"><g data-mml-node="mtd"><g data-mml-node="mi" data-latex="T"><path data-c="1D447" d="M344 631C344 628 343 621 340 611L208 83C204 68 200 59 197 55C188 44 154 39 94 39C63 39 49 42 49 16C49 5 56 0 69 0C120 0 192 4 235 3L317 2C331 2 386 0 403 0C420 0 428 8 428 24C428 34 416 39 391 39C339 39 309 41 300 46C297 48 295 52 295 58L430 603C433 617 436 626 439 629C443 635 467 638 511 638C566 638 604 634 623 625C642 616 652 595 652 561C652 543 649 517 644 483C642 475 641 469 641 464C641 453 646 447 657 447C666 447 672 456 675 473L702 645C703 650 704 656 704 662C704 672 694 677 673 677L125 677C99 677 97 674 89 655L30 481C27 472 25 466 24 462C24 452 29 447 40 447C48 447 55 455 60 470C85 543 110 588 133 607C159 628 209 638 282 638L321 638C332 638 344 639 344 631Z"/></g><g data-mml-node="mi" data-latex="F" transform="translate(704,0)"><path data-c="1D439" d="M199 656C199 646 210 641 231 641C271 641 291 637 291 628C291 625 289 618 286 605L156 82C150 60 140 47 126 42C119 40 101 39 70 39C48 39 38 37 38 16C38 5 44 0 57 0L187 3L335 0C351 0 359 8 359 23C359 40 348 39 322 39C278 39 253 41 247 46C244 47 243 51 243 56L307 321L400 321C446 321 478 319 478 281C478 268 476 252 471 233C470 230 469 226 468 222C468 211 473 206 484 206C489 207 496 214 503 229L557 444C559 452 560 458 560 461C557 470 551 475 544 475C536 475 530 467 526 452C516 414 502 390 486 378C470 366 442 360 402 360L317 360L379 606C387 640 387 641 429 641L559 641C656 641 700 626 700 537C700 517 699 499 697 484C696 473 695 467 695 466C695 455 700 450 710 450C720 450 726 459 728 478L748 649C751 677 744 680 717 680L233 680C210 680 199 679 199 656Z"/></g><g data-mml-node="mo" data-latex="-" transform="translate(1677.2,0)"><path data-c="2212" d="M698 270L80 270C64 270 56 263 56 250C56 237 64 230 80 230L698 230C714 230 722 237 722 250C722 262 710 270 698 270Z"/></g><g data-mml-node="mi" data-latex="I" transform="translate(2677.4,0)"><path data-c="1D43C" d="M497 667C497 678 491 683 478 683L349 680L218 683C202 684 194 676 194 659C194 649 205 644 226 644C269 644 290 639 290 630C290 625 289 620 288 615L155 82C150 60 140 47 125 42C118 40 100 39 69 39C44 39 34 38 34 15C34 5 40 0 53 0L181 3L313 0C329-1 337 7 337 23C337 39 325 39 303 39C264 39 240 37 240 53C240 58 241 65 244 75L376 602C381 623 391 636 406 641C413 643 431 644 462 644C486 644 497 645 497 667Z"/></g><g data-mml-node="mi" data-latex="D" transform="translate(3174.4,0)"><path data-c="1D437" d="M567 683L235 683C212 683 201 682 201 660C201 649 212 644 234 644C254 644 294 647 294 631C294 629 293 623 290 613L158 82C153 60 143 47 128 42C121 40 103 39 72 39C50 39 40 37 40 16C40 5 51 0 72 0L399 0C467 0 532 20 595 61C702 130 804 265 804 429C804 577 713 683 567 683M710 466C710 353 659 216 607 149C550 76 475 39 381 39L270 39C259 39 252 39 248 40C242 40 239 42 239 45C239 47 241 54 244 67L379 610C388 643 387 644 429 644L535 644C647 644 710 578 710 466Z"/></g><g data-mml-node="mi" data-latex="F" transform="translate(4002.4,0)"><path data-c="1D439" d="M199 656C199 646 210 641 231 641C271 641 291 637 291 628C291 625 289 618 286 605L156 82C150 60 140 47 126 42C119 40 101 39 70 39C48 39 38 37 38 16C38 5 44 0 57 0L187 3L335 0C351 0 359 8 359 23C359 40 348 39 322 39C278 39 253 41 247 46C244 47 243 51 243 56L307 321L400 321C446 321 478 319 478 281C478 268 476 252 471 233C470 230 469 226 468 222C468 211 473 206 484 206C489 207 496 214 503 229L557 444C559 452 560 458 560 461C557 470 551 475 544 475C536 475 530 467 526 452C516 414 502 390 486 378C470 366 442 360 402 360L317 360L379 606C387 640 387 641 429 641L559 641C656 641 700 626 700 537C700 517 699 499 697 484C696 473 695 467 695 466C695 455 700 450 710 450C720 450 726 459 728 478L748 649C751 677 744 680 717 680L233 680C210 680 199 679 199 656Z"/></g><g data-mml-node="mo" data-latex="=" transform="translate(5031.2,0)"><path data-c="3D" d="M698 367L80 367C64 367 56 359 56 344C56 329 64 321 80 321L698 321C714 321 722 329 722 344C722 356 711 367 698 367M698 179L80 179C64 179 56 171 56 156C56 141 64 133 80 133L698 133C714 133 722 141 722 156C722 169 711 179 698 179Z"/></g><g data-mml-node="mi" data-latex="词" transform="translate(6087,0)"><text data-variant="normal" transform="scale(1,-1)" font-size="884px" font-family="serif">词</text></g><g data-mml-node="mi" data-latex="频" transform="translate(7087,0)"><text data-variant="normal" transform="scale(1,-1)" font-size="884px" font-family="serif">频</text></g><g data-mml-node="mo" data-latex="(" transform="translate(8087,0)"><path data-c="28" d="M318-248C327-248 332-243 332-234C332-231 330-227 327-223C275-183 233-117 202-26C175 53 161 131 161 208L161 292C161 369 175 447 202 526C233 617 275 683 327 723C330 726 332 730 332 734C332 743 327 748 318 748C317 748 314 747 311 745C251 699 201 631 160 540C121 453 101 371 101 292L101 208C101 129 121 47 160-40C201-131 251-199 311-245C314-247 317-248 318-248Z"/></g><g data-mml-node="mi" data-latex="T" transform="translate(8476,0)"><path data-c="1D447" d="M344 631C344 628 343 621 340 611L208 83C204 68 200 59 197 55C188 44 154 39 94 39C63 39 49 42 49 16C49 5 56 0 69 0C120 0 192 4 235 3L317 2C331 2 386 0 403 0C420 0 428 8 428 24C428 34 416 39 391 39C339 39 309 41 300 46C297 48 295 52 295 58L430 603C433 617 436 626 439 629C443 635 467 638 511 638C566 638 604 634 623 625C642 616 652 595 652 561C652 543 649 517 644 483C642 475 641 469 641 464C641 453 646 447 657 447C666 447 672 456 675 473L702 645C703 650 704 656 704 662C704 672 694 677 673 677L125 677C99 677 97 674 89 655L30 481C27 472 25 466 24 462C24 452 29 447 40 447C48 447 55 455 60 470C85 543 110 588 133 607C159 628 209 638 282 638L321 638C332 638 344 639 344 631Z"/></g><g data-mml-node="mi" data-latex="F" transform="translate(9180,0)"><path data-c="1D439" d="M199 656C199 646 210 641 231 641C271 641 291 637 291 628C291 625 289 618 286 605L156 82C150 60 140 47 126 42C119 40 101 39 70 39C48 39 38 37 38 16C38 5 44 0 57 0L187 3L335 0C351 0 359 8 359 23C359 40 348 39 322 39C278 39 253 41 247 46C244 47 243 51 243 56L307 321L400 321C446 321 478 319 478 281C478 268 476 252 471 233C470 230 469 226 468 222C468 211 473 206 484 206C489 207 496 214 503 229L557 444C559 452 560 458 560 461C557 470 551 475 544 475C536 475 530 467 526 452C516 414 502 390 486 378C470 366 442 360 402 360L317 360L379 606C387 640 387 641 429 641L559 641C656 641 700 626 700 537C700 517 699 499 697 484C696 473 695 467 695 466C695 455 700 450 710 450C720 450 726 459 728 478L748 649C751 677 744 680 717 680L233 680C210 680 199 679 199 656Z"/></g><g data-mml-node="mo" data-latex=")" transform="translate(9931,0)"><path data-c="29" d="M78-245C138-199 188-131 229-40C268 47 288 129 288 208L288 292C288 371 268 453 229 540C188 631 138 699 78 745C75 747 72 748 71 748C62 748 57 743 57 734C57 730 59 726 62 723C114 683 156 617 187 526C214 447 228 369 228 292L228 208C228 131 214 53 187-26C156-117 114-183 62-223C59-227 57-231 57-234C57-243 62-248 71-248C72-248 75-247 78-245Z"/></g><g data-mml-node="mo" data-latex="\times" transform="translate(10542.2,0)"><path data-c="D7" d="M630 32C630 39 628 44 623 49L422 250L623 451C628 456 630 461 630 468C630 481 620 491 607 491C600 491 595 489 590 484L389 283L188 484C183 489 178 491 171 491C158 491 148 481 148 468C148 461 150 456 155 451L356 250L155 49C150 44 148 39 148 32C148 19 158 9 171 9C178 9 183 11 188 16L389 217L590 16C595 11 600 9 607 9C620 9 630 19 630 32Z"/></g><g data-mml-node="mi" data-latex="逆" transform="translate(11542.4,0)"><text data-variant="normal" transform="scale(1,-1)" font-size="884px" font-family="serif">逆</text></g><g data-mml-node="mi" data-latex="文" transform="translate(12542.4,0)"><text data-variant="normal" transform="scale(1,-1)" font-size="884px" font-family="serif">文</text></g><g data-mml-node="mi" data-latex="档" transform="translate(13542.4,0)"><text data-variant="normal" transform="scale(1,-1)" font-size="884px" font-family="serif">档</text></g><g data-mml-node="mi" data-latex="频" transform="translate(14542.4,0)"><text data-variant="normal" transform="scale(1,-1)" font-size="884px" font-family="serif">频</text></g><g data-mml-node="mi" data-latex="率" transform="translate(15542.4,0)"><text data-variant="normal" transform="scale(1,-1)" font-size="884px" font-family="serif">率</text></g><g data-mml-node="mo" data-latex="(" transform="translate(16542.4,0)"><path data-c="28" d="M318-248C327-248 332-243 332-234C332-231 330-227 327-223C275-183 233-117 202-26C175 53 161 131 161 208L161 292C161 369 175 447 202 526C233 617 275 683 327 723C330 726 332 730 332 734C332 743 327 748 318 748C317 748 314 747 311 745C251 699 201 631 160 540C121 453 101 371 101 292L101 208C101 129 121 47 160-40C201-131 251-199 311-245C314-247 317-248 318-248Z"/></g><g data-mml-node="mi" data-latex="I" transform="translate(16931.4,0)"><path data-c="1D43C" d="M497 667C497 678 491 683 478 683L349 680L218 683C202 684 194 676 194 659C194 649 205 644 226 644C269 644 290 639 290 630C290 625 289 620 288 615L155 82C150 60 140 47 125 42C118 40 100 39 69 39C44 39 34 38 34 15C34 5 40 0 53 0L181 3L313 0C329-1 337 7 337 23C337 39 325 39 303 39C264 39 240 37 240 53C240 58 241 65 244 75L376 602C381 623 391 636 406 641C413 643 431 644 462 644C486 644 497 645 497 667Z"/></g><g data-mml-node="mi" data-latex="D" transform="translate(17428.4,0)"><path data-c="1D437" d="M567 683L235 683C212 683 201 682 201 660C201 649 212 644 234 644C254 644 294 647 294 631C294 629 293 623 290 613L158 82C153 60 143 47 128 42C121 40 103 39 72 39C50 39 40 37 40 16C40 5 51 0 72 0L399 0C467 0 532 20 595 61C702 130 804 265 804 429C804 577 713 683 567 683M710 466C710 353 659 216 607 149C550 76 475 39 381 39L270 39C259 39 252 39 248 40C242 40 239 42 239 45C239 47 241 54 244 67L379 610C388 643 387 644 429 644L535 644C647 644 710 578 710 466Z"/></g><g data-mml-node="mi" data-latex="F" transform="translate(18256.4,0)"><path data-c="1D439" d="M199 656C199 646 210 641 231 641C271 641 291 637 291 628C291 625 289 618 286 605L156 82C150 60 140 47 126 42C119 40 101 39 70 39C48 39 38 37 38 16C38 5 44 0 57 0L187 3L335 0C351 0 359 8 359 23C359 40 348 39 322 39C278 39 253 41 247 46C244 47 243 51 243 56L307 321L400 321C446 321 478 319 478 281C478 268 476 252 471 233C470 230 469 226 468 222C468 211 473 206 484 206C489 207 496 214 503 229L557 444C559 452 560 458 560 461C557 470 551 475 544 475C536 475 530 467 526 452C516 414 502 390 486 378C470 366 442 360 402 360L317 360L379 606C387 640 387 641 429 641L559 641C656 641 700 626 700 537C700 517 699 499 697 484C696 473 695 467 695 466C695 455 700 450 710 450C720 450 726 459 728 478L748 649C751 677 744 680 717 680L233 680C210 680 199 679 199 656Z"/></g><g data-mml-node="mo" data-latex=")" transform="translate(19007.4,0)"><path data-c="29" d="M78-245C138-199 188-131 229-40C268 47 288 129 288 208L288 292C288 371 268 453 229 540C188 631 138 699 78 745C75 747 72 748 71 748C62 748 57 743 57 734C57 730 59 726 62 723C114 683 156 617 187 526C214 447 228 369 228 292L228 208C228 131 214 53 187-26C156-117 114-183 62-223C59-227 57-231 57-234C57-243 62-248 71-248C72-248 75-247 78-245Z"/></g></g></g></g></svg><svg data-labels="true" preserveaspectratio="xMaxYMid" viewbox="1278 -750 1 1000"><g data-labels="true" transform="matrix(1 0 0 -1 0 0)"><g data-mml-node="mtd" id="mjx-eqn:6"><g data-mml-node="mtext" data-latex="\text{(}"><path data-c="28" d="M318-248C327-248 332-243 332-234C332-231 330-227 327-223C275-183 233-117 202-26C175 53 161 131 161 208L161 292C161 369 175 447 202 526C233 617 275 683 327 723C330 726 332 730 332 734C332 743 327 748 318 748C317 748 314 747 311 745C251 699 201 631 160 540C121 453 101 371 101 292L101 208C101 129 121 47 160-40C201-131 251-199 311-245C314-247 317-248 318-248Z"/></g><g data-mml-node="mtext" data-latex="\text{6}" transform="translate(389,0)"><path data-c="36" d="M383 504C416 504 432 521 432 555C432 627 378 666 304 666C221 666 155 627 106 548C63 480 42 403 42 316C42 189 65 100 112 47C152 1 198-22 251-22C312-22 362 1 401 47C438 91 457 144 457 205C457 266 439 318 403 361C365 407 316 431 257 431C205 431 165 402 138 346L138 352C138 465 166 561 226 605C252 624 279 633 306 633C342 633 368 623 385 602C351 602 334 583 334 553C334 525 355 504 383 504M344 340C355 317 361 272 361 206C361 141 356 98 345 76C325 35 294 14 251 14C222 14 200 24 184 44C171 60 162 74 158 85C146 116 140 163 140 227C140 255 144 282 151 308C164 355 201 399 256 399C295 399 325 379 344 340Z"/></g><g data-mml-node="mtext" data-latex="\text{)}" transform="translate(889,0)"><path data-c="29" d="M78-245C138-199 188-131 229-40C268 47 288 129 288 208L288 292C288 371 268 453 229 540C188 631 138 699 78 745C75 747 72 748 71 748C62 748 57 743 57 734C57 730 59 726 62 723C114 683 156 617 187 526C214 447 228 369 228 292L228 208C228 131 214 53 187-26C156-117 114-183 62-223C59-227 57-231 57-234C57-243 62-248 71-248C72-248 75-247 78-245Z"/></g></g></g></svg></g></g></g></g></svg></mjx-container></p><p>可以看到,TF-IDF与一个词在文档中的出现次数成正比,与该词在整个文档库中的出现次数成反比。</p><figure class="highlight bash"><table><tbody><tr><td class="code"><pre><span class="line">句子A:</span><br><span class="line"></span><br><span class="line">{</span><br><span class="line">  <span class="string">'我'</span>: -0.047947012075296815,</span><br><span class="line">  <span class="string">'这里'</span>: 0.06757751801802739,</span><br><span class="line">  <span class="string">'有'</span>: 0.06757751801802739,</span><br><span class="line">  <span class="string">'苹果'</span>: 0,</span><br><span class="line">  <span class="string">'和'</span>: 0.06757751801802739,</span><br><span class="line">  <span class="string">'西瓜'</span>: 0,</span><br><span class="line">  <span class="string">'喜欢'</span>: 0,</span><br><span class="line">  <span class="string">'吃'</span>: 0,</span><br><span class="line">  <span class="string">'不'</span>: 0,</span><br><span class="line">  <span class="string">'蔬菜'</span>: 0</span><br><span class="line">}</span><br><span class="line"></span><br><span class="line">句子B:</span><br><span class="line">{</span><br><span class="line">  <span class="string">'我'</span>: -0.03596025905647261,</span><br><span class="line">  <span class="string">'这里'</span>: 0,</span><br><span class="line">  <span class="string">'有'</span>: 0,</span><br><span class="line">  <span class="string">'苹果'</span>: 0,</span><br><span class="line">  <span class="string">'和'</span>: 0,</span><br><span class="line">  <span class="string">'西瓜'</span>: 0,</span><br><span class="line">  <span class="string">'喜欢'</span>: 0,</span><br><span class="line">  <span class="string">'吃'</span>: 0,</span><br><span class="line">  <span class="string">'不'</span>: 0.05068313851352055,</span><br><span class="line">  <span class="string">'蔬菜'</span>: 0</span><br><span class="line">}</span><br><span class="line"></span><br><span class="line">句子C:</span><br><span class="line"></span><br><span class="line">{</span><br><span class="line">  <span class="string">'我'</span>: -0.07192051811294523,</span><br><span class="line">  <span class="string">'这里'</span>: 0,</span><br><span class="line">  <span class="string">'有'</span>: 0,</span><br><span class="line">  <span class="string">'苹果'</span>: 0,</span><br><span class="line">  <span class="string">'和'</span>: 0,</span><br><span class="line">  <span class="string">'西瓜'</span>: 0,</span><br><span class="line">  <span class="string">'喜欢'</span>: 0,</span><br><span class="line">  <span class="string">'吃'</span>: 0,</span><br><span class="line">  <span class="string">'不'</span>: 0,</span><br><span class="line">  <span class="string">'蔬菜'</span>: 0.1013662770270411</span><br><span class="line">}</span><br></pre></td></tr></tbody></table></figure></div><div class="story post-story"><h2 id="第七步:列出文档向量"><a href="#第七步:列出文档向量" class="headerlink" title="第七步:列出文档向量"></a>第七步:列出文档向量</h2><p>这里准确来说应该是 TF-IDF 特征向量,这是一个稀疏矩阵。下面把它作为描述文章特征的向量。</p><p>说明一点,这里的文章的特征不是由某几个关键词的 TF-IDF 值决定的,而是由所有的词的 TF-IDF 值共同决定的。</p><figure class="highlight bash"><table><tbody><tr><td class="code"><pre><span class="line">句子A:</span><br><span class="line"></span><br><span class="line">[</span><br><span class="line">  -0.047947012075296815,</span><br><span class="line">  0.06757751801802739,</span><br><span class="line">  0.06757751801802739,</span><br><span class="line">  0,</span><br><span class="line">  0.06757751801802739,</span><br><span class="line">  0,</span><br><span class="line">  0,</span><br><span class="line">  0,</span><br><span class="line">  0,</span><br><span class="line">  0</span><br><span class="line">]</span><br><span class="line"></span><br><span class="line">句子B:</span><br><span class="line"></span><br><span class="line">[</span><br><span class="line">  -0.03596025905647261,</span><br><span class="line">  0,</span><br><span class="line">  0,</span><br><span class="line">  0,</span><br><span class="line">  0,</span><br><span class="line">  0,</span><br><span class="line">  0,</span><br><span class="line">  0,</span><br><span class="line">  0.05068313851352055,</span><br><span class="line">  0</span><br><span class="line">]</span><br><span class="line"></span><br><span class="line">句子C:</span><br><span class="line"></span><br><span class="line">[</span><br><span class="line">  -0.07192051811294523,</span><br><span class="line">  0,</span><br><span class="line">  0,</span><br><span class="line">  0,</span><br><span class="line">  0,</span><br><span class="line">  0,</span><br><span class="line">  0,</span><br><span class="line">  0,</span><br><span class="line">  0,</span><br><span class="line">  0.1013662770270411</span><br><span class="line">]</span><br></pre></td></tr></tbody></table></figure><p>可以对文档向量进行标准化,使得这些向量能够不受向量里有效元素多少的影响,也就是不同的文档可能有不同的长度。把向量都标准化为一个单位向量的长度。这个时候再进行点积运算,就相当于在原来的向量上进行余弦相似度的运算。</p><p><mjx-container class="MathJax" jax="SVG" overflow="overflow" display="true" width="full" style="min-width: 33.501ex;"><svg style="vertical-align: -0.949ex; min-width: 33.501ex;" xmlns="http://www.w3.org/2000/svg" width="100%" height="3.029ex" role="img" focusable="false" data-mjx-viewbox="0 -919.5 14807.6 1339"><g stroke="currentColor" fill="currentColor" stroke-width="0" transform="scale(0.0181,-0.0181) translate(0, -919.5)"><g data-mml-node="math" data-latex="
\vec{a} \cdot \vec{b}=|\vec{a}||\vec{b}|\cos\theta=\cos\theta
"><g data-mml-node="mtable" data-latex="\vec{a} \cdot \vec{b}=|\vec{a}||\vec{b}|\cos\theta=\cos\theta" transform="translate(2078,0) translate(-2078,0)"><g transform="translate(0 919.5) matrix(1 0 0 -1 0 0) scale(55.25)"><svg data-table="true" preserveaspectratio="xMidYMid" viewbox="5325.8 -919.5 1 1339"><g transform="matrix(1 0 0 -1 0 0)"><g data-mml-node="mlabeledtr" transform="translate(0,-169.5)"><g data-mml-node="mtd"><g data-mml-node="TeXAtom" data-latex="\vec{a}" data-mjx-texclass="ORD"><g data-mml-node="mover"><g data-mml-node="mi" data-latex="a"><path data-c="1D44E" d="M498 144C498 153 493 158 482 158C474 158 468 151 465 137C445 58 421 18 394 18C377 18 368 32 368 60C368 73 372 97 381 132L438 357C443 376 445 387 445 392C445 412 434 422 412 422C391 422 377 410 370 387C349 424 319 442 281 442C216 442 159 409 109 343C63 281 40 217 40 150C40 63 91-11 175-11C218-11 260 12 300 58C311 20 345-11 392-11C461-11 482 70 498 144M341 374C350 353 355 339 355 330C355 326 354 321 353 314L304 122C301 111 294 99 285 87C248 41 212 18 177 18C138 18 118 48 118 107C118 131 124 167 136 215C157 300 187 357 224 388C244 405 263 413 282 413C309 413 329 400 341 374Z"/></g><g data-mml-node="mo" transform="translate(550.5,26)"><path data-c="20D7" d="M-69 599C-60 602-56 607-56 616C-56 625-60 630-69 633C-105 645-131 667-147 700C-150 707-156 711-163 711C-176 711-182 705-182 693C-182 678-169 658-143 634L-453 634C-466 634-472 628-472 616C-472 604-466 598-453 598L-143 598C-169 574-182 554-182 539C-182 527-176 521-163 521C-156 521-150 525-147 532C-131 565-105 587-69 599Z"/></g></g></g><g data-mml-node="mo" data-latex="\cdot" transform="translate(772.7,0)"><path data-c="22C5" d="M192 250C192 279 168 303 139 303C110 303 86 279 86 250C86 221 110 197 139 197C168 197 192 221 192 250Z"/></g><g data-mml-node="TeXAtom" data-latex="\vec{b}" data-mjx-texclass="ORD" transform="translate(1272.9,0)"><g data-mml-node="mover"><g data-mml-node="mi" data-latex="b"><path data-c="1D44F" d="M281 445C245 445 209 428 174 394L243 679C241 688 238 694 226 694C193 694 120 685 107 684C92 682 84 675 84 660C84 650 93 645 112 645C131 645 157 646 157 632C157 628 152 608 143 571L63 249C52 207 47 173 47 148C47 62 93-11 175-11C240-11 297 22 347 89C392 151 415 216 415 283C415 370 364 445 281 445M279 415C318 415 337 385 337 326C337 299 331 263 319 218C297 133 268 75 233 44C213 27 194 19 175 19C134 19 114 51 114 115C114 137 119 170 129 214L151 304C154 319 159 330 165 338C204 389 242 415 279 415Z"/></g><g data-mml-node="mo" transform="translate(467.5,278)"><path data-c="20D7" d="M-69 599C-60 602-56 607-56 616C-56 625-60 630-69 633C-105 645-131 667-147 700C-150 707-156 711-163 711C-176 711-182 705-182 693C-182 678-169 658-143 634L-453 634C-466 634-472 628-472 616C-472 604-466 598-453 598L-143 598C-169 574-182 554-182 539C-182 527-176 521-163 521C-156 521-150 525-147 532C-131 565-105 587-69 599Z"/></g></g></g><g data-mml-node="mo" data-latex="=" transform="translate(2018.2,0)"><path data-c="3D" d="M698 367L80 367C64 367 56 359 56 344C56 329 64 321 80 321L698 321C714 321 722 329 722 344C722 356 711 367 698 367M698 179L80 179C64 179 56 171 56 156C56 141 64 133 80 133L698 133C714 133 722 141 722 156C722 169 711 179 698 179Z"/></g><g data-mml-node="mo" data-latex="|" transform="translate(3074,0)"><path data-c="7C" d="M139-250C152-250 159-242 159-226L159 726C159 742 152 750 139 750C126 750 119 742 119 726L119-226C119-242 126-250 139-250Z"/></g><g data-mml-node="TeXAtom" data-latex="\vec{a}" data-mjx-texclass="ORD" transform="translate(3352,0)"><g data-mml-node="mover"><g data-mml-node="mi" data-latex="a"><path data-c="1D44E" d="M498 144C498 153 493 158 482 158C474 158 468 151 465 137C445 58 421 18 394 18C377 18 368 32 368 60C368 73 372 97 381 132L438 357C443 376 445 387 445 392C445 412 434 422 412 422C391 422 377 410 370 387C349 424 319 442 281 442C216 442 159 409 109 343C63 281 40 217 40 150C40 63 91-11 175-11C218-11 260 12 300 58C311 20 345-11 392-11C461-11 482 70 498 144M341 374C350 353 355 339 355 330C355 326 354 321 353 314L304 122C301 111 294 99 285 87C248 41 212 18 177 18C138 18 118 48 118 107C118 131 124 167 136 215C157 300 187 357 224 388C244 405 263 413 282 413C309 413 329 400 341 374Z"/></g><g data-mml-node="mo" transform="translate(550.5,26)"><path data-c="20D7" d="M-69 599C-60 602-56 607-56 616C-56 625-60 630-69 633C-105 645-131 667-147 700C-150 707-156 711-163 711C-176 711-182 705-182 693C-182 678-169 658-143 634L-453 634C-466 634-472 628-472 616C-472 604-466 598-453 598L-143 598C-169 574-182 554-182 539C-182 527-176 521-163 521C-156 521-150 525-147 532C-131 565-105 587-69 599Z"/></g></g></g><g data-mml-node="mo" data-latex="|" transform="translate(3902.5,0)"><path data-c="7C" d="M139-250C152-250 159-242 159-226L159 726C159 742 152 750 139 750C126 750 119 742 119 726L119-226C119-242 126-250 139-250Z"/></g><g data-mml-node="mo" data-latex="|" transform="translate(4180.5,0)"><path data-c="7C" d="M139-250C152-250 159-242 159-226L159 726C159 742 152 750 139 750C126 750 119 742 119 726L119-226C119-242 126-250 139-250Z"/></g><g data-mml-node="TeXAtom" data-latex="\vec{b}" data-mjx-texclass="ORD" transform="translate(4458.5,0)"><g data-mml-node="mover"><g data-mml-node="mi" data-latex="b"><path data-c="1D44F" d="M281 445C245 445 209 428 174 394L243 679C241 688 238 694 226 694C193 694 120 685 107 684C92 682 84 675 84 660C84 650 93 645 112 645C131 645 157 646 157 632C157 628 152 608 143 571L63 249C52 207 47 173 47 148C47 62 93-11 175-11C240-11 297 22 347 89C392 151 415 216 415 283C415 370 364 445 281 445M279 415C318 415 337 385 337 326C337 299 331 263 319 218C297 133 268 75 233 44C213 27 194 19 175 19C134 19 114 51 114 115C114 137 119 170 129 214L151 304C154 319 159 330 165 338C204 389 242 415 279 415Z"/></g><g data-mml-node="mo" transform="translate(467.5,278)"><path data-c="20D7" d="M-69 599C-60 602-56 607-56 616C-56 625-60 630-69 633C-105 645-131 667-147 700C-150 707-156 711-163 711C-176 711-182 705-182 693C-182 678-169 658-143 634L-453 634C-466 634-472 628-472 616C-472 604-466 598-453 598L-143 598C-169 574-182 554-182 539C-182 527-176 521-163 521C-156 521-150 525-147 532C-131 565-105 587-69 599Z"/></g></g></g><g data-mml-node="mo" data-latex="|" transform="translate(4926,0)"><path data-c="7C" d="M139-250C152-250 159-242 159-226L159 726C159 742 152 750 139 750C126 750 119 742 119 726L119-226C119-242 126-250 139-250Z"/></g><g data-mml-node="mi" data-latex="\cos" transform="translate(5370.7,0)"><path data-c="63" d="M251 416C293 416 325 406 347 386C323 383 306 361 306 338C306 305 322 289 355 289C388 289 404 306 404 339C404 410 327 448 250 448C188 448 137 426 96 380C55 334 34 279 34 216C34 155 55 101 96 56C137 11 187-11 248-11C298-11 337 3 365 32C388 55 403 78 411 102C414 111 415 117 415 121C415 130 409 134 398 134C390 134 385 130 382 122C361 55 320 21 257 21C228 21 200 34 172 61C139 92 123 144 123 218C123 318 161 416 251 416Z"/><path data-c="6F" d="M249-11C311-11 363 11 406 55C449 99 471 152 471 214C471 277 450 332 408 378C366 424 313 448 250 448C187 448 135 424 92 378C49 332 28 277 28 214C28 152 49 99 92 55C135 11 188-11 249-11M250 21C202 21 166 42 141 85C125 113 117 159 117 222C117 283 125 327 140 355C164 398 200 419 249 419C296 419 332 398 357 357C374 329 382 284 382 222C382 106 348 21 250 21Z" transform="translate(444,0)"/><path data-c="73" d="M360 130C360 206 308 254 205 274C158 283 128 294 112 305C96 316 88 332 88 351C88 398 123 421 193 421C261 421 298 383 303 306C304 298 309 294 319 294C330 294 336 303 336 321L336 420C336 439 331 448 321 448C310 448 295 430 285 422C260 439 229 448 193 448C104 448 33 408 33 323C33 289 47 260 76 237C111 208 144 202 207 191C272 178 305 149 305 104C305 47 270 18 199 18C130 18 86 64 67 155C64 168 59 175 50 175C39 175 33 165 33 146L33 17C33-2 38-11 48-11C51-11 56-8 64-1C82 15 74 12 92 30C121 3 157-11 199-11C294-11 360 38 360 130Z" transform="translate(944,0)"/></g><g data-mml-node="mo" transform="translate(6708.7,0)"><path data-c="2061" d=""/></g><g data-mml-node="mi" data-latex="\theta" transform="translate(6875.3,0)"><path data-c="1D703" d="M164-11C209-11 256 16 302 70C382 163 455 335 455 498C455 539 448 582 434 625C416 678 382 705 333 705C288 705 243 678 196 624C116 532 42 360 42 196C42 94 75-11 164-11M332 675C365 675 382 637 382 560C382 517 372 452 352 367L155 367C180 460 204 529 229 574C266 641 301 675 332 675M145 327L341 327C322 246 299 181 274 132C235 57 199 19 164 19C131 19 115 58 115 135C115 185 125 249 145 327Z"/></g><g data-mml-node="mo" data-latex="=" transform="translate(7622.1,0)"><path data-c="3D" d="M698 367L80 367C64 367 56 359 56 344C56 329 64 321 80 321L698 321C714 321 722 329 722 344C722 356 711 367 698 367M698 179L80 179C64 179 56 171 56 156C56 141 64 133 80 133L698 133C714 133 722 141 722 156C722 169 711 179 698 179Z"/></g><g data-mml-node="mi" data-latex="\cos" transform="translate(8677.9,0)"><path data-c="63" d="M251 416C293 416 325 406 347 386C323 383 306 361 306 338C306 305 322 289 355 289C388 289 404 306 404 339C404 410 327 448 250 448C188 448 137 426 96 380C55 334 34 279 34 216C34 155 55 101 96 56C137 11 187-11 248-11C298-11 337 3 365 32C388 55 403 78 411 102C414 111 415 117 415 121C415 130 409 134 398 134C390 134 385 130 382 122C361 55 320 21 257 21C228 21 200 34 172 61C139 92 123 144 123 218C123 318 161 416 251 416Z"/><path data-c="6F" d="M249-11C311-11 363 11 406 55C449 99 471 152 471 214C471 277 450 332 408 378C366 424 313 448 250 448C187 448 135 424 92 378C49 332 28 277 28 214C28 152 49 99 92 55C135 11 188-11 249-11M250 21C202 21 166 42 141 85C125 113 117 159 117 222C117 283 125 327 140 355C164 398 200 419 249 419C296 419 332 398 357 357C374 329 382 284 382 222C382 106 348 21 250 21Z" transform="translate(444,0)"/><path data-c="73" d="M360 130C360 206 308 254 205 274C158 283 128 294 112 305C96 316 88 332 88 351C88 398 123 421 193 421C261 421 298 383 303 306C304 298 309 294 319 294C330 294 336 303 336 321L336 420C336 439 331 448 321 448C310 448 295 430 285 422C260 439 229 448 193 448C104 448 33 408 33 323C33 289 47 260 76 237C111 208 144 202 207 191C272 178 305 149 305 104C305 47 270 18 199 18C130 18 86 64 67 155C64 168 59 175 50 175C39 175 33 165 33 146L33 17C33-2 38-11 48-11C51-11 56-8 64-1C82 15 74 12 92 30C121 3 157-11 199-11C294-11 360 38 360 130Z" transform="translate(944,0)"/></g><g data-mml-node="mo" transform="translate(10015.9,0)"><path data-c="2061" d=""/></g><g data-mml-node="mi" data-latex="\theta" transform="translate(10182.6,0)"><path data-c="1D703" d="M164-11C209-11 256 16 302 70C382 163 455 335 455 498C455 539 448 582 434 625C416 678 382 705 333 705C288 705 243 678 196 624C116 532 42 360 42 196C42 94 75-11 164-11M332 675C365 675 382 637 382 560C382 517 372 452 352 367L155 367C180 460 204 529 229 574C266 641 301 675 332 675M145 327L341 327C322 246 299 181 274 132C235 57 199 19 164 19C131 19 115 58 115 135C115 185 125 249 145 327Z"/></g></g></g></g></svg><svg data-labels="true" preserveaspectratio="xMaxYMid" viewbox="1278 -919.5 1 1339"><g data-labels="true" transform="matrix(1 0 0 -1 0 0)"><g data-mml-node="mtd" id="mjx-eqn:7" transform="translate(0,578.5)"><text data-id-align="true"/><g data-idbox="true" transform="translate(0,-748)"><g data-mml-node="mtext" data-latex="\text{(}"><path data-c="28" d="M318-248C327-248 332-243 332-234C332-231 330-227 327-223C275-183 233-117 202-26C175 53 161 131 161 208L161 292C161 369 175 447 202 526C233 617 275 683 327 723C330 726 332 730 332 734C332 743 327 748 318 748C317 748 314 747 311 745C251 699 201 631 160 540C121 453 101 371 101 292L101 208C101 129 121 47 160-40C201-131 251-199 311-245C314-247 317-248 318-248Z"/></g><g data-mml-node="mtext" data-latex="\text{7}" transform="translate(389,0)"><path data-c="37" d="M475 604C482 613 485 626 485 644L243 644C174 644 135 648 128 657C125 660 122 667 120 676L89 676L55 464L88 464C98 520 106 550 112 555C115 558 146 560 205 560L401 560L295 410C214 295 174 171 174 36C174-3 190-22 223-22C256-22 272-3 272 36L272 87C272 239 296 349 343 416Z"/></g><g data-mml-node="mtext" data-latex="\text{)}" transform="translate(889,0)"><path data-c="29" d="M78-245C138-199 188-131 229-40C268 47 288 129 288 208L288 292C288 371 268 453 229 540C188 631 138 699 78 745C75 747 72 748 71 748C62 748 57 743 57 734C57 730 59 726 62 723C114 683 156 617 187 526C214 447 228 369 228 292L228 208C228 131 214 53 187-26C156-117 114-183 62-223C59-227 57-231 57-234C57-243 62-248 71-248C72-248 75-247 78-245Z"/></g></g></g></g></svg></g></g></g></g></svg></mjx-container></p></div><div class="story post-story"><h2 id="第八步:计算余弦相似度"><a href="#第八步:计算余弦相似度" class="headerlink" title="第八步:计算余弦相似度"></a>第八步:计算余弦相似度</h2><p>到这里,如何寻找两篇相似文章的问题转变成了如何计算这两个向量的相似程度的问题。</p><p>什么叫做向量相似?</p><p>一般地,如果两个向量平行或重合,我们认为这两个向量相似度为 <mjx-container class="MathJax" jax="SVG" overflow="overflow"><svg style="vertical-align: 0;" xmlns="http://www.w3.org/2000/svg" width="1.131ex" height="1.507ex" role="img" focusable="false" viewbox="0 -666 500 666"><g stroke="currentColor" fill="currentColor" stroke-width="0" transform="scale(1,-1)"><g data-mml-node="math" data-latex="1"><g data-mml-node="mn" data-latex="1"><path data-c="31" d="M269 666C228 624 168 603 89 603L89 564C141 564 184 572 217 588L217 82C217 64 213 52 204 47C195 42 170 39 130 39L95 39L95 0C120 2 174 3 257 3C340 3 394 2 419 0L419 39L384 39C343 39 318 42 310 47C302 52 297 64 297 82L297 636C297 660 295 666 269 666Z"/></g></g></g></svg></mjx-container>。如果这两个向量垂直,或者说正交,我们认为这两个向量的相似度为 <mjx-container class="MathJax" jax="SVG" overflow="overflow"><svg style="vertical-align: -0.05ex;" xmlns="http://www.w3.org/2000/svg" width="1.131ex" height="1.557ex" role="img" focusable="false" viewbox="0 -666 500 688"><g stroke="currentColor" fill="currentColor" stroke-width="0" transform="scale(1,-1)"><g data-mml-node="math" data-latex="0"><g data-mml-node="mn" data-latex="0"><path data-c="30" d="M249-22C390-22 460 92 460 320C460 473 428 575 365 625C330 652 291 666 250 666C109 666 39 551 39 320C39 136 88-22 249-22M361 524C368 489 371 425 371 332C371 240 367 172 360 128C347 48 310 8 249 8C226 8 203 17 182 34C155 57 139 104 132 176C129 201 128 253 128 332C128 419 131 480 136 513C145 568 163 603 191 618C213 630 232 636 249 636C314 636 350 583 361 524Z"/></g></g></g></svg></mjx-container>。</p><p>以二维空间为例,<mjx-container class="MathJax" jax="SVG" overflow="overflow"><svg style="vertical-align: -0.025ex;" xmlns="http://www.w3.org/2000/svg" width="1.245ex" height="1.919ex" role="img" focusable="false" viewbox="0 -837 550.5 848"><g stroke="currentColor" fill="currentColor" stroke-width="0" transform="scale(1,-1)"><g data-mml-node="math" data-latex="\vec{a}"><g data-mml-node="TeXAtom" data-latex="\vec{a}" data-mjx-texclass="ORD"><g data-mml-node="mover"><g data-mml-node="mi" data-latex="a"><path data-c="1D44E" d="M498 144C498 153 493 158 482 158C474 158 468 151 465 137C445 58 421 18 394 18C377 18 368 32 368 60C368 73 372 97 381 132L438 357C443 376 445 387 445 392C445 412 434 422 412 422C391 422 377 410 370 387C349 424 319 442 281 442C216 442 159 409 109 343C63 281 40 217 40 150C40 63 91-11 175-11C218-11 260 12 300 58C311 20 345-11 392-11C461-11 482 70 498 144M341 374C350 353 355 339 355 330C355 326 354 321 353 314L304 122C301 111 294 99 285 87C248 41 212 18 177 18C138 18 118 48 118 107C118 131 124 167 136 215C157 300 187 357 224 388C244 405 263 413 282 413C309 413 329 400 341 374Z"/></g><g data-mml-node="mo" transform="translate(550.5,26)"><path data-c="20D7" d="M-69 599C-60 602-56 607-56 616C-56 625-60 630-69 633C-105 645-131 667-147 700C-150 707-156 711-163 711C-176 711-182 705-182 693C-182 678-169 658-143 634L-453 634C-466 634-472 628-472 616C-472 604-466 598-453 598L-143 598C-169 574-182 554-182 539C-182 527-176 521-163 521C-156 521-150 525-147 532C-131 565-105 587-69 599Z"/></g></g></g></g></g></svg></mjx-container> 和 <mjx-container class="MathJax" jax="SVG" overflow="overflow"><svg style="vertical-align: -0.025ex;" xmlns="http://www.w3.org/2000/svg" width="1.058ex" height="2.489ex" role="img" focusable="false" viewbox="0 -1089 467.5 1100"><g stroke="currentColor" fill="currentColor" stroke-width="0" transform="scale(1,-1)"><g data-mml-node="math" data-latex="\vec{b}"><g data-mml-node="TeXAtom" data-latex="\vec{b}" data-mjx-texclass="ORD"><g data-mml-node="mover"><g data-mml-node="mi" data-latex="b"><path data-c="1D44F" d="M281 445C245 445 209 428 174 394L243 679C241 688 238 694 226 694C193 694 120 685 107 684C92 682 84 675 84 660C84 650 93 645 112 645C131 645 157 646 157 632C157 628 152 608 143 571L63 249C52 207 47 173 47 148C47 62 93-11 175-11C240-11 297 22 347 89C392 151 415 216 415 283C415 370 364 445 281 445M279 415C318 415 337 385 337 326C337 299 331 263 319 218C297 133 268 75 233 44C213 27 194 19 175 19C134 19 114 51 114 115C114 137 119 170 129 214L151 304C154 319 159 330 165 338C204 389 242 415 279 415Z"/></g><g data-mml-node="mo" transform="translate(467.5,278)"><path data-c="20D7" d="M-69 599C-60 602-56 607-56 616C-56 625-60 630-69 633C-105 645-131 667-147 700C-150 707-156 711-163 711C-176 711-182 705-182 693C-182 678-169 658-143 634L-453 634C-466 634-472 628-472 616C-472 604-466 598-453 598L-143 598C-169 574-182 554-182 539C-182 527-176 521-163 521C-156 521-150 525-147 532C-131 565-105 587-69 599Z"/></g></g></g></g></g></svg></mjx-container> 是两个向量,我们要计算它们的夹角 <mjx-container class="MathJax" jax="SVG" overflow="overflow"><svg style="vertical-align: -0.025ex;" xmlns="http://www.w3.org/2000/svg" width="1.061ex" height="1.62ex" role="img" focusable="false" viewbox="0 -705 469 716"><g stroke="currentColor" fill="currentColor" stroke-width="0" transform="scale(1,-1)"><g data-mml-node="math" data-latex="θ"><g data-mml-node="mi" data-latex="θ"><path data-c="1D703" d="M164-11C209-11 256 16 302 70C382 163 455 335 455 498C455 539 448 582 434 625C416 678 382 705 333 705C288 705 243 678 196 624C116 532 42 360 42 196C42 94 75-11 164-11M332 675C365 675 382 637 382 560C382 517 372 452 352 367L155 367C180 460 204 529 229 574C266 641 301 675 332 675M145 327L341 327C322 246 299 181 274 132C235 57 199 19 164 19C131 19 115 58 115 135C115 185 125 249 145 327Z"/></g></g></g></svg></mjx-container> 。余弦定理告诉我们,可以用下面的公式求得:</p><p><mjx-container class="MathJax" jax="SVG" overflow="overflow" display="true" width="full" style="min-width: 29.522ex;"><svg style="vertical-align: -1.931ex; min-width: 29.522ex;" xmlns="http://www.w3.org/2000/svg" width="100%" height="4.993ex" role="img" focusable="false" data-mjx-viewbox="0 -1353.5 13048.8 2206.9"><g stroke="currentColor" fill="currentColor" stroke-width="0" transform="scale(0.0181,-0.0181) translate(0, -1353.5)"><g data-mml-node="math" data-latex="
\cos\theta=\frac{a^2+b^2-c^2}{2ab}
"><g data-mml-node="mtable" data-latex="\cos\theta=\frac{a^2+b^2-c^2}{2ab}" transform="translate(2078,0) translate(-2078,0)"><g transform="translate(0 1353.5) matrix(1 0 0 -1 0 0) scale(55.25)"><svg data-table="true" preserveaspectratio="xMidYMid" viewbox="4446.4 -1353.5 1 2206.9"><g transform="matrix(1 0 0 -1 0 0)"><g data-mml-node="mlabeledtr" transform="translate(0,-156.5)"><g data-mml-node="mtd"><g data-mml-node="mi" data-latex="\cos"><path data-c="63" d="M251 416C293 416 325 406 347 386C323 383 306 361 306 338C306 305 322 289 355 289C388 289 404 306 404 339C404 410 327 448 250 448C188 448 137 426 96 380C55 334 34 279 34 216C34 155 55 101 96 56C137 11 187-11 248-11C298-11 337 3 365 32C388 55 403 78 411 102C414 111 415 117 415 121C415 130 409 134 398 134C390 134 385 130 382 122C361 55 320 21 257 21C228 21 200 34 172 61C139 92 123 144 123 218C123 318 161 416 251 416Z"/><path data-c="6F" d="M249-11C311-11 363 11 406 55C449 99 471 152 471 214C471 277 450 332 408 378C366 424 313 448 250 448C187 448 135 424 92 378C49 332 28 277 28 214C28 152 49 99 92 55C135 11 188-11 249-11M250 21C202 21 166 42 141 85C125 113 117 159 117 222C117 283 125 327 140 355C164 398 200 419 249 419C296 419 332 398 357 357C374 329 382 284 382 222C382 106 348 21 250 21Z" transform="translate(444,0)"/><path data-c="73" d="M360 130C360 206 308 254 205 274C158 283 128 294 112 305C96 316 88 332 88 351C88 398 123 421 193 421C261 421 298 383 303 306C304 298 309 294 319 294C330 294 336 303 336 321L336 420C336 439 331 448 321 448C310 448 295 430 285 422C260 439 229 448 193 448C104 448 33 408 33 323C33 289 47 260 76 237C111 208 144 202 207 191C272 178 305 149 305 104C305 47 270 18 199 18C130 18 86 64 67 155C64 168 59 175 50 175C39 175 33 165 33 146L33 17C33-2 38-11 48-11C51-11 56-8 64-1C82 15 74 12 92 30C121 3 157-11 199-11C294-11 360 38 360 130Z" transform="translate(944,0)"/></g><g data-mml-node="mo" transform="translate(1338,0)"><path data-c="2061" d=""/></g><g data-mml-node="mi" data-latex="\theta" transform="translate(1504.7,0)"><path data-c="1D703" d="M164-11C209-11 256 16 302 70C382 163 455 335 455 498C455 539 448 582 434 625C416 678 382 705 333 705C288 705 243 678 196 624C116 532 42 360 42 196C42 94 75-11 164-11M332 675C365 675 382 637 382 560C382 517 372 452 352 367L155 367C180 460 204 529 229 574C266 641 301 675 332 675M145 327L341 327C322 246 299 181 274 132C235 57 199 19 164 19C131 19 115 58 115 135C115 185 125 249 145 327Z"/></g><g data-mml-node="mo" data-latex="=" transform="translate(2251.4,0)"><path data-c="3D" d="M698 367L80 367C64 367 56 359 56 344C56 329 64 321 80 321L698 321C714 321 722 329 722 344C722 356 711 367 698 367M698 179L80 179C64 179 56 171 56 156C56 141 64 133 80 133L698 133C714 133 722 141 722 156C722 169 711 179 698 179Z"/></g><g data-mml-node="mfrac" data-latex="\frac{a^2+b^2-c^2}{2ab}" transform="translate(3307.2,0)"><g data-mml-node="mrow" data-latex="a^2 +b^2 -c^2" transform="translate(220,676)"><g data-mml-node="msup" data-latex="a^2"><g data-mml-node="mi" data-latex="a"><path data-c="1D44E" d="M498 144C498 153 493 158 482 158C474 158 468 151 465 137C445 58 421 18 394 18C377 18 368 32 368 60C368 73 372 97 381 132L438 357C443 376 445 387 445 392C445 412 434 422 412 422C391 422 377 410 370 387C349 424 319 442 281 442C216 442 159 409 109 343C63 281 40 217 40 150C40 63 91-11 175-11C218-11 260 12 300 58C311 20 345-11 392-11C461-11 482 70 498 144M341 374C350 353 355 339 355 330C355 326 354 321 353 314L304 122C301 111 294 99 285 87C248 41 212 18 177 18C138 18 118 48 118 107C118 131 124 167 136 215C157 300 187 357 224 388C244 405 263 413 282 413C309 413 329 400 341 374Z"/></g><g data-mml-node="mn" transform="translate(562,363) scale(0.707)" data-latex="2"><path data-c="32" d="M237 666C186 666 143 648 106 612C69 576 50 534 50 483C50 449 75 424 106 424C136 424 161 450 161 480C161 513 137 536 105 536C102 536 100 536 98 535C117 584 161 627 224 627C306 627 352 556 352 470C352 403 318 331 250 255L62 43C49 28 50 29 50 0L421 0L450 180L417 180C409 129 402 100 396 91C391 86 361 84 306 84L139 84L236 179C304 243 390 312 419 365C439 400 449 435 449 470C449 588 357 666 237 666Z"/></g></g><g data-mml-node="mo" data-latex="+" transform="translate(1187.8,0)"><path data-c="2B" d="M698 274L413 274L413 559C413 575 405 583 389 583C373 583 365 575 365 559L365 274L80 274C64 274 56 266 56 250C56 234 64 226 80 226L365 226L365-59C365-75 373-83 389-83C405-83 413-75 413-59L413 226L698 226C714 226 722 234 722 250C722 263 711 274 698 274Z"/></g><g data-mml-node="msup" data-latex="b^2" transform="translate(2188,0)"><g data-mml-node="mi" data-latex="b"><path data-c="1D44F" d="M281 445C245 445 209 428 174 394L243 679C241 688 238 694 226 694C193 694 120 685 107 684C92 682 84 675 84 660C84 650 93 645 112 645C131 645 157 646 157 632C157 628 152 608 143 571L63 249C52 207 47 173 47 148C47 62 93-11 175-11C240-11 297 22 347 89C392 151 415 216 415 283C415 370 364 445 281 445M279 415C318 415 337 385 337 326C337 299 331 263 319 218C297 133 268 75 233 44C213 27 194 19 175 19C134 19 114 51 114 115C114 137 119 170 129 214L151 304C154 319 159 330 165 338C204 389 242 415 279 415Z"/></g><g data-mml-node="mn" transform="translate(462,363) scale(0.707)" data-latex="2"><path data-c="32" d="M237 666C186 666 143 648 106 612C69 576 50 534 50 483C50 449 75 424 106 424C136 424 161 450 161 480C161 513 137 536 105 536C102 536 100 536 98 535C117 584 161 627 224 627C306 627 352 556 352 470C352 403 318 331 250 255L62 43C49 28 50 29 50 0L421 0L450 180L417 180C409 129 402 100 396 91C391 86 361 84 306 84L139 84L236 179C304 243 390 312 419 365C439 400 449 435 449 470C449 588 357 666 237 666Z"/></g></g><g data-mml-node="mo" data-latex="-" transform="translate(3275.8,0)"><path data-c="2212" d="M698 270L80 270C64 270 56 263 56 250C56 237 64 230 80 230L698 230C714 230 722 237 722 250C722 262 710 270 698 270Z"/></g><g data-mml-node="msup" data-latex="c^2" transform="translate(4276,0)"><g data-mml-node="mi" data-latex="c"><path data-c="1D450" d="M328 325C328 300 341 287 368 287C404 287 427 318 427 354C427 410 368 442 308 442C239 442 176 412 122 353C68 294 41 229 41 159C41 61 106-11 204-11C257-11 304 2 345 27C379 48 404 69 420 90C427 99 430 106 430 109C430 120 425 126 414 126C409 126 404 122 398 114C365 70 324 42 277 30C246 22 223 18 206 18C149 18 121 53 121 122C121 184 150 274 174 317C198 361 249 413 308 413C346 413 372 402 386 381C355 378 328 358 328 325Z"/></g><g data-mml-node="mn" transform="translate(466,363) scale(0.707)" data-latex="2"><path data-c="32" d="M237 666C186 666 143 648 106 612C69 576 50 534 50 483C50 449 75 424 106 424C136 424 161 450 161 480C161 513 137 536 105 536C102 536 100 536 98 535C117 584 161 627 224 627C306 627 352 556 352 470C352 403 318 331 250 255L62 43C49 28 50 29 50 0L421 0L450 180L417 180C409 129 402 100 396 91C391 86 361 84 306 84L139 84L236 179C304 243 390 312 419 365C439 400 449 435 449 470C449 588 357 666 237 666Z"/></g></g></g><g data-mml-node="mrow" data-latex="2ab" transform="translate(2063.8,-686)"><g data-mml-node="mn" data-latex="2"><path data-c="32" d="M237 666C186 666 143 648 106 612C69 576 50 534 50 483C50 449 75 424 106 424C136 424 161 450 161 480C161 513 137 536 105 536C102 536 100 536 98 535C117 584 161 627 224 627C306 627 352 556 352 470C352 403 318 331 250 255L62 43C49 28 50 29 50 0L421 0L450 180L417 180C409 129 402 100 396 91C391 86 361 84 306 84L139 84L236 179C304 243 390 312 419 365C439 400 449 435 449 470C449 588 357 666 237 666Z"/></g><g data-mml-node="mi" data-latex="a" transform="translate(500,0)"><path data-c="1D44E" d="M498 144C498 153 493 158 482 158C474 158 468 151 465 137C445 58 421 18 394 18C377 18 368 32 368 60C368 73 372 97 381 132L438 357C443 376 445 387 445 392C445 412 434 422 412 422C391 422 377 410 370 387C349 424 319 442 281 442C216 442 159 409 109 343C63 281 40 217 40 150C40 63 91-11 175-11C218-11 260 12 300 58C311 20 345-11 392-11C461-11 482 70 498 144M341 374C350 353 355 339 355 330C355 326 354 321 353 314L304 122C301 111 294 99 285 87C248 41 212 18 177 18C138 18 118 48 118 107C118 131 124 167 136 215C157 300 187 357 224 388C244 405 263 413 282 413C309 413 329 400 341 374Z"/></g><g data-mml-node="mi" data-latex="b" transform="translate(1029,0)"><path data-c="1D44F" d="M281 445C245 445 209 428 174 394L243 679C241 688 238 694 226 694C193 694 120 685 107 684C92 682 84 675 84 660C84 650 93 645 112 645C131 645 157 646 157 632C157 628 152 608 143 571L63 249C52 207 47 173 47 148C47 62 93-11 175-11C240-11 297 22 347 89C392 151 415 216 415 283C415 370 364 445 281 445M279 415C318 415 337 385 337 326C337 299 331 263 319 218C297 133 268 75 233 44C213 27 194 19 175 19C134 19 114 51 114 115C114 137 119 170 129 214L151 304C154 319 159 330 165 338C204 389 242 415 279 415Z"/></g></g><rect width="5345.5" height="60" x="120" y="220"/></g></g></g></g></svg><svg data-labels="true" preserveaspectratio="xMaxYMid" viewbox="1278 -1353.5 1 2206.9"><g data-labels="true" transform="matrix(1 0 0 -1 0 0)"><g data-mml-node="mtd" id="mjx-eqn:8" transform="translate(0,591.5)"><text data-id-align="true"/><g data-idbox="true" transform="translate(0,-748)"><g data-mml-node="mtext" data-latex="\text{(}"><path data-c="28" d="M318-248C327-248 332-243 332-234C332-231 330-227 327-223C275-183 233-117 202-26C175 53 161 131 161 208L161 292C161 369 175 447 202 526C233 617 275 683 327 723C330 726 332 730 332 734C332 743 327 748 318 748C317 748 314 747 311 745C251 699 201 631 160 540C121 453 101 371 101 292L101 208C101 129 121 47 160-40C201-131 251-199 311-245C314-247 317-248 318-248Z"/></g><g data-mml-node="mtext" data-latex="\text{8}" transform="translate(389,0)"><path data-c="38" d="M250 666C201 666 158 650 122 618C86 586 68 546 68 497C68 456 83 419 113 386C120 378 142 361 179 335C88 288 42 227 42 153C42 100 64 57 107 24C147-7 194-22 249-22C305-22 354-4 395 32C436 68 457 115 457 170C457 216 441 257 408 294C396 307 365 330 316 361C393 402 431 454 431 515C431 606 344 666 250 666M379 515C379 463 348 418 286 381L167 459C136 479 120 505 120 536C120 596 185 633 249 633C318 633 379 584 379 515M250 14C168 14 99 73 99 153C99 220 136 274 210 315L328 240C376 209 400 174 400 134C400 62 325 14 250 14Z"/></g><g data-mml-node="mtext" data-latex="\text{)}" transform="translate(889,0)"><path data-c="29" d="M78-245C138-199 188-131 229-40C268 47 288 129 288 208L288 292C288 371 268 453 229 540C188 631 138 699 78 745C75 747 72 748 71 748C62 748 57 743 57 734C57 730 59 726 62 723C114 683 156 617 187 526C214 447 228 369 228 292L228 208C228 131 214 53 187-26C156-117 114-183 62-223C59-227 57-231 57-234C57-243 62-248 71-248C72-248 75-247 78-245Z"/></g></g></g></g></svg></g></g></g></g></svg></mjx-container></p><p>假定<mjx-container class="MathJax" jax="SVG" overflow="overflow"><svg style="vertical-align: 0;" xmlns="http://www.w3.org/2000/svg" width="1.697ex" height="1.62ex" role="img" focusable="false" viewbox="0 -716 750 716"><g stroke="currentColor" fill="currentColor" stroke-width="0" transform="scale(1,-1)"><g data-mml-node="math" data-latex="A"><g data-mml-node="mi" data-latex="A"><path data-c="1D434" d="M137 3C155 3 217 0 236 0C251 0 258 8 258 23C258 32 252 38 239 39C210 40 196 50 196 69C196 78 205 98 224 128C251 173 270 206 283 228L526 228C526 221 527 207 530 185C537 112 541 72 541 67C541 48 519 39 474 39C455 39 446 31 446 15C446 5 452 0 464 0C488 0 564 3 588 3C608 3 679 0 699 0C714 0 721 8 721 24C721 34 712 39 694 39C666 39 649 41 644 44C639 47 635 56 634 71L574 689C571 708 572 716 551 716C539 716 529 710 522 697L178 120C148 70 108 43 59 39C43 38 35 30 35 15C35 5 41 0 52 0C68 0 121 3 137 3M492 577L522 267L307 267Z"/></g></g></g></svg></mjx-container>和<mjx-container class="MathJax" jax="SVG" overflow="overflow"><svg style="vertical-align: 0;" xmlns="http://www.w3.org/2000/svg" width="1.717ex" height="1.545ex" role="img" focusable="false" viewbox="0 -683 759 683"><g stroke="currentColor" fill="currentColor" stroke-width="0" transform="scale(1,-1)"><g data-mml-node="math" data-latex="B"><g data-mml-node="mi" data-latex="B"><path data-c="1D435" d="M756 543C756 634 666 683 568 683L236 683C213 683 203 682 203 659C203 643 223 644 235 644C265 643 283 641 288 640C293 639 295 636 295 631C295 629 294 623 291 613L159 82C154 60 144 47 129 42C122 40 104 39 73 39C52 39 42 31 42 15C42 5 52 0 73 0L426 0C491 0 551 20 608 59C671 102 703 155 703 217C703 296 638 344 567 358C655 379 756 446 756 543M554 644C623 644 658 612 658 547C658 496 638 454 596 420C554 386 507 370 456 370L317 370L377 610C385 644 385 644 427 644M582 299C596 276 603 253 603 228C603 176 583 131 542 94C501 57 455 39 402 39L267 39C257 39 250 39 246 40C240 40 237 42 237 45C237 46 237 49 238 53C269 180 293 276 309 340L493 340C536 340 565 326 582 299Z"/></g></g></g></svg></mjx-container>是两个<mjx-container class="MathJax" jax="SVG" overflow="overflow"><svg style="vertical-align: -0.025ex;" xmlns="http://www.w3.org/2000/svg" width="1.357ex" height="1.025ex" role="img" focusable="false" viewbox="0 -442 600 453"><g stroke="currentColor" fill="currentColor" stroke-width="0" transform="scale(1,-1)"><g data-mml-node="math" data-latex="n"><g data-mml-node="mi" data-latex="n"><path data-c="1D45B" d="M537 137C514 58 481 18 440 18C427 18 420 28 420 47C420 61 426 84 438 115C478 224 498 296 498 333C498 403 451 442 381 442C322 442 271 416 230 363C222 407 187 442 136 442C80 442 58 390 44 345C34 313 29 294 29 287C29 278 34 273 45 273C50 273 53 274 56 276C61 285 64 292 65 299C83 375 106 413 133 413C151 413 160 399 160 371C160 358 155 331 144 290L87 63C84 50 78 24 78 19C78-1 89-11 111-11C130-11 144-1 151 19C153 24 159 49 170 92L191 181L221 295C232 318 249 341 270 365C299 397 335 413 378 413C411 413 427 391 427 348C427 310 406 234 363 120C356 102 353 87 353 74C353 25 390-11 438-11C482-11 517 14 542 64C561 104 571 131 571 144C571 153 566 158 555 158C552 158 537 149 537 137Z"/></g></g></g></svg></mjx-container>维向量,我们把这些向量放到<mjx-container class="MathJax" jax="SVG" overflow="overflow"><svg style="vertical-align: -0.025ex;" xmlns="http://www.w3.org/2000/svg" width="1.357ex" height="1.025ex" role="img" focusable="false" viewbox="0 -442 600 453"><g stroke="currentColor" fill="currentColor" stroke-width="0" transform="scale(1,-1)"><g data-mml-node="math" data-latex="n"><g data-mml-node="mi" data-latex="n"><path data-c="1D45B" d="M537 137C514 58 481 18 440 18C427 18 420 28 420 47C420 61 426 84 438 115C478 224 498 296 498 333C498 403 451 442 381 442C322 442 271 416 230 363C222 407 187 442 136 442C80 442 58 390 44 345C34 313 29 294 29 287C29 278 34 273 45 273C50 273 53 274 56 276C61 285 64 292 65 299C83 375 106 413 133 413C151 413 160 399 160 371C160 358 155 331 144 290L87 63C84 50 78 24 78 19C78-1 89-11 111-11C130-11 144-1 151 19C153 24 159 49 170 92L191 181L221 295C232 318 249 341 270 365C299 397 335 413 378 413C411 413 427 391 427 348C427 310 406 234 363 120C356 102 353 87 353 74C353 25 390-11 438-11C482-11 517 14 542 64C561 104 571 131 571 144C571 153 566 158 555 158C552 158 537 149 537 137Z"/></g></g></g></svg></mjx-container>维欧几里得空间中讨论,向量之间的距离使用欧几里得距离。</p><p><mjx-container class="MathJax" jax="SVG" overflow="overflow" display="true" width="full" style="min-width: 26.576ex;"><svg style="vertical-align: -2.095ex; min-width: 26.576ex;" xmlns="http://www.w3.org/2000/svg" width="100%" height="5.321ex" role="img" focusable="false" data-mjx-viewbox="0 -1426 11746.7 2352"><g stroke="currentColor" fill="currentColor" stroke-width="0" transform="scale(0.0181,-0.0181) translate(0, -1426)"><g data-mml-node="math" data-latex="
\cos \theta=\frac{A \cdot B}{|A| \times |B|}
"><g data-mml-node="mtable" data-latex="\cos \theta=\frac{A \cdot B}{|A| \times |B|}" transform="translate(2078,0) translate(-2078,0)"><g transform="translate(0 1426) matrix(1 0 0 -1 0 0) scale(55.25)"><svg data-table="true" preserveaspectratio="xMidYMid" viewbox="3795.3 -1426 1 2352"><g transform="matrix(1 0 0 -1 0 0)"><g data-mml-node="mlabeledtr" transform="translate(0,34)"><g data-mml-node="mtd"><g data-mml-node="mi" data-latex="\cos"><path data-c="63" d="M251 416C293 416 325 406 347 386C323 383 306 361 306 338C306 305 322 289 355 289C388 289 404 306 404 339C404 410 327 448 250 448C188 448 137 426 96 380C55 334 34 279 34 216C34 155 55 101 96 56C137 11 187-11 248-11C298-11 337 3 365 32C388 55 403 78 411 102C414 111 415 117 415 121C415 130 409 134 398 134C390 134 385 130 382 122C361 55 320 21 257 21C228 21 200 34 172 61C139 92 123 144 123 218C123 318 161 416 251 416Z"/><path data-c="6F" d="M249-11C311-11 363 11 406 55C449 99 471 152 471 214C471 277 450 332 408 378C366 424 313 448 250 448C187 448 135 424 92 378C49 332 28 277 28 214C28 152 49 99 92 55C135 11 188-11 249-11M250 21C202 21 166 42 141 85C125 113 117 159 117 222C117 283 125 327 140 355C164 398 200 419 249 419C296 419 332 398 357 357C374 329 382 284 382 222C382 106 348 21 250 21Z" transform="translate(444,0)"/><path data-c="73" d="M360 130C360 206 308 254 205 274C158 283 128 294 112 305C96 316 88 332 88 351C88 398 123 421 193 421C261 421 298 383 303 306C304 298 309 294 319 294C330 294 336 303 336 321L336 420C336 439 331 448 321 448C310 448 295 430 285 422C260 439 229 448 193 448C104 448 33 408 33 323C33 289 47 260 76 237C111 208 144 202 207 191C272 178 305 149 305 104C305 47 270 18 199 18C130 18 86 64 67 155C64 168 59 175 50 175C39 175 33 165 33 146L33 17C33-2 38-11 48-11C51-11 56-8 64-1C82 15 74 12 92 30C121 3 157-11 199-11C294-11 360 38 360 130Z" transform="translate(944,0)"/></g><g data-mml-node="mo" transform="translate(1338,0)"><path data-c="2061" d=""/></g><g data-mml-node="mi" data-latex="\theta" transform="translate(1504.7,0)"><path data-c="1D703" d="M164-11C209-11 256 16 302 70C382 163 455 335 455 498C455 539 448 582 434 625C416 678 382 705 333 705C288 705 243 678 196 624C116 532 42 360 42 196C42 94 75-11 164-11M332 675C365 675 382 637 382 560C382 517 372 452 352 367L155 367C180 460 204 529 229 574C266 641 301 675 332 675M145 327L341 327C322 246 299 181 274 132C235 57 199 19 164 19C131 19 115 58 115 135C115 185 125 249 145 327Z"/></g><g data-mml-node="mo" data-latex="=" transform="translate(2251.4,0)"><path data-c="3D" d="M698 367L80 367C64 367 56 359 56 344C56 329 64 321 80 321L698 321C714 321 722 329 722 344C722 356 711 367 698 367M698 179L80 179C64 179 56 171 56 156C56 141 64 133 80 133L698 133C714 133 722 141 722 156C722 169 711 179 698 179Z"/></g><g data-mml-node="mfrac" data-latex="\frac{A \cdot B}{|A| \times |B|}" transform="translate(3307.2,0)"><g data-mml-node="mrow" data-latex="A \cdot B" transform="translate(1026,676)"><g data-mml-node="mi" data-latex="A"><path data-c="1D434" d="M137 3C155 3 217 0 236 0C251 0 258 8 258 23C258 32 252 38 239 39C210 40 196 50 196 69C196 78 205 98 224 128C251 173 270 206 283 228L526 228C526 221 527 207 530 185C537 112 541 72 541 67C541 48 519 39 474 39C455 39 446 31 446 15C446 5 452 0 464 0C488 0 564 3 588 3C608 3 679 0 699 0C714 0 721 8 721 24C721 34 712 39 694 39C666 39 649 41 644 44C639 47 635 56 634 71L574 689C571 708 572 716 551 716C539 716 529 710 522 697L178 120C148 70 108 43 59 39C43 38 35 30 35 15C35 5 41 0 52 0C68 0 121 3 137 3M492 577L522 267L307 267Z"/></g><g data-mml-node="mo" data-latex="\cdot" transform="translate(972.2,0)"><path data-c="22C5" d="M192 250C192 279 168 303 139 303C110 303 86 279 86 250C86 221 110 197 139 197C168 197 192 221 192 250Z"/></g><g data-mml-node="mi" data-latex="B" transform="translate(1472.4,0)"><path data-c="1D435" d="M756 543C756 634 666 683 568 683L236 683C213 683 203 682 203 659C203 643 223 644 235 644C265 643 283 641 288 640C293 639 295 636 295 631C295 629 294 623 291 613L159 82C154 60 144 47 129 42C122 40 104 39 73 39C52 39 42 31 42 15C42 5 52 0 73 0L426 0C491 0 551 20 608 59C671 102 703 155 703 217C703 296 638 344 567 358C655 379 756 446 756 543M554 644C623 644 658 612 658 547C658 496 638 454 596 420C554 386 507 370 456 370L317 370L377 610C385 644 385 644 427 644M582 299C596 276 603 253 603 228C603 176 583 131 542 94C501 57 455 39 402 39L267 39C257 39 250 39 246 40C240 40 237 42 237 45C237 46 237 49 238 53C269 180 293 276 309 340L493 340C536 340 565 326 582 299Z"/></g></g><g data-mml-node="mrow" data-latex="|A| \times |B|" transform="translate(220,-710)"><g data-mml-node="mo" data-latex="|"><path data-c="7C" d="M139-250C152-250 159-242 159-226L159 726C159 742 152 750 139 750C126 750 119 742 119 726L119-226C119-242 126-250 139-250Z"/></g><g data-mml-node="mi" data-latex="A" transform="translate(278,0)"><path data-c="1D434" d="M137 3C155 3 217 0 236 0C251 0 258 8 258 23C258 32 252 38 239 39C210 40 196 50 196 69C196 78 205 98 224 128C251 173 270 206 283 228L526 228C526 221 527 207 530 185C537 112 541 72 541 67C541 48 519 39 474 39C455 39 446 31 446 15C446 5 452 0 464 0C488 0 564 3 588 3C608 3 679 0 699 0C714 0 721 8 721 24C721 34 712 39 694 39C666 39 649 41 644 44C639 47 635 56 634 71L574 689C571 708 572 716 551 716C539 716 529 710 522 697L178 120C148 70 108 43 59 39C43 38 35 30 35 15C35 5 41 0 52 0C68 0 121 3 137 3M492 577L522 267L307 267Z"/></g><g data-mml-node="mo" data-latex="|" transform="translate(1028,0)"><path data-c="7C" d="M139-250C152-250 159-242 159-226L159 726C159 742 152 750 139 750C126 750 119 742 119 726L119-226C119-242 126-250 139-250Z"/></g><g data-mml-node="mo" data-latex="\times" transform="translate(1528.2,0)"><path data-c="D7" d="M630 32C630 39 628 44 623 49L422 250L623 451C628 456 630 461 630 468C630 481 620 491 607 491C600 491 595 489 590 484L389 283L188 484C183 489 178 491 171 491C158 491 148 481 148 468C148 461 150 456 155 451L356 250L155 49C150 44 148 39 148 32C148 19 158 9 171 9C178 9 183 11 188 16L389 217L590 16C595 11 600 9 607 9C620 9 630 19 630 32Z"/></g><g data-mml-node="mo" data-latex="|" transform="translate(2528.4,0)"><path data-c="7C" d="M139-250C152-250 159-242 159-226L159 726C159 742 152 750 139 750C126 750 119 742 119 726L119-226C119-242 126-250 139-250Z"/></g><g data-mml-node="mi" data-latex="B" transform="translate(2806.4,0)"><path data-c="1D435" d="M756 543C756 634 666 683 568 683L236 683C213 683 203 682 203 659C203 643 223 644 235 644C265 643 283 641 288 640C293 639 295 636 295 631C295 629 294 623 291 613L159 82C154 60 144 47 129 42C122 40 104 39 73 39C52 39 42 31 42 15C42 5 52 0 73 0L426 0C491 0 551 20 608 59C671 102 703 155 703 217C703 296 638 344 567 358C655 379 756 446 756 543M554 644C623 644 658 612 658 547C658 496 638 454 596 420C554 386 507 370 456 370L317 370L377 610C385 644 385 644 427 644M582 299C596 276 603 253 603 228C603 176 583 131 542 94C501 57 455 39 402 39L267 39C257 39 250 39 246 40C240 40 237 42 237 45C237 46 237 49 238 53C269 180 293 276 309 340L493 340C536 340 565 326 582 299Z"/></g><g data-mml-node="mo" data-latex="|" transform="translate(3565.4,0)"><path data-c="7C" d="M139-250C152-250 159-242 159-226L159 726C159 742 152 750 139 750C126 750 119 742 119 726L119-226C119-242 126-250 139-250Z"/></g></g><rect width="4043.4" height="60" x="120" y="220"/></g></g></g></g></svg><svg data-labels="true" preserveaspectratio="xMaxYMid" viewbox="1278 -1426 1 2352"><g data-labels="true" transform="matrix(1 0 0 -1 0 0)"><g data-mml-node="mtd" id="mjx-eqn:9" transform="translate(0,782)"><text data-id-align="true"/><g data-idbox="true" transform="translate(0,-748)"><g data-mml-node="mtext" data-latex="\text{(}"><path data-c="28" d="M318-248C327-248 332-243 332-234C332-231 330-227 327-223C275-183 233-117 202-26C175 53 161 131 161 208L161 292C161 369 175 447 202 526C233 617 275 683 327 723C330 726 332 730 332 734C332 743 327 748 318 748C317 748 314 747 311 745C251 699 201 631 160 540C121 453 101 371 101 292L101 208C101 129 121 47 160-40C201-131 251-199 311-245C314-247 317-248 318-248Z"/></g><g data-mml-node="mtext" data-latex="\text{9}" transform="translate(389,0)"><path data-c="39" d="M116 140C83 140 67 123 67 89C67 14 128-22 207-22C287-22 351 18 398 99C437 166 457 243 457 329C457 456 434 546 388 599C349 644 304 666 253 666C194 666 145 645 106 602C63 557 42 503 42 440C42 379 60 327 96 284C134 238 183 215 242 215C294 215 334 243 361 299L361 286C361 177 342 103 303 63C272 30 239 14 206 14C166 14 137 23 118 42C149 42 165 60 165 91C165 119 144 140 116 140M243 246C204 246 175 266 155 306C144 329 138 374 138 439C138 504 145 548 158 573C180 613 212 633 253 633C294 633 324 608 343 558C354 531 361 485 361 420C361 333 322 246 243 246Z"/></g><g data-mml-node="mtext" data-latex="\text{)}" transform="translate(889,0)"><path data-c="29" d="M78-245C138-199 188-131 229-40C268 47 288 129 288 208L288 292C288 371 268 453 229 540C188 631 138 699 78 745C75 747 72 748 71 748C62 748 57 743 57 734C57 730 59 726 62 723C114 683 156 617 187 526C214 447 228 369 228 292L228 208C228 131 214 53 187-26C156-117 114-183 62-223C59-227 57-231 57-234C57-243 62-248 71-248C72-248 75-247 78-245Z"/></g></g></g></g></svg></g></g></g></g></svg></mjx-container></p><p>假定<mjx-container class="MathJax" jax="SVG" overflow="overflow"><svg style="vertical-align: 0;" xmlns="http://www.w3.org/2000/svg" width="1.697ex" height="1.62ex" role="img" focusable="false" viewbox="0 -716 750 716"><g stroke="currentColor" fill="currentColor" stroke-width="0" transform="scale(1,-1)"><g data-mml-node="math" data-latex="A"><g data-mml-node="mi" data-latex="A"><path data-c="1D434" d="M137 3C155 3 217 0 236 0C251 0 258 8 258 23C258 32 252 38 239 39C210 40 196 50 196 69C196 78 205 98 224 128C251 173 270 206 283 228L526 228C526 221 527 207 530 185C537 112 541 72 541 67C541 48 519 39 474 39C455 39 446 31 446 15C446 5 452 0 464 0C488 0 564 3 588 3C608 3 679 0 699 0C714 0 721 8 721 24C721 34 712 39 694 39C666 39 649 41 644 44C639 47 635 56 634 71L574 689C571 708 572 716 551 716C539 716 529 710 522 697L178 120C148 70 108 43 59 39C43 38 35 30 35 15C35 5 41 0 52 0C68 0 121 3 137 3M492 577L522 267L307 267Z"/></g></g></g></svg></mjx-container>是 <mjx-container class="MathJax" jax="SVG" overflow="overflow"><svg style="vertical-align: -0.566ex;" xmlns="http://www.w3.org/2000/svg" width="14.873ex" height="2.262ex" role="img" focusable="false" viewbox="0 -750 6574 1000"><g stroke="currentColor" fill="currentColor" stroke-width="0" transform="scale(1,-1)"><g data-mml-node="math" data-latex="[A1, A2, ..., An] "><g data-mml-node="mo" data-latex="["><path data-c="5B" d="M233-202L159-202L159 702L233 702C248 702 256 710 256 726C256 742 248 750 233 750L114 750L114-250L233-250C248-250 256-242 256-226C256-214 245-202 233-202Z"/></g><g data-mml-node="mi" data-latex="A" transform="translate(278,0)"><path data-c="1D434" d="M137 3C155 3 217 0 236 0C251 0 258 8 258 23C258 32 252 38 239 39C210 40 196 50 196 69C196 78 205 98 224 128C251 173 270 206 283 228L526 228C526 221 527 207 530 185C537 112 541 72 541 67C541 48 519 39 474 39C455 39 446 31 446 15C446 5 452 0 464 0C488 0 564 3 588 3C608 3 679 0 699 0C714 0 721 8 721 24C721 34 712 39 694 39C666 39 649 41 644 44C639 47 635 56 634 71L574 689C571 708 572 716 551 716C539 716 529 710 522 697L178 120C148 70 108 43 59 39C43 38 35 30 35 15C35 5 41 0 52 0C68 0 121 3 137 3M492 577L522 267L307 267Z"/></g><g data-mml-node="mn" data-latex="1" transform="translate(1028,0)"><path data-c="31" d="M269 666C228 624 168 603 89 603L89 564C141 564 184 572 217 588L217 82C217 64 213 52 204 47C195 42 170 39 130 39L95 39L95 0C120 2 174 3 257 3C340 3 394 2 419 0L419 39L384 39C343 39 318 42 310 47C302 52 297 64 297 82L297 636C297 660 295 666 269 666Z"/></g><g data-mml-node="mo" data-latex="," transform="translate(1528,0)"><path data-c="2C" d="M139 106C107 106 86 82 86 50C86 20 109-5 139-5C153-5 165-1 174 8L175 0C175-63 154-117 112-160C105-168 101-174 101-178C101-188 105-193 114-193C123-193 135-181 152-158C186-110 203-57 203 0C203 53 185 106 139 106Z"/></g><g data-mml-node="mi" data-latex="A" transform="translate(1972.7,0)"><path data-c="1D434" d="M137 3C155 3 217 0 236 0C251 0 258 8 258 23C258 32 252 38 239 39C210 40 196 50 196 69C196 78 205 98 224 128C251 173 270 206 283 228L526 228C526 221 527 207 530 185C537 112 541 72 541 67C541 48 519 39 474 39C455 39 446 31 446 15C446 5 452 0 464 0C488 0 564 3 588 3C608 3 679 0 699 0C714 0 721 8 721 24C721 34 712 39 694 39C666 39 649 41 644 44C639 47 635 56 634 71L574 689C571 708 572 716 551 716C539 716 529 710 522 697L178 120C148 70 108 43 59 39C43 38 35 30 35 15C35 5 41 0 52 0C68 0 121 3 137 3M492 577L522 267L307 267Z"/></g><g data-mml-node="mn" data-latex="2" transform="translate(2722.7,0)"><path data-c="32" d="M237 666C186 666 143 648 106 612C69 576 50 534 50 483C50 449 75 424 106 424C136 424 161 450 161 480C161 513 137 536 105 536C102 536 100 536 98 535C117 584 161 627 224 627C306 627 352 556 352 470C352 403 318 331 250 255L62 43C49 28 50 29 50 0L421 0L450 180L417 180C409 129 402 100 396 91C391 86 361 84 306 84L139 84L236 179C304 243 390 312 419 365C439 400 449 435 449 470C449 588 357 666 237 666Z"/></g><g data-mml-node="mo" data-latex="," transform="translate(3222.7,0)"><path data-c="2C" d="M139 106C107 106 86 82 86 50C86 20 109-5 139-5C153-5 165-1 174 8L175 0C175-63 154-117 112-160C105-168 101-174 101-178C101-188 105-193 114-193C123-193 135-181 152-158C186-110 203-57 203 0C203 53 185 106 139 106Z"/></g><g data-mml-node="mo" data-latex="." transform="translate(3667.3,0)"><path data-c="2E" d="M192 53C192 82 168 106 139 106C110 106 86 82 86 53C86 24 110 0 139 0C168 0 192 24 192 53Z"/></g><g data-mml-node="mo" data-latex="." transform="translate(3945.3,0)"><path data-c="2E" d="M192 53C192 82 168 106 139 106C110 106 86 82 86 53C86 24 110 0 139 0C168 0 192 24 192 53Z"/></g><g data-mml-node="mo" data-latex="." transform="translate(4223.3,0)"><path data-c="2E" d="M192 53C192 82 168 106 139 106C110 106 86 82 86 53C86 24 110 0 139 0C168 0 192 24 192 53Z"/></g><g data-mml-node="mo" data-latex="," transform="translate(4501.3,0)"><path data-c="2C" d="M139 106C107 106 86 82 86 50C86 20 109-5 139-5C153-5 165-1 174 8L175 0C175-63 154-117 112-160C105-168 101-174 101-178C101-188 105-193 114-193C123-193 135-181 152-158C186-110 203-57 203 0C203 53 185 106 139 106Z"/></g><g data-mml-node="mi" data-latex="A" transform="translate(4946,0)"><path data-c="1D434" d="M137 3C155 3 217 0 236 0C251 0 258 8 258 23C258 32 252 38 239 39C210 40 196 50 196 69C196 78 205 98 224 128C251 173 270 206 283 228L526 228C526 221 527 207 530 185C537 112 541 72 541 67C541 48 519 39 474 39C455 39 446 31 446 15C446 5 452 0 464 0C488 0 564 3 588 3C608 3 679 0 699 0C714 0 721 8 721 24C721 34 712 39 694 39C666 39 649 41 644 44C639 47 635 56 634 71L574 689C571 708 572 716 551 716C539 716 529 710 522 697L178 120C148 70 108 43 59 39C43 38 35 30 35 15C35 5 41 0 52 0C68 0 121 3 137 3M492 577L522 267L307 267Z"/></g><g data-mml-node="mi" data-latex="n" transform="translate(5696,0)"><path data-c="1D45B" d="M537 137C514 58 481 18 440 18C427 18 420 28 420 47C420 61 426 84 438 115C478 224 498 296 498 333C498 403 451 442 381 442C322 442 271 416 230 363C222 407 187 442 136 442C80 442 58 390 44 345C34 313 29 294 29 287C29 278 34 273 45 273C50 273 53 274 56 276C61 285 64 292 65 299C83 375 106 413 133 413C151 413 160 399 160 371C160 358 155 331 144 290L87 63C84 50 78 24 78 19C78-1 89-11 111-11C130-11 144-1 151 19C153 24 159 49 170 92L191 181L221 295C232 318 249 341 270 365C299 397 335 413 378 413C411 413 427 391 427 348C427 310 406 234 363 120C356 102 353 87 353 74C353 25 390-11 438-11C482-11 517 14 542 64C561 104 571 131 571 144C571 153 566 158 555 158C552 158 537 149 537 137Z"/></g><g data-mml-node="mo" data-latex="]" transform="translate(6296,0)"><path data-c="5D" d="M45-250L164-250L164 750L45 750C30 750 22 742 22 726C22 710 30 702 45 702L119 702L119-202L45-202C30-202 22-210 22-226C22-242 30-250 45-250Z"/></g></g></g></svg></mjx-container> ,<mjx-container class="MathJax" jax="SVG" overflow="overflow"><svg style="vertical-align: 0;" xmlns="http://www.w3.org/2000/svg" width="1.717ex" height="1.545ex" role="img" focusable="false" viewbox="0 -683 759 683"><g stroke="currentColor" fill="currentColor" stroke-width="0" transform="scale(1,-1)"><g data-mml-node="math" data-latex="B"><g data-mml-node="mi" data-latex="B"><path data-c="1D435" d="M756 543C756 634 666 683 568 683L236 683C213 683 203 682 203 659C203 643 223 644 235 644C265 643 283 641 288 640C293 639 295 636 295 631C295 629 294 623 291 613L159 82C154 60 144 47 129 42C122 40 104 39 73 39C52 39 42 31 42 15C42 5 52 0 73 0L426 0C491 0 551 20 608 59C671 102 703 155 703 217C703 296 638 344 567 358C655 379 756 446 756 543M554 644C623 644 658 612 658 547C658 496 638 454 596 420C554 386 507 370 456 370L317 370L377 610C385 644 385 644 427 644M582 299C596 276 603 253 603 228C603 176 583 131 542 94C501 57 455 39 402 39L267 39C257 39 250 39 246 40C240 40 237 42 237 45C237 46 237 49 238 53C269 180 293 276 309 340L493 340C536 340 565 326 582 299Z"/></g></g></g></svg></mjx-container>是 <mjx-container class="MathJax" jax="SVG" overflow="overflow"><svg style="vertical-align: -0.566ex;" xmlns="http://www.w3.org/2000/svg" width="14.934ex" height="2.262ex" role="img" focusable="false" viewbox="0 -750 6601 1000"><g stroke="currentColor" fill="currentColor" stroke-width="0" transform="scale(1,-1)"><g data-mml-node="math" data-latex="[B1, B2, ..., Bn] "><g data-mml-node="mo" data-latex="["><path data-c="5B" d="M233-202L159-202L159 702L233 702C248 702 256 710 256 726C256 742 248 750 233 750L114 750L114-250L233-250C248-250 256-242 256-226C256-214 245-202 233-202Z"/></g><g data-mml-node="mi" data-latex="B" transform="translate(278,0)"><path data-c="1D435" d="M756 543C756 634 666 683 568 683L236 683C213 683 203 682 203 659C203 643 223 644 235 644C265 643 283 641 288 640C293 639 295 636 295 631C295 629 294 623 291 613L159 82C154 60 144 47 129 42C122 40 104 39 73 39C52 39 42 31 42 15C42 5 52 0 73 0L426 0C491 0 551 20 608 59C671 102 703 155 703 217C703 296 638 344 567 358C655 379 756 446 756 543M554 644C623 644 658 612 658 547C658 496 638 454 596 420C554 386 507 370 456 370L317 370L377 610C385 644 385 644 427 644M582 299C596 276 603 253 603 228C603 176 583 131 542 94C501 57 455 39 402 39L267 39C257 39 250 39 246 40C240 40 237 42 237 45C237 46 237 49 238 53C269 180 293 276 309 340L493 340C536 340 565 326 582 299Z"/></g><g data-mml-node="mn" data-latex="1" transform="translate(1037,0)"><path data-c="31" d="M269 666C228 624 168 603 89 603L89 564C141 564 184 572 217 588L217 82C217 64 213 52 204 47C195 42 170 39 130 39L95 39L95 0C120 2 174 3 257 3C340 3 394 2 419 0L419 39L384 39C343 39 318 42 310 47C302 52 297 64 297 82L297 636C297 660 295 666 269 666Z"/></g><g data-mml-node="mo" data-latex="," transform="translate(1537,0)"><path data-c="2C" d="M139 106C107 106 86 82 86 50C86 20 109-5 139-5C153-5 165-1 174 8L175 0C175-63 154-117 112-160C105-168 101-174 101-178C101-188 105-193 114-193C123-193 135-181 152-158C186-110 203-57 203 0C203 53 185 106 139 106Z"/></g><g data-mml-node="mi" data-latex="B" transform="translate(1981.7,0)"><path data-c="1D435" d="M756 543C756 634 666 683 568 683L236 683C213 683 203 682 203 659C203 643 223 644 235 644C265 643 283 641 288 640C293 639 295 636 295 631C295 629 294 623 291 613L159 82C154 60 144 47 129 42C122 40 104 39 73 39C52 39 42 31 42 15C42 5 52 0 73 0L426 0C491 0 551 20 608 59C671 102 703 155 703 217C703 296 638 344 567 358C655 379 756 446 756 543M554 644C623 644 658 612 658 547C658 496 638 454 596 420C554 386 507 370 456 370L317 370L377 610C385 644 385 644 427 644M582 299C596 276 603 253 603 228C603 176 583 131 542 94C501 57 455 39 402 39L267 39C257 39 250 39 246 40C240 40 237 42 237 45C237 46 237 49 238 53C269 180 293 276 309 340L493 340C536 340 565 326 582 299Z"/></g><g data-mml-node="mn" data-latex="2" transform="translate(2740.7,0)"><path data-c="32" d="M237 666C186 666 143 648 106 612C69 576 50 534 50 483C50 449 75 424 106 424C136 424 161 450 161 480C161 513 137 536 105 536C102 536 100 536 98 535C117 584 161 627 224 627C306 627 352 556 352 470C352 403 318 331 250 255L62 43C49 28 50 29 50 0L421 0L450 180L417 180C409 129 402 100 396 91C391 86 361 84 306 84L139 84L236 179C304 243 390 312 419 365C439 400 449 435 449 470C449 588 357 666 237 666Z"/></g><g data-mml-node="mo" data-latex="," transform="translate(3240.7,0)"><path data-c="2C" d="M139 106C107 106 86 82 86 50C86 20 109-5 139-5C153-5 165-1 174 8L175 0C175-63 154-117 112-160C105-168 101-174 101-178C101-188 105-193 114-193C123-193 135-181 152-158C186-110 203-57 203 0C203 53 185 106 139 106Z"/></g><g data-mml-node="mo" data-latex="." transform="translate(3685.3,0)"><path data-c="2E" d="M192 53C192 82 168 106 139 106C110 106 86 82 86 53C86 24 110 0 139 0C168 0 192 24 192 53Z"/></g><g data-mml-node="mo" data-latex="." transform="translate(3963.3,0)"><path data-c="2E" d="M192 53C192 82 168 106 139 106C110 106 86 82 86 53C86 24 110 0 139 0C168 0 192 24 192 53Z"/></g><g data-mml-node="mo" data-latex="." transform="translate(4241.3,0)"><path data-c="2E" d="M192 53C192 82 168 106 139 106C110 106 86 82 86 53C86 24 110 0 139 0C168 0 192 24 192 53Z"/></g><g data-mml-node="mo" data-latex="," transform="translate(4519.3,0)"><path data-c="2C" d="M139 106C107 106 86 82 86 50C86 20 109-5 139-5C153-5 165-1 174 8L175 0C175-63 154-117 112-160C105-168 101-174 101-178C101-188 105-193 114-193C123-193 135-181 152-158C186-110 203-57 203 0C203 53 185 106 139 106Z"/></g><g data-mml-node="mi" data-latex="B" transform="translate(4964,0)"><path data-c="1D435" d="M756 543C756 634 666 683 568 683L236 683C213 683 203 682 203 659C203 643 223 644 235 644C265 643 283 641 288 640C293 639 295 636 295 631C295 629 294 623 291 613L159 82C154 60 144 47 129 42C122 40 104 39 73 39C52 39 42 31 42 15C42 5 52 0 73 0L426 0C491 0 551 20 608 59C671 102 703 155 703 217C703 296 638 344 567 358C655 379 756 446 756 543M554 644C623 644 658 612 658 547C658 496 638 454 596 420C554 386 507 370 456 370L317 370L377 610C385 644 385 644 427 644M582 299C596 276 603 253 603 228C603 176 583 131 542 94C501 57 455 39 402 39L267 39C257 39 250 39 246 40C240 40 237 42 237 45C237 46 237 49 238 53C269 180 293 276 309 340L493 340C536 340 565 326 582 299Z"/></g><g data-mml-node="mi" data-latex="n" transform="translate(5723,0)"><path data-c="1D45B" d="M537 137C514 58 481 18 440 18C427 18 420 28 420 47C420 61 426 84 438 115C478 224 498 296 498 333C498 403 451 442 381 442C322 442 271 416 230 363C222 407 187 442 136 442C80 442 58 390 44 345C34 313 29 294 29 287C29 278 34 273 45 273C50 273 53 274 56 276C61 285 64 292 65 299C83 375 106 413 133 413C151 413 160 399 160 371C160 358 155 331 144 290L87 63C84 50 78 24 78 19C78-1 89-11 111-11C130-11 144-1 151 19C153 24 159 49 170 92L191 181L221 295C232 318 249 341 270 365C299 397 335 413 378 413C411 413 427 391 427 348C427 310 406 234 363 120C356 102 353 87 353 74C353 25 390-11 438-11C482-11 517 14 542 64C561 104 571 131 571 144C571 153 566 158 555 158C552 158 537 149 537 137Z"/></g><g data-mml-node="mo" data-latex="]" transform="translate(6323,0)"><path data-c="5D" d="M45-250L164-250L164 750L45 750C30 750 22 742 22 726C22 710 30 702 45 702L119 702L119-202L45-202C30-202 22-210 22-226C22-242 30-250 45-250Z"/></g></g></g></svg></mjx-container> ,则<mjx-container class="MathJax" jax="SVG" overflow="overflow"><svg style="vertical-align: 0;" xmlns="http://www.w3.org/2000/svg" width="1.697ex" height="1.62ex" role="img" focusable="false" viewbox="0 -716 750 716"><g stroke="currentColor" fill="currentColor" stroke-width="0" transform="scale(1,-1)"><g data-mml-node="math" data-latex="A"><g data-mml-node="mi" data-latex="A"><path data-c="1D434" d="M137 3C155 3 217 0 236 0C251 0 258 8 258 23C258 32 252 38 239 39C210 40 196 50 196 69C196 78 205 98 224 128C251 173 270 206 283 228L526 228C526 221 527 207 530 185C537 112 541 72 541 67C541 48 519 39 474 39C455 39 446 31 446 15C446 5 452 0 464 0C488 0 564 3 588 3C608 3 679 0 699 0C714 0 721 8 721 24C721 34 712 39 694 39C666 39 649 41 644 44C639 47 635 56 634 71L574 689C571 708 572 716 551 716C539 716 529 710 522 697L178 120C148 70 108 43 59 39C43 38 35 30 35 15C35 5 41 0 52 0C68 0 121 3 137 3M492 577L522 267L307 267Z"/></g></g></g></svg></mjx-container>与<mjx-container class="MathJax" jax="SVG" overflow="overflow"><svg style="vertical-align: 0;" xmlns="http://www.w3.org/2000/svg" width="1.717ex" height="1.545ex" role="img" focusable="false" viewbox="0 -683 759 683"><g stroke="currentColor" fill="currentColor" stroke-width="0" transform="scale(1,-1)"><g data-mml-node="math" data-latex="B"><g data-mml-node="mi" data-latex="B"><path data-c="1D435" d="M756 543C756 634 666 683 568 683L236 683C213 683 203 682 203 659C203 643 223 644 235 644C265 643 283 641 288 640C293 639 295 636 295 631C295 629 294 623 291 613L159 82C154 60 144 47 129 42C122 40 104 39 73 39C52 39 42 31 42 15C42 5 52 0 73 0L426 0C491 0 551 20 608 59C671 102 703 155 703 217C703 296 638 344 567 358C655 379 756 446 756 543M554 644C623 644 658 612 658 547C658 496 638 454 596 420C554 386 507 370 456 370L317 370L377 610C385 644 385 644 427 644M582 299C596 276 603 253 603 228C603 176 583 131 542 94C501 57 455 39 402 39L267 39C257 39 250 39 246 40C240 40 237 42 237 45C237 46 237 49 238 53C269 180 293 276 309 340L493 340C536 340 565 326 582 299Z"/></g></g></g></svg></mjx-container>的夹角<mjx-container class="MathJax" jax="SVG" overflow="overflow"><svg style="vertical-align: -0.025ex;" xmlns="http://www.w3.org/2000/svg" width="1.061ex" height="1.62ex" role="img" focusable="false" viewbox="0 -705 469 716"><g stroke="currentColor" fill="currentColor" stroke-width="0" transform="scale(1,-1)"><g data-mml-node="math" data-latex="θ"><g data-mml-node="mi" data-latex="θ"><path data-c="1D703" d="M164-11C209-11 256 16 302 70C382 163 455 335 455 498C455 539 448 582 434 625C416 678 382 705 333 705C288 705 243 678 196 624C116 532 42 360 42 196C42 94 75-11 164-11M332 675C365 675 382 637 382 560C382 517 372 452 352 367L155 367C180 460 204 529 229 574C266 641 301 675 332 675M145 327L341 327C322 246 299 181 274 132C235 57 199 19 164 19C131 19 115 58 115 135C115 185 125 249 145 327Z"/></g></g></g></svg></mjx-container>的余弦等于:</p><p><mjx-container class="MathJax" jax="SVG" overflow="overflow" display="true" width="full" style="min-width: 44.014ex;"><svg style="vertical-align: -3.24ex; min-width: 44.014ex;" xmlns="http://www.w3.org/2000/svg" width="100%" height="7.61ex" role="img" focusable="false" data-mjx-viewbox="0 -1931.9 19454.4 3363.7"><g stroke="currentColor" fill="currentColor" stroke-width="0" transform="scale(0.0181,-0.0181) translate(0, -1931.9)"><g data-mml-node="math" data-latex="
\cos\theta=\frac{\sum_{i=1}^{n}(A_i \times B_i)}{\sqrt{\sum_{i=1}^{n}A_i^2} \times \sqrt{\sum_{i=1}^{n}B_i^2} }
"><g data-mml-node="mtable" data-latex="\cos\theta=\frac{\sum_{i=1}^{n}(A_i \times B_i)}{\sqrt{\sum_{i=1}^{n}A_i^2} \times \sqrt{\sum_{i=1}^{n}B_i^2} }" transform="translate(2578,0) translate(-2578,0)"><g transform="translate(0 1931.9) matrix(1 0 0 -1 0 0) scale(55.25)"><svg data-table="true" preserveaspectratio="xMidYMid" viewbox="7149.2 -1931.9 1 3363.7"><g transform="matrix(1 0 0 -1 0 0)"><g data-mml-node="mlabeledtr" transform="translate(0,389.1)"><g data-mml-node="mtd"><g data-mml-node="mi" data-latex="\cos"><path data-c="63" d="M251 416C293 416 325 406 347 386C323 383 306 361 306 338C306 305 322 289 355 289C388 289 404 306 404 339C404 410 327 448 250 448C188 448 137 426 96 380C55 334 34 279 34 216C34 155 55 101 96 56C137 11 187-11 248-11C298-11 337 3 365 32C388 55 403 78 411 102C414 111 415 117 415 121C415 130 409 134 398 134C390 134 385 130 382 122C361 55 320 21 257 21C228 21 200 34 172 61C139 92 123 144 123 218C123 318 161 416 251 416Z"/><path data-c="6F" d="M249-11C311-11 363 11 406 55C449 99 471 152 471 214C471 277 450 332 408 378C366 424 313 448 250 448C187 448 135 424 92 378C49 332 28 277 28 214C28 152 49 99 92 55C135 11 188-11 249-11M250 21C202 21 166 42 141 85C125 113 117 159 117 222C117 283 125 327 140 355C164 398 200 419 249 419C296 419 332 398 357 357C374 329 382 284 382 222C382 106 348 21 250 21Z" transform="translate(444,0)"/><path data-c="73" d="M360 130C360 206 308 254 205 274C158 283 128 294 112 305C96 316 88 332 88 351C88 398 123 421 193 421C261 421 298 383 303 306C304 298 309 294 319 294C330 294 336 303 336 321L336 420C336 439 331 448 321 448C310 448 295 430 285 422C260 439 229 448 193 448C104 448 33 408 33 323C33 289 47 260 76 237C111 208 144 202 207 191C272 178 305 149 305 104C305 47 270 18 199 18C130 18 86 64 67 155C64 168 59 175 50 175C39 175 33 165 33 146L33 17C33-2 38-11 48-11C51-11 56-8 64-1C82 15 74 12 92 30C121 3 157-11 199-11C294-11 360 38 360 130Z" transform="translate(944,0)"/></g><g data-mml-node="mo" transform="translate(1338,0)"><path data-c="2061" d=""/></g><g data-mml-node="mi" data-latex="\theta" transform="translate(1504.7,0)"><path data-c="1D703" d="M164-11C209-11 256 16 302 70C382 163 455 335 455 498C455 539 448 582 434 625C416 678 382 705 333 705C288 705 243 678 196 624C116 532 42 360 42 196C42 94 75-11 164-11M332 675C365 675 382 637 382 560C382 517 372 452 352 367L155 367C180 460 204 529 229 574C266 641 301 675 332 675M145 327L341 327C322 246 299 181 274 132C235 57 199 19 164 19C131 19 115 58 115 135C115 185 125 249 145 327Z"/></g><g data-mml-node="mo" data-latex="=" transform="translate(2251.4,0)"><path data-c="3D" d="M698 367L80 367C64 367 56 359 56 344C56 329 64 321 80 321L698 321C714 321 722 329 722 344C722 356 711 367 698 367M698 179L80 179C64 179 56 171 56 156C56 141 64 133 80 133L698 133C714 133 722 141 722 156C722 169 711 179 698 179Z"/></g><g data-mml-node="mfrac" data-latex="\frac{\sum_{i=1}^{n}(A_i \times B_i)}{\sqrt{\sum_{i=1}^{n}A_i^2} \times \sqrt{\sum_{i=1}^{n}B_i^2} }" transform="translate(3307.2,0)"><g data-mml-node="mrow" data-latex="\sum_{i=1}^{n}(A_i \times B_i)" transform="translate(2270.6,753.1)"><g data-mml-node="munderover" data-latex="\sum_{i=1}^{n}"><g data-mml-node="mo" data-latex="\sum"><path data-c="2211" d="M56 713L417 216L67-217C60-225 57-231 57-235C57-245 67-250 88-250L913-250L1001 5L967 5C954-33 933-66 902-95C825-166 719-188 565-188L152-188L490 232C497 240 500 246 500 250C500 254 498 259 493 266L175 702L560 702C682 702 764 691 854 644C907 616 944 571 967 510L1001 510L913 750L88 750C57 750 56 746 56 713Z"/></g><g data-mml-node="TeXAtom" transform="translate(1089,477.1) scale(0.707)" data-latex="{n}" data-mjx-texclass="ORD"><g data-mml-node="mi" data-latex="n"><path data-c="1D45B" d="M537 137C514 58 481 18 440 18C427 18 420 28 420 47C420 61 426 84 438 115C478 224 498 296 498 333C498 403 451 442 381 442C322 442 271 416 230 363C222 407 187 442 136 442C80 442 58 390 44 345C34 313 29 294 29 287C29 278 34 273 45 273C50 273 53 274 56 276C61 285 64 292 65 299C83 375 106 413 133 413C151 413 160 399 160 371C160 358 155 331 144 290L87 63C84 50 78 24 78 19C78-1 89-11 111-11C130-11 144-1 151 19C153 24 159 49 170 92L191 181L221 295C232 318 249 341 270 365C299 397 335 413 378 413C411 413 427 391 427 348C427 310 406 234 363 120C356 102 353 87 353 74C353 25 390-11 438-11C482-11 517 14 542 64C561 104 571 131 571 144C571 153 566 158 555 158C552 158 537 149 537 137Z"/></g></g><g data-mml-node="TeXAtom" transform="translate(1089,-285.4) scale(0.707)" data-latex="{i=1}" data-mjx-texclass="ORD"><g data-mml-node="mi" data-latex="i"><path data-c="1D456" d="M284 621C284 648 271 661 244 661C216 661 188 633 188 605C188 578 202 565 229 565C257 565 284 593 284 621M259 138C237 59 205 19 164 19C151 19 144 28 144 47C144 64 173 150 232 306C240 329 244 347 244 360C244 409 210 445 161 445C118 445 84 420 59 369C39 328 29 301 29 288C29 279 34 275 45 275C58 275 60 281 64 295C87 375 118 415 158 415C171 415 178 406 178 387C178 373 175 357 168 338C145 275 121 208 101 155C86 115 78 88 78 74C78 25 114-11 162-11C205-11 239 14 264 64C283 103 293 130 293 145C293 154 288 159 277 159C274 159 259 150 259 138Z"/></g><g data-mml-node="mo" data-latex="=" transform="translate(345,0)"><path data-c="3D" d="M698 367L80 367C64 367 56 359 56 344C56 329 64 321 80 321L698 321C714 321 722 329 722 344C722 356 711 367 698 367M698 179L80 179C64 179 56 171 56 156C56 141 64 133 80 133L698 133C714 133 722 141 722 156C722 169 711 179 698 179Z"/></g><g data-mml-node="mn" data-latex="1" transform="translate(1123,0)"><path data-c="31" d="M269 666C228 624 168 603 89 603L89 564C141 564 184 572 217 588L217 82C217 64 213 52 204 47C195 42 170 39 130 39L95 39L95 0C120 2 174 3 257 3C340 3 394 2 419 0L419 39L384 39C343 39 318 42 310 47C302 52 297 64 297 82L297 636C297 660 295 666 269 666Z"/></g></g></g><g data-mml-node="mo" data-latex="(" transform="translate(2286.6,0)"><path data-c="28" d="M318-248C327-248 332-243 332-234C332-231 330-227 327-223C275-183 233-117 202-26C175 53 161 131 161 208L161 292C161 369 175 447 202 526C233 617 275 683 327 723C330 726 332 730 332 734C332 743 327 748 318 748C317 748 314 747 311 745C251 699 201 631 160 540C121 453 101 371 101 292L101 208C101 129 121 47 160-40C201-131 251-199 311-245C314-247 317-248 318-248Z"/></g><g data-mml-node="msub" data-latex="A_i" transform="translate(2675.6,0)"><g data-mml-node="mi" data-latex="A"><path data-c="1D434" d="M137 3C155 3 217 0 236 0C251 0 258 8 258 23C258 32 252 38 239 39C210 40 196 50 196 69C196 78 205 98 224 128C251 173 270 206 283 228L526 228C526 221 527 207 530 185C537 112 541 72 541 67C541 48 519 39 474 39C455 39 446 31 446 15C446 5 452 0 464 0C488 0 564 3 588 3C608 3 679 0 699 0C714 0 721 8 721 24C721 34 712 39 694 39C666 39 649 41 644 44C639 47 635 56 634 71L574 689C571 708 572 716 551 716C539 716 529 710 522 697L178 120C148 70 108 43 59 39C43 38 35 30 35 15C35 5 41 0 52 0C68 0 121 3 137 3M492 577L522 267L307 267Z"/></g><g data-mml-node="mi" transform="translate(783,-150) scale(0.707)" data-latex="i"><path data-c="1D456" d="M284 621C284 648 271 661 244 661C216 661 188 633 188 605C188 578 202 565 229 565C257 565 284 593 284 621M259 138C237 59 205 19 164 19C151 19 144 28 144 47C144 64 173 150 232 306C240 329 244 347 244 360C244 409 210 445 161 445C118 445 84 420 59 369C39 328 29 301 29 288C29 279 34 275 45 275C58 275 60 281 64 295C87 375 118 415 158 415C171 415 178 406 178 387C178 373 175 357 168 338C145 275 121 208 101 155C86 115 78 88 78 74C78 25 114-11 162-11C205-11 239 14 264 64C283 103 293 130 293 145C293 154 288 159 277 159C274 159 259 150 259 138Z"/></g></g><g data-mml-node="mo" data-latex="\times" transform="translate(3974.8,0)"><path data-c="D7" d="M630 32C630 39 628 44 623 49L422 250L623 451C628 456 630 461 630 468C630 481 620 491 607 491C600 491 595 489 590 484L389 283L188 484C183 489 178 491 171 491C158 491 148 481 148 468C148 461 150 456 155 451L356 250L155 49C150 44 148 39 148 32C148 19 158 9 171 9C178 9 183 11 188 16L389 217L590 16C595 11 600 9 607 9C620 9 630 19 630 32Z"/></g><g data-mml-node="msub" data-latex="B_i" transform="translate(4975,0)"><g data-mml-node="mi" data-latex="B"><path data-c="1D435" d="M756 543C756 634 666 683 568 683L236 683C213 683 203 682 203 659C203 643 223 644 235 644C265 643 283 641 288 640C293 639 295 636 295 631C295 629 294 623 291 613L159 82C154 60 144 47 129 42C122 40 104 39 73 39C52 39 42 31 42 15C42 5 52 0 73 0L426 0C491 0 551 20 608 59C671 102 703 155 703 217C703 296 638 344 567 358C655 379 756 446 756 543M554 644C623 644 658 612 658 547C658 496 638 454 596 420C554 386 507 370 456 370L317 370L377 610C385 644 385 644 427 644M582 299C596 276 603 253 603 228C603 176 583 131 542 94C501 57 455 39 402 39L267 39C257 39 250 39 246 40C240 40 237 42 237 45C237 46 237 49 238 53C269 180 293 276 309 340L493 340C536 340 565 326 582 299Z"/></g><g data-mml-node="mi" transform="translate(792,-150) scale(0.707)" data-latex="i"><path data-c="1D456" d="M284 621C284 648 271 661 244 661C216 661 188 633 188 605C188 578 202 565 229 565C257 565 284 593 284 621M259 138C237 59 205 19 164 19C151 19 144 28 144 47C144 64 173 150 232 306C240 329 244 347 244 360C244 409 210 445 161 445C118 445 84 420 59 369C39 328 29 301 29 288C29 279 34 275 45 275C58 275 60 281 64 295C87 375 118 415 158 415C171 415 178 406 178 387C178 373 175 357 168 338C145 275 121 208 101 155C86 115 78 88 78 74C78 25 114-11 162-11C205-11 239 14 264 64C283 103 293 130 293 145C293 154 288 159 277 159C274 159 259 150 259 138Z"/></g></g><g data-mml-node="mo" data-latex=")" transform="translate(6061,0)"><path data-c="29" d="M78-245C138-199 188-131 229-40C268 47 288 129 288 208L288 292C288 371 268 453 229 540C188 631 138 699 78 745C75 747 72 748 71 748C62 748 57 743 57 734C57 730 59 726 62 723C114 683 156 617 187 526C214 447 228 369 228 292L228 208C228 131 214 53 187-26C156-117 114-183 62-223C59-227 57-231 57-234C57-243 62-248 71-248C72-248 75-247 78-245Z"/></g></g><g data-mml-node="mrow" data-latex="\sqrt{\sum_{i=1}^{n}A_i^2} \times \sqrt{\sum_{i=1}^{n}B_i^2}" transform="translate(220,-1249.5)"><g data-mml-node="msqrt" data-latex="\sqrt{\sum_{i=1}^{n}A_i^2}"><g data-mml-node="mo" transform="translate(0,79.5)"><path data-c="221A" d="M1015 1105C1018 1116 1020 1123 1020 1126C1020 1142 1012 1150 996 1150C985 1150 976 1140 970 1121L465-483L254 258L108 87L130 67L195 144L422-650C460-650 463-651 471-623Z"/></g><g transform="translate(1020,0)"><g data-mml-node="munderover" data-latex="\sum_{i=1}^{n}"><g data-mml-node="mo" data-latex="\sum"><path data-c="2211" d="M56 713L417 216L67-217C60-225 57-231 57-235C57-245 67-250 88-250L913-250L1001 5L967 5C954-33 933-66 902-95C825-166 719-188 565-188L152-188L490 232C497 240 500 246 500 250C500 254 498 259 493 266L175 702L560 702C682 702 764 691 854 644C907 616 944 571 967 510L1001 510L913 750L88 750C57 750 56 746 56 713Z"/></g><g data-mml-node="TeXAtom" transform="translate(1089,477.1) scale(0.707)" data-latex="{n}" data-mjx-texclass="ORD"><g data-mml-node="mi" data-latex="n"><path data-c="1D45B" d="M537 137C514 58 481 18 440 18C427 18 420 28 420 47C420 61 426 84 438 115C478 224 498 296 498 333C498 403 451 442 381 442C322 442 271 416 230 363C222 407 187 442 136 442C80 442 58 390 44 345C34 313 29 294 29 287C29 278 34 273 45 273C50 273 53 274 56 276C61 285 64 292 65 299C83 375 106 413 133 413C151 413 160 399 160 371C160 358 155 331 144 290L87 63C84 50 78 24 78 19C78-1 89-11 111-11C130-11 144-1 151 19C153 24 159 49 170 92L191 181L221 295C232 318 249 341 270 365C299 397 335 413 378 413C411 413 427 391 427 348C427 310 406 234 363 120C356 102 353 87 353 74C353 25 390-11 438-11C482-11 517 14 542 64C561 104 571 131 571 144C571 153 566 158 555 158C552 158 537 149 537 137Z"/></g></g><g data-mml-node="TeXAtom" transform="translate(1089,-285.4) scale(0.707)" data-latex="{i=1}" data-mjx-texclass="ORD"><g data-mml-node="mi" data-latex="i"><path data-c="1D456" d="M284 621C284 648 271 661 244 661C216 661 188 633 188 605C188 578 202 565 229 565C257 565 284 593 284 621M259 138C237 59 205 19 164 19C151 19 144 28 144 47C144 64 173 150 232 306C240 329 244 347 244 360C244 409 210 445 161 445C118 445 84 420 59 369C39 328 29 301 29 288C29 279 34 275 45 275C58 275 60 281 64 295C87 375 118 415 158 415C171 415 178 406 178 387C178 373 175 357 168 338C145 275 121 208 101 155C86 115 78 88 78 74C78 25 114-11 162-11C205-11 239 14 264 64C283 103 293 130 293 145C293 154 288 159 277 159C274 159 259 150 259 138Z"/></g><g data-mml-node="mo" data-latex="=" transform="translate(345,0)"><path data-c="3D" d="M698 367L80 367C64 367 56 359 56 344C56 329 64 321 80 321L698 321C714 321 722 329 722 344C722 356 711 367 698 367M698 179L80 179C64 179 56 171 56 156C56 141 64 133 80 133L698 133C714 133 722 141 722 156C722 169 711 179 698 179Z"/></g><g data-mml-node="mn" data-latex="1" transform="translate(1123,0)"><path data-c="31" d="M269 666C228 624 168 603 89 603L89 564C141 564 184 572 217 588L217 82C217 64 213 52 204 47C195 42 170 39 130 39L95 39L95 0C120 2 174 3 257 3C340 3 394 2 419 0L419 39L384 39C343 39 318 42 310 47C302 52 297 64 297 82L297 636C297 660 295 666 269 666Z"/></g></g></g><g data-mml-node="msubsup" data-latex="A_i^2" transform="translate(2453.3,0)"><g data-mml-node="mi" data-latex="A"><path data-c="1D434" d="M137 3C155 3 217 0 236 0C251 0 258 8 258 23C258 32 252 38 239 39C210 40 196 50 196 69C196 78 205 98 224 128C251 173 270 206 283 228L526 228C526 221 527 207 530 185C537 112 541 72 541 67C541 48 519 39 474 39C455 39 446 31 446 15C446 5 452 0 464 0C488 0 564 3 588 3C608 3 679 0 699 0C714 0 721 8 721 24C721 34 712 39 694 39C666 39 649 41 644 44C639 47 635 56 634 71L574 689C571 708 572 716 551 716C539 716 529 710 522 697L178 120C148 70 108 43 59 39C43 38 35 30 35 15C35 5 41 0 52 0C68 0 121 3 137 3M492 577L522 267L307 267Z"/></g><g data-mml-node="mn" transform="translate(783,353.6) scale(0.707)" data-latex="2"><path data-c="32" d="M237 666C186 666 143 648 106 612C69 576 50 534 50 483C50 449 75 424 106 424C136 424 161 450 161 480C161 513 137 536 105 536C102 536 100 536 98 535C117 584 161 627 224 627C306 627 352 556 352 470C352 403 318 331 250 255L62 43C49 28 50 29 50 0L421 0L450 180L417 180C409 129 402 100 396 91C391 86 361 84 306 84L139 84L236 179C304 243 390 312 419 365C439 400 449 435 449 470C449 588 357 666 237 666Z"/></g><g data-mml-node="mi" transform="translate(783,-293.8) scale(0.707)" data-latex="i"><path data-c="1D456" d="M284 621C284 648 271 661 244 661C216 661 188 633 188 605C188 578 202 565 229 565C257 565 284 593 284 621M259 138C237 59 205 19 164 19C151 19 144 28 144 47C144 64 173 150 232 306C240 329 244 347 244 360C244 409 210 445 161 445C118 445 84 420 59 369C39 328 29 301 29 288C29 279 34 275 45 275C58 275 60 281 64 295C87 375 118 415 158 415C171 415 178 406 178 387C178 373 175 357 168 338C145 275 121 208 101 155C86 115 78 88 78 74C78 25 114-11 162-11C205-11 239 14 264 64C283 103 293 130 293 145C293 154 288 159 277 159C274 159 259 150 259 138Z"/></g></g></g><rect width="3639.9" height="60" x="1020" y="1169.5"/></g><g data-mml-node="mo" data-latex="\times" transform="translate(4882.1,0)"><path data-c="D7" d="M630 32C630 39 628 44 623 49L422 250L623 451C628 456 630 461 630 468C630 481 620 491 607 491C600 491 595 489 590 484L389 283L188 484C183 489 178 491 171 491C158 491 148 481 148 468C148 461 150 456 155 451L356 250L155 49C150 44 148 39 148 32C148 19 158 9 171 9C178 9 183 11 188 16L389 217L590 16C595 11 600 9 607 9C620 9 630 19 630 32Z"/></g><g data-mml-node="msqrt" data-latex="\sqrt{\sum_{i=1}^{n}B_i^2}" transform="translate(5882.3,0)"><g data-mml-node="mo" transform="translate(0,79.5)"><path data-c="221A" d="M1015 1105C1018 1116 1020 1123 1020 1126C1020 1142 1012 1150 996 1150C985 1150 976 1140 970 1121L465-483L254 258L108 87L130 67L195 144L422-650C460-650 463-651 471-623Z"/></g><g transform="translate(1020,0)"><g data-mml-node="munderover" data-latex="\sum_{i=1}^{n}"><g data-mml-node="mo" data-latex="\sum"><path data-c="2211" d="M56 713L417 216L67-217C60-225 57-231 57-235C57-245 67-250 88-250L913-250L1001 5L967 5C954-33 933-66 902-95C825-166 719-188 565-188L152-188L490 232C497 240 500 246 500 250C500 254 498 259 493 266L175 702L560 702C682 702 764 691 854 644C907 616 944 571 967 510L1001 510L913 750L88 750C57 750 56 746 56 713Z"/></g><g data-mml-node="TeXAtom" transform="translate(1089,477.1) scale(0.707)" data-latex="{n}" data-mjx-texclass="ORD"><g data-mml-node="mi" data-latex="n"><path data-c="1D45B" d="M537 137C514 58 481 18 440 18C427 18 420 28 420 47C420 61 426 84 438 115C478 224 498 296 498 333C498 403 451 442 381 442C322 442 271 416 230 363C222 407 187 442 136 442C80 442 58 390 44 345C34 313 29 294 29 287C29 278 34 273 45 273C50 273 53 274 56 276C61 285 64 292 65 299C83 375 106 413 133 413C151 413 160 399 160 371C160 358 155 331 144 290L87 63C84 50 78 24 78 19C78-1 89-11 111-11C130-11 144-1 151 19C153 24 159 49 170 92L191 181L221 295C232 318 249 341 270 365C299 397 335 413 378 413C411 413 427 391 427 348C427 310 406 234 363 120C356 102 353 87 353 74C353 25 390-11 438-11C482-11 517 14 542 64C561 104 571 131 571 144C571 153 566 158 555 158C552 158 537 149 537 137Z"/></g></g><g data-mml-node="TeXAtom" transform="translate(1089,-285.4) scale(0.707)" data-latex="{i=1}" data-mjx-texclass="ORD"><g data-mml-node="mi" data-latex="i"><path data-c="1D456" d="M284 621C284 648 271 661 244 661C216 661 188 633 188 605C188 578 202 565 229 565C257 565 284 593 284 621M259 138C237 59 205 19 164 19C151 19 144 28 144 47C144 64 173 150 232 306C240 329 244 347 244 360C244 409 210 445 161 445C118 445 84 420 59 369C39 328 29 301 29 288C29 279 34 275 45 275C58 275 60 281 64 295C87 375 118 415 158 415C171 415 178 406 178 387C178 373 175 357 168 338C145 275 121 208 101 155C86 115 78 88 78 74C78 25 114-11 162-11C205-11 239 14 264 64C283 103 293 130 293 145C293 154 288 159 277 159C274 159 259 150 259 138Z"/></g><g data-mml-node="mo" data-latex="=" transform="translate(345,0)"><path data-c="3D" d="M698 367L80 367C64 367 56 359 56 344C56 329 64 321 80 321L698 321C714 321 722 329 722 344C722 356 711 367 698 367M698 179L80 179C64 179 56 171 56 156C56 141 64 133 80 133L698 133C714 133 722 141 722 156C722 169 711 179 698 179Z"/></g><g data-mml-node="mn" data-latex="1" transform="translate(1123,0)"><path data-c="31" d="M269 666C228 624 168 603 89 603L89 564C141 564 184 572 217 588L217 82C217 64 213 52 204 47C195 42 170 39 130 39L95 39L95 0C120 2 174 3 257 3C340 3 394 2 419 0L419 39L384 39C343 39 318 42 310 47C302 52 297 64 297 82L297 636C297 660 295 666 269 666Z"/></g></g></g><g data-mml-node="msubsup" data-latex="B_i^2" transform="translate(2453.3,0)"><g data-mml-node="mi" data-latex="B"><path data-c="1D435" d="M756 543C756 634 666 683 568 683L236 683C213 683 203 682 203 659C203 643 223 644 235 644C265 643 283 641 288 640C293 639 295 636 295 631C295 629 294 623 291 613L159 82C154 60 144 47 129 42C122 40 104 39 73 39C52 39 42 31 42 15C42 5 52 0 73 0L426 0C491 0 551 20 608 59C671 102 703 155 703 217C703 296 638 344 567 358C655 379 756 446 756 543M554 644C623 644 658 612 658 547C658 496 638 454 596 420C554 386 507 370 456 370L317 370L377 610C385 644 385 644 427 644M582 299C596 276 603 253 603 228C603 176 583 131 542 94C501 57 455 39 402 39L267 39C257 39 250 39 246 40C240 40 237 42 237 45C237 46 237 49 238 53C269 180 293 276 309 340L493 340C536 340 565 326 582 299Z"/></g><g data-mml-node="mn" transform="translate(792,353.6) scale(0.707)" data-latex="2"><path data-c="32" d="M237 666C186 666 143 648 106 612C69 576 50 534 50 483C50 449 75 424 106 424C136 424 161 450 161 480C161 513 137 536 105 536C102 536 100 536 98 535C117 584 161 627 224 627C306 627 352 556 352 470C352 403 318 331 250 255L62 43C49 28 50 29 50 0L421 0L450 180L417 180C409 129 402 100 396 91C391 86 361 84 306 84L139 84L236 179C304 243 390 312 419 365C439 400 449 435 449 470C449 588 357 666 237 666Z"/></g><g data-mml-node="mi" transform="translate(792,-293.8) scale(0.707)" data-latex="i"><path data-c="1D456" d="M284 621C284 648 271 661 244 661C216 661 188 633 188 605C188 578 202 565 229 565C257 565 284 593 284 621M259 138C237 59 205 19 164 19C151 19 144 28 144 47C144 64 173 150 232 306C240 329 244 347 244 360C244 409 210 445 161 445C118 445 84 420 59 369C39 328 29 301 29 288C29 279 34 275 45 275C58 275 60 281 64 295C87 375 118 415 158 415C171 415 178 406 178 387C178 373 175 357 168 338C145 275 121 208 101 155C86 115 78 88 78 74C78 25 114-11 162-11C205-11 239 14 264 64C283 103 293 130 293 145C293 154 288 159 277 159C274 159 259 150 259 138Z"/></g></g></g><rect width="3648.9" height="60" x="1020" y="1169.5"/></g></g><rect width="10751.2" height="60" x="120" y="220"/></g></g></g></g></svg><svg data-labels="true" preserveaspectratio="xMaxYMid" viewbox="1778 -1931.9 1 3363.7"><g data-labels="true" transform="matrix(1 0 0 -1 0 0)"><g data-mml-node="mtd" id="mjx-eqn:10" transform="translate(0,1137.1)"><text data-id-align="true"/><g data-idbox="true" transform="translate(0,-748)"><g data-mml-node="mtext" data-latex="\text{(}"><path data-c="28" d="M318-248C327-248 332-243 332-234C332-231 330-227 327-223C275-183 233-117 202-26C175 53 161 131 161 208L161 292C161 369 175 447 202 526C233 617 275 683 327 723C330 726 332 730 332 734C332 743 327 748 318 748C317 748 314 747 311 745C251 699 201 631 160 540C121 453 101 371 101 292L101 208C101 129 121 47 160-40C201-131 251-199 311-245C314-247 317-248 318-248Z"/></g><g data-mml-node="mtext" data-latex="\text{10}" transform="translate(389,0)"><path data-c="31" d="M269 666C228 624 168 603 89 603L89 564C141 564 184 572 217 588L217 82C217 64 213 52 204 47C195 42 170 39 130 39L95 39L95 0C120 2 174 3 257 3C340 3 394 2 419 0L419 39L384 39C343 39 318 42 310 47C302 52 297 64 297 82L297 636C297 660 295 666 269 666Z"/><path data-c="30" d="M249-22C390-22 460 92 460 320C460 473 428 575 365 625C330 652 291 666 250 666C109 666 39 551 39 320C39 136 88-22 249-22M361 524C368 489 371 425 371 332C371 240 367 172 360 128C347 48 310 8 249 8C226 8 203 17 182 34C155 57 139 104 132 176C129 201 128 253 128 332C128 419 131 480 136 513C145 568 163 603 191 618C213 630 232 636 249 636C314 636 350 583 361 524Z" transform="translate(500,0)"/></g><g data-mml-node="mtext" data-latex="\text{)}" transform="translate(1389,0)"><path data-c="29" d="M78-245C138-199 188-131 229-40C268 47 288 129 288 208L288 292C288 371 268 453 229 540C188 631 138 699 78 745C75 747 72 748 71 748C62 748 57 743 57 734C57 730 59 726 62 723C114 683 156 617 187 526C214 447 228 369 228 292L228 208C228 131 214 53 187-26C156-117 114-183 62-223C59-227 57-231 57-234C57-243 62-248 71-248C72-248 75-247 78-245Z"/></g></g></g></g></svg></g></g></g></g></svg></mjx-container></p><figure class="highlight bash"><table><tbody><tr><td class="code"><pre><span class="line">{</span><br><span class="line">  <span class="string">'句子A'</span>: {</span><br><span class="line">    <span class="string">'句子A'</span>: 1.0000000000000002,</span><br><span class="line">    <span class="string">'句子B'</span>: 0.21934876427664535,</span><br><span class="line">    <span class="string">'句子C'</span>: 0.21934876427664535</span><br><span class="line">  },</span><br><span class="line">  <span class="string">'句子B'</span>: {</span><br><span class="line">    <span class="string">'句子A'</span>: 0.21934876427664535,</span><br><span class="line">    <span class="string">'句子B'</span>: 1,</span><br><span class="line">    <span class="string">'句子C'</span>: 0.33484380220099325</span><br><span class="line">  },</span><br><span class="line">  <span class="string">'句子C'</span>: {</span><br><span class="line">    <span class="string">'句子A'</span>: 0.21934876427664535,</span><br><span class="line">    <span class="string">'句子B'</span>: 0.33484380220099325,</span><br><span class="line">    <span class="string">'句子C'</span>: 1</span><br><span class="line">  }</span><br><span class="line">}</span><br></pre></td></tr></tbody></table></figure></div><div class="story post-story"><h2 id="第九步:余弦相似度按照降序排序"><a href="#第九步:余弦相似度按照降序排序" class="headerlink" title="第九步:余弦相似度按照降序排序"></a>第九步:余弦相似度按照降序排序</h2><p>两两计算向量夹角的余弦值,然后按降序排列,取排在最前面的几个文章,就是相似度较高的文章,作为推荐结果。</p><figure class="highlight bash"><table><tbody><tr><td class="code"><pre><span class="line">{</span><br><span class="line">  <span class="string">'句子A'</span>: {</span><br><span class="line">    <span class="string">'句子A'</span>: 1.0000000000000002,</span><br><span class="line">    <span class="string">'句子B'</span>: 0.21934876427664535,</span><br><span class="line">    <span class="string">'句子C'</span>: 0.21934876427664535</span><br><span class="line">  },</span><br><span class="line">  <span class="string">'句子B'</span>: {</span><br><span class="line">    <span class="string">'句子B'</span>: 1,</span><br><span class="line">    <span class="string">'句子C'</span>: 0.33484380220099325,</span><br><span class="line">    <span class="string">'句子A'</span>: 0.21934876427664535</span><br><span class="line">  },</span><br><span class="line">  <span class="string">'句子C'</span>: {</span><br><span class="line">    <span class="string">'句子C'</span>: 1,</span><br><span class="line">    <span class="string">'句子B'</span>: 0.33484380220099325,</span><br><span class="line">    <span class="string">'句子A'</span>: 0.21934876427664535,</span><br><span class="line">  }</span><br><span class="line">}</span><br></pre></td></tr></tbody></table></figure><p>相同句子的余弦值是 <mjx-container class="MathJax" jax="SVG" overflow="overflow"><svg style="vertical-align: 0;" xmlns="http://www.w3.org/2000/svg" width="1.131ex" height="1.507ex" role="img" focusable="false" viewbox="0 -666 500 666"><g stroke="currentColor" fill="currentColor" stroke-width="0" transform="scale(1,-1)"><g data-mml-node="math" data-latex="1"><g data-mml-node="mn" data-latex="1"><path data-c="31" d="M269 666C228 624 168 603 89 603L89 564C141 564 184 572 217 588L217 82C217 64 213 52 204 47C195 42 170 39 130 39L95 39L95 0C120 2 174 3 257 3C340 3 394 2 419 0L419 39L384 39C343 39 318 42 310 47C302 52 297 64 297 82L297 636C297 660 295 666 269 666Z"/></g></g></g></svg></mjx-container>.余弦值越接近<mjx-container class="MathJax" jax="SVG" overflow="overflow"><svg style="vertical-align: 0;" xmlns="http://www.w3.org/2000/svg" width="1.131ex" height="1.507ex" role="img" focusable="false" viewbox="0 -666 500 666"><g stroke="currentColor" fill="currentColor" stroke-width="0" transform="scale(1,-1)"><g data-mml-node="math" data-latex="1"><g data-mml-node="mn" data-latex="1"><path data-c="31" d="M269 666C228 624 168 603 89 603L89 564C141 564 184 572 217 588L217 82C217 64 213 52 204 47C195 42 170 39 130 39L95 39L95 0C120 2 174 3 257 3C340 3 394 2 419 0L419 39L384 39C343 39 318 42 310 47C302 52 297 64 297 82L297 636C297 660 295 666 269 666Z"/></g></g></g></svg></mjx-container>,就表明夹角越接近<mjx-container class="MathJax" jax="SVG" overflow="overflow"><svg style="vertical-align: -0.05ex;" xmlns="http://www.w3.org/2000/svg" width="1.131ex" height="1.557ex" role="img" focusable="false" viewbox="0 -666 500 688"><g stroke="currentColor" fill="currentColor" stroke-width="0" transform="scale(1,-1)"><g data-mml-node="math" data-latex="0"><g data-mml-node="mn" data-latex="0"><path data-c="30" d="M249-22C390-22 460 92 460 320C460 473 428 575 365 625C330 652 291 666 250 666C109 666 39 551 39 320C39 136 88-22 249-22M361 524C368 489 371 425 371 332C371 240 367 172 360 128C347 48 310 8 249 8C226 8 203 17 182 34C155 57 139 104 132 176C129 201 128 253 128 332C128 419 131 480 136 513C145 568 163 603 191 618C213 630 232 636 249 636C314 636 350 583 361 524Z"/></g></g></g></svg></mjx-container>度,也就是两个向量越相似.</p></div><div class="story post-story"><h2 id="第十步:收集推荐结果"><a href="#第十步:收集推荐结果" class="headerlink" title="第十步:收集推荐结果"></a>第十步:收集推荐结果</h2><figure class="highlight bash"><table><tbody><tr><td class="code"><pre><span class="line">{</span><br><span class="line">  <span class="string">'句子A'</span>: [ <span class="string">'句子B'</span>, <span class="string">'句子C'</span> ],</span><br><span class="line">  <span class="string">'句子B'</span>: [ <span class="string">'句子C'</span>, <span class="string">'句子A'</span> ],</span><br><span class="line">  <span class="string">'句子C'</span>: [ <span class="string">'句子B'</span>, <span class="string">'句子A'</span> ]</span><br><span class="line">}</span><br></pre></td></tr></tbody></table></figure><p>即:</p><figure class="highlight bash"><table><tbody><tr><td class="code"><pre><span class="line">A-B</span><br><span class="line">B-C</span><br><span class="line">C-B</span><br></pre></td></tr></tbody></table></figure><p>A和C之间没什么关系。</p></div><div class="story post-story"><h2 id="源码实现"><a href="#源码实现" class="headerlink" title="源码实现"></a>源码实现</h2><div class="tag link"><a class="link-card" title="Volantis主题实现文章推荐" target="_blank" rel="external nofollow noopener noreferrer" href="/go.html?u=aHR0cHM6Ly9naXRodWIuY29tL3ZvbGFudGlzLXgvaGV4by10aGVtZS12b2xhbnRpcy9ibG9iLzY4NGM0MDMzM2IxNmI1ZDFkZjFhOWU0YTdmMWRhOTAyMTZlNWExN2Evc2NyaXB0cy9oZWxwZXJzL-aWh-eroOaOqOiNkC5qcw"><div class="left"><img src="https://static.mhuig.top/npm/volantis-static@0.0.1649552113628/media/twemoji/assets/svg/1f433.svg" class="lazyload" data-srcset="https://static.mhuig.top/npm/volantis-static@0.0.1649552113628/media/twemoji/assets/svg/1f433.svg" srcset="data:image/gif;base64,R0lGODlhAQABAIAAAP///////yH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=="></div><div class="right"><p class="text">Volantis主题实现文章推荐</p><p class="url">https://github.com/volantis-x/hexo-theme-volantis/blob/684c40333b16b5d1df1a9e4a7f1da90216e5a17a/scripts/helpers/文章推荐.js</p></div></a></div><p><del>UI界面是随手写的,又不是不能用(</del></p><p>代码变量是中文写的,方便易读。<psw>其实是中间出Bug了,然后调试Debug时顺便整的活</psw></p></div></div><div class="footer"><div class="copyright license"><div class="license-title">尝试在博客中添加简易文章推荐功能</div><div class="license-link"><a href="https://blog.mhuig.top/p/175a1706/">https://blog.mhuig.top/p/175a1706/</a></div><div class="license-meta"><div class="license-meta-item"><div class="license-meta-title">本文作者</div><div class="license-meta-text">MHuiG</div></div><div class="license-meta-item"><div class="license-meta-title">发布于</div><div class="license-meta-text">Sep 15, 2022</div></div><div class="license-meta-item"><div class="license-meta-title">更新于</div><div class="license-meta-text">Nov 20, 2025</div></div><div class="license-meta-item"><div class="license-meta-title">许可协议</div><div class="license-meta-text"><a href="/go.html?u=aHR0cHM6Ly9jcmVhdGl2ZWNvbW1vbnMub3JnL2xpY2Vuc2VzL2J5LW5jLXNhLzQuMC9kZWVkLnpoLWhhbnMj" target="_blank" rel="external nofollow noopener noreferrer">CC BY-NC-SA 4.0</a></div></div></div><div class="license-statement">署名-非商业性使用-相同方式共享 4.0 国际。</div></div></div><div class="article-meta" id="bottom"><div class="new-meta-box"><div class="new-meta-item category"><i class="fa-duotone fa-folder-open fa-fw" aria-hidden="true"></i> <a class="category-link" href="/categories/%E6%95%B0%E6%8D%AE%E6%8C%96%E6%8E%98/">数据挖掘</a> <span hidden itemprop="about" itemscope itemtype="http://schema.org/Thing"><a href="/categories/%E6%95%B0%E6%8D%AE%E6%8C%96%E6%8E%98/" itemprop="url"><span itemprop="name">数据挖掘</span></a></span></div><div class="new-meta-item meta-tags"><a class="tag" href="/tags/%E6%8E%A8%E8%8D%90%E7%B3%BB%E7%BB%9F/" rel="nofollow"><i class="fa-duotone fa-hashtag fa-fw" aria-hidden="true"></i><p>推荐系统</p></a></div> <span hidden itemprop="keywords">推荐系统</span><div class="new-meta-item date" itemprop="dateCreated datePublished" datetime="2022-09-15T19:13:00+08:00"><a class="notlink"><i class="fa-duotone fa-calendar-alt fa-fw" aria-hidden="true"></i><p>发布于:Sep 15, 2022</p></a></div><div class="new-meta-item date" itemprop="dateModified" datetime="2025-11-20T18:26:00+08:00"><a class="notlink"><i class="fa-duotone fa-edit fa-fw" aria-hidden="true"></i><p>更新于:Nov 20, 2025</p></a></div></div></div><div class="prev-next"><a class="prev" href="/p/2f345bb/"><p class="title"><i class="fa-solid fa-chevron-left" aria-hidden="true"></i>辛普森悖论|你还相信数据吗</p><p class="content">辛普森悖论揭示数据整体趋势与分组趋势可能矛盾,如肾结石治疗案例中,A疗法整体成功率高于B疗法,但分组看B对大小结石成功率均高于A。其根源是忽略混杂变量,警示需通过科学分组与因果分析避免数据误读。</p></a><a class="next" href="/p/de4b9576/"><p class="title">记一次重装系统(Win11)<i class="fa-solid fa-chevron-right" aria-hidden="true"></i></p><p class="content">记录因电脑卡顿重装Win11的经历,包括重装前备份列表,适用于Win10/11、使用微软官方镜像的建议,以及重装后系统激活、软件安装、权限夺回、登录界面优化等操作指南。</p></a></div><div class="recommended-article"><div class="recommended-article-header"><i class="fa-solid fa-bookmark fa-fw" aria-hidden="true"></i> <span>推荐阅读</span></div><div class="recommended-article-group"> <a class="recommended-article-item" href="/notes/c/t/hitokoto.html" title="Hitokoto" rel="bookmark"><img src="https://gcore.jsdelivr.net/gh/MHG-LAB/cron@gh-pages/bing/bing.jpg" class="lazyload" data-srcset="https://gcore.jsdelivr.net/gh/MHG-LAB/cron@gh-pages/bing/bing.jpg" srcset="data:image/gif;base64,R0lGODlhAQABAIAAAP///////yH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==" alt="Hitokoto"> <span class="title">Hitokoto</span></a> <a class="recommended-article-item" href="/p/48f700eb/" title="BERT预训练模型及其应用案例" rel="bookmark"><img src="https://static.mhuig.top/npm/mhgoos@0.0.1651974150318/2020116102430.webp" class="lazyload" data-srcset="https://static.mhuig.top/npm/mhgoos@0.0.1651974150318/2020116102430.webp" srcset="data:image/gif;base64,R0lGODlhAQABAIAAAP///////yH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==" alt="BERT预训练模型及其应用案例"> <span class="title">BERT预训练模型及其应用案例</span></a> <a class="recommended-article-item" href="/notes/rzf/1.5.html" title="ζ(s)的取值" rel="bookmark"><img src="https://static.mhuig.top/npm/imbox@0.0.15/c/48.webp" class="lazyload" data-srcset="https://static.mhuig.top/npm/imbox@0.0.15/c/48.webp" srcset="data:image/gif;base64,R0lGODlhAQABAIAAAP///////yH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==" alt="ζ(s)的取值"> <span class="title">ζ(s)的取值</span></a> <a class="recommended-article-item" href="/notes/person/1.html" title="希尔伯特23问题" rel="bookmark"><img src="https://static.mhuig.top/npm/imbox@0.0.15/c/93.webp" class="lazyload" data-srcset="https://static.mhuig.top/npm/imbox@0.0.15/c/93.webp" srcset="data:image/gif;base64,R0lGODlhAQABAIAAAP///////yH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==" alt="希尔伯特23问题"> <span class="title">希尔伯特23问题</span></a> <a class="recommended-article-item" href="/notes/person/40.html" title="Riemann德国数学家黎曼:短暂而辉煌的生涯及其对数学与物理的深远影响" rel="bookmark"><img src="https://static.mhuig.top/npm/imbox@0.0.15/c/99.webp" class="lazyload" data-srcset="https://static.mhuig.top/npm/imbox@0.0.15/c/99.webp" srcset="data:image/gif;base64,R0lGODlhAQABAIAAAP///////yH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==" alt="Riemann德国数学家黎曼:短暂而辉煌的生涯及其对数学与物理的深远影响"> <span class="title">Riemann德国数学家黎曼:短暂而辉煌的生涯及其对数学与物理的深远影响</span></a> <a class="recommended-article-item" href="/notes/zeta/153.html" title="探索Zeta函数的几何直觉:从无限叠加矩形到Zeta函数零点的视觉化路径" rel="bookmark"><img src="https://static.mhuig.top/npm/imbox@0.0.15/c/29.webp" class="lazyload" data-srcset="https://static.mhuig.top/npm/imbox@0.0.15/c/29.webp" srcset="data:image/gif;base64,R0lGODlhAQABAIAAAP///////yH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==" alt="探索Zeta函数的几何直觉:从无限叠加矩形到Zeta函数零点的视觉化路径"> <span class="title">探索Zeta函数的几何直觉:从无限叠加矩形到Zeta函数零点的视觉化路径</span></a></div></div></article><article class="post white-box shadow floatable blur" id="comments"><span hidden><meta itemprop="discussionUrl" content="/p/175a1706/#comments"></span><p ct><i class="fa-duotone fa-comments"></i> 留言区</p><div id="layoutHelper-comments"></div></article></div><aside id="l_side" itemscope itemtype="http://schema.org/WPSideBar"><div class="pjax"></div><section class="widget recent desktop mobile shadow floatable blur pjax"><header><i class="fa-solid fa-clock fa-fw" aria-hidden="true"></i> <span class="name">最近更新</span></header><div class="content"><widget class="widget-wrapper recent post-list"><div class="widget-body fs14"><a class="item title" href="/p/b150f6f2/"><span class="title">OKR目标管理中的七成完成度现象及其博弈论分析</span></a><a class="item title" href="/p/cb3fc42/"><span class="title">空白的答案</span></a><a class="item title" href="/p/56c48370/"><span class="title">爱与时空的星际救赎:《星际穿越》中的生存抉择与人性光辉</span></a><a class="item title" href="/p/2f345bb/"><span class="title">辛普森悖论|你还相信数据吗</span></a><a class="item title" href="/p/175a1706/"><span class="title">尝试在博客中添加简易文章推荐功能</span></a><a class="item title" href="/p/de4b9576/"><span class="title">记一次重装系统(Win11)</span></a><a class="item title" href="/p/6a03238d/"><span class="title">部署第一个智能合约</span></a><a class="item title" href="/p/6dc844b7/"><span class="title">一组粗略的类比</span></a><a class="item title" href="/p/6ace289f/"><span class="title">唯物辩证法</span></a><a class="item title" href="/p/171a81d0/"><span class="title">辩证唯物论</span></a></div></widget></div></section><div class="widget-sticky pjax"><section class="widget toc-wrapper toc desktop mobile shadow floatable blur" id="toc-div"><header><i class="fa-duotone fa-list fa-fw" aria-hidden="true"></i> <span class="name">本文目录</span></header><div class="content"><ol class="toc"><li class="toc-item toc-level-2"><a class="toc-link" href="#%E6%9E%84%E5%BB%BA%E5%90%91%E9%87%8F%E7%A9%BA%E9%97%B4%E6%A8%A1%E5%9E%8B"><span class="toc-text">构建向量空间模型</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E4%B8%BE%E4%B8%AA%E6%A0%97%E5%AD%90"><span class="toc-text">举个栗子</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E7%AC%AC%E4%B8%80%E6%AD%A5%EF%BC%9A%E6%95%B0%E6%8D%AE%E6%B8%85%E6%B4%97"><span class="toc-text">第一步:数据清洗</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E7%AC%AC%E4%BA%8C%E6%AD%A5%EF%BC%9A%E5%88%86%E8%AF%8D"><span class="toc-text">第二步:分词</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E7%AC%AC%E4%B8%89%E6%AD%A5%EF%BC%9A%E5%8E%BB%E9%87%8D%E6%94%B6%E9%9B%86%E6%89%80%E6%9C%89%E5%8F%A5%E5%AD%90%E4%B8%AD%E6%89%80%E6%9C%89%E7%9A%84%E8%AF%8D"><span class="toc-text">第三步:去重收集所有句子中所有的词</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E7%AC%AC%E5%9B%9B%E6%AD%A5%EF%BC%9A%E8%AE%A1%E7%AE%97%E8%AF%8D%E9%A2%91"><span class="toc-text">第四步:计算词频</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E7%AC%AC%E5%9B%9B%E6%AD%A5%EF%BC%9A%E8%AF%8D%E9%A2%91%E6%A0%87%E5%87%86%E5%8C%96"><span class="toc-text">第四步:词频标准化</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E7%AC%AC%E4%BA%94%E6%AD%A5%EF%BC%9A%E8%AE%A1%E7%AE%97%E9%80%86%E6%96%87%E6%A1%A3%E9%A2%91%E7%8E%87"><span class="toc-text">第五步:计算逆文档频率</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E7%AC%AC%E5%85%AD%E6%AD%A5%EF%BC%9A%E8%AE%A1%E7%AE%97TF-IDF"><span class="toc-text">第六步:计算TF-IDF</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E7%AC%AC%E4%B8%83%E6%AD%A5%EF%BC%9A%E5%88%97%E5%87%BA%E6%96%87%E6%A1%A3%E5%90%91%E9%87%8F"><span class="toc-text">第七步:列出文档向量</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E7%AC%AC%E5%85%AB%E6%AD%A5%EF%BC%9A%E8%AE%A1%E7%AE%97%E4%BD%99%E5%BC%A6%E7%9B%B8%E4%BC%BC%E5%BA%A6"><span class="toc-text">第八步:计算余弦相似度</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E7%AC%AC%E4%B9%9D%E6%AD%A5%EF%BC%9A%E4%BD%99%E5%BC%A6%E7%9B%B8%E4%BC%BC%E5%BA%A6%E6%8C%89%E7%85%A7%E9%99%8D%E5%BA%8F%E6%8E%92%E5%BA%8F"><span class="toc-text">第九步:余弦相似度按照降序排序</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E7%AC%AC%E5%8D%81%E6%AD%A5%EF%BC%9A%E6%94%B6%E9%9B%86%E6%8E%A8%E8%8D%90%E7%BB%93%E6%9E%9C"><span class="toc-text">第十步:收集推荐结果</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E6%BA%90%E7%A0%81%E5%AE%9E%E7%8E%B0"><span class="toc-text">源码实现</span></a></li></ol></div></section></div><div class="widget pjax"></div><div class="widget pjax"></div><div class="widget pjax"></div><div class="widget pjax"></div><div class="widget pjax"></div><div class="widget pjax"></div><div class="widget pjax"></div><div class="widget pjax"></div><div class="widget pjax"></div><div class="widget pjax"></div><div class="widget pjax"></div><div class="widget pjax"></div><div class="widget pjax"></div><div class="widget pjax"></div><div class="widget pjax"></div><div class="widget pjax"></div><div class="widget pjax"></div><div class="widget pjax"></div><div class="widget pjax"></div><div class="widget pjax"></div><div class="widget pjax"></div><div class="widget pjax"></div><div class="widget pjax"></div><div class="widget pjax"></div><div class="widget pjax"></div><div class="widget pjax"></div><div class="widget pjax"></div><div class="widget pjax"></div><div class="widget pjax"></div><div class="widget pjax"></div><div class="widget pjax"></div><div class="widget pjax"></div><div class="widget pjax"></div><div class="widget pjax"></div><div class="widget pjax"></div><div class="widget pjax"></div><div class="widget pjax"></div><div class="widget pjax"></div><div class="widget pjax"></div></aside><pjax><script>window.pdata={},pdata.ispage=!0,pdata.commentPath="",pdata.commentPlaceholder="",pdata.commentConfig={};var l_header=document.getElementById("l_header");l_header.classList.add("show");var cover_wrapper=document.querySelector("#l_cover .cover-wrapper"),scroll_down=document.getElementById("scroll-down");cover_wrapper.id="none",cover_wrapper.style.display="none",scroll_down.style.display="none"</script></pjax></div><footer class="footer clearfix" itemscope itemtype="http://schema.org/WPFooter"><br><br><div class="aplayer-container"><div class="aplayer-local"></div></div><br><div class="social-wrapper" itemprop="about" itemscope itemtype="http://schema.org/Thing"><a href="/atom.xml" class="social fa-duotone fa-rss flat-btn" target="_blank" rel="external nofollow noopener noreferrer" itemprop="url"></a><a href="https://mhuig.top/contact/" class="social fa-duotone fa-envelope flat-btn" target="_blank" rel="external nofollow noopener noreferrer" itemprop="url"></a><a href="https://github.com/MHuiG" class="social fa-brands fa-github flat-btn" target="_blank" rel="external nofollow noopener noreferrer" itemprop="url"></a><a href="https://t.me/MHuiG" class="social fa-brands fa-telegram flat-btn" target="_blank" rel="external nofollow noopener noreferrer" itemprop="url"></a></div><div><p>博客内容遵循 <a target="_blank" rel="external nofollow noopener noreferrer" href="https://creativecommons.org/licenses/by-nc-sa/4.0/deed.zh-hans">署名-非商业性使用-相同方式共享 4.0 国际 (CC BY-NC-SA 4.0) 协议</a></p></div><div class="copyright"><p><a href="https://icp.gov.moe" target="_blank" rel="external nofollow noopener noreferrer">萌ICP备</a> <a href="https://icp.gov.moe/?keyword=2020012138" target="_blank" rel="external nofollow noopener noreferrer">2020012138号</a><br><a target="_blank" rel="noopener" href="https://mhuig.top/">Copyright © Since 2018 MHuiG</a></p></div></footer><a id="s-top" class="fa-solid fa-arrow-up fa-fw" title="top"></a></div></div><div><script>volantis.css("https://static.mhuig.top/npm/volantis-static@0.0.1761982841160/libs/@fortawesome/fontawesome-pro/css/all.min.css")</script><script src="/js/app.js"></script><script>const rootElement=document.documentElement,darkModeStorageKey="color-scheme",rootElementDarkModeAttributeName="color-scheme",setLS=(e,t)=>{localStorage.setItem(e,t)},removeLS=e=>{localStorage.removeItem(e)},getLS=e=>localStorage.getItem(e),getModeFromCSSMediaQuery=()=>window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light",resetRootDarkModeAttributeAndLS=()=>{rootElement.removeAttribute("color-scheme"),removeLS("color-scheme")},validColorModeKeys={dark:!0,light:!0},applyCustomDarkModeSettings=e=>{const t=e||getLS("color-scheme");getCustomDarkMode(),t===getModeFromCSSMediaQuery()?resetRootDarkModeAttributeAndLS():validColorModeKeys[t]?rootElement.setAttribute("color-scheme",t):resetRootDarkModeAttributeAndLS()},invertDarkModeObj={dark:"light",light:"dark"},getCustomDarkMode=()=>{let e=getLS("color-scheme");if(validColorModeKeys[e])e=invertDarkModeObj[e];else{if(null!==e)return;e=invertDarkModeObj[getModeFromCSSMediaQuery()]}volantis.dark.mode="dark"==e?"light":"dark"},toggleCustomDarkMode=()=>{let e=getLS("color-scheme");if(validColorModeKeys[e])e=invertDarkModeObj[e];else{if(null!==e)return;e=invertDarkModeObj[getModeFromCSSMediaQuery()]}return setLS("color-scheme",e),e};function bindToggleButton(){document.querySelectorAll("#wrapper .toggle-mode-btn,#rightmenu-wrapper .toggle-mode-btn").forEach(function(e){volantis.dom.$(e).on("click",volantis.dark.toggle)})}volantis.dark.toggle=()=>{const e=toggleCustomDarkMode();applyCustomDarkModeSettings(e),volantis.dark.method.toggle.start()},applyCustomDarkModeSettings(),document.addEventListener("DOMContentLoaded",()=>{volantis.requestAnimationFrame(bindToggleButton)}),volantis.pjax.push(bindToggleButton,"dark_bindToggleButton");const darkModelListeners={dark:e=>{e.matches&&(volantis.dark.mode="dark"),volantis.dark.method.toggle.start()},light:e=>{e.matches&&(volantis.dark.mode="light"),volantis.dark.method.toggle.start()}};window.matchMedia("(prefers-color-scheme: dark)").addListener(darkModelListeners.dark),window.matchMedia("(prefers-color-scheme: light)").addListener(darkModelListeners.light)</script><script>function loadIssuesJS(){null!=document.getElementById("sites-api")&&"undefined"==typeof SitesJS&&volantis.js("/js/plugins/tags/sites.js");null!=document.getElementById("friends-api")&&"undefined"==typeof FriendsJS&&volantis.js("/js/plugins/tags/friends.js");null!=document.getElementById("fposts-api")&&"undefined"==typeof FpostsJS&&volantis.js("/js/plugins/tags/fposts.js");null!=document.getElementById("contributors-api")&&"undefined"==typeof ContributorsJS&&volantis.js("/js/plugins/tags/contributors.js")}loadIssuesJS(),volantis.pjax.push(()=>{loadIssuesJS()},"loadIssuesJS")</script><script>function loadDataService(){const e=document.querySelectorAll("a.link-card[cardlink]");e?.length>0&&volantis.js("/js/plugins/tags/siteinfo.js",{defer:!0}).then(function(){setCardLink(e)});document.querySelector(".tag-plugin.timeline.ds-timeline")&&volantis.js("https://static.mhuig.top/npm/marked@14.1.2/marked.min.js").then(function(){volantis.js("/js/plugins/tags/timeline.js",{defer:!0})});const t=document.querySelectorAll(".voice>audio");t?.length>0&&volantis.js("/js/plugins/tags/chat/voice.js",{defer:!0}).then(function(){createVoiceDom(t)});const n=document.querySelectorAll(".video>video");n?.length>0&&volantis.js("/js/plugins/tags/chat/video.js",{defer:!0}).then(function(){videoEvents(n)});const o=document.querySelectorAll(".chat-file");o?.length>0&&volantis.js("/js/plugins/tags/chat/download-file.js",{defer:!0}).then(function(){downloadFileEvent(o)});let i=document.querySelectorAll(".chat .status-bar .time"),s=null,l=null;if(i.length>0){c();const d=(new Date).getSeconds();function c(){for(let e=0;e<i.length;++e){const t=i[e],n=new Date,o=n.getHours(),s=n.getMinutes();t.innerHTML=a(o)+":"+a(s)}}function a(e){return e<10?"0"+e:e}s=setInterval(function(){c(),s&&(clearInterval(s),s=null);l=setInterval(c,6e4)},1e3*(60-d))}const r=new Map,u=new IntersectionObserver((e,t)=>{e.filter(e=>e.isIntersecting).sort((e,t)=>e.intersectionRect.y!==t.intersectionRect.y?e.intersectionRect.y-t.intersectionRect.y:e.intersectionRect.x-t.intersectionRect.x).forEach((e,n)=>{t.unobserve(e.target),setTimeout(()=>{e.target.classList.add("quote-blink"),setTimeout(()=>{e.target.classList.remove("quote-blink")},1e3)},Math.max(100,16)*(n+1))})});document.querySelectorAll(".chat .talk .quote").forEach(e=>{const t=function(){var t=document.getElementById("quote-"+e.getAttribute("quotedCellTag"));if(t){var n=t.parentElement,o=n.clientHeight/2;t.offsetTop>o-t.clientHeight/2?n.scrollTo({top:t.offsetTop-o+t.clientHeight/2,behavior:"smooth"}):n.scrollTo({top:0,behavior:"smooth"}),u.observe(t)}};e.addEventListener("click",t),r.set(e,t)}),volantis.pjax.send(()=>{u&&u.disconnect(),r.forEach((e,t)=>{t.removeEventListener("click",e)}),r.clear()},"chatQuotes")}loadDataService(),volantis.pjax.push(()=>{loadDataService()},"loadDataService")</script><script defer="defer" src="https://static.mhuig.top/npm/vanilla-lazyload@19.1.3/dist/lazyload.min.js"></script><script>window.lazyLoadOptions={elements_selector:".lazyload",threshold:0},window.addEventListener("LazyLoad::Initialized",function(n){window.lazyLoadInstance=n.detail.instance},!1),document.addEventListener("DOMContentLoaded",function(){lazyLoadInstance.update()}),document.addEventListener("pjax:complete",function(){lazyLoadInstance.update()})</script><script>window.FPConfig={delay:0,ignoreKeywords:["#"],maxRPS:6,hoverDelay:0}</script><script defer="defer" src="https://static.mhuig.top/npm/volantis-static@0.0.1761982841160/libs/flying-pages/flying-pages.min.js"></script><script>volantis.css("https://static.mhuig.top/npm/aplayer@1.10.1/dist/APlayer.min.css"),volantis.js("https://static.mhuig.top/npm/aplayer@1.10.1/dist/APlayer.min.js").then(()=>{function e(){document.querySelector(".aplayer-local-min")&&document.querySelectorAll(".aplayer-local-min").forEach(e=>{new APlayer(Object.assign({container:e,mini:!0,order:"list",volume:"0.7",autoplay:!1,loop:"all",theme:"#1BCDFC",listMaxHeight:"320px",listFolded:"true",preload:"auto",lrcType:3,audio:[{name:"虹之间",artist:"钢琴版伴奏",url:"https://blog.mhuig.top/music-Archive/BetweenTheRainbow.mp3",lrc:"https://blog.mhuig.top/music-Archive/BetweenTheRainbow.lrc",cover:"https://blog.mhuig.top/music-Archive/BetweenTheRainbow.jpg"},{name:"Avem",artist:"Alan Walker",url:"https://blog.mhuig.top/music-Archive/Avem.mp3",lrc:"https://blog.mhuig.top/music-Archive/Avem.lrc",cover:"https://blog.mhuig.top/music-Archive/Avem.jpg"},{name:"Fly",artist:"Marshmello / Leau Culver",url:"https://blog.mhuig.top/music-Archive/fly.mp3",lrc:"https://blog.mhuig.top/music-Archive/fly.lrc",cover:"https://blog.mhuig.top/music-Archive/fly.jpg"},{name:"Alone",artist:"Marshmello",url:"https://blog.mhuig.top/music-Archive/alone.mp3",lrc:"https://blog.mhuig.top/music-Archive/alone.lrc",cover:"https://blog.mhuig.top/music-Archive/alone.jpg"}]},JSON.parse(e.querySelector(".aplayer-local-min-conf").innerText)))})}document.querySelectorAll(".aplayer-local").forEach(e=>{new APlayer({container:e,fixed:!1,order:"list",volume:"0.7",autoplay:!1,loop:"all",theme:"#1BCDFC",listMaxHeight:"320px",listFolded:"true",preload:"auto",lrcType:3,audio:[{name:"虹之间",artist:"钢琴版伴奏",url:"https://blog.mhuig.top/music-Archive/BetweenTheRainbow.mp3",lrc:"https://blog.mhuig.top/music-Archive/BetweenTheRainbow.lrc",cover:"https://blog.mhuig.top/music-Archive/BetweenTheRainbow.jpg"},{name:"Avem",artist:"Alan Walker",url:"https://blog.mhuig.top/music-Archive/Avem.mp3",lrc:"https://blog.mhuig.top/music-Archive/Avem.lrc",cover:"https://blog.mhuig.top/music-Archive/Avem.jpg"},{name:"Fly",artist:"Marshmello / Leau Culver",url:"https://blog.mhuig.top/music-Archive/fly.mp3",lrc:"https://blog.mhuig.top/music-Archive/fly.lrc",cover:"https://blog.mhuig.top/music-Archive/fly.jpg"},{name:"Alone",artist:"Marshmello",url:"https://blog.mhuig.top/music-Archive/alone.mp3",lrc:"https://blog.mhuig.top/music-Archive/alone.lrc",cover:"https://blog.mhuig.top/music-Archive/alone.jpg"}]})}),e(),volantis.pjax.push(e,"aplayerMin")})</script><script>function check_giscus(){return"dark"===volantis.dark.mode?volantis.giscus.Theme="dark":volantis.giscus.Theme="light",document.getElementById("giscus_container")}function pjax_giscus(){const s=check_giscus();if(!s)return;let t=Object.assign({theme:{light:"light",dark:"dark"},repo:"MHuiG/talk","repo-id":"MDEwOlJlcG9zaXRvcnkyODQ4NDg1NTg=",category:"Giscus","category-id":"DIC_kwDOEPpxrs4B_X67",mapping:"pathname","reactions-enabled":"1","emit-metadata":"1",lang:"zh-CN","input-position":"top"},pdata.commentConfig);const e=document.createElement("script");e.setAttribute("src","https://giscus.app/client.js"),Object.keys(t).forEach(s=>{"theme"!=s&&e.setAttribute("data-"+s,t[s])}),e.setAttribute("data-theme",volantis.giscus.Theme),e.setAttribute("crossorigin","anonymous"),s.appendChild(e)}function dark_giscus(){if(!check_giscus())return;const s={setConfig:{theme:volantis.giscus.Theme}};document.querySelector("iframe.giscus-frame").contentWindow.postMessage({giscus:s},"https://giscus.app")}volantis.layoutHelper("comments",'<div id="giscus_container"></div>'),volantis.giscus={},pjax_giscus(),volantis.pjax.push(pjax_giscus,"giscus"),volantis.dark.push(dark_giscus,"giscus")</script><script>async function loadSearchScript(){return volantis.js("/js/search/hexo.js")}function loadSearchService(){loadSearchScript(),document.querySelectorAll(".input.u-search-input").forEach(e=>{e.removeEventListener("focus",loadSearchService,!1)}),document.querySelectorAll(".u-search-form").forEach(e=>{e.addEventListener("submit",e=>{e.preventDefault()},!1)})}function OpenSearch(e){"undefined"==typeof SearchService?loadSearchScript().then(()=>{SearchService.setQueryText(e),SearchService.search()}):(SearchService.setQueryText(e),SearchService.search())}if(window.location.search&&/^\?s=/g.test(window.location.search)){OpenSearch(decodeURI(window.location.search).replace(/\ /g,"-").replace(/^\?s=/g,""))}document.querySelectorAll(".input.u-search-input").forEach(e=>{e.addEventListener("focus",loadSearchService,!1)})</script><script>function pjax_highlightjs_copyCode(){(document.querySelector(".highlight .code pre")||document.querySelector(".article pre code"))&&VolantisApp.utilCopyCode(".highlight .code pre, .article pre code")}volantis.requestAnimationFrame(pjax_highlightjs_copyCode),volantis.pjax.push(pjax_highlightjs_copyCode,"pjax_highlightjs_copyCode")</script><script>function load_swiper(){document.querySelector(".swiper-container")&&(volantis.css("https://static.mhuig.top/npm/swiper@11.1.14/swiper-bundle.min.css"),volantis.js("https://static.mhuig.top/npm/swiper@11.1.14/swiper-bundle.min.js").then(()=>{pjax_swiper()}))}function pjax_swiper(){const e=document.querySelector(".swiper-container").getAttribute("effect")||"cards";volantis.swiper=new Swiper(".swiper-container",{slidesPerView:"auto",spaceBetween:8,centeredSlides:!0,effect:e,rewind:!0,pagination:{el:".swiper-pagination",clickable:!0},navigation:{nextEl:".swiper-button-next",prevEl:".swiper-button-prev"}})}load_swiper(),volantis.pjax.push(()=>{document.querySelectorAll(".swiper-container")[0]&&(void 0===volantis.swiper?load_swiper():pjax_swiper())},"swiper")</script><script>window.paceOptions={eventLag:{lagThreshold:30},ajax:{ignoreURLs:["signalr","__browserLink","browserLinkSignalR"],trackWebSockets:!1}},volantis.css("https://static.mhuig.top/npm/pace-js@1.2.4/themes/blue/pace-theme-minimal.css"),volantis.js("https://static.mhuig.top/npm/pace-js@1.2.4/pace.min.js").then(()=>{Pace.options.restartOnPushState=!1,volantis.pjax.send(Pace.restart,"Pace.restart"),volantis.pjax.push(()=>{setTimeout(()=>{Pace.stop(),document.body.className=document.body.className.replaceAll("pace-running ","")},1200)},"Pace.stop"),volantis.scroll.push(volantis.debounce(()=>{Pace.stop(),Pace.trigger("start"),Pace.bar.update(100*volantis.scroll.progress()),document.body.className=document.body.className.replaceAll("pace-running ","")}),"阅读进度")})</script><script src="https://static.mhuig.top/npm/pjax@0.2.8/pjax.min.js"></script><script>const performanceMonitor={slowThreshold:800,slowCount:0,maxSlowAllowed:1,requestStartTime:0,start(){this.requestStartTime=Date.now()},check(){Date.now()-this.requestStartTime>this.slowThreshold?this.slowCount++:this.slowCount=0},res(){return this.slowCount>=this.maxSlowAllowed}};var pjax;document.addEventListener("DOMContentLoaded",function(){pjax=new Pjax({elements:'a[href]:not([href^="#"]):not([href="javascript:void(0)"]):not([pjax-fancybox]):not([onclick="return false;"]):not([onclick="return!1"]):not([target="_blank"]):not([target="view_window"]):not([href$=".xml"])',selectors:["head title","head meta[name=keywords]","head meta[name=description]","#l_main","#pjax-header-nav-list",".pjax","pjax","meta[name=robots]","link[rel=canonical]","meta[property='og:title']","meta[property='og:description']","meta[property='og:url']","meta[property='og:image']","script[type='application/ld+json']"],cacheBust:!1,timeout:900})}),document.addEventListener("pjax:send",function(e){window.stop(),performanceMonitor.start();try{var t=window.location.pathname,o=e.triggerElement.href,n=[""];""!=n[0]&&n.forEach(e=>{-1==t.indexOf(e)&&-1==o.indexOf(e)||(window.location.href=o)}),performanceMonitor.res()&&(window.location.href=o)}catch(e){}volantis.pjax.method.send.start()}),document.addEventListener("pjax:complete",function(){performanceMonitor.check(),document.querySelectorAll("script[data-pjax], .pjax-reload script").forEach(e=>{const t=e.text||e.textContent||e.innerHTML||"",o=document.createElement("script");Object.keys(e.attributes).forEach(t=>{o.setAttribute(e.attributes[t].nodeName,e.attributes[t].nodeValue)}),t&&o.appendChild(document.createTextNode(t)),e.parentNode.replaceChild(o,e)}),volantis.pjax.method.complete.start()}),document.addEventListener("pjax:error",function(e){"pjax"===volantis.debug?(console.error(e),console.log("pjax error: \n"+JSON.stringify(e))):(volantis.pjax.method.error.start(),window.location.href=e.triggerElement.href)})</script><pjax><style>#post-body p{text-indent:2em}#post-body .new-meta-box p,#post-body .note p,#post-body .prev-next p,#post-body .tab-pane .checkbox #post-body section p,#post-body .tag p,#post-body blockquote p,#post-body details p,#post-body p.p{text-indent:initial}</style></pjax><script>function listenSidebarTOC(){const t=document.querySelectorAll(".toc li");if(!t.length)return;const e=[];Array.from(t).forEach(t=>{const n=t.querySelector(".toc-link"),i=document.getElementById(n.getAttribute("href")?decodeURI(n.getAttribute("href")).replace("#",""):n.getAttribute("toc-action")?.split("toc-")[1]);return e.push(i),n.getAttribute("href")&&(n.setAttribute("toc-action","toc-"+decodeURI(n.getAttribute("href")).replace("#","")),n.removeAttribute("href")),i&&i.id&&n.addEventListener("click",t=>{t.preventDefault(),volantis.scroll.to(i,{addTop:5,observer:!0}),history.pushState(null,document.title,"#"+i.id)}),i});function n(t){if(t.classList.contains("active-current"))return;document.querySelectorAll(".toc .active").forEach(t=>{t.classList.remove("active","active-current")}),t.classList.add("active","active-current");let e=t.parentNode;for(;!e.matches(".toc");)e.matches("li")&&e.classList.add("active"),e=e.parentNode}volantis.activateNavIndex=0,n(t[volantis.activateNavIndex]),e[0]&&volantis.scroll.push(volantis.debounce(()=>{if(e[0].getBoundingClientRect().top>=0)volantis.activateNavIndex=0;else if(e[e.length-1].getBoundingClientRect().top<0)volantis.activateNavIndex=e.length-1;else for(let t=0;t<e.length;t++){const n=e[t],i=e[(t+1)%e.length];if(n.getBoundingClientRect().top<0&&i.getBoundingClientRect().top>=0){volantis.activateNavIndex=t;break}}n(t[volantis.activateNavIndex])}),"sidebar-toc")}document.addEventListener("DOMContentLoaded",()=>{volantis.requestAnimationFrame(listenSidebarTOC)}),volantis.pjax.push(listenSidebarTOC,"listenSidebarTOC")</script><script>try{let t=(t,e,i=2)=>Math.abs(t-e)<=i,e=(e,i)=>!t(e.width,i.width)||!t(e.height,i.height),i=new WeakMap,n=(t,n=t.getClientBoundingRect())=>{let o=i.get(t);o&&!e(o,n)||(i.set(t,n),t.style["contain-intrinsic-size"]=`${n.width}px ${n.height}px`)},o=new IntersectionObserver((t,e)=>{t.forEach(t=>{n(t.target,t.boundingClientRect)})},{rootMargin:"500px 0px 500px 0px"}),r=new ResizeObserver((t,e)=>{t.forEach(t=>{n(t.target,t.contentRect)})}),s=t=>{let e=document.querySelectorAll(t);e.length&&(e.forEach(t=>{o.observe(t),r.observe(t)}),requestAnimationFrame(()=>{requestAnimationFrame(()=>{e[0].style["content-visibility"]="auto"})}))},c=()=>{"content-visibility"in document.documentElement.style&&s(".post-story")};c(),volantis.pjax.push(c,"contentVisibilityScrollFix")}catch(t){console.log(t)}</script><script>document.onreadystatechange=function(){if("complete"==document.readyState){const{saveData:e,effectiveType:t}=navigator.connection||navigator.mozConnection||navigator.webkitConnection||{};("none"==getComputedStyle(document.querySelector("#safearea"),null).display||e||/2g/.test(t))&&(document.querySelectorAll(".reveal").forEach(function(e){e.style.opacity="1"}),document.querySelector("#safearea").style.display="block")}}</script></div><pjax> <a style="position:absolute;left:-9999px" target="_blank" rel="external nofollow noopener noreferrer" href="https://bot-trap.mhuig.top/">Are You A Robot?</a> <a style="position:absolute;left:-9999px" href="/post-sitemap.xml">站点文章地图</a> <a style="position:absolute;left:-9999px" href="/page-sitemap.xml">站点页面地图</a></pjax><script>(()=>{function t(){if("localhost:4000"!=window.location.host&&!/blog\.mhuig\.top/.test(window.location.host)){const t=document.createElement("meta");t.name="robots",t.content=atob("bm9pbmRleCwgbm9mb2xsb3csIG5vYXJjaGl2ZQ=="),document.head.appendChild(t)}}function o(){document.querySelector("figcaption")&&document.querySelectorAll("figcaption").forEach(t=>{volantis.dom.$(t).on("click",function(){const t=!window.CodeBlockFullscreen;window.CodeBlockFullscreen=t;const o=document.getElementById("post")||document.getElementById("docs")||document.getElementById("page");if(!o)return;const e=this.parentElement,n=e.parentElement,l=document.documentElement,c=document.querySelectorAll(".highlight > table .gutter");o.classList.toggle("code-block-fullscreen",t),e.classList.toggle("code-block-fullscreen",t),n.classList.toggle("code-block-fullscreen",t),e.classList.toggle("code-block-fullscreen-overflow-auto",t),l.classList.toggle("code-block-fullscreen-html-scroll",t),c.forEach(o=>{o.classList.toggle("code-block-fullscreen-gutter",t)})})})}t(),volantis.pjax.push(t),top.location!=self.location&&(top.location=self.location),"mhuig.github.io"==window.location.host||"localhost:4000"==window.location.host||/mhuig\.top$/.test(window.location.host)||/kix\.moe$/.test(window.location.host)||/mhuig/.test(window.location.host)||/ipfs/.test(window.location.host)||(window.location.href=atob("aHR0cHM6Ly9ibG9nLm1odWlnLnRvcC8=")),o(),volantis.pjax.push(o);const e=[{month:12,day:13},function(){const t=(new Date).getFullYear(),o=t%100,e=t>=2e3?4.81:5.59,n=Math.floor(o/4),l=Math.floor(.2422*o+e)-n;return{month:4,day:Math.max(4,l)}}(),{month:7,day:7},{month:9,day:18},{month:9,day:30}];function n(){document.documentElement.classList.remove("mourning-mode");if(!["/","/index.html","/index.htm","/index"].includes(window.location.pathname))return;const t=new Date,o=t.getMonth()+1,n=t.getDate();e.some(t=>t.month===o&&t.day===n)&&document.documentElement.classList.add("mourning-mode")}const l=document.createElement("style");l.textContent="\n      html.mourning-mode {\n        filter: grayscale(100%);\n        -webkit-filter: grayscale(100%);\n        transition: filter 0.5s ease;\n      }\n    ",document.head.appendChild(l),n(),document.addEventListener("pjax:complete",n)})()</script><pjax><script>function isSpider(){const e=navigator.userAgent.toLowerCase();return["Googlebot","Bingbot","BaiduSpider","360Spider","SogouSpider","YandexBot","DuckDuckBot","Baiduspider","Bytespider"].some(t=>e.includes(t.toLowerCase()))}function decodeShift(e,t=3){return[...e].map(e=>String.fromCharCode(e.charCodeAt(0)-t)).join("")}function autoWrapDash(e=document.body,t=!1){if("string"==typeof e&&(e=document.querySelector(e)),!e)return;const n="zh-dash",o=["——"];t&&o.push("--");const r=`\n    script,\n    style,\n    noscript,\n    textarea,\n    select,\n    option,\n    pre,\n    code,\n    .${n}\n  `,a=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,{acceptNode(e){const t=e.parentElement;if(!t)return NodeFilter.FILTER_REJECT;if(t.closest(r))return NodeFilter.FILTER_REJECT;const n=e.nodeValue;return o.some(e=>n.includes(e))?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_REJECT}}),c=[];for(;a.nextNode();)c.push(a.currentNode);c.forEach(e=>{const r=e.nodeValue,a=document.createDocumentFragment();let c=0;const i=o.map(e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("|"),u=new RegExp(i,"g");let l;for(;null!==(l=u.exec(r));){l.index>c&&a.appendChild(document.createTextNode(r.slice(c,l.index)));const e=document.createElement("span");e.className=n,t&&"--"===l[0]?e.textContent="——":e.textContent=l[0],a.appendChild(e),c=l.index+l[0].length}c<r.length&&a.appendChild(document.createTextNode(r.slice(c))),e.parentNode.replaceChild(a,e)})}!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).DevtoolsDetecter=t()}(this,function(){"use strict";function e(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}function t(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,o=new Array(t);n<t;n++)o[n]=e[n];return o}function n(e,n){var o="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!o){if(Array.isArray(e)||(o=function(e,n){if(e){if("string"==typeof e)return t(e,n);var o=Object.prototype.toString.call(e).slice(8,-1);return"Object"===o&&e.constructor&&(o=e.constructor.name),"Map"===o||"Set"===o?Array.from(e):"Arguments"===o||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(o)?t(e,n):void 0}}(e))||n&&e&&"number"==typeof e.length){o&&(e=o);var r=0,a=function(){};return{s:a,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:a}}throw new TypeError("d.")}var c,i=!0,u=!1;return{s:function(){o=o.call(e)},n:function(){var e=o.next();return i=e.done,e},e:function(e){u=!0,c=e},f:function(){try{i||null==o.return||o.return()}finally{if(u)throw c}}}}return function(){var t=!1,o=!1,r=!1,a=7e6,c=1e3,i=500,u=null,l=null,f=function(){return t||o},d=[],s=function(){var e,t=n(d);try{for(t.s();!(e=t.n()).done;){var o=e.value;try{o(f())}catch(e){}}}catch(e){t.e(e)}finally{t.f()}},p=function(e){if(r){var t=document.createElement("div");t.innerHTML="".concat(e,"<br>"),document.body.appendChild(t)}},m=console,y=Math,h=Int8Array,v=setInterval,g=Date,w=!1;"undefined"!=typeof performance&&(w=performance);var b=function(){return w?w.now():+new g},S=document.createElement("div");try{S.__defineGetter__("id",function(){o=!0,p("**"),s()})}catch(e){o=0}var T=function(){if(0!==o){o=!1,m.log(S);try{m.clear()}catch(e){}}},C=function(e){for(var t=0,n=0;n<e.length;n++)t+=e[n];return t/e.length},E=function(e,t){e.push(t),e.length>5&&e.shift()},k=function(){for(var e=b(),t=a,n=new h(t+1),o=2;o<=t;++o)if(0===n[o])for(var r=o*o;r<=t;r+=o)n[r]=1;return b()-e},x=[],I=[],j=[],D=-1,N=k(),A=N,F=N,L=function(){D++;var e=function(){for(var e=b(),t=0;t<c;t++){m.log||alert("Ha"),m.log(t);try{m.clear()}catch(e){}}return b()-e}();if(E(x,e),p(x),D&&D%5==0){var n=C(x),o=function(e){for(var t=C(e),n=0,o=0;o<e.length;o++)n+=y.pow(e[o]-t,2);return n/e.length}(x);E(I,n),E(j,o),p("=".concat(n,"e").concat(o,"")),n>A||n>.85*A&&o>F&&C([x[0],x[1],x[2]])<C([x[1],x[2],x[3]])&&C([x[1],x[2],x[3]])<C([x[2],x[3],x[4]])?(t=!0,p("**")):(t=!1,D>=25&&(A=y.min(5*C(I),N),F=y.min(5*C(j),N),p("==".concat(A," ").concat(F," "))))}_(),s()},_=function(){var e,n;t||"undefined"!=typeof eruda&&(!0===(null===(e=eruda)||void 0===e||null===(n=e._devTools)||void 0===n?void 0:n._isShow)?(t=!0,p("**")):t=!1)};return new(function(){function t(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t)}var n,o;return n=t,(o=[{key:"debug",value:function(){r=!0,p("ua: ".concat(navigator.userAgent)),p("hardwareConcurrency: ".concat(navigator.hardwareConcurrency));try{performance&&performance.memory&&(p("memory used: ".concat(performance.memory.usedJSHeapSize)),p("memory total: ".concat(performance.memory.totalJSHeapSize)),p("memory limit: ".concat(performance.memory.jsHeapSizeLimit)))}catch(e){}p("Benchmark: ".concat(N))}},{key:"getStatus",value:function(){return f()}},{key:"setBenchmarkMaxN",value:function(e){a=e}},{key:"setTimingSamplingMaxN",value:function(e){c=e}},{key:"setBenchmark",value:function(e){k=e}},{key:"setTimer",value:function(e){i=e}},{key:"addListener",value:function(e){d.push(e)}},{key:"launch",value:function(){u=v(L,i),l=v(T,i)}},{key:"stop",value:function(){clearInterval(u),clearInterval(l)}}])&&e(n.prototype,o),Object.defineProperty(n,"prototype",{writable:!1}),t}())}()}),DevtoolsDetecter.addListener(e=>{if(e){new Function(atob("Y29uc29sZS5jbGVhcigpOw=="))(),new Function('console.log(decodeShift("敷炼恹佟剪/云昲係刹佟争七亞exj敁圫远量"))')();for(let e in console)"function"==typeof console[e]&&(console[e]=()=>{});for(let e in window)"function"==typeof window[e]&&(window[e]=()=>{});setTimeout=clearTimeout=setInterval=clearInterval=()=>{},alert=confirm=prompt=()=>{},Object.defineProperty(window,"localStorage",{value:{getItem:()=>null,setItem:()=>{},removeItem:()=>{},clear:()=>{},key:()=>null},writable:!1}),Object.defineProperty(window,"sessionStorage",{value:{getItem:()=>null,setItem:()=>{},removeItem:()=>{},clear:()=>{},key:()=>null},writable:!1}),fetch=()=>Promise.reject("disabled"),XMLHttpRequest=function(){return{open(){},send(){},abort(){}}},document.querySelectorAll("script").forEach(e=>{e.remove()})}}),isSpider()||localStorage&&"k"==localStorage.getItem("k")||DevtoolsDetecter.launch(),autoWrapDash(document.body,!1),volantis.pjax.push(()=>{autoWrapDash(document.body,!1)},"autoWrapDash")</script></pjax></body></html>