<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Python on Hieu Phay</title><link>https://hieuphay.com/tags/python/</link><description>Recent content in Python on Hieu Phay</description><generator>Hugo</generator><language>en</language><managingEditor>Nguyen Duc Hieu</managingEditor><webMaster>Nguyen Duc Hieu</webMaster><lastBuildDate>Fri, 30 Oct 2020 00:00:00 +0000</lastBuildDate><atom:link href="https://hieuphay.com/tags/python/index.xml" rel="self" type="application/rss+xml"/><item><title>Batch translations via Google Translate</title><link>https://hieuphay.com/blog/2020-10-30_google-translation/</link><pubDate>Fri, 30 Oct 2020 00:00:00 +0000</pubDate><guid>https://hieuphay.com/blog/2020-10-30_google-translation/</guid><description>&lt;p&gt;Slightly related to my &lt;a href="https://hieuphay.com/blog/2020-10-01_python-polyglot-detect-and-tokenize/"&gt;previous post&lt;/a&gt;, one of my tasks today was to translate a list of keywords into different languages. The inputs I received generally looks something like below. There were many more, but I truncated the bulk of it to provide a simpler example:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;- Institutions: disputes, grievance, court, penal, judicial, prosecutorial, punishment, lawyer, attorney&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;- Infrastructure: railways, traffic, trucks, cars, vehicles, road, taxi, public transportation, port, logistics, collision, passenger&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;[...]&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="reshape-the-text-into-a-processible-format"&gt;&#10; Reshape the text into a processible format&#10; &lt;a class="heading-link" href="#reshape-the-text-into-a-processible-format" aria-labelledby="reshape-the-text-into-a-processible-format"&gt;&#10; &lt;i class="fa fa-link" aria-hidden="true"&gt;&lt;/i&gt;&#10; &lt;/a&gt;&#10;&lt;/h2&gt;&#10;&lt;p&gt;Firstly, I need to transform these texts into a better format. A good text editor certainly helps. I was able to quickly convert these texts into &lt;code&gt;csv&lt;/code&gt; format, using Emacs&amp;rsquo; macro functionality and Vi&amp;rsquo;s keybindings.&lt;/p&gt;</description></item><item><title>Notes on using Python for language detection and tokenization</title><link>https://hieuphay.com/blog/2020-10-01_python-polyglot-detect-and-tokenize/</link><pubDate>Thu, 01 Oct 2020 00:00:00 +0000</pubDate><guid>https://hieuphay.com/blog/2020-10-01_python-polyglot-detect-and-tokenize/</guid><description>&lt;p&gt;My upcoming works involves some text analysis so I&amp;rsquo;m exploring some of the available tools in Python. Today I tested some of the basic operations with the &lt;code&gt;polyglot&lt;/code&gt; package.&lt;/p&gt;&#10;&lt;h2 id="installation"&gt;&#10; Installation&#10; &lt;a class="heading-link" href="#installation" aria-labelledby="installation"&gt;&#10; &lt;i class="fa fa-link" aria-hidden="true"&gt;&lt;/i&gt;&#10; &lt;/a&gt;&#10;&lt;/h2&gt;&#10;&lt;p&gt;Following the &lt;a href="https://polyglot.readthedocs.io/en/latest/Installation.html"&gt;installation instructions&lt;/a&gt;, I install the dependencies for &lt;code&gt;polyglot&lt;/code&gt; on my Ubuntu 20.04 machine with:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-shell" data-lang="shell"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;sudo apt-get install python-numpy libicu-dev&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;But I still got an &lt;code&gt;ModuleNotFoundError&lt;/code&gt; for &lt;code&gt;icu&lt;/code&gt; when I try to import &lt;code&gt;polyglot&lt;/code&gt; in, so I fixed this by installing the module with &lt;code&gt;pip&lt;/code&gt;:&lt;/p&gt;</description></item></channel></rss>