Skip to content

Commit 4dcf1e9

Browse files
committed
Site updated: 2020-02-08 11:02:27
1 parent 8f36d1e commit 4dcf1e9

File tree

16 files changed

+44
-307
lines changed

16 files changed

+44
-307
lines changed

Diff for: article/about/index.html

-19
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@
3131
<link rel="stylesheet" href="/css/f25.css">
3232
<link rel="stylesheet" href="/css/highlight.css">
3333

34-
<link rel="stylesheet" href="/css/gitalk.css">
35-
3634

3735
<!-- Global site tag (gtag.js) - Google Analytics -->
3836
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-147288599-1"></script>
@@ -120,22 +118,5 @@ <h4 id="公众号二维码"><a href="#公众号二维码" class="headerlink" tit
120118
</section>
121119
<script src="/js/f25.js"></script>
122120

123-
<script src="/js/gitalk.min.js"></script>
124-
125-
<script>
126-
var gitalkAdmin = 'xxg1413'.split(',');
127-
var gitalk = new Gitalk({
128-
clientID: 'd0e566bfc45c0b852c6c',
129-
clientSecret: '6b69b3a841c85a6223e5a904c47f5e2d84322980',
130-
repo: 'gitalk',
131-
owner: 'flypythoncom',
132-
admin: gitalkAdmin,
133-
id: location.pathname.length > 50 ? location.pathname.substr(0,50) : location.pathname, // Ensure uniqueness and length less than 50
134-
distractionFreeMode: false // Facebook-like distraction free mode
135-
});
136-
gitalk.render('gitalk-container');
137-
</script>
138-
139-
140121
</body>
141122
</html>

Diff for: article/python-class-01/index.html

-19
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@
3131
<link rel="stylesheet" href="/css/f25.css">
3232
<link rel="stylesheet" href="/css/highlight.css">
3333

34-
<link rel="stylesheet" href="/css/gitalk.css">
35-
3634

3735
<!-- Global site tag (gtag.js) - Google Analytics -->
3836
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-147288599-1"></script>
@@ -179,22 +177,5 @@ <h4 id="课程访问资源"><a href="#课程访问资源" class="headerlink" tit
179177
</section>
180178
<script src="/js/f25.js"></script>
181179

182-
<script src="/js/gitalk.min.js"></script>
183-
184-
<script>
185-
var gitalkAdmin = 'xxg1413'.split(',');
186-
var gitalk = new Gitalk({
187-
clientID: 'd0e566bfc45c0b852c6c',
188-
clientSecret: '6b69b3a841c85a6223e5a904c47f5e2d84322980',
189-
repo: 'gitalk',
190-
owner: 'flypythoncom',
191-
admin: gitalkAdmin,
192-
id: location.pathname.length > 50 ? location.pathname.substr(0,50) : location.pathname, // Ensure uniqueness and length less than 50
193-
distractionFreeMode: false // Facebook-like distraction free mode
194-
});
195-
gitalk.render('gitalk-container');
196-
</script>
197-
198-
199180
</body>
200181
</html>

Diff for: article/python-class-02/index.html

-19
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@
3131
<link rel="stylesheet" href="/css/f25.css">
3232
<link rel="stylesheet" href="/css/highlight.css">
3333

34-
<link rel="stylesheet" href="/css/gitalk.css">
35-
3634

3735
<!-- Global site tag (gtag.js) - Google Analytics -->
3836
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-147288599-1"></script>
@@ -147,22 +145,5 @@ <h4 id="解法"><a href="#解法" class="headerlink" title="解法"></a>解法</
147145
</section>
148146
<script src="/js/f25.js"></script>
149147

150-
<script src="/js/gitalk.min.js"></script>
151-
152-
<script>
153-
var gitalkAdmin = 'xxg1413'.split(',');
154-
var gitalk = new Gitalk({
155-
clientID: 'd0e566bfc45c0b852c6c',
156-
clientSecret: '6b69b3a841c85a6223e5a904c47f5e2d84322980',
157-
repo: 'gitalk',
158-
owner: 'flypythoncom',
159-
admin: gitalkAdmin,
160-
id: location.pathname.length > 50 ? location.pathname.substr(0,50) : location.pathname, // Ensure uniqueness and length less than 50
161-
distractionFreeMode: false // Facebook-like distraction free mode
162-
});
163-
gitalk.render('gitalk-container');
164-
</script>
165-
166-
167148
</body>
168149
</html>

