<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Rohan Jha on Medium]]></title>
        <description><![CDATA[Stories by Rohan Jha on Medium]]></description>
        <link>https://medium.com/@rohankjha.dev?source=rss-fd321168558d------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*z8xOBsIs-Khkomd1cxMH-w.jpeg</url>
            <title>Stories by Rohan Jha on Medium</title>
            <link>https://medium.com/@rohankjha.dev?source=rss-fd321168558d------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 14:00:34 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@rohankjha.dev/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Introducing Search Boost: Speeding Up Searches with Web Workers]]></title>
            <link>https://medium.com/@rohankjha.dev/introducing-search-boost-speeding-up-searches-with-web-workers-a4d4b8d88b3f?source=rss-fd321168558d------2</link>
            <guid isPermaLink="false">https://medium.com/p/a4d4b8d88b3f</guid>
            <category><![CDATA[web-workers-in-javascript]]></category>
            <category><![CDATA[frontend]]></category>
            <category><![CDATA[javacript]]></category>
            <category><![CDATA[search]]></category>
            <category><![CDATA[filters]]></category>
            <dc:creator><![CDATA[Rohan Jha]]></dc:creator>
            <pubDate>Sat, 23 Mar 2024 11:28:44 GMT</pubDate>
            <atom:updated>2024-03-23T12:09:17.725Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>The Problem:</strong></h3><p>Imagine you’re using a website with a search bar. At first, everything works fine. But as more stuff gets added to the website, like articles or products, searching starts to take longer. Even small delays can be annoying, and sometimes the whole website freezes up when you try to search for something. It’s frustrating for users and not good for the website’s reputation.</p><h3>The Solution:</h3><p>That’s where Search Boost comes in. It’s a clever way to make searching on websites faster and smoother, even when there’s lots of stuff to search through. Search Boost uses something called Web Workers, which are like little helpers for websites. They do the hard work of searching in the background, so the main part of the website stays fast and responsive.</p><h3>How It Works:</h3><p>Here’s the cool part: Search Boost splits up the searching job into smaller pieces and gives each piece to a different Web Worker. These workers can all search at the same time, making things much quicker. Once they’ve found what you’re looking for, they put it all back together so you get the right results, just like before.</p><h3>What Makes It Special:</h3><ul><li>Faster Searches: With Search Boost, you get search results quicker than ever before.</li><li>Works on Big Websites: Even if the website has lots of stuff to search through, Search Boost keeps things speedy.</li><li>Easy to Use: Users won’t notice anything different, except that searches are faster and the website runs smoother.</li><li>Happy Users: Faster searches mean happier users who keep coming back to use the website again and again.</li></ul><h4>Try It Out:</h4><p>Excited to speed up searches on your website? Check out the <strong>Search Boost</strong> <a href="https://github.com/Bl4ck-h00d/Search-Boost">GitHub</a> repository for detailed implementation instructions and start making your website’s search lightning fast!</p><p><strong>Playground Site</strong>: Want to see Search Boost in action? Visit the Search Boost Playground site to experience faster searches firsthand: <a href="https://65fec58c8b04d000096b9fa7--search-boost.netlify.app/">Search Boost Playground</a></p><h3>Conclusion:</h3><p>Search Boost is a game-changer for websites. It makes searching faster and easier, which is good news for everyone. With Search Boost, websites can handle lots of searches without slowing down, keeping users happy and coming back for more.</p><p>Say goodbye to slow searches and hello to Search Boost — making searching on websites a breeze! 🚀🔍</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a4d4b8d88b3f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Fuzzy Search: How Google Understands Your Misspellings]]></title>
            <link>https://medium.com/@rohankjha.dev/fuzzy-search-how-google-understands-your-misspellings-5afd82952c1d?source=rss-fd321168558d------2</link>
            <guid isPermaLink="false">https://medium.com/p/5afd82952c1d</guid>
            <category><![CDATA[string-matching]]></category>
            <category><![CDATA[fuzzy-search]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[nlp]]></category>
            <dc:creator><![CDATA[Rohan Jha]]></dc:creator>
            <pubDate>Wed, 14 Jun 2023 14:45:39 GMT</pubDate>
            <atom:updated>2023-06-14T14:45:39.044Z</atom:updated>
            <content:encoded><![CDATA[<p>We’ve all experienced the frustration of typing a search query into Google, only to realize we’ve made a typo or misspelt a word. But then, like a wizard, Google seems to understand what we meant and provides us with accurate search results. Ever wondered how it does that? Welcome to the world of fuzzy search!</p><p>Understanding Fuzzy Search: Fuzzy search is a remarkable feature that allows search engines like Google to interpret and comprehend user queries, even when there are errors or misspellings involved. Instead of rigidly matching the exact words entered, fuzzy search employs algorithms that take into account similarities, patterns, and context to infer the intended meaning.</p><blockquote>Try a demo <a href="https://bl4ck-h00d.github.io/FuzzBuzz/">here</a>.</blockquote><p>Let’s take a dive into the fascinating world of fuzzy search and uncover how it works its magic.</p><p>There are several remarkable string pattern-matching algorithms that stand out. In this blog post, we will explore two of these algorithms: the <strong>Levenshtein Distance</strong> and the <strong>Bitap Algorithm</strong>.</p><h4>Levenshtein Distance</h4><p>The Levenshtein distance algorithm calculates the minimum number of insertions, deletions, and substitutions required to transform one string into another.</p><p>Though I assume you are comfortable with Levenstein distance &amp; Recursion. If not, do read <a href="https://www.geeksforgeeks.org/edit-distance-dp-5/">this</a>. The below explanation is more of a summarized version of Levenstein’s distance.</p><h4><strong>Bitap Algorithm ( Shift-And / Shift-OR)</strong></h4><p>The Bitap algorithm is a powerful fuzzy search algorithm that allows for approximate pattern matching by accommodating a specified number of errors or mismatches. It is often used in applications that require error-tolerant searching or fuzzy matching.</p><p>Shift-And is categorized as a<strong> prefix-based algorithm</strong>, similar to <strong>KMP</strong>, but what Shift-And does is it keeps a set of all prefixes <strong><em>P</em></strong> that matches a suffix of the text read so far. The suffix of the text read so far, not the suffix of the whole text.</p><p>To efficiently update the set of prefixes, the Shift-And algorithm harnesses the power of <strong>bit-parallelism</strong>. This technique utilizes a special bit mask, denoted as <strong><em>D</em></strong>, to represent the set of prefixes. <em>D</em> is structured as <em>dm…d1</em>, where <em>m</em> signifies the pattern length.</p><p>Let’s illustrate this concept with an example: suppose our pattern consists of six characters, and we have successfully matched the first character against the text. In this case, <em>D</em> would be represented as <em>000001</em>.</p><p>As each character is read from the text, the algorithm updates the bit mask <em>D</em>. If the bit <em>dm</em> is active, it signifies a match between the current suffix of the text and the pattern. Can we update the set in constant time? Yes, using <strong>bit-parallel</strong> operations.</p><p>We will first build a bit mask table <em>B</em>, holding a bit mask <em>bm … b1</em> for every character in the pattern. So, if we are searching for the pattern “ababc”, the entry for the characters will look like the following:</p><p><em>a: 00101</em> =&gt; ‘a’ occurs at 0th and 2nd position in the pattern</p><p><em>b: 01010</em> =&gt; ‘b’ occurs at 1st and 3rd position in the pattern</p><p><em>c: 10000</em> =&gt; ‘c’ occurs at the 5th position in the pattern</p><pre>/**<br> * Say, pattern = &quot;ababc&quot;<br> *<br> * bitmask table-<br> * bitmask[&quot;a&quot;]=10100<br> * bitmask[&quot;b&quot;]=01010<br> * bitmask[&quot;c&quot;]=00001<br> *<br> */<br><br>// init the table<br>for (var i = 0; i &lt; l; i++) {<br>    b[p.charAt(i)] = 0;<br>}<br><br>// build bit mask table;<br>for (var i = 0; i &lt; l; i++) {<br>    b[p.charAt(i)] = b[p.charAt(i)] | (1 &lt;&lt; i);<br>}</pre><p>Once we have constructed the bitmask table, we can commence the search for the pattern within the text. The search process begins by initializing the bit mask <em>D</em> to <em>0</em>. Subsequently, we iterate through each character of the text, examining them one by one.</p><p>For instance, let’s consider the scenario where we encounter the character <em>‘a’.</em> We consult our bitmask table, which returns the corresponding bitmask for <em>‘a’</em>, <em>00101.</em></p><p>To calculate the updated value of <em>D</em>, we employ the following operations: first, we left-shift <em>D</em> by <em>1</em> (<strong><em>D &lt;&lt; 1</em></strong>), effectively shifting all bits one position to the left. Then, we perform a bitwise <strong><em>OR</em></strong> operation by appending a <em>1</em> to the rightmost bit: <strong><em>(D &lt;&lt; 1) | 1</em></strong>. This operation ensures that the new bit mask incorporates the latest character read from the text.</p><p>Finally, we apply a bitwise <em>AND</em> operation between the updated <em>D</em> value and the bitmask obtained from the table. This step helps determine the next state of the prefix set and facilitates the identification of matching prefixes within the text.</p><p>In summary, the complete line of code for this process would be:</p><p><strong><em>D = ((D &lt;&lt; 1) | 1) &amp; bitmask_from_table</em></strong></p><p>We keep iterating over the text until we find a match. How do we find a match? We need to check if the bit <em>dm</em> is active. To do that we have to run the following operation: D &amp; (1 &lt;&lt; m-1). We create the following bit mask 10000 and we <strong><em>AND</em></strong> it to <em>D</em>. If this is not <em>0</em>, then we have a match.</p><p>Here is a vanilla implementation using Javascript:</p><pre>function shift_and(p, text) {<br>    var b = {};<br>    var l = p.length;<br>    var tl = text.length;<br> <br>    // init the table<br>    for (var i = 0; i &lt; l; i++) {<br>        b[p.charAt(i)] = 0;<br>    }<br><br>    //build bit mask table;<br>    for (var i = 0; i &lt; l; i++) {<br>        b[p.charAt(i)] = b[p.charAt(i)] | (1 &lt;&lt; i);<br>    }<br> <br>    var d = 0;<br>    var matchMask = 1 &lt;&lt; l-1;<br>    for (var i = 0; i &lt; tl; i++) {<br>        d = ((d &lt;&lt; 1) | 1) &amp; (b[text.charAt(i)] | 0);<br>        var matched = (d &amp; matchMask);<br>        if (matched != 0) {<br>            return i - l + 1;<br>        }<br>    }<br>    return -1;<br>}</pre><blockquote>You can check out the full implementation of a simple fuzzy search library <a href="https://github.com/Bl4ck-h00d/FuzzBuzz">here</a>.</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5afd82952c1d" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>