﻿<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>N blog</title>
	<atom:link href="http://blog.yanaoki.org/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.yanaoki.org</link>
	<description>たぶん5回目のチャレンジ</description>
	<lastBuildDate>Wed, 11 Jan 2012 12:08:40 +0000</lastBuildDate>
	<language>ja</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>DSPはあなたにとって何を意味する？  （和訳）</title>
		<link>http://blog.yanaoki.org/2012/01/05/what-does-demand-side-platform-mean-to-you/</link>
		<comments>http://blog.yanaoki.org/2012/01/05/what-does-demand-side-platform-mean-to-you/#comments</comments>
		<pubDate>Wed, 04 Jan 2012 18:39:03 +0000</pubDate>
		<dc:creator>yanaoki</dc:creator>
				<category><![CDATA[Advertising]]></category>

		<guid isPermaLink="false">http://blog.yanaoki.org/?p=361</guid>
		<description><![CDATA[http://www.adexchanger.com/one-question/what-does-demand-side-platform-mean-to-you/ 最近身近でちょっと話題だった記事を和訳しました。 What Does ‘Demand-Side Platform’ Mean To You? What does DSP (demand-side platform) mean to you? JG: Let me start by saying that one of the unfortunate things about ad technology is that we ruin words. I was in the middle of this before when I created the first ad exchange (AdECN) in 2004. [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.adexchanger.com/one-question/what-does-demand-side-platform-mean-to-you/" target="_blank">http://www.adexchanger.com/one-question/what-does-demand-side-platform-mean-to-you/</a></p>
<p>最近身近でちょっと話題だった記事を和訳しました。</p>
<blockquote>
<h3>What Does ‘Demand-Side Platform’ Mean To You?</h3>
<h4>What does DSP (demand-side platform) mean to you?</h4>
<p>JG: Let me start by saying that one of the unfortunate things about ad technology is that we ruin words. I was in the middle of this before when I created the first ad exchange (AdECN) in 2004. We went out into the world and said, &#8220;We&#8217;ve created an ad exchange and we&#8217;re fair, neutral and transparent &#8211; and we run an auction for every impression.&#8221;</p>
<p>Then suddenly, that idea took hold. Before I knew it, there was no longer any distinctions (at least in powerpoint) between ad networks and ad exchanges.  And nearly every ad network transformed into either an exchange or a marketplace, or something other than an ad network. The word “exchange” started to become diluted. We then had to open every sales conversation with, &#8220;Let me tell you about our type of exchange.&#8221; We would oscillate between saying, &#8220;Our competitors are not exchanges,&#8221; to &#8220;They&#8217;re a different kind of exchange.&#8221;</p>
<p>So, in 2012 it is now 2006 all over again, except that instead of us squabbling about the term &#8220;ad exchange,&#8221; we&#8217;re diluting the term DSP, which has come to mean something other than a demand-side platform. Instead it&#8217;s come to mean,  &#8220;I plug into RTB (real-time bidding) inventory and I get access to the exchanges.&#8221;</p>
<p>There are often a variety of business models built on top of that – such as arbitrage focused business that are operating on 50 percent margins and offering little transparency – which I would argue is a business model that is closer to an ad network.</p>
<p>I’d argue that more often than not, most so-called DSPs are an outsourced agency, or they are a new type of ad network. Some DSPs have more service layers than they do technology—and their margins, their staffing, and sales pitch certainly do not lead with “platform.”</p>
<p>Anyway, it is admittedly self-serving to make this statement, but we&#8217;re one of the few companies that can actually say we&#8217;re a platform. We are a demand-side platform, or a buy-side platform. In fact, we often refer to ourselves as a buyer&#8217;s platform just because we&#8217;re trying to distinguish ourselves from the term DSP, which has come to mean so many different things.</p>
<p>As a buyer&#8217;s platform, we operate transparently. We leave a gap in the stack so that agencies and ad networks create the service layer – and can create and protect our client’s proprietary advantage when they play on our platform. We are trying to be the ad tech company that powers other ad tech companies instead of trying to compete with them all, which is different.  Most DSPs are competing with ad networks and ad agencies.  We don’t compete with them; we power them.</p>
<p>&nbsp;</p></blockquote>
<h3>あなたにとってのDSPの意味とは？</h3>
<p>&nbsp;</p>
<p>私は広告技術に関する不幸なことの一つは、我々は言葉を台無しにすることであるということから始めてみましょう。私は2004年に最初のアドエクスチェンジ（AdECN）を作ろうとした時もそうだった。みんなは世界に向けてこう言った。</p>
<p>「私たちはアドエクスチェンジを始めます。それは公平で、中立で、透明です。そしてすべてのインプレッションに対してオークション方式です」。</p>
<p>そして突然、そのアイデアは保留しました。私がそれを知る前に、アドネットワークとアドエクスチェンジの間に区別は、(少なくともpowerpointの中では)ありませんでした。そして、ほとんどすべてのアドネットワークは、アドエクスチェンジかアドマーケットプレイス、またはそれ以外の何かに変わった。「アドエクスチェンジ」という単語は、薄まり始めました。そして私たちはセールスの度に、こんなこと言わなけれなりませんでした。</p>
<p>「私たちのアドエクスチェンジについてご紹介させてください。」</p>
<p>それで矛盾してくるだろう。</p>
<p>「私たちの競合はアドエクスチェンジではない」「彼らのアドエクスチェンジとは異なる」とか。</p>
<p>そう、2012年、それは2006年の再来です。「アドエクスチェンジ」について論争する代わりに、DSPという言葉の意味を曖昧にして、広告主サイドのプラットフォーム以外に以外の意味を持つようになってきました。私たちは用語DSPを曖昧にしています。それは需要側プラットフォーム以外にこのように意味されます。</p>
<p>「私はRTB (real-time bidding) でインベントリに接続します。そしてエクスチェンジにアクセスします。」</p>
<p>このように50％のマージンビジネスのようなモデルがよくある。私は、ほとんどのDSPは外注代理店、ある種のアドネットワークだと思う。そのDSPは、テクノロジー層よりも、サービス層を重要視していて、そのマージン率、人員配置、売り込み文句、、それは「プラットフォーム」としてリードすることはないでしょう。</p>
<p>我々は、「demand-side platform」または「buy-side platform」であるが、実際に、しばしば私たち自身を</p>
<p>「buyer&#8217;s platform」と呼びます。</p>
<p>理由としては、とても多くの異なったものを意味するようになってきた「DSP」という言葉から、自分たちを区別したいからです。</p>
<p>buyer&#8217;s platformとして、我々は透過的に動作します。代理店やアドネットワークは、サービス層を作成するような構造としている。我々のプラットフォームで動作させると、クライアントの独自の優位性を作成し、保護することができます 。私たちは、他社と競争しようとする代わりに、他のアドテクノロジー企業に動力を供給するようなアドテクノロジ企業であるとなろうとしています。そこが違います。ほとんどのDSPは広告ネットワークおよび広告代理店と競争していますが、私たちは競合しません。</p>
<p>私たちはそれらにパワーを与えます。</p>
<p>&nbsp;</p>
<blockquote><p>&nbsp;</p>
<h4>What&#8217;s your thought on Google&#8217;s position right now in the marketplace? Is it a fait accompli? Have they got it wrapped up?</h4>
<p>No, and I know at times I&#8217;ve somewhat been in the minority on this. It&#8217;s not that we shouldn&#8217;t keep our eye on Google, but display and search are different. People often want to apply what&#8217;s happened in search to display. It just can&#8217;t happen that way. The primary reason it can&#8217;t happen that way is that in search, Google is the publisher 75% of the time.  In display, they rarely are the publisher. The argument that people often make is that Google has millions of advertisers plugged into them on the demand side, and they&#8217;ve got millions of publishers on the supply side and, as a result, the display ecosystem is theirs to lose. Unfortunately, most of the volume doesn&#8217;t come from the long tail and they have to continue to pay well.</p>
<p>The Admeld acquisition I think was a brilliant move for Google. But there is also risk. If Google takes too much margin &#8211;which is what’s required in order to really move the needle for investors accustomed to the high margins Google makes in search &#8212; than those publishers will eventually end up at other ad exchanges.</p>
<p>If Google decides to subsidize the business and accept lower margins, they may be able to sustain what they have. But I don&#8217;t see Google ever having more display market share than they have today.   Every major publisher is going to fight against Google growing in display.</p>
<p>That said, I’d like to see some of the other could-be-competitors actually compete with Google.</p></blockquote>
<p>&nbsp;</p>
<h3>市場におけるグーグルの位置についてのあなたの考えは？もう勝ち組なの？</h3>
<p>いいえ。</p>
<p>サーチ業界とディスプレイ業界は異なります。人々はよく、検索業界で起こったことを、ディスプレイにも適用しようとします。でもそれは起こりえません。主な理由は、サーチではGoogleのシェアが75％であるということに対し、ディスプレイにでは彼ら稀にしかない。</p>
<p>よく皆が議論するのは、グーグルは何百万もの広告主とパブリッシャーを接続したことで、ディスプレイ広告のエコシステムは失われるということ。でも、そのほとんどのボリュームはロングテール部分ではないため、彼らは、払い続けなければなりません。</p>
<p>私が思うadmeld買収は、Googleのための華麗な動きだった。 しかし、リスクもあります。Googleがあまりにも多くのマージン（サーチで慣れている高いマージン）を取る場合 、パブリッシャーは他のアドエクスチェンジでそれを終了させるでしょう。Googleは低マージンを受け入れる必要があると判断した場合、彼らが持っているもの維持できる可能性があります。しかし、私は、グーグルが、それらが今日持つより多くのディスプレイ市場占有率を常に持つとは思えません。すべての主要なパブリッシャーははディスプレイで成長するグーグルとの争うことになるでしょう。</p>
<p>&nbsp;</p>
<p>（関連キーワード： ad teck / DSP/ ad exchange / RTB )</p>
<p>&nbsp;</p>
<div id="-chrome-auto-translate-plugin-dialog" style="opacity: 1 !important; background-image: initial !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: transparent !important; position: absolute !important; top: 0px; left: 0px; overflow-x: visible !important; overflow-y: visible !important; z-index: 999999 !important; text-align: left !important; display: none; padding: 0px !important; margin: 0px !important;">
<div style="max-width: 300px !important; color: #fafafa !important; opacity: 0.8 !important; border-color: #000000 !important; border-width: 0px !important; -webkit-border-radius: 10px !important; background-color: #363636 !important; font-size: 16px !important; padding: 8px !important; overflow: visible !important; background-image: -webkit-gradient(linear, left top, right bottom, color-stop(0%, #000), color-stop(50%, #363636), color-stop(100%, #000)); z-index: 999999 !important; text-align: left  !important;"></div>
<p><img style="position: absolute !important; z-index: -1 !important; right: 1px !important; top: -20px !important; cursor: pointer !important; -webkit-border-radius: 20px; background-color: rgba(200, 200, 200, 0.3) !important; padding: 3px 5px 0 !important; margin: 0 !important;" onclick="document.location.href='http://translate.google.com/';" src="http://www.google.com/uds/css/small-logo.png" alt="" /></p>
</div>
<div id="extensionsWeblioEjBx" style="position: absolute; z-index: 2147483647; left: 165px; top: 126px; display: none;"><iframe name="weblioExtensionsFrame" src="http://api.weblio.jp/act/quote/v_1_0/e/?q=side&amp;type=elarge&amp;opul=chrome-extension%3A%2F%2Foingodpdjohhkelnginmkagmkbplgema%2Foptions.html" frameborder="0" scrolling="no" width="320" height="205"></iframe></div>
<div id="extensionsWeblioEjBx" style="position: absolute; z-index: 2147483647; left: 165px; top: 126px; display: none;"><iframe name="weblioExtensionsFrame" src="http://api.weblio.jp/act/quote/v_1_0/e/?q=What%20does%20DSP%20(demand-side%20platform)%20mean%20to%20you%3F%0A&amp;type=elarge&amp;opul=chrome-extension%3A%2F%2Foingodpdjohhkelnginmkagmkbplgema%2Foptions.html" frameborder="0" scrolling="no" width="320" height="205"></iframe></div>
]]></content:encoded>
			<wfw:commentRss>http://blog.yanaoki.org/2012/01/05/what-does-demand-side-platform-mean-to-you/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Learn about online behavioral advertising, privacy, cookies, and how this all works! （NAIのリンク集）</title>
		<link>http://blog.yanaoki.org/2012/01/04/nai-intr/</link>
		<comments>http://blog.yanaoki.org/2012/01/04/nai-intr/#comments</comments>
		<pubDate>Tue, 03 Jan 2012 16:07:19 +0000</pubDate>
		<dc:creator>yanaoki</dc:creator>
				<category><![CDATA[Advertising]]></category>

		<guid isPermaLink="false">http://blog.yanaoki.org/?p=357</guid>
		<description><![CDATA[http://www.networkadvertising.org/managing/learn_more.asp &#160; Learn about online behavioral advertising, privacy, cookies, and how this all works! オンライン行動広告、プライバシー、クッキーそしてそれがどのように動くのか。 &#160; A way to support the websites and products you care about ウェブサイト、またあなたの関心がある製品のために &#160; Advertising supports most of the free content people enjoy viewing online. Allowing cookies and online advertising to personalize services to your browser can be a great [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.networkadvertising.org/managing/learn_more.asp">http://www.networkadvertising.org/managing/learn_more.asp</a></p>
<p>&nbsp;</p>
<h3>Learn about online behavioral advertising, privacy, cookies, and how this all works!</h3>
<p>オンライン行動広告、プライバシー、クッキーそしてそれがどのように動くのか。</p>
<p>&nbsp;</p>
<h4>A way to support the websites and products you care about</h4>
<p>ウェブサイト、またあなたの関心がある製品のために</p>
<p>&nbsp;</p>
<blockquote><p>Advertising supports most of the free content people enjoy viewing online.</p>
<p>Allowing cookies and online advertising to personalize services to your browser can be a great benefit to the websites you support, by helping them earn revenue.</p>
<p>It can also be a great benefit to you by helping ensure that you don&#8217;t see too much repetition or irrelevant advertising while you surf the web. To read more about the value of advertising, you can check out the following:</p>
<ul>
<li>The World Federation of Advertisers&#8217; website explaining the values of advertising: <a href="http://www.valueofadvertising.org/home.php">http://www.valueofadvertising.org/home.php</a></li>
<li>&#8220;Making ads more interesting,&#8221; from the Google Blog: <a href="http://googleblog.blogspot.com/">http://googleblog.blogspot.com/</a></li>
<li>&#8220;I am the Long Tail,&#8221; a video montage produced by the IAB (US) where the operators of small websites discuss why advertising is critical for their small businesses. It is available at <a href="http://iamthelongtail.com/">http://iamthelongtail.com/</a>.</li>
</ul>
</blockquote>
<p>&nbsp;</p>
<p>オンラインで楽しめるほとんどの無料コンテンツを支えるのは広告です。</p>
<p>クッキーを許可し、オンライン広告をパーソナライズ化を許することが、あなたが応援するウェブサイトが、収入を得るのを支援し大きな利益になるかもしれません。</p>
<p>さらに、それは、ウェブをサーフィンしている上で、あまりに繰り返されたり不適切だったりな広告を表示しないことを保証するので、あなたへの大きな利益でもあります。</p>
<p>広告の価値に関するさらなる情報はリンクをチェックしましょう。</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<h4>On Cookies</h4>
<p>クッキー</p>
<p>&nbsp;</p>
<blockquote><p>What are http cookies?How are they used? How can I control what cookies are set on my computer? This and much more, as you learn about cookies via the following links:</p>
<ul>
<li>The Interactive Advertising Bureau of Europe&#8217;s Cookie resources page: <a href="http://www.allaboutcookies.org/">http://www.allaboutcookies.org/</a></li>
<li>The Harvard Berkman Center&#8217;s Cookie Crumble Contest: <a href="http://cyber.law.harvard.edu/cookiecontest/">http://cyber.law.harvard.edu/cookiecontest/</a> (These videos are also available on the right panel of this page)</li>
<li>A simple description on Wikipedia: <a href="http://en.wikipedia.org/wiki/HTTP_cookie">http://en.wikipedia.org/wiki/HTTP_cookie</a></li>
</ul>
</blockquote>
<p>&nbsp;</p>
<p>HTTPクッキーとは何か。どのように使用されるのか？自分のコンピュータのクッキーをどのように制御できるか？クッキーに関してはリンクをチェック。</p>
<p>&nbsp;</p>
<h3>On Regulation, Self-Regulation &amp; Accountability</h3>
<p>レギュレーション、自己規制&amp;責任能力</p>
<p>&nbsp;</p>
<blockquote><p>Online privacy and behavioral advertising are hot topics! Read what regulators and business groups are thinking about these issues:</p>
<p>regulators</p>
<ul>
<li>The U.S. Federal Trade Commission has been actively discussing online privacy and behavioral advertising: <a href="http://ftc.gov/bcp/consumer.shtm">http://ftc.gov/bcp/consumer.shtm</a></li>
</ul>
<p>From business groups, technologists, and self-regulatory bodies:</p>
<ul>
<li>The NAI&#8217;s updated Self-Regulatory Code of Conduct for Online Behavioral Advertising: <a href="http://networkadvertising.org/">http://networkadvertising.org/</a></li>
<li>The IAB UK&#8217;s Good Practice Principles for Online Behavioural Advertising: <a href="http://www.iabuk.net/">http://www.iabuk.net/</a></li>
<li>Digital Advertising Alliance Consumer Information: <a href="http://www.aboutads.info/consumers">http://www.aboutads.info/consumers</a></li>
<li>ESRB&#8217;s privacy resources: <a href="http://www.esrb.org/privacy/resources.jsp">http://www.esrb.org/privacy/resources.jsp</a></li>
<li>CDT&#8217;s Guide to Behavioral Advertising: <a href="http://www.cdt.org/privacy/targeting/">http://www.cdt.org/privacy/targeting/</a></li>
<li>PrivacyChoice.org&#8217;s FAQ&#8217;s and choice plugin: <a href="http://privacychoice.org/">http://privacychoice.org/</a></li>
</ul>
<div></div>
<div></div>
</blockquote>
<div>
<p>オンライン・プライバシーおよび行動の広告は最新のトピックです!</p>
<p>どの規制者および企業集団がこれらの問題に関して考えているか読んでください。</p>
<p>&nbsp;</p>
<p>（関連キーワード： NAI, FTC, HTTPクッキー, iAB）</p>
</div>
<div id="-chrome-auto-translate-plugin-dialog" style="display: none; opacity: 1 !important; border-color: none !important; background: transparent !important; padding: 0 !important; margin: 0 !important; position: absolute !important; top: 0; left: 0; overflow: visible !important; z-index: 999999 !important; text-align: left !important;">
<div style="max-width: 300px !important; color: #fafafa !important; opacity: 0.8 !important; border-color: #000000 !important; border-width: 0px !important; -webkit-border-radius: 10px !important; background-color: #363636 !important; font-size: 16px !important; padding: 8px !important; overflow: visible !important; background-image: -webkit-gradient(linear, left top, right bottom, color-stop(0%, #000), color-stop(50%, #363636), color-stop(100%, #000)); z-index: 999999 !important; text-align: left  !important;"></div>
<p><img style="position: absolute !important; z-index: -1 !important; right: 1px !important; top: -20px !important; cursor: pointer !important; -webkit-border-radius: 20px; background-color: rgba(200, 200, 200, 0.3) !important; padding: 3px 5px 0 !important; margin: 0 !important;" onclick="document.location.href='http://translate.google.com/';" src="http://www.google.com/uds/css/small-logo.png" alt="" /></p>
</div>
<div id="extensionsWeblioEjBx" style="position: absolute; z-index: 2147483647; left: 86px; top: 1028px; display: none;"><iframe name="weblioExtensionsFrame" src="http://api.weblio.jp/act/quote/v_1_0/e/?q=On%20Cookies%0A&amp;type=elarge&amp;opul=chrome-extension%3A%2F%2Foingodpdjohhkelnginmkagmkbplgema%2Foptions.html" frameborder="0" scrolling="no" width="320" height="205"></iframe></div>
<div id="extensionsWeblioEjBx" style="position: absolute; z-index: 2147483647; left: 52px; top: 1005px; display: none;"><iframe name="weblioExtensionsFrame" src="http://api.weblio.jp/act/quote/v_1_0/e/?q=On%20Cookies%0A&amp;type=elarge&amp;opul=chrome-extension%3A%2F%2Foingodpdjohhkelnginmkagmkbplgema%2Foptions.html" frameborder="0" scrolling="no" width="320" height="205"></iframe></div>
]]></content:encoded>
			<wfw:commentRss>http://blog.yanaoki.org/2012/01/04/nai-intr/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>What are the best similarity search engines? （Quora和訳）</title>
		<link>http://blog.yanaoki.org/2012/01/03/qa-3/</link>
		<comments>http://blog.yanaoki.org/2012/01/03/qa-3/#comments</comments>
		<pubDate>Mon, 02 Jan 2012 15:24:44 +0000</pubDate>
		<dc:creator>yanaoki</dc:creator>
				<category><![CDATA[Datamining]]></category>

		<guid isPermaLink="false">http://blog.yanaoki.org/?p=352</guid>
		<description><![CDATA[http://www.quora.com/What-are-the-best-similarity-search-engines &#160; What are the best similarity search engines? 最も優れた類似検索エンジンは？ How do you find people with similar interests on the web (not limited to FB, Quora, LinkedIn), How do you find similar cars, music, videos, clothes, images, products, books (not only on Amazon), electronic parts, web sites, related academic papers, stocks, homes for sale, service [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.quora.com/What-are-the-best-similarity-search-engines">http://www.quora.com/What-are-the-best-similarity-search-engines</a></p>
<p>&nbsp;</p>
<h3>What are the best similarity search engines?</h3>
<p>最も優れた類似検索エンジンは？</p>
<blockquote><p>How do you find people with similar interests on the web (not limited to FB, Quora, LinkedIn), How do you find similar cars, music, videos, clothes, images, products, books (not only on Amazon), electronic parts, web sites, related academic papers, stocks, homes for sale, service providers etc</p></blockquote>
<p>あなたは、ウェブ上（FB、quora、LinkedInに限定されない）で似たような関心を持つ人々をどのように見つけるのですか 。<br />
またあなたは、同じような、車、音楽、ビデオ、洋服、画像、製品、書籍（だけではなくアマゾンで）、電子部品、ウェブサイト、関連する学術論文、株、売り家、サービスプロバイダー、をどのように見つけるのか。</p>
<p>&nbsp;</p>
<h3>回答1</h3>
<blockquote><p>You can cluster queries in user query logs to suggest similar queries. I suggest to look at Microsoft researcher Ji-Rong Wen work.</p>
<ul>
<li>Query Clustering Using User Logs- <a href="http://research.microsoft.com/en-us/um/people/jrwen/jrwen_files/publications/QC-TOIS.pdf">http://research.microsoft.com/en-us/um/people/jrwen/jrwen_files/publications/QC-TOIS.pdf</a></li>
<li>Query Clustering in the Web Context- <a href="http://research.microsoft.com/en-us/um/people/jrwen/jrwen_files/publications/QC-CIR.pdf">http://research.microsoft.com/en-us/um/people/jrwen/jrwen_files/publications/QC-CIR.pdf</a></li>
<li>Hierarchical Clustering of WWW Image Search Results Using Visual, Textual and Link Analysis- <a href="http://research.microsoft.com/en-us/um/people/jrwen/jrwen_files/publications/MM04.pdf">http://research.microsoft.com/en-us/um/people/jrwen/jrwen_files/publications/MM04.pdf</a></li>
<li>Query Clustering Using Content Words and User Feedback-</li>
<li>Clustering User Queries of a Search Engine- <a href="http://research.microsoft.com/en-us/um/people/jrwen/jrwen_files/publications/QC-WWW10.pdf">http://research.microsoft.com/en-us/um/people/jrwen/jrwen_files/publications/QC-WWW10.pdf</a></li>
</ul>
</blockquote>
<div></div>
<div>
<p>ユーザーのクエリによるクラスタクエリは、類似クエリを推薦する。 私はMicrosoftの研究者の論文をお勧めします。</p>
<p>&nbsp;</p>
<h3>回答2</h3>
<blockquote><p>I assume you are talking about similarity search of images.</p>
<p>Tineye</p>
<p>It is a popular image matching site (frequented by quizzers like me anyway). It checks for proper copies of images and its database has grown significantly since its launch.</p>
<p><a href="http://www.tineye.com/">http://www.tineye.com/</a></p>
<p>&nbsp;</p></blockquote>
<p>私はあなたの画像の類似検索について話していると仮定します。<br />
Tineye<br />
それは一般的なイメージのマッチングサイトです。 それは画像の適切なコピーをチェックし、そのデータベースは、ローンチ以降大幅に成長してきました。<br />
他のエンジンはあなたが入力したキーワードの少なくと少しは依存します。でも、これは私の知っている唯一の純粋な画像ベースの検索エンジンです。</p>
</div>
<div id="-chrome-auto-translate-plugin-dialog" style="opacity: 1 !important; background-image: initial !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: transparent !important; position: absolute !important; top: 0px; left: 0px; overflow-x: visible !important; overflow-y: visible !important; z-index: 999999 !important; text-align: left !important; display: none; background-position: initial initial !important; background-repeat: initial initial !important; padding: 0px !important; margin: 0px !important;">undefined</div>
]]></content:encoded>
			<wfw:commentRss>http://blog.yanaoki.org/2012/01/03/qa-3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>What is a good way to create an item-item similarity matrix for a recommendation engine where items aren&#8217;t actually rated by users, but rather &#8220;used&#8221;, &#8220;clicked&#8221;, &#8220;bought&#8221; or &#8220;played&#8221; by users? （Quora和訳）</title>
		<link>http://blog.yanaoki.org/2012/01/02/qa-2/</link>
		<comments>http://blog.yanaoki.org/2012/01/02/qa-2/#comments</comments>
		<pubDate>Mon, 02 Jan 2012 05:40:19 +0000</pubDate>
		<dc:creator>yanaoki</dc:creator>
				<category><![CDATA[Datamining]]></category>

		<guid isPermaLink="false">http://blog.yanaoki.org/?p=298</guid>
		<description><![CDATA[http://www.quora.com/What-is-a-good-way-to-create-an-item-item-similarity-matrix-for-a-recommendation-engine-where-items-arent-actually-rated-by-users-but-rather-used-clicked-bought-or-played-by-users What is a good way to create an item-item similarity matrix for a recommendation engine where items aren&#8217;t actually rated by users, but rather &#8220;used&#8221;, &#8220;clicked&#8221;, &#8220;bought&#8221; or &#8220;played&#8221; by users? ユーザーによる評価ではなく、ユーザーによって&#8221;クリック&#8221;、&#8221;使用&#8221;、&#8221;購入&#8221;、&#8221;プレイ&#8221;されたアイテムの場合で、 レコメンデーションエンジンのためのアイテムxアイテムの類似度行列を作成するための良い方法は何ですか？ &#160; &#160; This has to do with Collaborative Filtering. Looks like many algorithms assume users have given ratings for the items. [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.quora.com/What-is-a-good-way-to-create-an-item-item-similarity-matrix-for-a-recommendation-engine-where-items-arent-actually-rated-by-users-but-rather-used-clicked-bought-or-played-by-users" target="_blank">http://www.quora.com/What-is-a-good-way-to-create-an-item-item-similarity-matrix-for-a-recommendation-engine-where-items-arent-actually-rated-by-users-but-rather-used-clicked-bought-or-played-by-users</a></p>
<h4>What is a good way to create an item-item similarity matrix for a recommendation engine where items aren&#8217;t actually rated by users, but rather &#8220;used&#8221;, &#8220;clicked&#8221;, &#8220;bought&#8221; or &#8220;played&#8221; by users?</h4>
<p>ユーザーによる評価ではなく、ユーザーによって&#8221;クリック&#8221;、&#8221;使用&#8221;、&#8221;購入&#8221;、&#8221;プレイ&#8221;されたアイテムの場合で、<br />
レコメンデーションエンジンのためのアイテムxアイテムの類似度行列を作成するための良い方法は何ですか？</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<blockquote><p>This has to do with Collaborative Filtering. Looks like many algorithms assume users have given ratings for the items. I think there are countless scenarios where users do not &#8220;rate&#8221; an item on some scale, but their behavior provides a &#8220;rating&#8221; which is just as valuable. I&#8217;m looking to figure out how to calculate similarity between items in this scenario.</p></blockquote>
<p>協調フィルタリング関連の話です。<br />
多くのアルゴリズムは、ユーザーが項目の評価を与えていると仮定しています。<br />
私はユーザの行動で実際に&#8221;評価&#8221;をしない無数のシナリオがあると考えます。<br />
しかしユーザの行動は、実は価値のある&#8221;評価&#8221;をしています。<br />
私はこのシナリオで項目間の類似度を計算する方法知りたいと思ってます。</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<h4>回答1</h4>
<blockquote><p> I&#8217;ve been using the Jaccard Coefficient, and specifically, the Tanimoto Coefficient, both described at <a href="http://en.wikipedia.org/wiki/Jaccard_index" target="_blank">http://en.wikipedia.org/wiki/Jaccard_index</a> to calculate item-item similarity. They are both measures of overlap.</p>
<p>The formula is</p>
<p>AB / ( A + B &#8211; AB)</p>
<p>Where AB is the number of times both items were rated(bought) together, A is the number of times item A was bought, and B is the number of times item B was bought.</p>
<p>How I calculate this, in a map-reduce friendly way:<br />
For each user, generate all of the (itemA, itemB) pairs for all of the items bought, and then keep track of the number of occurrences of each item-item pair.</p>
<p>The hard part is determining AB for each item-item pair. Once you have that figured out, calculating the Tanimoto coefficient is easy(refer to formula).</p>
<p>Consider this simplified example:<br />
Customer A bought items 1, 2, and 3<br />
Customer B bought items 2, 3, 4, and 6<br />
Customer C bought items 1, 2 and 5</p>
<p>Items 1 and 2 would be considered most similar because they were bought together most often, compared to the number of times they were individually bought, and and thus their Jaccard score is .66. The AB would be 2 while A(item 1) = 2 and B(item2) = 3.</p>
<p>The similarity between items 3 and 6 would be 1 / (2 + 1 &#8211; 1), or .50 since they were bought together only once.</p>
<p>How you get the number of times (itemA/itemB) were bought together is up to you, my approach involved using python streaming so that I can run it on a hadoop cluster. I was inspired by Peter Skomoroch &#8216;s excellent article on similarity calculations using python streaming, found at</p>
<p><a href="http://aws.amazon.com/articles/2294">http://aws.amazon.com/articles/2294</a></p>
<p>I&#8217;m currently computing item-item similarity on about 10k items using over 3.5 million &#8216;purchase&#8217; records, and it runs in only a few minutes. When you generate the (item,item) pairs for each item in a user&#8217;s history, you will generate a LOT of data but then you can reduce this when you sum the counts of occurrences.</p>
<p>A white-paper on this can be found at <a href="http://www.infosci.cornell.edu/weblab/papers/Bank2008.pdf">http://www.infosci.cornell.edu/weblab/papers/Bank2008.pdf</a></p></blockquote>
<p>私はジャカール係数を使用しています、そしてまた谷本係数も関連します。それらのアイテム-アイテムの類似性を計算についてはwikipedia参照。</p>
<p>それらは両方ともオーバーラップの手段です。<br />
その計算式は、<br />
AB / ( A + B &#8211; AB)<br />
ここでABは、AB同時に購入された回数、AはAがく購入された回数、BはBが購入された回数です。<br />
私はこれを計算する方法として、MapReduceアルゴリズムに沿った方法として、</p>
<p>各ユーザーに対して、購入したアイテムのすべての「アイテム &#8211; アイテム」ペアを生成し、<br />
その後、各「アイテム &#8211; アイテム」ペアの出現回数を追跡する。</p>
<p>難しい部分は、各アイテム-アイテムペアのABを決定することである<br />
谷本係数を算出するのは簡単です。<br />
以下のシンプルな例：<br />
顧客Aは商品1,2,3を購入<br />
顧客Bは商品2,3,4,6を購入<br />
顧客Cは商品1,2,5を購入</p>
<p>&nbsp;</p>
<p>アイテム1と2は、彼らが購入した回数に対して、最も頻繁に一緒に購入されているため、最も類似していると見なす、<br />
ジャカールスコアは0.66である。AB=2、A=2、B=3。（これを上記の計算式に当てはめる）<br />
アイテム3と6は、一度だけ一緒に購入されており、ジャカールスコアは0.50。<br />
どのようにアイテムペアの同時購入回数を計算するか、pythonによるhadoop streamingのアプローチがあります。<br />
私は現在350万人以上&#8221;購入&#8221;レコードを使用して約10,000のアイテム対し、アイテム-アイテム類似度を計算しています。<br />
そしてそれはわずか数分で実行されます。<br />
あなたがユーザの購入履歴らアイテム-アイテムペアを生成するときに大量のデータを生成しますが、出現回数のカウントすることとで、それを集計します。</p>
<p>参考論文があります。<a href="http://www.infosci.cornell.edu/weblab/papers/Bank2008.pdf">http://www.infosci.cornell.edu/weblab/papers/Bank2008.pdf</a></p>
<h4>回答2</h4>
<blockquote><p>Perform cohort analysis on how much these different events lead to each other. Then you&#8217;ll be able to normalize the &#8220;downstream&#8221; likelihood (i.e., conditional probability) of events in relation to each other. For example, if 1 &#8220;clicked&#8221; event has .03 probability of leading to a &#8220;bought&#8221; event, now you can normalize to find the expected value of 1000 &#8220;clicked&#8221; events, in terms of &#8220;bought&#8221; outcomes.</p></blockquote>
<p>これらの異なる出来事がどれくらい互いヘ導くかについての同世代分析を行なってください。<br />
その後、互いに関しての出来事の「下流の」可能性(つまり条件付き確率)を標準化することができるでしょう。<br />
例えば、今、1つの「クリックされた」出来事が「買われた」出来事に結びつく.03の可能性を持っている場合、1000の「クリックされた」出来事の期待値を見つけるために「買われた」結果の点から標準化することができます。</p>
<p>&nbsp;</p>
<h4>回答3</h4>
<blockquote><p>I think you might be interested in looking at this paper:<br />
H. Yu, Y. Koren, C. Volinsky. Collaborative Filtering for Implicit Feedback Datasets. IEEE International Conference on Data Mining 2008.</p>
<p>http://research.yahoo.com/pub/2433</p>
<p>It includes a very thorough discussion of how to deal with implicit data (like clicks, views, etc); where, unlike ratings, you (a) don&#8217;t have negative feedback, and (b) the feedback you obtain can be used to measure the confidence you have that someone likes something, rather than their preference.<br />
They also give some detailed descriptions of algorithms for this kind of data, ranging from neighborhood to latent factor models.</p></blockquote>
<p>&nbsp;</p>
<p>私は、この論文を見ることに、あなたは興味を持っているかもしれないと思います:<br />
<a href="http://research.yahoo.com/pub/2433" target="_blank">http://research.yahoo.com/pub/2433</a></p>
<p>それは、暗黙のデータ(クリック、視界などのような)に対処する方法の非常に完全な議論を含んでいます;<br />
格付けと異なり、あなたが(a)ネガティブ・フィードバックを持たず、(b)得るフィードバックは、ユーザの好みではなく、誰かが何かを好きであることを測定するために使用することができます。<br />
さらに、近隣から潜在している因子モデルまで、この種のデータ用アルゴリズムのいくつかの詳細な記述もあります。</p>
<p>&nbsp;</p>
<h4>回答4</h4>
<blockquote><p>It&#8217;s entirely reasonable to map these behaviors to some scalar values &#8212; maybe a page view is &#8220;0.1&#8243;, a video play is &#8220;0.3&#8243; and a favorite is &#8220;1.0&#8243;. Then you can apply any technique that operates on rating values. Picking the right values is up to your domain and your intuition, though you could also use machine learning techniques to figure optimum weights even!</p></blockquote>
<p>いくつかのスカラー値にこれらの行動を割り当てることは完全に合理的です<br />
おそらく、ページビューは「0.1」です。ビデオ・プレーは「0.3」です。また、お気に入りは「1.0」です。<br />
その後、値の評価上で作動するあらゆる技術を適用することができます。</p>
<p>さらに、あなたは最適の重量を計算するために機械学習技術を使用することができましたが、正しい値を取ることはあなたの領域とあなたの直観 さえあります!</p>
<p>&nbsp;</p>
<h4>回答5</h4>
<blockquote><p>One way would be to have separate matrices for each type of action.<br />
You could interpolate the results from each to get your final output. Obviously &#8220;bought&#8221; would have a much higher weight than &#8220;clicked&#8221;&#8230; Instead of interpolation you could also use something like a backoff model.</p></blockquote>
<p>1つの方法は各タイプのアクション用の個別のマトリックスを持つことでしょう。<br />
最終産出物を得るために、各々の結果を設定します。<br />
「買われた」は、明らかに「クリックされた」よりはるかに高い重量を持つだろう&#8230;<br />
書き入れの代わりに、さらにbackoffモデルのようなものを使用することができました。</p>
<div id="-chrome-auto-translate-plugin-dialog" style="opacity: 1 !important; background-image: initial !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: transparent !important; position: absolute !important; top: 0px; left: 0px; overflow-x: visible !important; overflow-y: visible !important; z-index: 999999 !important; text-align: left !important; display: none; background-position: initial initial !important; background-repeat: initial initial !important; padding: 0px !important; margin: 0px !important;">
<div style="max-width: 300px !important; color: #fafafa !important; opacity: 0.8 !important; border-color: #000000 !important; border-width: 0px !important; -webkit-border-radius: 10px !important; background-color: #363636 !important; font-size: 16px !important; padding: 8px !important; overflow: visible !important; background-image: -webkit-gradient(linear, left top, right bottom, color-stop(0%, #000), color-stop(50%, #363636), color-stop(100%, #000)); z-index: 999999 !important; text-align: left  !important;"></div>
<p><img style="position: absolute !important; z-index: -1 !important; right: 1px !important; top: -20px !important; cursor: pointer !important; -webkit-border-radius: 20px; background-color: rgba(200, 200, 200, 0.3) !important; padding: 3px 5px 0 !important; margin: 0 !important;" onclick="document.location.href='http://translate.google.com/';" src="http://www.google.com/uds/css/small-logo.png" alt="" /></p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://blog.yanaoki.org/2012/01/02/qa-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How does one determine similarity between people online? （Quora和訳）</title>
		<link>http://blog.yanaoki.org/2012/01/01/qa-1/</link>
		<comments>http://blog.yanaoki.org/2012/01/01/qa-1/#comments</comments>
		<pubDate>Sat, 31 Dec 2011 16:11:46 +0000</pubDate>
		<dc:creator>yanaoki</dc:creator>
				<category><![CDATA[Datamining]]></category>

		<guid isPermaLink="false">http://blog.yanaoki.org/?p=287</guid>
		<description><![CDATA[http://www.quora.com/How-does-one-determine-similarity-between-people-online &#160; How does one determine similarity between people online? どのようにオンラインのユーザ間の類似度を決定するか？ How do you quantify similarities between people using shopping sites, social networks, Q&#38;A sites etc (e.g how do Netflix, Amazon, Paypal, Twitter, Linkedin, Facebook, Quora calculate user similarity/assign users into groups) どのようにショッピングサイト、ソーシャルネットワーク、QAサイトのユーザ間の類似度を定量化するか。 &#160; 回答１ &#160; Here are some educated guesses about what serves as [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.quora.com/How-does-one-determine-similarity-between-people-online">http://www.quora.com/How-does-one-determine-similarity-between-people-online</a></p>
<p>&nbsp;</p>
<h4>How does one determine similarity between people online?</h4>
<h4>どのようにオンラインのユーザ間の類似度を決定するか？</h4>
<blockquote><p>How do you quantify similarities between people using shopping sites, social networks, Q&amp;A sites etc (e.g how do Netflix, Amazon, Paypal, Twitter, Linkedin, Facebook, Quora calculate user similarity/assign users into groups)</p></blockquote>
<p>どのようにショッピングサイト、ソーシャルネットワーク、QAサイトのユーザ間の類似度を定量化するか。</p>
<p>&nbsp;</p>
<h4>回答１</h4>
<p>&nbsp;</p>
<blockquote><p>Here are some educated guesses about what serves as a basis for their work:</p>
<p>(1) Use vector models. For each user, look at the text he wrote.</p>
<p>Build a tf.idf vector. See <a href="http://en.wikipedia.org/wiki/TF_IDF">http://en.wikipedia.org/wiki/TF_IDF</a> for details.</p>
<p>Then compute the cosine between any two users.</p>
<p>You can supplement this with fancier Techniques such as LSI.</p>
<p>If you want to implement something such as similarity measure based on text, you can look at the</p>
<p>org.apache.lucene.search.similar package in Lucene (open source).</p>
<p>(2) Networking sites such as Facebook might simply look at how many friends you have in common and compute something like the Jaccard index .</p></blockquote>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>彼らの仕事の基礎について、いくつかの経験から推測は以下のとおりです。</p>
<p>（1）ベクトルモデルを使用してください。 ユーザーごとに、彼が書いたテキストをもとに。TF-IDFベクトルを構築します。</p>
<p>その後、任意の2つのユーザー間のコサインを計算します。</p>
<p>またLSIの等の凝ったテクニックこれを補完することができます。</p>
<p>このようなテキストに基づいて類似度として何かを実装する場合は、（オープンソースの）Luceneライブラリがあります。</p>
<p>（2）Facebookなどのネットワーキングサイトは、単にあなたが共通に持ってどのように多くの友人を見て、Jaccardインデックスのようなものを計算しているのかもしれない。</p>
<p>（関連キーワード： LSI / Jaccard Index ）</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<h4>回答２</h4>
<p>&nbsp;</p>
<blockquote><p>A good place to start is: Programming Collective Intelligence</p>
<p><a href="http://www.amazon.com/Programming-Collective-Intelligence-Building-Applications/dp/0596529325">http://www.amazon.com/Programming-Collective-Intelligence-Building-Applications/dp/0596529325</a></p>
<p>Whole books have been written on this area so answering it in a few words is not give anywhere near a full answer.</p>
<p>But if using the collaborative filtering approach, then find how many actions (e.g. products purchased, likes, friends) two people have in common. But to make it work well you have assign weights to the actions in common. The correlation value between two people is the sum of the weights of the actions. But the tricky part is assigning good weights to the actions. The weight has to be relative the two people, the cluster of the two people and the whole population.</p></blockquote>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>集合知プログラミングは入門には良い。</p>
<p>その領域についてこの本に書かれている。</p>
<p>しかし、協調フィルタリング手法を使用している場合は、その後二人が共通して持ってどのように多くのアクション（購入などの商品、好き、友人）を見つける。</p>
<p>しかしそれはあなたが共通のアクションに重みを割り当てるているうまく機能させるために。</p>
<p>二人の間の相関値は、アクションの重みの合計です。</p>
<p>しかし、トリッキーな部分はアクションに適切な重みを割り当てています。 重量は相対的な二人、二人のクラスタと全体の人口にする必要があります。</p>
<p>&nbsp;</p>
<h4>回答3</h4>
<div></div>
<blockquote><p>Recommendation mining is very useful to determine similarity between peoples using shopping sites, social networks and Q&amp;A sites on the basis of their likes, choices and on-line behavior</p>
<p>Some of popular recommendation engine are</p>
<ul>
<li>Apache mahout</li>
<li>Cofi</li>
<li><a href="http://lemire.me/fr/abstracts/TRD01.html">http://lemire.me/fr/abstracts/TRD01.html</a></li>
</ul>
<p>&nbsp;</p>
<p>You can also find similarity between in text posted by authors in Q&amp;A, social networks, blogs etc. For that you can try out following techniques</p>
<ul>
<li>Jaccard Index</li>
<li>Simrank</li>
<li>Vector space model with Cosine Similarity</li>
<li>Sorensen similarity index</li>
<li>BM25 Okapi model</li>
</ul>
</blockquote>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>レコメンドマイニングは、ショッピングサイト、ソーシャルネットワーク、Q&amp;Aを用いて人々の間の類似性を決定するために非常に便利です。</p>
<p>有名なレコマンドエンジンとしては以下があります。</p>
<ul>
<li>Apache Mahout</li>
<li>Cofi</li>
<li><a href="http://lemire.me/fr/abstracts/TRD01.html">http://lemire.me/fr/abstracts/TRD01.html</a></li>
</ul>
<p>また、Q&amp;A、ソーシャルネットワーク、ブログ等での、投稿者間の類似性を見つけることができます。</p>
<p>そのためには、次の方法を試してみることができます</p>
<ul>
<li>ジャッカード係数</li>
<li>Simrank</li>
<li>コサイン類似度によるベクトル空間モデル</li>
<li>Sorensen similarity index</li>
<li>BM25 Okapi model</li>
</ul>
<div></div>
<div></div>
<div>
<p>（関連キーワード： Jaccard Index / Simrank / Vector space model with Cosine Similarity / Sorensen similarity index / BM25 Okapi model ）</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<h4> 関連するQuoraのQA</h4>
<p>&nbsp;</p>
<ul>
<li> Twitterはどのようにして私に似たユーザを決定するか？</li>
<li>This is a follow-up question to &#8220;How does Twitter determine who is similar to me?&#8221;</li>
<li><a href="http://www.quora.com/How-does-Twitter-determine-who-is-similar-to-me">http://www.quora.com/How-does-Twitter-determine-who-is-similar-to-me</a></li>
</ul>
<p>&nbsp;</p>
<ul>
<li>Social Discovery: How do you find people with similar interests?</li>
<li>同じような興味を持つ人々をどのように見つけるのですか？</li>
<li><a href="http://www.quora.com/Social-Discovery/How-do-you-find-people-with-similar-interests">http://www.quora.com/Social-Discovery/How-do-you-find-people-with-similar-interests</a></li>
</ul>
<p>&nbsp;</p>
<ul>
<li>What are the best similarity search engines?</li>
<li>最も優れた類似検索エンジンは？</li>
<li><a href="http://www.quora.com/What-are-the-best-similarity-search-engines">http://www.quora.com/What-are-the-best-similarity-search-engines</a></li>
</ul>
<p>&nbsp;</p>
<ul>
<li>PeopleRank: What are some existing &#8220;PeopleRank&#8221; algorithms?</li>
<li>（Quoraが開発する）PeopleRankアルゴリズムとは何か？</li>
<li><a href="http://www.quora.com/PeopleRank/What-are-some-existing-PeopleRank-algorithms">http://www.quora.com/PeopleRank/What-are-some-existing-PeopleRank-algorithms</a></li>
</ul>
<p>&nbsp;</p>
<ul>
<li>Recommendation Engines: What are some good research papers and articles on recommendation systems and engines? Why?</li>
<li>レコメンドシステム・エンジンの良い研究論文と記事は何ですか？ なぜですか？</li>
<li><a href="http://www.quora.com/Recommendation-Engines/What-are-some-good-research-papers-and-articles-on-recommendation-systems-and-engines-Why">http://www.quora.com/Recommendation-Engines/What-are-some-good-research-papers-and-articles-on-recommendation-systems-and-engines-Why</a></li>
</ul>
<p>&nbsp;</p>
<ul>
<li>Recommendation Systems: Who are the best experts on designing recommendation systems?</li>
<li>レコメンドシステムを設計する上で最高の専門家は誰ですか？</li>
<li><a href="http://www.quora.com/Recommendation-Systems/Who-are-the-best-experts-on-designing-recommendation-systems">http://www.quora.com/Recommendation-Systems/Who-are-the-best-experts-on-designing-recommendation-systems</a></li>
</ul>
<p>&nbsp;</p>
<ul>
<li>How does Amazon&#8217;s collaborative-filtering recommendation engine work?</li>
<li><a href="http://www.quora.com/How-does-Amazons-collaborative-filtering-recommendation-engine-work">http://www.quora.com/How-does-Amazons-collaborative-filtering-recommendation-engine-work</a></li>
<li>Amazonの協調フィルタリングレコメンデーションエンジンの仕組みは？</li>
</ul>
<p>&nbsp;</p>
<ul>
<li>Recommendation Engines: What are some best of breed online recommendation engines (other than Hunch)?</li>
<li><a href="http://www.quora.com/Recommendation-Engines/What-are-some-best-of-breed-online-recommendation-engines-other-than-Hunch">http://www.quora.com/Recommendation-Engines/What-are-some-best-of-breed-online-recommendation-engines-other-than-Hunch</a></li>
<li>最高のオンラインリコメンデーションエンジンは何ですか？</li>
</ul>
<p>&nbsp;</p>
<ul>
<li>LinkedIn: How exactly does LinkedIn generate the &#8220;viewers of this profile also viewed&#8221; list of users?</li>
<li><a href="http://www.quora.com/LinkedIn/How-exactly-does-LinkedIn-generate-the-viewers-of-this-profile-also-viewed-list-of-users">http://www.quora.com/LinkedIn/How-exactly-does-LinkedIn-generate-the-viewers-of-this-profile-also-viewed-list-of-users</a></li>
<li>どのように正確にLinkedInはユーザーの「このプロファイルを見たユーザは他にここも見ています」リストを生成するのでしょうか？</li>
</ul>
<p>&nbsp;</p>
<ul>
<li>Netflix Prize: Is there any summary of top models for the Netflix prize?</li>
<li><a href="http://www.quora.com/Netflix-Prize/Is-there-any-summary-of-top-models-for-the-Netflix-prize">http://www.quora.com/Netflix-Prize/Is-there-any-summary-of-top-models-for-the-Netflix-prize</a></li>
<li>Netflixの最優秀のモデルのまとめはありますか？</li>
</ul>
<p>&nbsp;</p>
<div></div>
</div>
<div id="-chrome-auto-translate-plugin-dialog" style="opacity: 1 !important; background-image: initial !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: transparent !important; position: absolute !important; top: 0px; left: 0px; overflow-x: visible !important; overflow-y: visible !important; z-index: 999999 !important; text-align: left !important; display: none; background-position: initial initial !important; background-repeat: initial initial !important; padding: 0px !important; margin: 0px !important;">
<div style="max-width: 300px !important; color: #fafafa !important; opacity: 0.8 !important; border-color: #000000 !important; border-width: 0px !important; -webkit-border-radius: 10px !important; background-color: #363636 !important; font-size: 16px !important; padding: 8px !important; overflow: visible !important; background-image: -webkit-gradient(linear, left top, right bottom, color-stop(0%, #000), color-stop(50%, #363636), color-stop(100%, #000)); z-index: 999999 !important; text-align: left  !important;"></div>
<p><img style="position: absolute !important; z-index: -1 !important; right: 1px !important; top: -20px !important; cursor: pointer !important; -webkit-border-radius: 20px; background-color: rgba(200, 200, 200, 0.3) !important; padding: 3px 5px 0 !important; margin: 0 !important;" onclick="document.location.href='http://translate.google.com/';" src="http://www.google.com/uds/css/small-logo.png" alt="" /></p>
</div>
<div id="extensionsWeblioEjBx" style="position: absolute; z-index: 2147483647; left: 329px; top: 85px; display: none;"><iframe name="weblioExtensionsFrame" src="http://api.weblio.jp/act/quote/v_1_0/e/?q=online&amp;type=elarge&amp;opul=chrome-extension%3A%2F%2Foingodpdjohhkelnginmkagmkbplgema%2Foptions.html" frameborder="0" scrolling="no" width="320" height="205"></iframe></div>
]]></content:encoded>
			<wfw:commentRss>http://blog.yanaoki.org/2012/01/01/qa-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>TwitterのUser Streams APIを試してみた</title>
		<link>http://blog.yanaoki.org/2010/11/25/twitter_user_streams_api/</link>
		<comments>http://blog.yanaoki.org/2010/11/25/twitter_user_streams_api/#comments</comments>
		<pubDate>Thu, 25 Nov 2010 13:09:50 +0000</pubDate>
		<dc:creator>yanaoki</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Twitter]]></category>

		<guid isPermaLink="false">http://blog.yanaoki.org/?p=256</guid>
		<description><![CDATA[こんばんは。最近、積極的にTwitterのストリーミングAPIを利用している（と思われる）サービスが増えてきましたね。何やらおもしろしそうなので少し触ってみる事に。 Streaming APIとは The Twitter Streaming API allows high-throughput near-realtime access to various subsets of public and protected Twitter data. http://dev.twitter.com/pages/streaming_api Streaming API User Streams Site Streams (現在BETA) ストリーミング系のAPIには３種類あって、それぞれ用途が分かれています。詳しくは上記リンク先を＾＾ 本当はSite Streamsを使いたいのだけど現在BETA版で申請が必要で、申請したけどなかなかレスがこないこともあり、今回はUser Streamsを試しました。 User Streamsとは User Streams provides real-time updates of all data needed to update a desktop application display. http://dev.twitter.com/pages/user_streams User Streamsは、デスクトップアプリケーションの表示を更新するのに必要なすべてのデータをリアルタイムで提供してくれるAPIです。 すでにEchofonやTweetDeckではこのAPIに対応していて、とくにフォローが多い人はタイムラインが凄い勢いで流れていると思います。また、このAPIに対応することで、リプライの受信やメッセージの受信、ふぁぼられ、もちろんリツイートをリアルタイムに捕えることができます。 以下、サンプルコードです。自分のツイートへのふぁぼりとリツイート、また自分への言及をリアルタイムに表示します。 お試し起動 [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://blog.yanaoki.org/wp-content/uploads/2010/11/user_streams.jpg"><img src="http://blog.yanaoki.org/wp-content/uploads/2010/11/user_streams-300x235.jpg" alt="" title="user_streams" width="300" height="235" class="aligncenter size-medium wp-image-276" /></a></p>
<p>こんばんは。最近、積極的にTwitterのストリーミングAPIを利用している（と思われる）サービスが増えてきましたね。何やらおもしろしそうなので少し触ってみる事に。</p>
<h5>Streaming APIとは</h5>
<blockquote><p>The Twitter Streaming API allows high-throughput near-realtime access to various subsets of public and protected Twitter data.<br />
<a href="http://dev.twitter.com/pages/streaming_api" target="_blank">http://dev.twitter.com/pages/streaming_api</a></p></blockquote>
<ul>
<li>Streaming API</li>
<li>User Streams</li>
<li>Site Streams (現在BETA)</li>
</ul>
<p>ストリーミング系のAPIには３種類あって、それぞれ用途が分かれています。詳しくは上記リンク先を＾＾ 本当はSite Streamsを使いたいのだけど現在BETA版で申請が必要で、申請したけどなかなかレスがこないこともあり、今回はUser Streamsを試しました。</p>
<h5>User Streamsとは</h5>
<blockquote><p>User Streams provides real-time updates of all data needed to update a desktop application display.<br />
<a href="http://dev.twitter.com/pages/user_streams" target="_blank">http://dev.twitter.com/pages/user_streams</a><br />
<strong>User Streams</strong>は、デスクトップアプリケーションの表示を更新するのに必要なすべてのデータをリアルタイムで提供してくれるAPIです。
</p></blockquote>
<p>すでにEchofonやTweetDeckではこのAPIに対応していて、とくにフォローが多い人はタイムラインが凄い勢いで流れていると思います。また、このAPIに対応することで、リプライの受信やメッセージの受信、ふぁぼられ、もちろんリツイートを<strong>リアルタイムに捕えることができます</strong>。<br />
以下、サンプルコードです。自分のツイートへのふぁぼりとリツイート、また自分への言及をリアルタイムに表示します。</p>
<h5>お試し起動</h5>
<p>以下のコマンドで。停止はCtrl+C。</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="sh" style="font-family:monospace;"># ruby user_timeline.rb</pre></td></tr></table></div>

<h5>お試し実行結果</h5>
<p><a href="http://blog.yanaoki.org/wp-content/uploads/2010/11/user_streams.jpg"><img src="http://blog.yanaoki.org/wp-content/uploads/2010/11/user_streams-300x235.jpg" alt="" title="user_streams" width="300" height="235" class="aligncenter size-medium wp-image-276" /></a></p>
<h5>ソースコード（user_timeline.rb）</h5>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
</pre></td><td class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#008000; font-style:italic;"># -*- coding: utf-8 -*-</span>
&nbsp;
<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'rubygems'</span>
<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'net/https'</span>
<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'oauth'</span>
<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'cgi'</span>
<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'json'</span>
&nbsp;
CONSUMER_KEY = <span style="color:#996600;">&quot;XXXXXXXXXXXXX&quot;</span>
CONSUMER_SECRET = <span style="color:#996600;">&quot;XXXXXXXXXXXXX&quot;</span>
ACCESS_TOKEN        = <span style="color:#996600;">&quot;XXXXXXXXXXXXX&quot;</span>
ACCESS_TOKEN_SECRET = <span style="color:#996600;">&quot;XXXXXXXXXXXXX&quot;</span>
SCREEN_NAME = <span style="color:#996600;">&quot;yanaoki&quot;</span>
&nbsp;
consumer = <span style="color:#6666ff; font-weight:bold;">OAuth::Consumer</span>.<span style="color:#9900CC;">new</span><span style="color:#006600; font-weight:bold;">&#40;</span> CONSUMER_KEY, CONSUMER_SECRET, <span style="color:#ff3333; font-weight:bold;">:site</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">'http://twitter.com'</span><span style="color:#006600; font-weight:bold;">&#41;</span> 
access_token = <span style="color:#6666ff; font-weight:bold;">OAuth::AccessToken</span>.<span style="color:#9900CC;">new</span><span style="color:#006600; font-weight:bold;">&#40;</span> consumer, ACCESS_TOKEN, ACCESS_TOKEN_SECRET<span style="color:#006600; font-weight:bold;">&#41;</span>
&nbsp;
uri = <span style="color:#CC00FF; font-weight:bold;">URI</span>.<span style="color:#9900CC;">parse</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'https://userstream.twitter.com/2/user.json'</span><span style="color:#006600; font-weight:bold;">&#41;</span>
https = <span style="color:#6666ff; font-weight:bold;">Net::HTTP</span>.<span style="color:#9900CC;">new</span><span style="color:#006600; font-weight:bold;">&#40;</span>uri.<span style="color:#9900CC;">host</span>, uri.<span style="color:#9900CC;">port</span><span style="color:#006600; font-weight:bold;">&#41;</span>
https.<span style="color:#9900CC;">use_ssl</span> = <span style="color:#0000FF; font-weight:bold;">true</span>
https.<span style="color:#9900CC;">ca_file</span> = <span style="color:#996600;">'/path/to/ca.cert'</span> <span style="color:#008000; font-style:italic;"># path to certificate</span>
https.<span style="color:#9900CC;">verify_mode</span> = <span style="color:#6666ff; font-weight:bold;">OpenSSL::SSL::VERIFY_PEER</span>
https.<span style="color:#9900CC;">verify_depth</span> = <span style="color:#006666;">5</span>
https.<span style="color:#9900CC;">start</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>https<span style="color:#006600; font-weight:bold;">|</span>
  request = <span style="color:#6666ff; font-weight:bold;">Net::HTTP::Get</span>.<span style="color:#9900CC;">new</span><span style="color:#006600; font-weight:bold;">&#40;</span>uri.<span style="color:#9900CC;">request_uri</span><span style="color:#006600; font-weight:bold;">&#41;</span>
  request.<span style="color:#9900CC;">oauth</span>!<span style="color:#006600; font-weight:bold;">&#40;</span>https, consumer, access_token<span style="color:#006600; font-weight:bold;">&#41;</span>
  buf = <span style="color:#996600;">&quot;&quot;</span>
  https.<span style="color:#9900CC;">request</span><span style="color:#006600; font-weight:bold;">&#40;</span>request<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>response<span style="color:#006600; font-weight:bold;">|</span>
    response.<span style="color:#9900CC;">read_body</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>chunk<span style="color:#006600; font-weight:bold;">|</span>
      buf <span style="color:#006600; font-weight:bold;">&lt;&lt;</span> chunk
      <span style="color:#9966CC; font-weight:bold;">while</span> <span style="color:#006600; font-weight:bold;">&#40;</span>line = buf<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006600; font-weight:bold;">/</span>.<span style="color:#006600; font-weight:bold;">+</span>?<span style="color:#006600; font-weight:bold;">&#40;</span>\r\n<span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">+/</span>m<span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span> != <span style="color:#0000FF; font-weight:bold;">nil</span>
        <span style="color:#9966CC; font-weight:bold;">begin</span>
          buf.<span style="color:#CC0066; font-weight:bold;">sub!</span><span style="color:#006600; font-weight:bold;">&#40;</span>line,<span style="color:#996600;">&quot;&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
          line.<span style="color:#9900CC;">strip</span>!
          status = JSON.<span style="color:#9900CC;">parse</span><span style="color:#006600; font-weight:bold;">&#40;</span>line<span style="color:#006600; font-weight:bold;">&#41;</span>
          <span style="color:#008000; font-style:italic;"># mentions</span>
          <span style="color:#9966CC; font-weight:bold;">if</span> status<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">&quot;entities&quot;</span><span style="color:#006600; font-weight:bold;">&#93;</span> <span style="color:#9966CC; font-weight:bold;">and</span> status<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">&quot;entities&quot;</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">&quot;user_mentions&quot;</span><span style="color:#006600; font-weight:bold;">&#93;</span>
            <span style="color:#9966CC; font-weight:bold;">if</span> status<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">&quot;entities&quot;</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">&quot;user_mentions&quot;</span><span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#CC0066; font-weight:bold;">select</span><span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006600; font-weight:bold;">|</span>u<span style="color:#006600; font-weight:bold;">|</span> u<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">'screen_name'</span><span style="color:#006600; font-weight:bold;">&#93;</span> == SCREEN_NAME <span style="color:#006600; font-weight:bold;">&#125;</span>.<span style="color:#9900CC;">size</span> <span style="color:#006600; font-weight:bold;">&gt;</span> <span style="color:#006666;">0</span> 
              <span style="color:#CC0066; font-weight:bold;">puts</span> status<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">'text'</span><span style="color:#006600; font-weight:bold;">&#93;</span>
              <span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">&quot;mention from #{status['user']['screen_name']}(#{status['user']['id']})&quot;</span>
            <span style="color:#9966CC; font-weight:bold;">end</span>
          <span style="color:#9966CC; font-weight:bold;">end</span>
          <span style="color:#008000; font-style:italic;"># retweets</span>
          <span style="color:#9966CC; font-weight:bold;">if</span> status<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">'retweeted_status'</span><span style="color:#006600; font-weight:bold;">&#93;</span> <span style="color:#9966CC; font-weight:bold;">and</span> status<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">'retweeted_status'</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">'user'</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">'screen_name'</span><span style="color:#006600; font-weight:bold;">&#93;</span> == SCREEN_NAME
            <span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">&quot;#{status['retweeted_status']['text']}&quot;</span>
            <span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">&quot;retweeted by #{status['user']['screen_name']}(#{status['user']['id']})&quot;</span>
          <span style="color:#9966CC; font-weight:bold;">end</span>
          <span style="color:#008000; font-style:italic;"># favorites</span>
          <span style="color:#9966CC; font-weight:bold;">if</span> status<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">'event'</span><span style="color:#006600; font-weight:bold;">&#93;</span> == <span style="color:#996600;">'favorite'</span> <span style="color:#9966CC; font-weight:bold;">and</span> status<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">'source'</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">'screen_name'</span><span style="color:#006600; font-weight:bold;">&#93;</span> != SCREEN_NAME
            <span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">&quot;#{status['target_object']['text']}&quot;</span>
            <span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">&quot;favorited by #{status['source']['screen_name']}(#{status['source']['id']})&quot;</span>
          <span style="color:#9966CC; font-weight:bold;">end</span>
        <span style="color:#9966CC; font-weight:bold;">rescue</span>
          <span style="color:#008000; font-style:italic;"># TODO</span>
        <span style="color:#9966CC; font-weight:bold;">end</span>
      <span style="color:#9966CC; font-weight:bold;">end</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://blog.yanaoki.org/2010/11/25/twitter_user_streams_api/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>第７回データマイニング+WEB勉強会＠東京で発表してきた</title>
		<link>http://blog.yanaoki.org/2010/09/27/tokyowebmining7/</link>
		<comments>http://blog.yanaoki.org/2010/09/27/tokyowebmining7/#comments</comments>
		<pubDate>Mon, 27 Sep 2010 12:04:56 +0000</pubDate>
		<dc:creator>yanaoki</dc:creator>
				<category><![CDATA[Datamining]]></category>

		<guid isPermaLink="false">http://blog.yanaoki.org/?p=232</guid>
		<description><![CDATA[こんにちは。2010/09/26（日）、第７回データマイニング+WEB勉強会＠東京に参加してきました。 ATND http://atnd.org/events/8164 主催者@hamadakoichiさんによる勉強会まとめ（発表資料一覧／Togetter） http://d.hatena.ne.jp/hamadakoichi/20100926/p1 この勉強会の特徴について 双方向の議論が多く、参加者の多くの方が発言するのが大きな特徴です。またIT系以外の方が参加される異業種交流ができる貴重な勉強回の一つです。内容については「理論〜詳細な実装〜実務」と幅広いものとなってます。 開始時の自己紹介、終了時の振り返り、で少なくとも全員２回ずつ発言する必要がありますw 今回も会場を提供してくださったニフティ・エンジニアサポート様に感謝！また、次回の勉強会は11/14（日）開催予定です。 今回は発表しました 以下発表資料です。 はじめてでもわかるベイズ分類器 －基礎からMahout実装まで－ 機会学習も統計も素人ですが、素人なりに勉強した結果と、MahoutというHadoop（またはElastic MapReduce）上で動作する分類器の使い方を解説しています。ベイズ分類器の学習・評価データにはWikipediaのデータを利用してます。 参加者をまとめたホワイトボード 恒例の参加者一覧です。 プレゼン内で紹介した本とRubyのサンプルコード 「この本持っている人います？」の質問に７割近くの人が手を挙げたのが印象的でした。この「集合知プログラミング」の６章では、Pythonによるナイーブベイズ分類器の実装を解説していますが、それを私が使い慣れているRubyで実装してみました。 集合知プログラミング まず使い方から # 分類器生成 n = NaiveBayes.new # 学習 n.train&#40;'Nobody owns the water.','good'&#41; n.train&#40;'the quick rabbit jumps fences','good'&#41; n.train&#40;'buy pharmaceuticals now','bad'&#41; n.train&#40;'make quick money at the online casino','bad'&#41; n.train&#40;'the quick brown fox jumps','good'&#41; # 推定 puts n.classify&#40;&#34;quick rabbit&#34;,default=&#34;unknown&#34;&#41; [...]]]></description>
			<content:encoded><![CDATA[<p>こんにちは。2010/09/26（日）、第７回データマイニング+WEB勉強会＠東京に参加してきました。</p>
<ul>
<li>ATND <a href="http://atnd.org/events/8164">http://atnd.org/events/8164</a></li>
<li>主催者@hamadakoichiさんによる勉強会まとめ（発表資料一覧／Togetter） <a href="http://d.hatena.ne.jp/hamadakoichi/20100926/p1">http://d.hatena.ne.jp/hamadakoichi/20100926/p1</a></li>
</ul>
<h5>この勉強会の特徴について</h5>
<p>双方向の議論が多く、参加者の多くの方が発言するのが大きな特徴です。またIT系以外の方が参加される異業種交流ができる貴重な勉強回の一つです。内容については「理論〜詳細な実装〜実務」と幅広いものとなってます。<br />
開始時の自己紹介、終了時の振り返り、で少なくとも全員２回ずつ発言する必要がありますw<br />
今回も会場を提供してくださったニフティ・エンジニアサポート様に感謝！また、次回の勉強会は11/14（日）開催予定です。</p>
<h5>今回は発表しました</h5>
<p>以下発表資料です。</p>
<p style="text-align: center;"><a href="http://www.slideshare.net/yanaoki/mahout">はじめてでもわかるベイズ分類器 －基礎からMahout実装まで－</a><a href="http://b.hatena.ne.jp/entry/www.slideshare.net/yanaoki/mahout"><img src="http://b.hatena.ne.jp/entry/image/http://www.slideshare.net/yanaoki/mahout" alt="" border="0" /></a><br />
<iframe src="http://www.slideshare.net/slideshow/embed_code/5288490" width="450" height="375" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe><br/><br/></p>
<p>機会学習も統計も素人ですが、素人なりに勉強した結果と、MahoutというHadoop（またはElastic MapReduce）上で動作する分類器の使い方を解説しています。ベイズ分類器の学習・評価データにはWikipediaのデータを利用してます。</p>
<h5>参加者をまとめたホワイトボード</h5>
<p>恒例の参加者一覧です。<br />
<a href="http://blog.yanaoki.org/wp-content/uploads/2010/09/snapshot-1285587079.172453.jpg"><img class="aligncenter size-medium wp-image-233" title="snapshot-1285587079.172453" src="http://blog.yanaoki.org/wp-content/uploads/2010/09/snapshot-1285587079.172453-300x224.jpg" alt="" width="300" height="224" /></a></p>
<h5>プレゼン内で紹介した本とRubyのサンプルコード</h5>
<p>「この本持っている人います？」の質問に７割近くの人が手を挙げたのが印象的でした。この「集合知プログラミング」の６章では、Pythonによるナイーブベイズ分類器の実装を解説していますが、それを私が使い慣れているRubyで実装してみました。</p>
<p><a href="http://www.amazon.co.jp/%E9%9B%86%E5%90%88%E7%9F%A5%E3%83%97%E3%83%AD%E3%82%B0%E3%83%A9%E3%83%9F%E3%83%B3%E3%82%B0-Toby-Segaran/dp/4873113644%3FSubscriptionId%3DAKIAIOTURB6KPI7XZJKA%26tag%3Dnblog02e-22%26linkCode%3Dxm2%26camp%3D2025%26creative%3D165953%26creativeASIN%3D4873113644">集合知プログラミング</a><br />
<a href="http://www.amazon.co.jp/%E9%9B%86%E5%90%88%E7%9F%A5%E3%83%97%E3%83%AD%E3%82%B0%E3%83%A9%E3%83%9F%E3%83%B3%E3%82%B0-Toby-Segaran/dp/4873113644%3FSubscriptionId%3DAKIAIOTURB6KPI7XZJKA%26tag%3Dnblog02e-22%26linkCode%3Dxm2%26camp%3D2025%26creative%3D165953%26creativeASIN%3D4873113644"><img src="http://ecx.images-amazon.com/images/I/51FgSThMzVL._SL160_.jpg" alt="" /></a></p>
<p><strong>まず使い方から</strong></p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#008000; font-style:italic;"># 分類器生成</span>
n = NaiveBayes.<span style="color:#9900CC;">new</span>
<span style="color:#008000; font-style:italic;"># 学習</span>
n.<span style="color:#9900CC;">train</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'Nobody owns the water.'</span>,<span style="color:#996600;">'good'</span><span style="color:#006600; font-weight:bold;">&#41;</span>
n.<span style="color:#9900CC;">train</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'the quick rabbit jumps fences'</span>,<span style="color:#996600;">'good'</span><span style="color:#006600; font-weight:bold;">&#41;</span>
n.<span style="color:#9900CC;">train</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'buy pharmaceuticals now'</span>,<span style="color:#996600;">'bad'</span><span style="color:#006600; font-weight:bold;">&#41;</span>
n.<span style="color:#9900CC;">train</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'make quick money at the online casino'</span>,<span style="color:#996600;">'bad'</span><span style="color:#006600; font-weight:bold;">&#41;</span>
n.<span style="color:#9900CC;">train</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'the quick brown fox jumps'</span>,<span style="color:#996600;">'good'</span><span style="color:#006600; font-weight:bold;">&#41;</span>
<span style="color:#008000; font-style:italic;"># 推定</span>
<span style="color:#CC0066; font-weight:bold;">puts</span> n.<span style="color:#9900CC;">classify</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;quick rabbit&quot;</span>,default=<span style="color:#996600;">&quot;unknown&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
<span style="color:#CC0066; font-weight:bold;">puts</span> n.<span style="color:#9900CC;">classify</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;quick money&quot;</span>,default=<span style="color:#996600;">&quot;unknown&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
<span style="color:#008000; font-style:italic;"># 閾値を与える</span>
n.<span style="color:#9900CC;">setthreshold</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;bad&quot;</span>,<span style="color:#006666;">3.0</span><span style="color:#006600; font-weight:bold;">&#41;</span>
<span style="color:#008000; font-style:italic;"># 推定</span>
<span style="color:#CC0066; font-weight:bold;">puts</span> n.<span style="color:#9900CC;">classify</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;quick money&quot;</span>,default=<span style="color:#996600;">&quot;unknown&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span></pre></div></div>

<p><strong>分類器のコード</strong></p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#008000; font-style:italic;"># 特徴抽出クラス</span>
<span style="color:#9966CC; font-weight:bold;">class</span> GetWordFeature
  <span style="color:#9966CC; font-weight:bold;">def</span> get_feature<span style="color:#006600; font-weight:bold;">&#40;</span>doc<span style="color:#006600; font-weight:bold;">&#41;</span>
    words = doc.<span style="color:#CC0066; font-weight:bold;">split</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">' '</span><span style="color:#006600; font-weight:bold;">&#41;</span>
    words.<span style="color:#9900CC;">map</span><span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006600; font-weight:bold;">|</span>w<span style="color:#006600; font-weight:bold;">|</span> w.<span style="color:#9900CC;">downcase</span><span style="color:#006600; font-weight:bold;">&#125;</span>.<span style="color:#CC0066; font-weight:bold;">select</span><span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006600; font-weight:bold;">|</span>w<span style="color:#006600; font-weight:bold;">|</span> w.<span style="color:#9900CC;">length</span> <span style="color:#006600; font-weight:bold;">&amp;</span>lt; <span style="color:#006666;">20</span> <span style="color:#006600; font-weight:bold;">&amp;</span>amp;<span style="color:#006600; font-weight:bold;">&amp;</span>amp; w.<span style="color:#9900CC;">length</span> <span style="color:#006600; font-weight:bold;">&amp;</span>gt; <span style="color:#006666;">2</span> <span style="color:#006600; font-weight:bold;">&#125;</span>.<span style="color:#9900CC;">uniq</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
<span style="color:#008000; font-style:italic;"># 分類器の基底クラス</span>
<span style="color:#9966CC; font-weight:bold;">class</span> Classifier
  <span style="color:#9966CC; font-weight:bold;">def</span> initialize<span style="color:#006600; font-weight:bold;">&#40;</span>f<span style="color:#006600; font-weight:bold;">&#41;</span>
    <span style="color:#0066ff; font-weight:bold;">@fc</span>,@cc,@feature = <span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006600; font-weight:bold;">&#125;</span>,<span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006600; font-weight:bold;">&#125;</span>,f
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  <span style="color:#9966CC; font-weight:bold;">def</span> incf<span style="color:#006600; font-weight:bold;">&#40;</span>f,cat<span style="color:#006600; font-weight:bold;">&#41;</span>
    <span style="color:#0066ff; font-weight:bold;">@fc</span><span style="color:#006600; font-weight:bold;">&#91;</span>f<span style="color:#006600; font-weight:bold;">&#93;</span> <span style="color:#006600; font-weight:bold;">||</span>= <span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006600; font-weight:bold;">&#125;</span>
    <span style="color:#0066ff; font-weight:bold;">@fc</span><span style="color:#006600; font-weight:bold;">&#91;</span>f<span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#91;</span>cat<span style="color:#006600; font-weight:bold;">&#93;</span> <span style="color:#006600; font-weight:bold;">||</span>= <span style="color:#006666;">0.0</span>
    <span style="color:#0066ff; font-weight:bold;">@fc</span><span style="color:#006600; font-weight:bold;">&#91;</span>f<span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#91;</span>cat<span style="color:#006600; font-weight:bold;">&#93;</span> = <span style="color:#0066ff; font-weight:bold;">@fc</span><span style="color:#006600; font-weight:bold;">&#91;</span>f<span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#91;</span>cat<span style="color:#006600; font-weight:bold;">&#93;</span> <span style="color:#006600; font-weight:bold;">+</span> <span style="color:#006666;">1.0</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  <span style="color:#9966CC; font-weight:bold;">def</span> incc<span style="color:#006600; font-weight:bold;">&#40;</span>cat<span style="color:#006600; font-weight:bold;">&#41;</span>
    <span style="color:#0066ff; font-weight:bold;">@cc</span><span style="color:#006600; font-weight:bold;">&#91;</span>cat<span style="color:#006600; font-weight:bold;">&#93;</span> <span style="color:#006600; font-weight:bold;">||</span>= <span style="color:#006666;">0.0</span>
    <span style="color:#0066ff; font-weight:bold;">@cc</span><span style="color:#006600; font-weight:bold;">&#91;</span>cat<span style="color:#006600; font-weight:bold;">&#93;</span> = <span style="color:#0066ff; font-weight:bold;">@cc</span><span style="color:#006600; font-weight:bold;">&#91;</span>cat<span style="color:#006600; font-weight:bold;">&#93;</span> <span style="color:#006600; font-weight:bold;">+</span> <span style="color:#006666;">1.0</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  <span style="color:#9966CC; font-weight:bold;">def</span> fcount<span style="color:#006600; font-weight:bold;">&#40;</span>f,cat<span style="color:#006600; font-weight:bold;">&#41;</span>
    <span style="color:#0066ff; font-weight:bold;">@fc</span><span style="color:#006600; font-weight:bold;">&#91;</span>f<span style="color:#006600; font-weight:bold;">&#93;</span> <span style="color:#006600; font-weight:bold;">||</span>= <span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006600; font-weight:bold;">&#125;</span>
    <span style="color:#0066ff; font-weight:bold;">@fc</span><span style="color:#006600; font-weight:bold;">&#91;</span>f<span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#91;</span>cat<span style="color:#006600; font-weight:bold;">&#93;</span> <span style="color:#006600; font-weight:bold;">||</span>= <span style="color:#006666;">0.0</span>
    <span style="color:#0066ff; font-weight:bold;">@fc</span><span style="color:#006600; font-weight:bold;">&#91;</span>f<span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#91;</span>cat<span style="color:#006600; font-weight:bold;">&#93;</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  <span style="color:#9966CC; font-weight:bold;">def</span> catcount<span style="color:#006600; font-weight:bold;">&#40;</span>cat<span style="color:#006600; font-weight:bold;">&#41;</span>
    <span style="color:#0066ff; font-weight:bold;">@cc</span><span style="color:#006600; font-weight:bold;">&#91;</span>cat<span style="color:#006600; font-weight:bold;">&#93;</span> ? <span style="color:#0066ff; font-weight:bold;">@cc</span><span style="color:#006600; font-weight:bold;">&#91;</span>cat<span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#9900CC;">to_f</span> : <span style="color:#006666;">0.0</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  <span style="color:#9966CC; font-weight:bold;">def</span> totalcount
    sum = <span style="color:#006666;">0</span>
    <span style="color:#0066ff; font-weight:bold;">@cc</span>.<span style="color:#9900CC;">each_value</span> <span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006600; font-weight:bold;">|</span>value<span style="color:#006600; font-weight:bold;">|</span> sum <span style="color:#006600; font-weight:bold;">+</span>= value<span style="color:#006600; font-weight:bold;">&#125;</span>
    <span style="color:#0000FF; font-weight:bold;">return</span> sum
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  <span style="color:#9966CC; font-weight:bold;">def</span> categories
    <span style="color:#0066ff; font-weight:bold;">@cc</span>.<span style="color:#9900CC;">keys</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  <span style="color:#008000; font-style:italic;"># 条件付き確率 Pr(A|B)</span>
  <span style="color:#9966CC; font-weight:bold;">def</span> fprob<span style="color:#006600; font-weight:bold;">&#40;</span>f,cat<span style="color:#006600; font-weight:bold;">&#41;</span>
    <span style="color:#0000FF; font-weight:bold;">return</span> <span style="color:#006666;">0</span> <span style="color:#9966CC; font-weight:bold;">if</span> catcount<span style="color:#006600; font-weight:bold;">&#40;</span>cat<span style="color:#006600; font-weight:bold;">&#41;</span> == <span style="color:#006666;">0</span> <span style="color:#006600; font-weight:bold;">||</span> fcount<span style="color:#006600; font-weight:bold;">&#40;</span>f,cat<span style="color:#006600; font-weight:bold;">&#41;</span> == <span style="color:#0000FF; font-weight:bold;">nil</span>
    fcount<span style="color:#006600; font-weight:bold;">&#40;</span>f,cat<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">/</span> catcount<span style="color:#006600; font-weight:bold;">&#40;</span>cat<span style="color:#006600; font-weight:bold;">&#41;</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  <span style="color:#008000; font-style:italic;"># 重み付き確率</span>
  <span style="color:#9966CC; font-weight:bold;">def</span> weightedprob<span style="color:#006600; font-weight:bold;">&#40;</span>f, cat, weight=<span style="color:#006666;">1.0</span>, ap=<span style="color:#006666;">0.5</span><span style="color:#006600; font-weight:bold;">&#41;</span>
    <span style="color:#008000; font-style:italic;"># 通常の条件付き確率</span>
    basicprob = fprob<span style="color:#006600; font-weight:bold;">&#40;</span>f,cat<span style="color:#006600; font-weight:bold;">&#41;</span>
    <span style="color:#008000; font-style:italic;"># この特徴がすべてのカテゴリ中に存在する確率</span>
    totals = <span style="color:#006666;">0</span>
    categories.<span style="color:#9900CC;">each</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>c<span style="color:#006600; font-weight:bold;">|</span>
      totals = totals <span style="color:#006600; font-weight:bold;">+</span> fcount<span style="color:#006600; font-weight:bold;">&#40;</span>f,c<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#9966CC; font-weight:bold;">if</span> fcount<span style="color:#006600; font-weight:bold;">&#40;</span>f,c<span style="color:#006600; font-weight:bold;">&#41;</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
    <span style="color:#008000; font-style:italic;"># 重み付けした平均計算</span>
    <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#40;</span>weight<span style="color:#006600; font-weight:bold;">*</span>ap<span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">+</span><span style="color:#006600; font-weight:bold;">&#40;</span>totals<span style="color:#006600; font-weight:bold;">*</span>basicprob<span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">/</span> <span style="color:#006600; font-weight:bold;">&#40;</span>weight<span style="color:#006600; font-weight:bold;">+</span>totals<span style="color:#006600; font-weight:bold;">&#41;</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  <span style="color:#9966CC; font-weight:bold;">def</span> train<span style="color:#006600; font-weight:bold;">&#40;</span>item, cat<span style="color:#006600; font-weight:bold;">&#41;</span>
    features =  <span style="color:#0066ff; font-weight:bold;">@feature</span>.<span style="color:#9900CC;">get_feature</span><span style="color:#006600; font-weight:bold;">&#40;</span>item<span style="color:#006600; font-weight:bold;">&#41;</span>;
    features.<span style="color:#9900CC;">each</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>f<span style="color:#006600; font-weight:bold;">|</span>
      incf<span style="color:#006600; font-weight:bold;">&#40;</span>f, cat<span style="color:#006600; font-weight:bold;">&#41;</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
    incc<span style="color:#006600; font-weight:bold;">&#40;</span>cat<span style="color:#006600; font-weight:bold;">&#41;</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
<span style="color:#008000; font-style:italic;">#　単純ベイズ分類器</span>
<span style="color:#9966CC; font-weight:bold;">class</span> NaiveBayes <span style="color:#006600; font-weight:bold;">&amp;</span>lt; Classifier
  <span style="color:#9966CC; font-weight:bold;">def</span> initialize
    <span style="color:#9966CC; font-weight:bold;">super</span><span style="color:#006600; font-weight:bold;">&#40;</span>GetWordFeature.<span style="color:#9900CC;">new</span><span style="color:#006600; font-weight:bold;">&#41;</span>
    <span style="color:#0066ff; font-weight:bold;">@thresholds</span> = <span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006600; font-weight:bold;">&#125;</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  <span style="color:#008000; font-style:italic;"># P(B|A):アイテム全体の与えられたカテゴリでの確率を求める（掛け合わせる）</span>
  <span style="color:#9966CC; font-weight:bold;">def</span> docprob<span style="color:#006600; font-weight:bold;">&#40;</span>item,cat<span style="color:#006600; font-weight:bold;">&#41;</span>
    features = <span style="color:#0066ff; font-weight:bold;">@feature</span>.<span style="color:#9900CC;">get_feature</span><span style="color:#006600; font-weight:bold;">&#40;</span>item<span style="color:#006600; font-weight:bold;">&#41;</span>
    <span style="color:#CC0066; font-weight:bold;">p</span> = <span style="color:#006666;">1.0</span>
    features.<span style="color:#9900CC;">each</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>f<span style="color:#006600; font-weight:bold;">|</span>
      ep = weightedprob<span style="color:#006600; font-weight:bold;">&#40;</span>f,cat<span style="color:#006600; font-weight:bold;">&#41;</span>
      <span style="color:#CC0066; font-weight:bold;">p</span> = <span style="color:#CC0066; font-weight:bold;">p</span> <span style="color:#006600; font-weight:bold;">*</span> ep
    <span style="color:#9966CC; font-weight:bold;">end</span>
    <span style="color:#0000FF; font-weight:bold;">return</span> <span style="color:#CC0066; font-weight:bold;">p</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  <span style="color:#9966CC; font-weight:bold;">def</span> prob<span style="color:#006600; font-weight:bold;">&#40;</span>item,cat<span style="color:#006600; font-weight:bold;">&#41;</span>
    catprob = catcount<span style="color:#006600; font-weight:bold;">&#40;</span>cat<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">/</span> totalcount
    docprob = docprob<span style="color:#006600; font-weight:bold;">&#40;</span>item,cat<span style="color:#006600; font-weight:bold;">&#41;</span>
    <span style="color:#0000FF; font-weight:bold;">return</span> docprob <span style="color:#006600; font-weight:bold;">*</span> catprob
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  <span style="color:#9966CC; font-weight:bold;">def</span> setthreshold<span style="color:#006600; font-weight:bold;">&#40;</span>cat,t<span style="color:#006600; font-weight:bold;">&#41;</span>
    <span style="color:#0066ff; font-weight:bold;">@thresholds</span><span style="color:#006600; font-weight:bold;">&#91;</span>cat<span style="color:#006600; font-weight:bold;">&#93;</span> = t
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  <span style="color:#9966CC; font-weight:bold;">def</span> getthreshold<span style="color:#006600; font-weight:bold;">&#40;</span>cat<span style="color:#006600; font-weight:bold;">&#41;</span>
    <span style="color:#0066ff; font-weight:bold;">@thresholds</span><span style="color:#006600; font-weight:bold;">&#91;</span>cat<span style="color:#006600; font-weight:bold;">&#93;</span> <span style="color:#006600; font-weight:bold;">||</span> <span style="color:#006666;">1.0</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  <span style="color:#9966CC; font-weight:bold;">def</span> classify<span style="color:#006600; font-weight:bold;">&#40;</span>item, default=<span style="color:#0000FF; font-weight:bold;">nil</span><span style="color:#006600; font-weight:bold;">&#41;</span>
    probs,max,best = <span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006600; font-weight:bold;">&#125;</span>,<span style="color:#006666;">0.0</span>,<span style="color:#0000FF; font-weight:bold;">nil</span>
    categories.<span style="color:#9900CC;">each</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>c<span style="color:#006600; font-weight:bold;">|</span>
      probs<span style="color:#006600; font-weight:bold;">&#91;</span>c<span style="color:#006600; font-weight:bold;">&#93;</span> = prob<span style="color:#006600; font-weight:bold;">&#40;</span>item,c<span style="color:#006600; font-weight:bold;">&#41;</span>
      <span style="color:#9966CC; font-weight:bold;">if</span> probs<span style="color:#006600; font-weight:bold;">&#91;</span>c<span style="color:#006600; font-weight:bold;">&#93;</span> <span style="color:#006600; font-weight:bold;">&amp;</span>gt; max
        max = probs<span style="color:#006600; font-weight:bold;">&#91;</span>c<span style="color:#006600; font-weight:bold;">&#93;</span>
        best = c
      <span style="color:#9966CC; font-weight:bold;">end</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
    probs.<span style="color:#9900CC;">each_key</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>c<span style="color:#006600; font-weight:bold;">|</span>
      <span style="color:#008000; font-style:italic;"># (2番目に確率の高いもの * 閾値)と比較</span>
      second = probs<span style="color:#006600; font-weight:bold;">&#91;</span>c<span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#9900CC;">to_f</span> <span style="color:#006600; font-weight:bold;">*</span> getthreshold<span style="color:#006600; font-weight:bold;">&#40;</span>best<span style="color:#006600; font-weight:bold;">&#41;</span>
      <span style="color:#0000FF; font-weight:bold;">return</span> default <span style="color:#9966CC; font-weight:bold;">if</span> second <span style="color:#006600; font-weight:bold;">&amp;</span>gt; probs<span style="color:#006600; font-weight:bold;">&#91;</span>best<span style="color:#006600; font-weight:bold;">&#93;</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
    <span style="color:#0000FF; font-weight:bold;">return</span> best
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>以上です！</p>
<div id="-chrome-auto-translate-plugin-dialog" style="display: none; opacity: 1 !important; border-color: none !important; background: transparent !important; padding: 0 !important; margin: 0 !important; position: absolute !important; top: 0; left: 0; overflow: visible !important; z-index: 999999 !important; text-align: left !important;">
<div style="max-width: 300px !important; color: #fafafa !important; opacity: 0.8 !important; border-color: #000000 !important; border-width: 0px !important; -webkit-border-radius: 10px !important; background-color: #363636 !important; font-size: 16px !important; padding: 8px !important; overflow: visible !important; background-image: -webkit-gradient(linear, left top, right bottom, color-stop(0%, #000), color-stop(50%, #363636), color-stop(100%, #000)); z-index: 999999 !important; text-align: left  !important;"></div>
<p><img style="position: absolute !important; z-index: -1 !important; right: 1px !important; top: -20px !important; cursor: pointer !important; -webkit-border-radius: 20px; background-color: rgba(200, 200, 200, 0.3) !important; padding: 3px 5px 0 !important; margin: 0 !important;" onclick="document.location.href='http://translate.google.com/';" src="http://www.google.com/uds/css/small-logo.png" alt="" /></div>
]]></content:encoded>
			<wfw:commentRss>http://blog.yanaoki.org/2010/09/27/tokyowebmining7/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ブログにmixiチェックボタンを設置してみた</title>
		<link>http://blog.yanaoki.org/2010/09/10/mixi_plugin/</link>
		<comments>http://blog.yanaoki.org/2010/09/10/mixi_plugin/#comments</comments>
		<pubDate>Fri, 10 Sep 2010 08:26:31 +0000</pubDate>
		<dc:creator>yanaoki</dc:creator>
				<category><![CDATA[未分類]]></category>

		<guid isPermaLink="false">http://blog.yanaoki.org/?p=218</guid>
		<description><![CDATA[こんにちは。 mixiチェックボタン、本当に簡単に設置できました！ さきほど「mixi meetup 2010」にて発表があったmixiチェックボタンをさっそくブログのに貼り付けてみました。 個人ブログに簡単に導入するための便利プラグインがmixiエンジニアblogにて提供されていたのでそれを使いました。 mixi Pluginとは mixiチェックのWordpress &#38; Movable Typeプラグイン公開 このページに貼り付けてもあまり意味はないのだが、商品ページやニュース記事ページなど、集客を目的とするページでの設置であれば、それなりの効果があるのかもしれない。ただし、以下の意見もある。 これまでも日記に「いいね！」ボタンをつけることができたんだけど、「チェック」はニュースやmixiコレクションの中で興味のあるものに対して「チェック」できるという。まあ災害のニュースに「いいね！」ボタンはつけられないしね。「いいね！」より広い領域の事象に対する興味、関心を、友人、知人と共有するというコミュニケーションの形を提案しているわけだ。　「mixiチェック」正式発表【湯川】 Facebookの「いいね！」ボタンと「mixiチェック」ボタンの違いの一つとして、ネガティブなコンテンツやコメント付加に対応できるにあると湯川さんはおっしゃってるんですね。 ただし、楽天やYahooも、mixi対応するようなので、注目です。]]></description>
			<content:encoded><![CDATA[<p>こんにちは。</p>
<p><strong>mixiチェックボタン、本当に簡単に設置できました！</strong><br />
さきほど「mixi meetup 2010」にて発表があったmixiチェックボタンをさっそくブログのに貼り付けてみました。<br />
個人ブログに簡単に導入するための便利プラグインがmixiエンジニアblogにて提供されていたのでそれを使いました。</p>
<ul>
<li><a href="http://developer.mixi.co.jp/connect/mixi_plugin/about_mixi_plugin" target="_blank">mixi Pluginとは</a></li>
<li><a href="http://alpha.mixi.co.jp/blog/?p=2259" target="_blank">mixiチェックのWordpress &amp; Movable Typeプラグイン公開</a></li>
</ul>
<p>このページに貼り付けてもあまり意味はないのだが、商品ページやニュース記事ページなど、集客を目的とするページでの設置であれば、それなりの効果があるのかもしれない。ただし、以下の意見もある。</p>
<blockquote><p>これまでも日記に「いいね！」ボタンをつけることができたんだけど、「チェック」はニュースやmixiコレクションの中で興味のあるものに対して「チェック」できるという。まあ災害のニュースに「いいね！」ボタンはつけられないしね。「いいね！」より広い領域の事象に対する興味、関心を、友人、知人と共有するというコミュニケーションの形を提案しているわけだ。　<a href="http://techwave.jp/archives/51498950.html" target="_blank">「mixiチェック」正式発表【湯川】</a></p></blockquote>
<p>Facebookの「いいね！」ボタンと「mixiチェック」ボタンの違いの一つとして、ネガティブなコンテンツやコメント付加に対応できるにあると湯川さんはおっしゃってるんですね。</p>
<p>ただし、楽天やYahooも、mixi対応するようなので、注目です。</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.yanaoki.org/2010/09/10/mixi_plugin/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>RubyWorld Conference 2010に参加してきた</title>
		<link>http://blog.yanaoki.org/2010/09/07/rubyworld-conference-2010/</link>
		<comments>http://blog.yanaoki.org/2010/09/07/rubyworld-conference-2010/#comments</comments>
		<pubDate>Tue, 07 Sep 2010 14:48:03 +0000</pubDate>
		<dc:creator>yanaoki</dc:creator>
				<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://blog.yanaoki.org/?p=188</guid>
		<description><![CDATA[こんばんは。 昨日から二日間（2010年9月6日～2010年9月7日）、「RubyWorld Conference 2010」に参加してきました。 http://www.rubyworld-conf.org/ （ Twitterハッシュタグ: #RWC2010 ) 参加者の他県率は８割くらい（レセプション時の感覚）で、スーツ率はなんと９割くらいでした。参加者は、6日 415名、7日 693名とのことです。 発表内容からメモした言葉をちょっとだけ紹介し、後は写真をアップして寝ることにします。 基調講演：まつもとゆきひろ氏(@yukihiro_matz)『持続可能なRuby』 1993 ruby開発開始　ユーザまつもとさん1人 1995 ruby公開 2009 Rubyユーザ100万人（ガートナ調査結果） 2013 Rubyユーザ400万人（ガートナー予想） すごいユーザ数の推移ですね。400万人予想はRails全盛期の予想らしく実際にはそこまでいかないらしいけど。 角谷信太郎氏(@kakutani)『ふつうのシステム開発~Rubyを活用した受託開発をアジャイルにするためのパターンの紹介』 「時を超えた建設の道: クリストファー アレグザンダー著」からの言葉 生きている花をつくろうとすれば、ピンセットで細胞を一つ一つ物理的に組み立てるのではなく種から育てるのであろう。 これは、ささりました。 何か事を成すときの考え方として、どんなケースでも当てはまる言葉ですよね。 そしてきっと誰でも思い当たる事があるでしょう。 Stevie Clifton氏(Animoto Productions)『How Ruby Enables Startup Success』 Stevie氏はANIMOTO(http://animoto.com/)という動画サービスのCTO。こういうサクセスストーリーを聞くのは楽しいです。とてつもない苦労をされてるんだろうけど、それにも増してサービスの提供を楽しんでいることが言葉の壁を超えて伝わってくる。クローゼット内のサーバで始めたサービス→EC2で30インスタンス規模まで拡大。Facebookアプリによって30台から3,000台までスケールアウト。そしてアーキテクチャの再構成。すべてのフェーズにてRubyとその周辺のプロダクトを採用したとのことです。 まさに海外でのRuby&#38;Railsの成功例ですね。そしてANIMOTOのデモすげーかっこよかった。 - 全て１日目のレポートになってしまいましたが。２日目も楽天・三木谷社長の講演など内容は濃かったですよ。 - 以下写真。 会場：島根県立産業交流会館「くにびきメッセ」 - ノベルティのエコ箸と、売店で売ってるRuby on 松江ラーメン（２食分） ラーメンの箱の上部に書いてあるのはMatzのサインだろうか…。 - Aホール：まつもとさん講演中 - １日目昼食お弁当：ボリュームたっぷり - [...]]]></description>
			<content:encoded><![CDATA[<p>こんばんは。</p>
<p>昨日から二日間（2010年9月6日～2010年9月7日）、「RubyWorld Conference 2010」に参加してきました。</p>
<p><a href="http://www.rubyworld-conf.org/ ">http://www.rubyworld-conf.org/</p>
<p></a></p>
<p>（ Twitterハッシュタグ: #RWC2010 )</p>
<p>参加者の他県率は８割くらい（レセプション時の感覚）で、スーツ率はなんと９割くらいでした。参加者は、6日 415名、7日 693名とのことです。</p>
<p>発表内容からメモした言葉をちょっとだけ紹介し、後は写真をアップして寝ることにします。</p>
<h5>基調講演：まつもとゆきひろ氏(@yukihiro_matz)『持続可能なRuby』</h5>
<p>1993 ruby開発開始　ユーザまつもとさん1人</p>
<p>1995 ruby公開</p>
<p>2009 Rubyユーザ100万人（ガートナ調査結果）</p>
<p>2013 Rubyユーザ400万人（ガートナー予想）</p>
<p>すごいユーザ数の推移ですね。400万人予想はRails全盛期の予想らしく実際にはそこまでいかないらしいけど。</p>
<h5>角谷信太郎氏(@kakutani)『ふつうのシステム開発~Rubyを活用した受託開発をアジャイルにするためのパターンの紹介』</h5>
<p>「時を超えた建設の道: クリストファー アレグザンダー著」からの言葉</p>
<blockquote><p>生きている花をつくろうとすれば、ピンセットで細胞を一つ一つ物理的に組み立てるのではなく種から育てるのであろう。</p></blockquote>
<p>これは、ささりました。</p>
<p>何か事を成すときの考え方として、どんなケースでも当てはまる言葉ですよね。</p>
<p>そしてきっと誰でも思い当たる事があるでしょう。</p>
<h5>Stevie Clifton氏(Animoto Productions)『How Ruby Enables Startup Success』</h5>
<p>Stevie氏はANIMOTO(<a href="http://animoto.com/">http://animoto.com/</a>)という動画サービスのCTO。こういうサクセスストーリーを聞くのは楽しいです。とてつもない苦労をされてるんだろうけど、それにも増してサービスの提供を楽しんでいることが言葉の壁を超えて伝わってくる。クローゼット内のサーバで始めたサービス→EC2で30インスタンス規模まで拡大。Facebookアプリによって30台から3,000台までスケールアウト。そしてアーキテクチャの再構成。すべてのフェーズにてRubyとその周辺のプロダクトを採用したとのことです。</p>
<p>まさに海外でのRuby&amp;Railsの成功例ですね。そしてANIMOTOのデモすげーかっこよかった。</p>
<p>-</p>
<p>全て１日目のレポートになってしまいましたが。２日目も楽天・三木谷社長の講演など内容は濃かったですよ。</p>
<p>-</p>
<p>以下写真。</p>
<p><a href="http://blog.yanaoki.org/wp-content/uploads/2010/09/07-22-37-52.jpg"><img class="aligncenter size-medium wp-image-197" title="07 22 37 52" src="http://blog.yanaoki.org/wp-content/uploads/2010/09/07-22-37-52-300x224.jpg" alt="" width="300" height="224" /></a></p>
<p style="text-align: center;">会場：島根県立産業交流会館「くにびきメッセ」</p>
<p style="text-align: center;">-</p>
<p style="text-align: center;"><a href="http://blog.yanaoki.org/wp-content/uploads/2010/09/07-22-36-31.jpg"><img title="07 22 36 31" src="http://blog.yanaoki.org/wp-content/uploads/2010/09/07-22-36-31-300x224.jpg" alt="" width="300" height="224" /></a></p>
<p style="text-align: center;">
ノベルティの<a href="http://www.rubyworld-conf.org/ja/news/20100823-hashi/" target="_blank">エコ箸</a>と、売店で売ってる<a href="http://www.mengurume.co.jp/ruby/index.html" target="_blank">Ruby on 松江ラーメン</a>（２食分）</p>
<p style="text-align: center;">ラーメンの箱の上部に書いてあるのはMatzのサインだろうか…。</p>
<p style="text-align: center;">-</p>
<p><a href="http://blog.yanaoki.org/wp-content/uploads/2010/09/07-22-39-59.jpg"><img class="aligncenter size-medium wp-image-198" title="07 22 39 59" src="http://blog.yanaoki.org/wp-content/uploads/2010/09/07-22-39-59-300x224.jpg" alt="" width="300" height="224" /></a></p>
<p style="text-align: center;">
Aホール：まつもとさん講演中</p>
<p style="text-align: center;">-</p>
<p><a href="http://blog.yanaoki.org/wp-content/uploads/2010/09/07-22-39-35.jpg"><img class="aligncenter size-medium wp-image-199" title="07 22 39 35" src="http://blog.yanaoki.org/wp-content/uploads/2010/09/07-22-39-35-300x224.jpg" alt="" width="300" height="224" /></a></p>
<p style="text-align: center;">１日目昼食お弁当：ボリュームたっぷり</p>
<p style="text-align: center;">-</p>
<p><a href="http://blog.yanaoki.org/wp-content/uploads/2010/09/07-22-38-151.jpg"><img class="aligncenter size-medium wp-image-202" title="07 22 38 15" src="http://blog.yanaoki.org/wp-content/uploads/2010/09/07-22-38-151-300x224.jpg" alt="" width="300" height="224" /></a></p>
<p style="text-align: center;">B会場</p>
<p style="text-align: center;">-</p>
<p><a href="http://blog.yanaoki.org/wp-content/uploads/2010/09/07-22-37-28.jpg"><img class="aligncenter size-medium wp-image-203" title="07 22 37 28" src="http://blog.yanaoki.org/wp-content/uploads/2010/09/07-22-37-28-300x224.jpg" alt="" width="300" height="224" /></a><a href="http://blog.yanaoki.org/wp-content/uploads/2010/09/07-22-37-081.jpg"></a></p>
<p style="text-align: center;">１日目：多目的ホール。夜のレセプションの開始直前</p>
<p style="text-align: center;">-</p>
<p><a href="http://blog.yanaoki.org/wp-content/uploads/2010/09/07-22-37-081.jpg"><img class="aligncenter size-medium wp-image-205" title="07 22 37 08" src="http://blog.yanaoki.org/wp-content/uploads/2010/09/07-22-37-081-300x224.jpg" alt="" width="300" height="224" /></a></p>
<p style="text-align: center;">２日目昼食お弁当</p>
<p style="text-align: center;">-</p>
<p style="text-align: auto;">なんか食べ物の写真ばかりで申し訳ない（汗）</p>
<p style="text-align: auto;">以上です。何を言いたいかというと、来年も参加したいなーということです。</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.yanaoki.org/2010/09/07/rubyworld-conference-2010/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>EC-CUBEの商品登録CSVデータを生成するRubyスクリプト</title>
		<link>http://blog.yanaoki.org/2010/08/31/eccube-rakuten-data/</link>
		<comments>http://blog.yanaoki.org/2010/08/31/eccube-rakuten-data/#comments</comments>
		<pubDate>Tue, 31 Aug 2010 12:54:22 +0000</pubDate>
		<dc:creator>yanaoki</dc:creator>
				<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://blog.yanaoki.org/?p=134</guid>
		<description><![CDATA[こんばんは。 EC-CUBE用のテストデータを登録するためのCSVファイルを作る必要があって、簡単なスクリプト書いたので公開しておきます。 今回は、楽天ランキングAPIのデータを使ってテストデータのCSVを作成し、EC-CUBEのテストデータとして登録する手順を紹介します。 間違ってもそのまま公開しないように！ EC-CUBEのWeb管理ツールで手動でカテゴリ登録する まず、EC-CUBEのWeb管理ツールでカテゴリを一つたとえば「ゴルフ」を手動で登録します。 登録したカテゴリのIDを管理ツール上で確認します。 ここでは「ゴルフ」のカテゴリIDが「5」だったとします。 楽天ジャンルIDの取得する 楽天のジャンル一覧で「ゴルフ」のジャンルIDを確認します。 ゴルフのジャンルIDは「101077」でした。 楽天ジャンルID(genreId)検索 必要なコードを準備 Simple JSON parser &#38; builder 以下のサイトからJSON解析スクリプトをダウンロードし「jsonparser.rb」とします。ここにも置いておきます。 http://rubyforge.org/snippet/detail.php?type=snippet&#38;id=148 httpclient 画像ファイルを取得するのにhttpclientを利用しているのでインストールします。 $ sudo gem install httpclient 以下のrubyスクリプトをコピーして適当な名前で保存します。 ここでは「itemgen.rb」とします。 ざっくしとした説明です。 setupメソッドでIDで設定を行う csv_formatメソッドでCSV形式を定義する rewriteメソッドでCSVの内容を定義する $KCODE='u' require 'rubygems' require 'httpclient' require 'open-uri' require 'kconv' require 'jsonparser.rb' require &#34;fileutils&#34; require 'jcode' &#160; # 初期設定 def setup $developer_id = [...]]]></description>
			<content:encoded><![CDATA[<p>こんばんは。</p>
<p>EC-CUBE用のテストデータを登録するためのCSVファイルを作る必要があって、簡単なスクリプト書いたので公開しておきます。</p>
<p>今回は、楽天ランキングAPIのデータを使ってテストデータのCSVを作成し、EC-CUBEのテストデータとして登録する手順を紹介します。<br />
間違ってもそのまま公開しないように！</p>
<h5>EC-CUBEのWeb管理ツールで手動でカテゴリ登録する</h5>
<p>まず、EC-CUBEのWeb管理ツールでカテゴリを一つたとえば「ゴルフ」を手動で登録します。<br />
登録したカテゴリのIDを管理ツール上で確認します。<br />
ここでは「ゴルフ」のカテゴリIDが「5」だったとします。</p>
<h5>楽天ジャンルIDの取得する</h5>
<p>楽天のジャンル一覧で「ゴルフ」のジャンルIDを確認します。<br />
ゴルフのジャンルIDは「101077」でした。<br />
<a href="http://kawama.jp/php/rakuten_genre.php">楽天ジャンルID(genreId)検索</a></p>
<h5>必要なコードを準備</h5>
<p><strong>Simple JSON parser &amp; builder</strong><br />
以下のサイトからJSON解析スクリプトをダウンロードし「jsonparser.rb」とします。<a href="http://blog.yanaoki.org/jsonparser.rb">ここ</a>にも置いておきます。<br />
<a href="http://rubyforge.org/snippet/detail.php?type=snippet&amp;id=148">http://rubyforge.org/snippet/detail.php?type=snippet&amp;id=148<br />
</a><strong>httpclient</strong><br />
画像ファイルを取得するのにhttpclientを利用しているのでインストールします。</p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">$ sudo gem install httpclient</pre></div></div>

<p>以下のrubyスクリプトをコピーして適当な名前で保存します。<br />
ここでは「itemgen.rb」とします。<br />
ざっくしとした説明です。</p>
<ul>
<li>setupメソッドでIDで設定を行う</li>
<li>csv_formatメソッドでCSV形式を定義する</li>
<li>rewriteメソッドでCSVの内容を定義する</li>
</ul>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#ff6633; font-weight:bold;">$KCODE</span>=<span style="color:#996600;">'u'</span>
<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'rubygems'</span>
<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'httpclient'</span>
<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'open-uri'</span>
<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'kconv'</span>
<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'jsonparser.rb'</span>
<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">&quot;fileutils&quot;</span>
<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'jcode'</span>
&nbsp;
<span style="color:#008000; font-style:italic;"># 初期設定</span>
<span style="color:#9966CC; font-weight:bold;">def</span> setup
  <span style="color:#ff6633; font-weight:bold;">$developer_id</span> = <span style="color:#996600;">'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'</span>  <span style="color:#008000; font-style:italic;"># APIのためのデベロッパID</span>
  <span style="color:#ff6633; font-weight:bold;">$img_dir</span> = <span style="color:#996600;">'img'</span>                         <span style="color:#008000; font-style:italic;"># 画像保存ディレクトリ名</span>
  <span style="color:#ff6633; font-weight:bold;">$item_csv_filename</span> = <span style="color:#996600;">&quot;item.csv&quot;</span>   <span style="color:#008000; font-style:italic;"># 商品CSVファイル名</span>
  <span style="color:#ff6633; font-weight:bold;">$genre_id</span> = ARGV<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">0</span><span style="color:#006600; font-weight:bold;">&#93;</span>                  <span style="color:#008000; font-style:italic;"># 楽天ジャンルID</span>
  <span style="color:#ff6633; font-weight:bold;">$category_id</span> = ARGV<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">1</span><span style="color:#006600; font-weight:bold;">&#93;</span>             <span style="color:#008000; font-style:italic;">#　カテゴリID</span>
  <span style="color:#ff6633; font-weight:bold;">$max_page</span> = ARGV<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">2</span><span style="color:#006600; font-weight:bold;">&#93;</span>               <span style="color:#008000; font-style:italic;"># 取得ページ数（1ページ30商品で10ページまであるらしい）</span>
<span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
<span style="color:#008000; font-style:italic;"># CVSフォーマット(HashをsortしてArray返してるので注意)</span>
<span style="color:#9966CC; font-weight:bold;">def</span> csv_format
  <span style="color:#006600; font-weight:bold;">&#123;</span>
    <span style="color:#006666;">0</span> =<span style="color:#006600; font-weight:bold;">&amp;</span>gt;  <span style="color:#996600;">&quot;商品ID&quot;</span>,
    <span style="color:#006666;">1</span> =<span style="color:#006600; font-weight:bold;">&amp;</span>gt; <span style="color:#996600;">&quot;商品規格ID&quot;</span>,
    <span style="color:#006666;">2</span> =<span style="color:#006600; font-weight:bold;">&amp;</span>gt; <span style="color:#996600;">&quot;規格名1&quot;</span>,
    <span style="color:#006666;">3</span> =<span style="color:#006600; font-weight:bold;">&amp;</span>gt; <span style="color:#996600;">&quot;規格名2&quot;</span>,
    <span style="color:#006666;">4</span> =<span style="color:#006600; font-weight:bold;">&amp;</span>gt; <span style="color:#996600;">&quot;商品名(必須)&quot;</span>,
    <span style="color:#006666;">5</span> =<span style="color:#006600; font-weight:bold;">&amp;</span>gt; <span style="color:#996600;">&quot;公開フラグ(1:公開 2:非公開)(必須)&quot;</span>,
    <span style="color:#006666;">6</span> =<span style="color:#006600; font-weight:bold;">&amp;</span>gt; <span style="color:#996600;">&quot;商品ステータス(必須)&quot;</span>,
    <span style="color:#006666;">7</span> =<span style="color:#006600; font-weight:bold;">&amp;</span>gt; <span style="color:#996600;">&quot;商品コード&quot;</span>,
    <span style="color:#006666;">8</span> =<span style="color:#006600; font-weight:bold;">&amp;</span>gt; <span style="color:#996600;">&quot;通常価格 &quot;</span>,
    <span style="color:#006666;">9</span> =<span style="color:#006600; font-weight:bold;">&amp;</span>gt; <span style="color:#996600;">&quot;販売価格(必須)&quot;</span>,
    <span style="color:#006666;">10</span> =<span style="color:#006600; font-weight:bold;">&amp;</span>gt;<span style="color:#996600;">&quot;在庫数&quot;</span>,
    <span style="color:#006666;">11</span> =<span style="color:#006600; font-weight:bold;">&amp;</span>gt;<span style="color:#996600;">&quot;送料&quot;</span>,
    <span style="color:#006666;">12</span> =<span style="color:#006600; font-weight:bold;">&amp;</span>gt;<span style="color:#996600;">&quot;ポイント付与率(必須)&quot;</span>,
    <span style="color:#006666;">13</span> =<span style="color:#006600; font-weight:bold;">&amp;</span>gt;<span style="color:#996600;">&quot;購入制限&quot;</span>,
    <span style="color:#006666;">14</span> =<span style="color:#006600; font-weight:bold;">&amp;</span>gt;<span style="color:#996600;">&quot;メーカーURL&quot;</span>,
    <span style="color:#006666;">15</span> =<span style="color:#006600; font-weight:bold;">&amp;</span>gt;<span style="color:#996600;">&quot;検索ワード&quot;</span>,
    <span style="color:#006666;">16</span> =<span style="color:#006600; font-weight:bold;">&amp;</span>gt;<span style="color:#996600;">&quot;備考欄(SHOP専用)&quot;</span>,
    <span style="color:#006666;">17</span> =<span style="color:#006600; font-weight:bold;">&amp;</span>gt;<span style="color:#996600;">&quot;一覧-メインコメント(必須)&quot;</span>,
    <span style="color:#006666;">18</span> =<span style="color:#006600; font-weight:bold;">&amp;</span>gt;<span style="color:#996600;">&quot;一覧-メイン画像(必須)&quot;</span>,
    <span style="color:#006666;">19</span> =<span style="color:#006600; font-weight:bold;">&amp;</span>gt;<span style="color:#996600;">&quot;メインコメント(必須)&quot;</span>,
    <span style="color:#006666;">20</span> =<span style="color:#006600; font-weight:bold;">&amp;</span>gt;<span style="color:#996600;">&quot;メイン画像(必須)&quot;</span>,
    <span style="color:#006666;">21</span> =<span style="color:#006600; font-weight:bold;">&amp;</span>gt;<span style="color:#996600;">&quot;メイン拡大画像&quot;</span>,
    <span style="color:#006666;">22</span> =<span style="color:#006600; font-weight:bold;">&amp;</span>gt;<span style="color:#996600;">&quot;カラー比較画像&quot;</span>,
    <span style="color:#006666;">23</span> =<span style="color:#006600; font-weight:bold;">&amp;</span>gt;<span style="color:#996600;">&quot;商品詳細ファイル&quot;</span>,
    <span style="color:#006666;">24</span> =<span style="color:#006600; font-weight:bold;">&amp;</span>gt;<span style="color:#996600;">&quot;詳細-サブタイトル(1)&quot;</span>,
    <span style="color:#006666;">25</span> =<span style="color:#006600; font-weight:bold;">&amp;</span>gt;<span style="color:#996600;">&quot;詳細-サブコメント(1)&quot;</span>,
    <span style="color:#006666;">26</span> =<span style="color:#006600; font-weight:bold;">&amp;</span>gt;<span style="color:#996600;">&quot;詳細-サブ画像(1)&quot;</span>,
    <span style="color:#006666;">27</span> =<span style="color:#006600; font-weight:bold;">&amp;</span>gt;<span style="color:#996600;">&quot;詳細-サブ拡大画像(1)&quot;</span>,
    <span style="color:#006666;">28</span> =<span style="color:#006600; font-weight:bold;">&amp;</span>gt;<span style="color:#996600;">&quot;詳細-サブタイトル(2)&quot;</span>,
    <span style="color:#006666;">29</span> =<span style="color:#006600; font-weight:bold;">&amp;</span>gt;<span style="color:#996600;">&quot;詳細-サブコメント(2)&quot;</span>,
    <span style="color:#006666;">30</span> =<span style="color:#006600; font-weight:bold;">&amp;</span>gt;<span style="color:#996600;">&quot;詳細-サブ画像(2)&quot;</span>,
    <span style="color:#006666;">31</span> =<span style="color:#006600; font-weight:bold;">&amp;</span>gt;<span style="color:#996600;">&quot;詳細-サブ拡大画像(2)&quot;</span>,
    <span style="color:#006666;">32</span> =<span style="color:#006600; font-weight:bold;">&amp;</span>gt;<span style="color:#996600;">&quot;詳細-サブタイトル(3)&quot;</span>,
    <span style="color:#006666;">33</span> =<span style="color:#006600; font-weight:bold;">&amp;</span>gt;<span style="color:#996600;">&quot;詳細-サブコメント(3)&quot;</span>,
    <span style="color:#006666;">34</span> =<span style="color:#006600; font-weight:bold;">&amp;</span>gt;<span style="color:#996600;">&quot;詳細-サブ画像(3)&quot;</span>,
    <span style="color:#006666;">35</span> =<span style="color:#006600; font-weight:bold;">&amp;</span>gt;<span style="color:#996600;">&quot;詳細-サブ拡大画像(3)&quot;</span>,
    <span style="color:#006666;">36</span> =<span style="color:#006600; font-weight:bold;">&amp;</span>gt;<span style="color:#996600;">&quot;詳細-サブタイトル(4)&quot;</span>,
    <span style="color:#006666;">37</span> =<span style="color:#006600; font-weight:bold;">&amp;</span>gt;<span style="color:#996600;">&quot;詳細-サブコメント(4)&quot;</span>,
    <span style="color:#006666;">38</span> =<span style="color:#006600; font-weight:bold;">&amp;</span>gt;<span style="color:#996600;">&quot;詳細-サブ画像(4)&quot;</span>,
    <span style="color:#006666;">39</span> =<span style="color:#006600; font-weight:bold;">&amp;</span>gt;<span style="color:#996600;">&quot;詳細-サブ拡大画像(4)&quot;</span>,
    <span style="color:#006666;">40</span> =<span style="color:#006600; font-weight:bold;">&amp;</span>gt;<span style="color:#996600;">&quot;詳細-サブタイトル(5)&quot;</span>,
    <span style="color:#006666;">41</span> =<span style="color:#006600; font-weight:bold;">&amp;</span>gt;<span style="color:#996600;">&quot;詳細-サブコメント(5)&quot;</span>,
    <span style="color:#006666;">42</span> =<span style="color:#006600; font-weight:bold;">&amp;</span>gt;<span style="color:#996600;">&quot;詳細-サブ画像(5)&quot;</span>,
    <span style="color:#006666;">43</span> =<span style="color:#006600; font-weight:bold;">&amp;</span>gt;<span style="color:#996600;">&quot;詳細-サブ拡大画像(5)&quot;</span>,
    <span style="color:#006666;">44</span> =<span style="color:#006600; font-weight:bold;">&amp;</span>gt;<span style="color:#996600;">&quot;発送日目安&quot;</span>,
    <span style="color:#006666;">45</span> =<span style="color:#006600; font-weight:bold;">&amp;</span>gt;<span style="color:#996600;">&quot;おすすめ商品(1)&quot;</span>,
    <span style="color:#006666;">46</span> =<span style="color:#006600; font-weight:bold;">&amp;</span>gt;<span style="color:#996600;">&quot;詳細-サブコメント(1)&quot;</span>,
    <span style="color:#006666;">47</span> =<span style="color:#006600; font-weight:bold;">&amp;</span>gt;<span style="color:#996600;">&quot;おすすめ商品(2)&quot;</span>,
    <span style="color:#006666;">48</span> =<span style="color:#006600; font-weight:bold;">&amp;</span>gt;<span style="color:#996600;">&quot;詳細-サブコメント(2)&quot;</span>,
    <span style="color:#006666;">49</span> =<span style="color:#006600; font-weight:bold;">&amp;</span>gt;<span style="color:#996600;">&quot;おすすめ商品(3)&quot;</span>,
    <span style="color:#006666;">50</span> =<span style="color:#006600; font-weight:bold;">&amp;</span>gt;<span style="color:#996600;">&quot;詳細-サブコメント(3)&quot;</span>,
    <span style="color:#006666;">51</span> =<span style="color:#006600; font-weight:bold;">&amp;</span>gt;<span style="color:#996600;">&quot;おすすめ商品(4)&quot;</span>,
    <span style="color:#006666;">52</span> =<span style="color:#006600; font-weight:bold;">&amp;</span>gt;<span style="color:#996600;">&quot;詳細-サブコメント(4)&quot;</span>,
    <span style="color:#006666;">53</span> =<span style="color:#006600; font-weight:bold;">&amp;</span>gt;<span style="color:#996600;">&quot;おすすめ商品(5)&quot;</span>,
    <span style="color:#006666;">54</span> =<span style="color:#006600; font-weight:bold;">&amp;</span>gt;<span style="color:#996600;">&quot;詳細-サブコメント(5)&quot;</span>,
    <span style="color:#006666;">55</span> =<span style="color:#006600; font-weight:bold;">&amp;</span>gt;<span style="color:#996600;">&quot;おすすめ商品(6)&quot;</span>,
    <span style="color:#006666;">56</span> =<span style="color:#006600; font-weight:bold;">&amp;</span>gt;<span style="color:#996600;">&quot;詳細-サブコメント(6)&quot;</span>,
    <span style="color:#006666;">57</span> =<span style="color:#006600; font-weight:bold;">&amp;</span>gt;<span style="color:#996600;">&quot;商品カテゴリ(必須)&quot;</span>
  <span style="color:#006600; font-weight:bold;">&#125;</span>.<span style="color:#9900CC;">sort_by</span><span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006600; font-weight:bold;">|</span>k,v<span style="color:#006600; font-weight:bold;">|</span>k<span style="color:#006600; font-weight:bold;">&#125;</span>
<span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
<span style="color:#008000; font-style:italic;"># CSVの値を定義（フォーマットの列番号に対応。xにはAPIで取得したitemが入る）</span>
<span style="color:#9966CC; font-weight:bold;">def</span> rewrite
  <span style="color:#006600; font-weight:bold;">&#123;</span>
    <span style="color:#006666;">4</span>  =<span style="color:#006600; font-weight:bold;">&amp;</span>gt;lambda<span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006600; font-weight:bold;">|</span>x<span style="color:#006600; font-weight:bold;">|</span> cut_off<span style="color:#006600; font-weight:bold;">&#40;</span>x<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">&quot;itemName&quot;</span><span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#9900CC;">to_s</span>.<span style="color:#9900CC;">toutf8</span>.<span style="color:#CC0066; font-weight:bold;">gsub</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">/</span>【.<span style="color:#006600; font-weight:bold;">&#91;</span>^【<span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">*</span>】<span style="color:#006600; font-weight:bold;">/</span>, <span style="color:#996600;">''</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#CC0066; font-weight:bold;">gsub</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;楽天&quot;</span>,<span style="color:#996600;">''</span><span style="color:#006600; font-weight:bold;">&#41;</span>,<span style="color:#006666;">45</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#125;</span>, <span style="color:#008000; font-style:italic;">#【】は取る</span>
    <span style="color:#006666;">5</span>  =<span style="color:#006600; font-weight:bold;">&amp;</span>gt;lambda<span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006600; font-weight:bold;">|</span>x<span style="color:#006600; font-weight:bold;">|</span> <span style="color:#996600;">&quot;1&quot;</span><span style="color:#006600; font-weight:bold;">&#125;</span>,
    <span style="color:#006666;">6</span>  =<span style="color:#006600; font-weight:bold;">&amp;</span>gt;lambda<span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006600; font-weight:bold;">|</span>x<span style="color:#006600; font-weight:bold;">|</span> <span style="color:#996600;">&quot;0&quot;</span><span style="color:#006600; font-weight:bold;">&#125;</span>,
    <span style="color:#006666;">7</span>  =<span style="color:#006600; font-weight:bold;">&amp;</span>gt;lambda<span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006600; font-weight:bold;">|</span>x<span style="color:#006600; font-weight:bold;">|</span> x<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">&quot;itemCode&quot;</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#125;</span>,
    <span style="color:#006666;">9</span>  =<span style="color:#006600; font-weight:bold;">&amp;</span>gt;lambda<span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006600; font-weight:bold;">|</span>x<span style="color:#006600; font-weight:bold;">|</span> x<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">&quot;itemPrice&quot;</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#125;</span>,
    <span style="color:#006666;">10</span> =<span style="color:#006600; font-weight:bold;">&amp;</span>gt;lambda<span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006600; font-weight:bold;">|</span>x<span style="color:#006600; font-weight:bold;">|</span> <span style="color:#996600;">&quot;20&quot;</span><span style="color:#006600; font-weight:bold;">&#125;</span>,
    <span style="color:#006666;">12</span> =<span style="color:#006600; font-weight:bold;">&amp;</span>gt;lambda<span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006600; font-weight:bold;">|</span>x<span style="color:#006600; font-weight:bold;">|</span> x<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">&quot;pointRate&quot;</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#125;</span>,
    <span style="color:#006666;">17</span> =<span style="color:#006600; font-weight:bold;">&amp;</span>gt;lambda<span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006600; font-weight:bold;">|</span>x<span style="color:#006600; font-weight:bold;">|</span> s = cut_off<span style="color:#006600; font-weight:bold;">&#40;</span>x<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">&quot;itemCaption&quot;</span><span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#9900CC;">to_s</span>.<span style="color:#9900CC;">toutf8</span>.<span style="color:#CC0066; font-weight:bold;">gsub</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;楽天&quot;</span>,<span style="color:#996600;">''</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#CC0066; font-weight:bold;">gsub</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'。'</span>,<span style="color:#996600;">'。'</span><span style="color:#006600; font-weight:bold;">&#41;</span>,<span style="color:#006666;">50</span><span style="color:#006600; font-weight:bold;">&#41;</span> ; s == <span style="color:#996600;">&quot;&quot;</span> ? <span style="color:#996600;">&quot;-&quot;</span> : s<span style="color:#006600; font-weight:bold;">&#125;</span>,
    <span style="color:#006666;">18</span> =<span style="color:#006600; font-weight:bold;">&amp;</span>gt;lambda<span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006600; font-weight:bold;">|</span>x<span style="color:#006600; font-weight:bold;">|</span> image_get<span style="color:#006600; font-weight:bold;">&#40;</span>x<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">&quot;smallImageUrl&quot;</span><span style="color:#006600; font-weight:bold;">&#93;</span>,x<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">&quot;itemCode&quot;</span><span style="color:#006600; font-weight:bold;">&#93;</span> <span style="color:#006600; font-weight:bold;">+</span> <span style="color:#996600;">&quot;_s.gif&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#125;</span>,
    <span style="color:#006666;">19</span> =<span style="color:#006600; font-weight:bold;">&amp;</span>gt;lambda<span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006600; font-weight:bold;">|</span>x<span style="color:#006600; font-weight:bold;">|</span> s = x<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">&quot;itemCaption&quot;</span><span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#9900CC;">to_s</span>.<span style="color:#9900CC;">toutf8</span>.<span style="color:#CC0066; font-weight:bold;">gsub</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;楽天&quot;</span>,<span style="color:#996600;">''</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#CC0066; font-weight:bold;">gsub</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'。'</span>,<span style="color:#996600;">'。'</span><span style="color:#006600; font-weight:bold;">&#41;</span> ; s == <span style="color:#996600;">&quot;&quot;</span> ? <span style="color:#996600;">&quot;-&quot;</span> : s<span style="color:#006600; font-weight:bold;">&#125;</span>,
    <span style="color:#006666;">20</span> =<span style="color:#006600; font-weight:bold;">&amp;</span>gt;lambda<span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006600; font-weight:bold;">|</span>x<span style="color:#006600; font-weight:bold;">|</span> image_get<span style="color:#006600; font-weight:bold;">&#40;</span>x<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">&quot;mediumImageUrl&quot;</span><span style="color:#006600; font-weight:bold;">&#93;</span>,x<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">&quot;itemCode&quot;</span><span style="color:#006600; font-weight:bold;">&#93;</span> <span style="color:#006600; font-weight:bold;">+</span> <span style="color:#996600;">&quot;_m.gif&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#125;</span>,
    <span style="color:#006666;">57</span> =<span style="color:#006600; font-weight:bold;">&amp;</span>gt;lambda<span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006600; font-weight:bold;">|</span>x<span style="color:#006600; font-weight:bold;">|</span> <span style="color:#ff6633; font-weight:bold;">$category_id</span><span style="color:#006600; font-weight:bold;">&#125;</span>
  <span style="color:#006600; font-weight:bold;">&#125;</span>
<span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
<span style="color:#9966CC; font-weight:bold;">def</span> image_get<span style="color:#006600; font-weight:bold;">&#40;</span>image_url,save_file_name<span style="color:#006600; font-weight:bold;">&#41;</span>
  hc = HTTPClient.<span style="color:#9900CC;">new</span>
  f = <span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#CC0066; font-weight:bold;">open</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;#{$img_dir}/&quot;</span> <span style="color:#006600; font-weight:bold;">+</span> save_file_name, <span style="color:#996600;">&quot;wb&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
  f.<span style="color:#CC0066; font-weight:bold;">print</span><span style="color:#006600; font-weight:bold;">&#40;</span>hc.<span style="color:#9900CC;">get_content</span><span style="color:#006600; font-weight:bold;">&#40;</span>image_url<span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
  f.<span style="color:#9900CC;">close</span>
  save_file_name
<span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
<span style="color:#9966CC; font-weight:bold;">def</span> api_call<span style="color:#006600; font-weight:bold;">&#40;</span>uri<span style="color:#006600; font-weight:bold;">&#41;</span>
  json_string = <span style="color:#996600;">''</span>
  <span style="color:#CC0066; font-weight:bold;">open</span><span style="color:#006600; font-weight:bold;">&#40;</span>uri<span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006600; font-weight:bold;">|</span>f<span style="color:#006600; font-weight:bold;">|</span> json_string = f.<span style="color:#9900CC;">read</span> <span style="color:#006600; font-weight:bold;">&#125;</span>
  parser = JsonParser.<span style="color:#9900CC;">new</span>
  parser.<span style="color:#9900CC;">parse</span><span style="color:#006600; font-weight:bold;">&#40;</span>json_string<span style="color:#006600; font-weight:bold;">&#41;</span>
<span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
<span style="color:#9966CC; font-weight:bold;">def</span> cut_off<span style="color:#006600; font-weight:bold;">&#40;</span>text,len<span style="color:#006600; font-weight:bold;">&#41;</span>
  <span style="color:#9966CC; font-weight:bold;">if</span> text != <span style="color:#0000FF; font-weight:bold;">nil</span>
    text.<span style="color:#9900CC;">jlength</span> <span style="color:#006600; font-weight:bold;">&amp;</span>lt; len ? text : text.<span style="color:#9900CC;">scan</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">/</span>^.<span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#008000; font-style:italic;">#{len}}/m)[0] + &quot;…&quot;</span>
  <span style="color:#9966CC; font-weight:bold;">else</span>
    <span style="color:#996600;">''</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
setup
<span style="color:#008000; font-style:italic;"># ファイルを掃除しとく</span>
<span style="color:#CC00FF; font-weight:bold;">FileUtils</span>.<span style="color:#9900CC;">remove_entry</span><span style="color:#006600; font-weight:bold;">&#40;</span>$img_dir,<span style="color:#0000FF; font-weight:bold;">true</span><span style="color:#006600; font-weight:bold;">&#41;</span>
<span style="color:#CC00FF; font-weight:bold;">FileUtils</span>.<span style="color:#9900CC;">mkdir</span><span style="color:#006600; font-weight:bold;">&#40;</span>$img_dir<span style="color:#006600; font-weight:bold;">&#41;</span>
<span style="color:#CC00FF; font-weight:bold;">FileUtils</span>.<span style="color:#9900CC;">rm</span><span style="color:#006600; font-weight:bold;">&#40;</span>$item_csv_filename, <span style="color:#006600; font-weight:bold;">&#123;</span>:force=<span style="color:#006600; font-weight:bold;">&amp;</span>gt;true<span style="color:#006600; font-weight:bold;">&#125;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
<span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#CC0066; font-weight:bold;">open</span><span style="color:#006600; font-weight:bold;">&#40;</span>$item_csv_filename,<span style="color:#996600;">'w'</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>f<span style="color:#006600; font-weight:bold;">|</span>
  <span style="color:#008000; font-style:italic;"># ヘッダ行を追加</span>
  f.<span style="color:#CC0066; font-weight:bold;">puts</span><span style="color:#006600; font-weight:bold;">&#40;</span>csv_format.<span style="color:#9900CC;">collect</span><span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006600; font-weight:bold;">|</span>col<span style="color:#006600; font-weight:bold;">|</span> <span style="color:#996600;">&quot;<span style="color:#000099;">\&quot;</span>#{col[1]}<span style="color:#000099;">\&quot;</span>&quot;</span><span style="color:#006600; font-weight:bold;">&#125;</span>.<span style="color:#9900CC;">join</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">','</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
  <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006666;">1</span>..$max_page.<span style="color:#9900CC;">to_i</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">each</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>page<span style="color:#006600; font-weight:bold;">|</span>
    items = <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006600; font-weight:bold;">&#93;</span>
    ranking_api_url = <span style="color:#996600;">&quot;http://api.rakuten.co.jp/rws/3.0/json?developerId=#{$developer_id}&amp;amp;operation=ItemRanking&amp;amp;version=2010-08-05&amp;amp;genreId=#{$genre_id}&amp;amp;page=#{page}&quot;</span>
    <span style="color:#008000; font-style:italic;"># APIを呼び出して戻り値のアイテムをもとにCSV行を作成</span>
    obj = api_call<span style="color:#006600; font-weight:bold;">&#40;</span>ranking_api_url<span style="color:#006600; font-weight:bold;">&#41;</span>
    <span style="color:#CC0066; font-weight:bold;">exit</span> <span style="color:#9966CC; font-weight:bold;">unless</span> obj<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">&quot;Body&quot;</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">&quot;ItemRanking&quot;</span><span style="color:#006600; font-weight:bold;">&#93;</span>
    rakuten_items = obj<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">&quot;Body&quot;</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">&quot;ItemRanking&quot;</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">&quot;Items&quot;</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">&quot;Item&quot;</span><span style="color:#006600; font-weight:bold;">&#93;</span>
    <span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">&quot;ページ#{page} から #{rakuten_items.size} 件取得しました。&quot;</span>
    rakuten_items.<span style="color:#9900CC;">each</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>item<span style="color:#006600; font-weight:bold;">|</span>
      items <span style="color:#006600; font-weight:bold;">&amp;</span>lt;<span style="color:#006600; font-weight:bold;">&amp;</span>lt; csv_format.<span style="color:#9900CC;">collect</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>col<span style="color:#006600; font-weight:bold;">|</span>
        i=col<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">0</span><span style="color:#006600; font-weight:bold;">&#93;</span>
        rewrite<span style="color:#006600; font-weight:bold;">&#91;</span>i<span style="color:#006600; font-weight:bold;">&#93;</span> ? rewrite<span style="color:#006600; font-weight:bold;">&#91;</span>i<span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#9900CC;">call</span><span style="color:#006600; font-weight:bold;">&#40;</span>item<span style="color:#006600; font-weight:bold;">&#41;</span> : <span style="color:#996600;">&quot;&quot;</span>
      <span style="color:#9966CC; font-weight:bold;">end</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
    <span style="color:#008000; font-style:italic;"># 出力</span>
    items.<span style="color:#9900CC;">each</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>item<span style="color:#006600; font-weight:bold;">|</span>
      f.<span style="color:#CC0066; font-weight:bold;">puts</span><span style="color:#006600; font-weight:bold;">&#40;</span>item.<span style="color:#9900CC;">collect</span><span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006600; font-weight:bold;">|</span>col<span style="color:#006600; font-weight:bold;">|</span> <span style="color:#996600;">&quot;<span style="color:#000099;">\&quot;</span>#{col.to_s.gsub(',','')}<span style="color:#000099;">\&quot;</span>&quot;</span><span style="color:#006600; font-weight:bold;">&#125;</span>.<span style="color:#9900CC;">join</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">','</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<h5>実行する</h5>
<p>以下のコマンドで実行します。<br />
パラメータは「ジャンルID カテゴリID 取得ページ数」です。</p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">$ ruby itemgen.rb 101077 5 3</pre></div></div>

<ul>
<li>item.csv</li>
<li>imgディレクトリ</li>
</ul>
<p>が生成されます。</p>
<h5>画像を配置する</h5>
<p>先に画像を配置しておく必要があるので、imgディレクトリ内の全画像を、<br />
「html/upload/save_image/」に配置します。</p>
<h5>登録する</h5>
<p>Web管理ツールからCSVファイルを登録します。</p>
<h5>完了</h5>
<p>以上です。いろいろと使えそうな気がしますね。</p>
<div id="-chrome-auto-translate-plugin-dialog" style="display: none; opacity: 1 !important; border-color: none !important; background: transparent !important; padding: 0 !important; margin: 0 !important; position: absolute !important; top: 0; left: 0; overflow: visible !important; z-index: 999999 !important; text-align: left !important;">
<div style="max-width: 300px !important; color: #fafafa !important; opacity: 0.8 !important; border-color: #000000 !important; border-width: 0px !important; -webkit-border-radius: 10px !important; background-color: #363636 !important; font-size: 16px !important; padding: 8px !important; overflow: visible !important; background-image: -webkit-gradient(linear, left top, right bottom, color-stop(0%, #000), color-stop(50%, #363636), color-stop(100%, #000)); z-index: 999999 !important; text-align: left  !important;"></div>
<p><img style="position: absolute !important; z-index: -1 !important; right: 1px !important; top: -20px !important; cursor: pointer !important; -webkit-border-radius: 20px; background-color: rgba(200, 200, 200, 0.3) !important; padding: 3px 5px 0 !important; margin: 0 !important;" onclick="document.location.href='http://translate.google.com/';" src="http://www.google.com/uds/css/small-logo.png" alt="" /></div>
]]></content:encoded>
			<wfw:commentRss>http://blog.yanaoki.org/2010/08/31/eccube-rakuten-data/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