Diff for: article/python-cs224n-01/index.html

-19
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@
3131
<link rel="stylesheet" href="/css/f25.css">
3232
<link rel="stylesheet" href="/css/highlight.css">
3333

34-
<link rel="stylesheet" href="/css/gitalk.css">
35-
3634

3735
<!-- Global site tag (gtag.js) - Google Analytics -->
3836
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-147288599-1"></script>
@@ -162,22 +160,5 @@ <h3 id="5-参考文献:"><a href="#5-参考文献:" class="headerlink" title
162160
</section>
163161
<script src="/js/f25.js"></script>
164162

165-
<script src="/js/gitalk.min.js"></script>
166-
167-
<script>
168-
var gitalkAdmin = 'xxg1413'.split(',');
169-
var gitalk = new Gitalk({
170-
clientID: 'd0e566bfc45c0b852c6c',
171-
clientSecret: '6b69b3a841c85a6223e5a904c47f5e2d84322980',
172-
repo: 'gitalk',
173-
owner: 'flypythoncom',
174-
admin: gitalkAdmin,
175-
id: location.pathname.length > 50 ? location.pathname.substr(0,50) : location.pathname, // Ensure uniqueness and length less than 50
176-
distractionFreeMode: false // Facebook-like distraction free mode
177-
});
178-
gitalk.render('gitalk-container');
179-
</script>
180-
181-
182163
</body>
183164
</html>

Diff for: article/python-cs224n-02/index.html

-19
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@
3131
<link rel="stylesheet" href="/css/f25.css">
3232
<link rel="stylesheet" href="/css/highlight.css">
3333

34-
<link rel="stylesheet" href="/css/gitalk.css">
35-
3634

3735
<!-- Global site tag (gtag.js) - Google Analytics -->
3836
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-147288599-1"></script>
@@ -155,22 +153,5 @@ <h3 id="3-如果U对应的词向量,那么V对应的是什么呢?"><a href="
155153
</section>
156154
<script src="/js/f25.js"></script>
157155

158-
<script src="/js/gitalk.min.js"></script>
159-
160-
<script>
161-
var gitalkAdmin = 'xxg1413'.split(',');
162-
var gitalk = new Gitalk({
163-
clientID: 'd0e566bfc45c0b852c6c',
164-
clientSecret: '6b69b3a841c85a6223e5a904c47f5e2d84322980',
165-
repo: 'gitalk',
166-
owner: 'flypythoncom',
167-
admin: gitalkAdmin,
168-
id: location.pathname.length > 50 ? location.pathname.substr(0,50) : location.pathname, // Ensure uniqueness and length less than 50
169-
distractionFreeMode: false // Facebook-like distraction free mode
170-
});
171-
gitalk.render('gitalk-container');
172-
</script>
173-
174-
175156
</body>
176157
</html>

Diff for: article/python-new-01/index.html

-19
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@
3131
<link rel="stylesheet" href="/css/f25.css">
3232
<link rel="stylesheet" href="/css/highlight.css">
3333

34-
<link rel="stylesheet" href="/css/gitalk.css">
35-
3634

3735
<!-- Global site tag (gtag.js) - Google Analytics -->
3836
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-147288599-1"></script>
@@ -167,22 +165,5 @@ <h4 id="参考"><a href="#参考" class="headerlink" title="参考"></a>参考</
167165
</section>
168166
<script src="/js/f25.js"></script>
169167

170-
<script src="/js/gitalk.min.js"></script>
171-
172-
<script>
173-
var gitalkAdmin = 'xxg1413'.split(',');
174-
var gitalk = new Gitalk({
175-
clientID: 'd0e566bfc45c0b852c6c',
176-
clientSecret: '6b69b3a841c85a6223e5a904c47f5e2d84322980',
177-
repo: 'gitalk',
178-
owner: 'flypythoncom',
179-
admin: gitalkAdmin,
180-
id: location.pathname.length > 50 ? location.pathname.substr(0,50) : location.pathname, // Ensure uniqueness and length less than 50
181-
distractionFreeMode: false // Facebook-like distraction free mode
182-
});
183-
gitalk.render('gitalk-container');
184-
</script>
185-
186-
187168
</body>
188169
</html>

