<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<oembed>
  <author_name>hayataka2049</author_name>
  <author_url>https://blog.hatena.ne.jp/hayataka2049/</author_url>
  <blog_title>静かなる名辞</blog_title>
  <blog_url>https://hayataka2049.hatenablog.jp/</blog_url>
  <categories>
    <anon>python</anon>
    <anon>Tips</anon>
    <anon>ネタ・小ネタ</anon>
  </categories>
  <description>はじめに n-gramは自然言語処理でよく使われる方法です。n-gram - Wikipedia さて、以下のような関数を作りたいとします。 n_gram(&quot;abcde&quot;, n=2, sep=&quot;-&quot;) # [&quot;a-b&quot;, &quot;b-c&quot;, &quot;c-d&quot;, &quot;d-e&quot;] n=2ならbigram, n=3ならtrigramという言い方があります。さて、たとえばbigramなら以下のように書けます。 &gt;&gt;&gt; def bigram(seq, sep=&quot;-&quot;): ... return [sep.join(x) for x in zip(seq, seq[1:])] ... &gt;&gt;&gt; bigram(&quot;abcde&quot;…</description>
  <height>190</height>
  <html>&lt;iframe src=&quot;https://hatenablog-parts.com/embed?url=https%3A%2F%2Fhayataka2049.hatenablog.jp%2Fentry%2F2020%2F02%2F04%2F100957&quot; title=&quot;【python】zipを使ってn-gram列を生成する - 静かなる名辞&quot; class=&quot;embed-card embed-blogcard&quot; scrolling=&quot;no&quot; frameborder=&quot;0&quot; style=&quot;display: block; width: 100%; height: 190px; max-width: 500px; margin: 10px 0px;&quot;&gt;&lt;/iframe&gt;</html>
  <image_url></image_url>
  <provider_name>Hatena Blog</provider_name>
  <provider_url>https://hatena.blog</provider_url>
  <published>2020-02-04 10:09:57</published>
  <title>【python】zipを使ってn-gram列を生成する</title>
  <type>rich</type>
  <url>https://hayataka2049.hatenablog.jp/entry/2020/02/04/100957</url>
  <version>1.0</version>
  <width>100%</width>
</oembed>
