<?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>MemoSoup &#187; soundex</title>
	<atom:link href="http://www.memosoup.com/tag/soundex/feed" rel="self" type="application/rss+xml" />
	<link>http://www.memosoup.com</link>
	<description>Mix of the things I always forget</description>
	<lastBuildDate>Tue, 07 Feb 2012 00:03:54 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>JavaScript: Soundex implementation</title>
		<link>http://www.memosoup.com/20100107/javascript-soundex-implementation.html</link>
		<comments>http://www.memosoup.com/20100107/javascript-soundex-implementation.html#comments</comments>
		<pubDate>Thu, 07 Jan 2010 10:28:06 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[soundex]]></category>

		<guid isPermaLink="false">http://www.memosoup.com/?p=242</guid>
		<description><![CDATA[<p>There is a special algorithm for comparision strings, which sound similar (Soundex).</p> <p>Here is JavaScript Soundex implementation:</p> function soundex &#40; s_src &#41; &#123; &#160; &#160; &#160;var s_rez = &#34;0000&#34; ; &#160;var new_code, prev, idx &#160; &#160;a_codes = &#123; &#34;bfpv&#34;: 1, &#34;cgjkqsxz&#34;:2, &#34;dt&#34;: 3, &#34;l&#34;: 4, &#34;mn&#34;: 5, &#34;r&#34;: 6 &#125;; &#160; &#160;s_src = s_src.toLowerCase&#40;&#41;.replace&#40;/ /g,&#34;&#34;&#41; [...]]]></description>
			<content:encoded><![CDATA[<p>There is a special algorithm for comparision strings, which sound similar (<a href="http://en.wikipedia.org/wiki/Soundex">Soundex</a>).</p>
<p>Here is JavaScript Soundex implementation:</p>
<div class="codecolorer-container javascript default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:100%;"><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #003366; font-weight: bold;">function</span> soundex <span style="color: #009900;">&#40;</span> s_src <span style="color: #009900;">&#41;</span><br />
<span style="color: #009900;">&#123;</span> &nbsp; &nbsp;<br />
&nbsp;<span style="color: #003366; font-weight: bold;">var</span> s_rez <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;0000&quot;</span> <span style="color: #339933;">;</span><br />
&nbsp;<span style="color: #003366; font-weight: bold;">var</span> new_code<span style="color: #339933;">,</span> prev<span style="color: #339933;">,</span> idx<br />
&nbsp;<br />
&nbsp;a_codes <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span> <span style="color: #3366CC;">&quot;bfpv&quot;</span><span style="color: #339933;">:</span> <span style="color: #CC0000;">1</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;cgjkqsxz&quot;</span><span style="color: #339933;">:</span><span style="color: #CC0000;">2</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;dt&quot;</span><span style="color: #339933;">:</span> <span style="color: #CC0000;">3</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;l&quot;</span><span style="color: #339933;">:</span> <span style="color: #CC0000;">4</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;mn&quot;</span><span style="color: #339933;">:</span> <span style="color: #CC0000;">5</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;r&quot;</span><span style="color: #339933;">:</span> <span style="color: #CC0000;">6</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span><br />
&nbsp;<br />
&nbsp;s_src <span style="color: #339933;">=</span> s_src.<span style="color: #660066;">toLowerCase</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">replace</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">/</span> <span style="color: #339933;">/</span>g<span style="color: #339933;">,</span><span style="color: #3366CC;">&quot;&quot;</span><span style="color: #009900;">&#41;</span><br />
&nbsp;<br />
&nbsp;<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span> s_src.<span style="color: #660066;">length</span> <span style="color: #339933;">&lt;</span> <span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp;<span style="color: #000066; font-weight: bold;">return</span><span style="color: #009900;">&#40;</span>s_rez<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp;<span style="color: #009900;">&#125;</span><br />
&nbsp;<br />
&nbsp;s_rez <span style="color: #339933;">=</span> s_src.<span style="color: #660066;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">0</span><span style="color: #339933;">,</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp;prev <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;0&quot;</span><span style="color: #339933;">;</span><br />
&nbsp;<br />
&nbsp;<span style="color: #000066; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span> idx <span style="color: #339933;">=</span> <span style="color: #CC0000;">1</span> <span style="color: #339933;">;</span> idx <span style="color: #339933;">&lt;</span> s_src.<span style="color: #660066;">length</span> <span style="color: #339933;">;</span> idx<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp;new_code <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;0&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp;cur_char <span style="color: #339933;">=</span> s_src.<span style="color: #660066;">substr</span><span style="color: #009900;">&#40;</span>idx<span style="color: #339933;">,</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp;<br />
&nbsp; &nbsp;<span style="color: #000066; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span>s_code <span style="color: #000066; font-weight: bold;">in</span> a_codes<span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>s_code.<span style="color: #660066;">indexOf</span><span style="color: #009900;">&#40;</span>cur_char<span style="color: #009900;">&#41;</span> <span style="color: #339933;">&gt;=</span> <span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#123;</span> new_code <span style="color: #339933;">=</span> a_codes<span style="color: #009900;">&#91;</span> s_code <span style="color: #009900;">&#93;</span> <span style="color: #339933;">;</span> <span style="color: #000066; font-weight: bold;">break</span> <span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; &nbsp;<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>new_code <span style="color: #339933;">!=</span> prev <span style="color: #339933;">&amp;&amp;</span> new_code <span style="color: #339933;">!=</span> <span style="color: #3366CC;">&quot;0&quot;</span> <span style="color: #009900;">&#41;</span> &nbsp;<span style="color: #009900;">&#123;</span> &nbsp; <br />
&nbsp; &nbsp; &nbsp;s_rez <span style="color: #339933;">+=</span> new_code<span style="color: #339933;">;</span><br />
&nbsp; &nbsp;<span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp;<br />
&nbsp; &nbsp;prev <span style="color: #339933;">=</span> new_code<span style="color: #339933;">;</span><br />
&nbsp; <span style="color: #009900;">&#125;</span> <br />
&nbsp; <br />
&nbsp;s_rez <span style="color: #339933;">=</span> s_rez <span style="color: #339933;">+</span> <span style="color: #3366CC;">&quot;0000&quot;</span><br />
&nbsp;<br />
&nbsp;<span style="color: #000066; font-weight: bold;">return</span> s_rez.<span style="color: #660066;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">0</span><span style="color: #339933;">,</span><span style="color: #CC0000;">4</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span></div></div>
<div style="height:33px; padding-top:2px; padding-bottom:2px; clear:both;" class="zare366"><div style="float:left; width:100px; " class="zare366_facebook_like"> 
				<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.memosoup.com%2F20100107%2Fjavascript-soundex-implementation.html&amp;layout=button_count&amp;show_faces=false&amp;width=100&amp;action=like&amp;colorscheme=light&amp;height=27" 
					scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:100px; height:27px;" allowTransparency="true"></iframe>
			</div><div style="float:left; width:90px; padding-left:10px;" class="zare366_google1"> 
				<g:plusone size="medium" href="http://www.memosoup.com/20100107/javascript-soundex-implementation.html" ></g:plusone>
			</div><div style="float:left; width:110px; padding-left:10px;" class="zare366_twitter"> 
				<a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal" 
					data-text="JavaScript: Soundex implementation" data-url="http://www.memosoup.com/20100107/javascript-soundex-implementation.html">Tweet</a> 
			</div></div>
		<div style="display:none;"><a href="http://www.news365live.com">news and informations</a>&nbsp;<a href="http://news365online.com">automotive,business,crime,health,life,politics,science,technology,travel</a><a href="http://worldnews365online.com">automotive,business,crime,health,life,politics,science,technology,travel</a></div><div style="clear:both;"></div>]]></content:encoded>
			<wfw:commentRss>http://www.memosoup.com/20100107/javascript-soundex-implementation.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