Diff for: article/python-new-02/index.html

-19
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@
3131
<link rel="stylesheet" href="/css/f25.css">
3232
<link rel="stylesheet" href="/css/highlight.css">
3333

34-
<link rel="stylesheet" href="/css/gitalk.css">
35-
3634

3735
<!-- Global site tag (gtag.js) - Google Analytics -->
3836
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-147288599-1"></script>
@@ -144,22 +142,5 @@ <h4 id="参考"><a href="#参考" class="headerlink" title="参考"></a>参考</
144142
</section>
145143
<script src="/js/f25.js"></script>
146144

147-
<script src="/js/gitalk.min.js"></script>
148-
149-
<script>
150-
var gitalkAdmin = 'xxg1413'.split(',');
151-
var gitalk = new Gitalk({
152-
clientID: 'd0e566bfc45c0b852c6c',
153-
clientSecret: '6b69b3a841c85a6223e5a904c47f5e2d84322980',
154-
repo: 'gitalk',
155-
owner: 'flypythoncom',
156-
admin: gitalkAdmin,
157-
id: location.pathname.length > 50 ? location.pathname.substr(0,50) : location.pathname, // Ensure uniqueness and length less than 50
158-
distractionFreeMode: false // Facebook-like distraction free mode
159-
});
160-
gitalk.render('gitalk-container');
161-
</script>
162-
163-
164145
</body>
165146
</html>

Diff for: article/python-nlp-01/index.html

+44-22
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@
3131
<link rel="stylesheet" href="/css/f25.css">
3232
<link rel="stylesheet" href="/css/highlight.css">
3333

34-
<link rel="stylesheet" href="/css/gitalk.css">
35-
3634

3735
<!-- Global site tag (gtag.js) - Google Analytics -->
3836
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-147288599-1"></script>
@@ -111,10 +109,51 @@ <h2 id="0-摘要"><a href="#0-摘要" class="headerlink" title="0.摘要"></a>0.
111109
<li>编写python代码并运行</li>
112110
<li>展示词云结果</li>
113111
</ol>
114-
<h2 id="1-安装wordcloud"><a href="#1-安装wordcloud" class="headerlink" title="1.安装wordcloud"></a>1.安装wordcloud</h2><p>可以在cmd窗口输入<figure class="highlight plain"><figcaption><span>install wordcloud matplotlib```</span></figcaption><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br></pre></td><td class="code"><pre><span class="line"></span><br><span class="line">![](http://jcjview.github.io/img/wordcloud001.png)</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">## 2.准备红楼梦文本</span><br><span class="line"></span><br><span class="line">文本可以用下面链接下载</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">`https://github.com/flypythoncom/flypython/blob/master/wordcloud_hlm_seg.txt`</span><br><span class="line"></span><br><span class="line">或者可以自己写代码,对文本进行清洗,分词。</span><br><span class="line">这里需要安装jieba分词,`pip install jieba`</span><br><span class="line">``` python</span><br><span class="line">import jieba</span><br><span class="line">import re</span><br><span class="line"></span><br><span class="line">special_character_removal = re.compile(r&apos;[,。、【 】“”:;()《》‘’&#123;&#125;?!⑦%&gt;℃.^-——=&amp;#@¥『』]&apos;, re.IGNORECASE)</span><br><span class="line"></span><br><span class="line">fw=open(&quot;hlm_seg.txt&quot;,&quot;w&quot;,encoding=&quot;utf-8&quot;)</span><br><span class="line"></span><br><span class="line">with open(&apos;hlm.txt&apos;,encoding=&quot;utf-8&quot;) as fp:</span><br><span class="line"> for line in fp:</span><br><span class="line"> l = special_character_removal.sub(&apos;&apos;, line.strip())</span><br><span class="line"> words=jieba.cut(l)</span><br><span class="line"> t=&quot; &quot;.join(words)</span><br><span class="line"> fw.write(t)</span><br><span class="line"> fw.write(&quot;\n&quot;)</span><br><span class="line"> </span><br><span class="line">fw.close()</span><br></pre></td></tr></table></figure></p>
115-
<h2 id="3-编写词云python代码并运行"><a href="#3-编写词云python代码并运行" class="headerlink" title="3. 编写词云python代码并运行"></a>3. 编写词云python代码并运行</h2><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">from</span> os <span class="keyword">import</span> path </span><br><span class="line"><span class="keyword">from</span> wordcloud <span class="keyword">import</span> WordCloud</span><br><span class="line"></span><br><span class="line">d = path.dirname(__file__) </span><br><span class="line"><span class="comment"># Read the whole text. </span></span><br><span class="line">text = open(path.join(d, <span class="string">'hlm_seg.txt'</span>),encoding=<span class="string">"utf-8"</span>).read() </span><br><span class="line"><span class="comment"># Generate a word cloud image </span></span><br><span class="line"><span class="comment"># font=path.join(d, "simkai.ttf") </span></span><br><span class="line">font=<span class="string">'C:/Windows/Fonts/simkai.ttf'</span> </span><br><span class="line">wordcloud = WordCloud(font_path=font,<span class="comment">#设置中文字体,不指定就会出现中文不显示 </span></span><br><span class="line"> width=<span class="number">1024</span>,<span class="comment">#宽 </span></span><br><span class="line"> height=<span class="number">840</span>,<span class="comment">#高 </span></span><br><span class="line"> background_color=<span class="string">'white'</span>,<span class="comment">#设置背景色 </span></span><br><span class="line"> <span class="comment"># max_words=100,#最大词汇数 </span></span><br><span class="line"> <span class="comment"># max_font_size=100#最大号字体 </span></span><br><span class="line"> ).generate(text) </span><br><span class="line"> </span><br><span class="line"><span class="comment"># Display the generated image: </span></span><br><span class="line"><span class="comment"># the matplotlib way: </span></span><br><span class="line"><span class="keyword">import</span> matplotlib.pyplot <span class="keyword">as</span> plt </span><br><span class="line"> </span><br><span class="line">plt.figure() </span><br><span class="line">plt.imshow(wordcloud) </span><br><span class="line">plt.axis(<span class="string">"off"</span>) </span><br><span class="line">plt.show()</span><br></pre></td></tr></table></figure>
112+
<h2 id="1-安装wordcloud"><a href="#1-安装wordcloud" class="headerlink" title="1.安装wordcloud"></a>1.安装wordcloud</h2><p>可以在cmd窗口输入</p>
113+
<p><code>pip install wordcloud matplotlib</code></p>
114+
<p><img src="http://jcjview.github.io/img/wordcloud001.png" alt></p>
115+
<h2 id="2-准备红楼梦文本"><a href="#2-准备红楼梦文本" class="headerlink" title="2.准备红楼梦文本"></a>2.准备红楼梦文本</h2><p>文本可以用下面链接下载</p>
116+
<p><code>https://github.com/flypythoncom/flypython/blob/master/wordcloud_hlm_seg.txt</code></p>
117+
<p>或者可以自己写代码,对文本进行清洗,分词。<br>这里需要安装jieba分词,<code>pip install jieba</code></p>
118+
<pre><code>import jieba
119+
import re
120+
121+
special_character_removal = re.compile(r&apos;[,。、【 】“”:;()《》‘’{}?!⑦%&gt;℃.^-——=&amp;#@¥『』]&apos;, re.IGNORECASE)
122+
123+
fw=open(&quot;hlm_seg.txt&quot;,&quot;w&quot;,encoding=&quot;utf-8&quot;)
124+
125+
with open(&apos;hlm.txt&apos;,encoding=&quot;utf-8&quot;) as fp:
126+
for line in fp:
127+
l = special_character_removal.sub(&apos;&apos;, line.strip())
128+
words=jieba.cut(l)
129+
t=&quot; &quot;.join(words)
130+
fw.write(t)
131+
fw.write(&quot;\n&quot;)
132+
fw.close()</code></pre><h2 id="3-编写词云python代码并运行"><a href="#3-编写词云python代码并运行" class="headerlink" title="3. 编写词云python代码并运行"></a>3. 编写词云python代码并运行</h2><pre><code>from os import path
133+
from wordcloud import WordCloud
134+
135+
d = path.dirname(__file__)
136+
# Read the whole text.
137+
text = open(path.join(d, &apos;hlm_seg.txt&apos;),encoding=&quot;utf-8&quot;).read()
138+
# Generate a word cloud image
139+
# font=path.join(d, &quot;simkai.ttf&quot;)
140+
font=&apos;C:/Windows/Fonts/simkai.ttf&apos;
141+
wordcloud = WordCloud(font_path=font,#设置中文字体,不指定就会出现中文不显示
142+
width=1024,#宽
143+
height=840,#高
144+
background_color=&apos;white&apos;,#设置背景色
145+
# max_words=100,#最大词汇数
146+
# max_font_size=100#最大号字体
147+
).generate(text)
148+
149+
# Display the generated image:
150+
# the matplotlib way:
151+
import matplotlib.pyplot as plt
116152

117-
<p>结果:</p>
153+
plt.figure()
154+
plt.imshow(wordcloud)
155+
plt.axis(&quot;off&quot;)
156+
plt.show()</code></pre><p>结果:</p>
118157
<p><img src="http://jcjview.github.io/img/Figure_1.png" alt="词云运行结果"></p>
119158
<p>后台回复“词云”获得完整运行代码</p>
120159
<p><em>人生苦短,我用python早下班。如果觉得不错,对你工作中有帮助,请加我微信公众号flypython,我们一起探讨python相关问题</em></p>
@@ -136,22 +175,5 @@ <h2 id="3-编写词云python代码并运行"><a href="#3-编写词云python代
136175
</section>
137176
<script src="/js/f25.js"></script>
138177

139-
<script src="/js/gitalk.min.js"></script>
140-
141-
<script>
142-
var gitalkAdmin = 'xxg1413'.split(',');
143-
var gitalk = new Gitalk({
144-
clientID: 'd0e566bfc45c0b852c6c',
145-
clientSecret: '6b69b3a841c85a6223e5a904c47f5e2d84322980',
146-
repo: 'gitalk',
147-
owner: 'flypythoncom',
148-
admin: gitalkAdmin,
149-
id: location.pathname.length > 50 ? location.pathname.substr(0,50) : location.pathname, // Ensure uniqueness and length less than 50
150-
distractionFreeMode: false // Facebook-like distraction free mode
151-
});
152-
gitalk.render('gitalk-container');
153-
</script>
154-
155-
156178
</body>
157179
</html>

Diff for: article/python-oa-01/index.html

-19
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@
3131
<link rel="stylesheet" href="/css/f25.css">
3232
<link rel="stylesheet" href="/css/highlight.css">
3333

34-
<link rel="stylesheet" href="/css/gitalk.css">
35-
3634

3735
<!-- Global site tag (gtag.js) - Google Analytics -->
3836
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-147288599-1"></script>
@@ -153,22 +151,5 @@ <h2 id="1-安装xlwt"><a href="#1-安装xlwt" class="headerlink" title="1.安装
153151
</section>
154152
<script src="/js/f25.js"></script>
155153

156-
<script src="/js/gitalk.min.js"></script>
157-
158-
<script>
159-
var gitalkAdmin = 'xxg1413'.split(',');
160-
var gitalk = new Gitalk({
161-
clientID: 'd0e566bfc45c0b852c6c',
162-
clientSecret: '6b69b3a841c85a6223e5a904c47f5e2d84322980',
163-
repo: 'gitalk',
164-
owner: 'flypythoncom',
165-
admin: gitalkAdmin,
166-
id: location.pathname.length > 50 ? location.pathname.substr(0,50) : location.pathname, // Ensure uniqueness and length less than 50
167-
distractionFreeMode: false // Facebook-like distraction free mode
168-
});
169-
gitalk.render('gitalk-container');
170-
</script>
171-
172-
173154
</body>
174155
</html>

0 commit comments

Comments
 (0)