<?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[Social Impact Analytics - Medium]]></title>
        <description><![CDATA[The Social Impact Analytics Institute is a nonprofit organization with a mission to use data science, artificial intelligence, and machine learning for social good. - Medium]]></description>
        <link>https://medium.com/social-impact-analytics?source=rss----4839bfa294fe---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>Social Impact Analytics - Medium</title>
            <link>https://medium.com/social-impact-analytics?source=rss----4839bfa294fe---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 19:21:42 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/social-impact-analytics" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Processing PPTX Files]]></title>
            <link>https://medium.com/social-impact-analytics/processing-pptx-files-194b25fa5d32?source=rss----4839bfa294fe---4</link>
            <guid isPermaLink="false">https://medium.com/p/194b25fa5d32</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[powerpoint-presentation]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[nlp]]></category>
            <category><![CDATA[text-extraction]]></category>
            <dc:creator><![CDATA[Kristen Davis]]></dc:creator>
            <pubDate>Thu, 29 Apr 2021 13:45:39 GMT</pubDate>
            <atom:updated>2021-04-29T13:45:39.127Z</atom:updated>
            <content:encoded><![CDATA[<p>Extracting text from PowerPoint files for Natural Language Processing Analysis</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/850/1*YRnNGxj0viIGoCFzrkcHVQ.jpeg" /><figcaption>PowerPoint Slide Deck Example</figcaption></figure><p>From business organizations to school presentations, information is delivered and shared via PowerPoint slide deck presentations. Rich with language, these decks can play a vital role in any natural language processing analysis. Slide deck analysis can be crucial in understanding topics, key words and themes that the creator of the presentation finds important, or wants to emphasize to the presentation’s intended audience.</p><h3>The PPTX Library</h3><p>The <a href="https://python-pptx.readthedocs.io/en/latest/user/install.html">pptx library</a> has a lot of functionality for extracting text from pptx files. There may be use cases for extracting specific elements from a presentation for analysis, but for most cases the fastest and most efficient way to gather information from a PowerPoint with this library is to use the slide shape and text_frame methods from the library to return all text detected.</p><p>The function below takes in a list of pptx files and returns a dictionary where each file name is the dictionary key and a value of all text detected from each slide of that side show.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/590/1*BgVvZh9PFTvM5fnXwZFJ_Q.png" /><figcaption>Function taking in pptx files and returning a data dictionary</figcaption></figure><p>This function can then be applied to your specific list of PowerPoint files with the following lines of code</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/399/1*jN37i1lA9ilatyqtLZ9y9A.png" /><figcaption>Apply PPTX processing function to files</figcaption></figure><h3>Transforming &amp; Cleaning the Data</h3><p>Once all of your PowerPoint text data has been stored in a dictionary, that dictionary can be transformed into a dataframe with the file name, original text and cleaned text columns. This allows for easy comparison between clean and original text and easy reference to your data via file name.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*FcQivQokCu-fMXZDLwZliQ.png" /></figure><p>Note — the red line indicates that the code string is longer than the recommended 80 characters by ASCII. As a coder it’s always important to consider readability when programming and whether a longer line or multi lines will lead to better readability. In this case a longer line of code was deemed better from a readability standpoint.</p><p>The above code applied basic cleaning to the text, and additional cleaning to remove other escape codes or text specific errors may be needed. To add those in, follow the format outlined above using the lambda function to apply changes to each row’s text within the data frame.</p><h3>Ensuring UTF-8 Encoding</h3><p>One of the most common additional cleaning steps you may need to take is to ensure that your text data is set to <a href="https://www.utf8.com/">UTF-8 Encoding</a>. Applying the following loop to your dataframe will ensure that all data is formatted in UTF-8 and compatible with python packages.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/933/1*JZ-EyylNOtAYIzWd-DWnxA.png" /><figcaption>Ensure UTF-8 encoding in text data</figcaption></figure><h3>Saving Your Dataframe to CSV</h3><p>Finally you can save your data frame to a CSV to be examined in Sheets/Excel or referenced later in a different working notebook.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/603/1*ScEu6pATCCfAmX_l9AuAWQ.png" /><figcaption>Save dataframe to CSV file</figcaption></figure><p>And there you have it! A working data frame of text from PowerPoint slide decks ready for Natural Language Processing analysis!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=194b25fa5d32" width="1" height="1" alt=""><hr><p><a href="https://medium.com/social-impact-analytics/processing-pptx-files-194b25fa5d32">Processing PPTX Files</a> was originally published in <a href="https://medium.com/social-impact-analytics">Social Impact Analytics</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Collecting & Cleaning YouTube Transcripts]]></title>
            <link>https://medium.com/social-impact-analytics/collecting-cleaning-youtube-transcripts-a93cb79b0022?source=rss----4839bfa294fe---4</link>
            <guid isPermaLink="false">https://medium.com/p/a93cb79b0022</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[youtube]]></category>
            <category><![CDATA[transcript]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[nlp]]></category>
            <dc:creator><![CDATA[Kristen Davis]]></dc:creator>
            <pubDate>Thu, 22 Apr 2021 19:55:59 GMT</pubDate>
            <atom:updated>2021-04-22T19:55:59.628Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/820/1*dTYpBpjc_41_MapIzlWgwg.png" /></figure><p>With over 500 hours of video uploaded to YouTube every minute worldwide, these videos account for a huge portion of available data in our world. This guide will walk you through how to collect a video’s transcript &amp; clean the text so that it is ready for you to analyze.</p><h3>Step 1: Save the YouTube Video</h3><p>Creators on YouTube are constantly updating, changing and deleting their content. This is important for anyone working with video data sources to recognize, as the video you analyze today may not be available to view tomorrow. It is important to always preserve your raw data — in this case the video — as it is at the time of processing, for analysis integrity. So before beginning any transcript collection, take some time to download and store the video in your analysis. There are many resources out there that will help you do this, like the <a href="https://yt1s.com/en41">YouTube Downloader</a>.</p><p>If memory on your computer is a concern, these videos can be uploaded to a folder in Google Drive or another cloud storage platform.</p><h3>Step 2: Download Video Transcripts</h3><p>Once you’ve created a back up for all the videos you wish to analyze <a href="https://pypi.org/project/youtube_dl/">youtube_d1</a> is a fantastic package that allows you download the subtitles YouTube has on the video.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/223/1*fgnpM4aNVZTaNBHaAf7txg.png" /><figcaption>Pip install youtube_dl</figcaption></figure><p>After installing the package you can use the below function to download the subtitles. This function takes in a YouTube video’s url and a language specification and returns a downloaded transcript in a VTT file with the URL as the file name.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*OHwBLQEl3T9pFhWg7Zjvqw.png" /><figcaption>Download video subtitles</figcaption></figure><p>Once downloaded, the videos subtitles will be saved in a VTT file in this format:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/491/1*Gmm1ee7pGAL1_xDROSzPow.png" /><figcaption>VTT file example</figcaption></figure><p>This format is easy to read and reference but contains some language errors, in addition to not being in a format that would be conducive to natural language processing.</p><h3>Step 3: Build a Data Dictionary</h3><p>In order to work with the transcripts once the videos have been downloaded, it is useful to read them into to your working notebook and store them in a data dictionary. The function below takes in a list of file names stored as VTT files and returns a data dictionary that contains each file name (video URL) as a key and the file contents (subtitles) as a value.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/692/1*e-biuWt8n8aXFRMqX5QnJA.png" /><figcaption>Function that reads in VTT files and returns a data dictionary</figcaption></figure><p>With that function you can create a dictionary of each video file and the corresponding subtitle transcript:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/440/1*3Ct3O-3Us3zD1dcK0ssFbg.png" /><figcaption>Process VTT files using custom function</figcaption></figure><h3>Step 4: Build a Data Frame to Store Unprocessed &amp; Cleaned Text</h3><p>Finally you can build a data frame that contains the file name (URL), the original text detected by youtube_dl, and a column containing cleaned text.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1001/1*yP6OsrwdD-C-7N1OsA0l1Q.png" /><figcaption>Build a dataframe with url, text and clean text columns</figcaption></figure><p>Note — the red line indicates that the code string is longer than the recommended 80 characters by ASCII. As a coder it’s always important to consider readability when programming and whether a longer line or multi lines will lead to better readability. In this case a longer line of code was deemed better from a readability standpoint.</p><p>The above code applied basic cleaning to the text, and additional cleaning to remove other escape codes or text specific errors may be needed. To add those in, follow the format outlined above using the lambda function to apply changes to each row’s text within the data frame.</p><h3>Step 5: Saving Your Data Frame to a CSV</h3><p>Finally you can save your data frame to a CSV to be examined in Sheets/Excel or referenced later in a different working notebook.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/523/1*ZSpwG6QuhgwF4Eq6yzjZuQ.png" /><figcaption>Save dataframe to CSV file</figcaption></figure><p>And there you have it! A working data frame of video transcripts ready for Natural Language Processing analysis!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a93cb79b0022" width="1" height="1" alt=""><hr><p><a href="https://medium.com/social-impact-analytics/collecting-cleaning-youtube-transcripts-a93cb79b0022">Collecting &amp; Cleaning YouTube Transcripts</a> was originally published in <a href="https://medium.com/social-impact-analytics">Social Impact Analytics</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Extract Text From Unsearchable PDFs For Data Analysis Using Python]]></title>
            <link>https://medium.com/social-impact-analytics/extract-text-from-unsearchable-pdfs-for-data-analysis-using-python-a6a2ca0866dd?source=rss----4839bfa294fe---4</link>
            <guid isPermaLink="false">https://medium.com/p/a6a2ca0866dd</guid>
            <category><![CDATA[social-impact]]></category>
            <category><![CDATA[nlp]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[pytesseract]]></category>
            <category><![CDATA[ocr]]></category>
            <dc:creator><![CDATA[Jonathan Lee]]></dc:creator>
            <pubDate>Sat, 17 Apr 2021 00:01:11 GMT</pubDate>
            <atom:updated>2021-04-17T00:01:11.865Z</atom:updated>
            <content:encoded><![CDATA[<h3>Extract Text From Unsearchable PDFs Using OCR, Tesseract, and Python</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*TR2l3KPCnHCiLM0Q" /><figcaption>Photo by <a href="https://unsplash.com/@loverna?utm_source=medium&amp;utm_medium=referral">Loverna Journey</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>At <a href="https://www.siainstitute.org/"><strong><em>Social Impact Analytics Institute</em></strong></a>, we do a lot of text extraction on PDF files. Problems arise when the PDF files are scanned documents, because that means general extraction libraries like Pdfminer, PyPDF2, or PyMuPDF are not able to extract text correctly. In order to read the files, make the text content of the files searchable, and be able to do further NLP data analysis, an OCR process must be used.</p><p>In this article, I’m going to demonstrate how to use an open source OCR engine (Optical Character Recognition) called <strong><em>Tesseract </em></strong>and its<strong><em> Python APIs</em></strong> to conduct text extraction and then put the text into a pandas data frame for further data analysis.</p><h4>Quick view of Contents</h4><ol><li>Install Tesseract engine.</li><li>Install Python Packages: PyTesseract, OCRmyPDF.</li><li>Code Example for Text Extraction</li></ol><h4>Tesseract Installation</h4><p>Tesseract is a free command line application powered by Google. It has been widely used for OCR tasks, however, it is not a python library so it must be installed separately<em>. </em>I suggest installing Tesseract on <strong><em>Mac OS, Ubuntu</em></strong> or another Linux-like system. However, if you are using Windows, <a href="https://medium.com/quantrium-tech/installing-and-using-tesseract-4-on-windows-10-4f7930313f82">this article</a> shows how to install it on Windows 10.</p><p><strong>Mac : </strong>brew install tesseract</p><p>If you already have homebrew, simply enter this code on your terminal and then you are done. If not, check homebrew’s <a href="https://brew.sh/">home page</a> to install it.</p><p><strong>Ubuntu: </strong>sudo apt-get install tesseract-ocr</p><h4>Python Packages</h4><p>There are 2 ways to use the Tesseract engine in this article: through<strong><em> Pytesseract</em></strong> or through <strong><em>OCRmyPDF. </em></strong>Both require the installation of additional libraries. I will show how these work together in the following sections. First, install the packages through the pip command in a python environment:</p><pre>pip install ocrmypdf</pre><pre>pip install pytesseract</pre><pre>pip install opencv-python</pre><pre>pip install pdf2image</pre><h4>1. Pytesseract</h4><p>Pytesseract reads the input file as an image, so <strong><em>opencv-python</em></strong> and <strong><em>pdf2image</em></strong> are included to help transfer PDF files into images. The steps will look like this:</p><ol><li>Read PDF files</li><li>Convert PDFs into images</li><li>Image preprocessing to check orientation, deskew, gray scale, etc.</li><li>Run OCR function from its API</li><li>Extract all/part of the text</li></ol><p>The syntax of the main OCR function is:</p><pre>pytesseract.image_to_string(page_arr)</pre><p>The code, including image processing steps and how to put the resulting text into a pandas data frame, is shown below. The code for the deskew function is referenced <a href="https://www.pyimagesearch.com/2017/02/20/text-skew-correction-opencv-python/">here</a>.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2f1d7118afb441fb2e60d407ff5a56e2/href">https://medium.com/media/2f1d7118afb441fb2e60d407ff5a56e2/href</a></iframe><p>To show the result:</p><pre>OCR_dic[file_list[0]</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/774/1*zISVX5uNecAoCbL93VrDig.png" /><figcaption>Seems odd that all the text files start with identical wording. This is a clue that a header may be in use.</figcaption></figure><h4>2.1 Remove Header and Footer</h4><p>After displaying the result, it seems that the header was included and it may not be wanted or required. Here I will show a simple code to exclude certain contents from our extraction results by using <strong><em>pytesseract</em></strong>.<strong><em>image_to_data</em></strong> syntax, which generates meta-data like box boundaries, confidence and other information.</p><pre>pytesseract.image_to_data(page_arr,output_type=Output.DICT)</pre><p>The keys of the output dictionary will look like this:</p><pre>dict_keys([&#39;level&#39;, &#39;page_num&#39;, &#39;block_num&#39;, &#39;par_num&#39;, &#39;line_num&#39;, &#39;word_num&#39;, &#39;left&#39;, &#39;top&#39;, &#39;width&#39;, &#39;height&#39;, &#39;conf&#39;, &#39;text&#39;])</pre><p>Note that <strong><em>level</em></strong> is critical to interpret these results. It will be an integer between 1~5 and each of them stands for</p><ol><li>page</li><li>block</li><li>paragraph</li><li>line</li><li>word</li></ol><p>Let see how it works on the PDF. Here I use a file’s first page as an example. I want to see how many blocks will be generated and want to see if it includes the header and footer.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d6f48db5e70fe775dc335a0c83d263b2/href">https://medium.com/media/d6f48db5e70fe775dc335a0c83d263b2/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/959/1*Zo58gSYiS4pREjXz76X7bw.png" /><figcaption>Blocks generated by Tesseract — notice there are a total 8 blocks. This can be checked by looking at the block_num column.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VJMwUXP9AIc5k_m9Mk6cVg.jpeg" /><figcaption>Blocks highlighted by green lines</figcaption></figure><p>The image and data frame above show that 8 blocks were generated from OCR, and fortunately the header and footer are included in the first and the last blocks. If I want to remove both of them, it is easy to achieve by removing these two blocks.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/cd2b68e3576c2f3935366e43627fe2d0/href">https://medium.com/media/cd2b68e3576c2f3935366e43627fe2d0/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/773/1*k3FKzNwWxWKmGPxNyo7t1A.png" /></figure><p>Now the extracted text does not include the header or footer. However, for different PDFs, this code may need to be modified or headers and footers may not be so easily excluded.</p><h4>2. OCRmyPDF</h4><p>It is more simple to use OCRmyPDF when compared to Pytesseract because OCRmyPDF doesn’t require image processing steps. The output result of OCRmyPDF will be a PDF file, though, so additional steps are required if one wants to extract its text data. Here I use PyMuPDF to do that, which provides multiple output format options like xml, html or json. Choose whichever type works best for your purposes. The steps of the process are:</p><ol><li>Run the OCRmyPDF function to create new, searchable PDF files.</li><li>Use PyMuPDF to extract text from the PDF.</li></ol><p>The code for using OCRmyPDF will look like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1342dcdf7512fa94be9d3bfae9dd3b38/href">https://medium.com/media/1342dcdf7512fa94be9d3bfae9dd3b38/href</a></iframe><p>To show the result of the first PDF file:</p><pre>extraction_pdfs[ocr_file_list[0]]</pre><h4>Conclusion</h4><p>In this article, I’ve shared code for how to use two popular Tesseract python APIs to conduct OCR on PDF files. My suggestions for which API should be used are:</p><ol><li>For simple OCR tasks where text extraction is a minor part of the whole project, you should use OCRmyPDF. It is faster and easier to conduct the OCR process without the extra image processing steps, and you can leave meta-data extraction to PyMuPDF once the PDF files are transferred into searchable PDF.</li><li>If the goal is to do customized text extraction such as getting the date/time from a group of receipts or removing headers and footers as I did in this article, then using Pytesseract will be more appropriate. Pytesseract prevents you from having to read the file twice, and filter conditions can be written during the OCR.</li></ol><h4>Reference</h4><p>https://tesseract-ocr.github.io/</p><p>https://pypi.org/project/pytesseract/</p><p>https://ocrmypdf.readthedocs.io/en/latest/index.html</p><p>https://www.pyimagesearch.com/2017/02/20/text-skew-correction-opencv-python/</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a6a2ca0866dd" width="1" height="1" alt=""><hr><p><a href="https://medium.com/social-impact-analytics/extract-text-from-unsearchable-pdfs-for-data-analysis-using-python-a6a2ca0866dd">Extract Text From Unsearchable PDFs For Data Analysis Using Python</a> was originally published in <a href="https://medium.com/social-impact-analytics">Social Impact Analytics</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How Data Can Boost Your Non-Profit]]></title>
            <link>https://medium.com/social-impact-analytics/how-data-can-boost-your-non-profit-1b4d1dd12e54?source=rss----4839bfa294fe---4</link>
            <guid isPermaLink="false">https://medium.com/p/1b4d1dd12e54</guid>
            <category><![CDATA[nonprofit]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[Kourosh Alizadeh]]></dc:creator>
            <pubDate>Fri, 09 Apr 2021 00:59:07 GMT</pubDate>
            <atom:updated>2021-04-09T01:36:44.327Z</atom:updated>
            <content:encoded><![CDATA[<h4>You’re already excellent, but it can’t hurt to put a number on it</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*G28CifGD1IPxJd2d" /><figcaption>Data-driven kindness please :) Photo by <a href="https://unsplash.com/@meilingmirow?utm_source=medium&amp;utm_medium=referral">Mei-Ling Mirow</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>If you’re running any kind of organization that interacts with the public, chances are you’re sitting on a pile of data. In many cases, this data is not formally contained on some central server, but it is there. Every time your members interact with clients, they generate some sort of information. Maybe they collect contact information, or start an email chain, or add to the files on a specific client. No matter how informally you may be collecting it, you have data.</p><p>On top of that, there is likely a lot of publicly available data that pertains to your field. Working on homelessness? There’s a <a href="https://www.kaggle.com/adamschroeder/homelessness">dataset</a> for that. Working on education? There’s a <a href="https://www.kaggle.com/theworldbank/education-statistics">dataset </a>for that. And not just one — most of these issues have many datasets from multiple sources that you can compare and consider.</p><p>Here, I won’t spend too much time on how to get pertinent data for your cause; that is a topic for another post. Instead, I want to start by motivating you to even get into the data game.</p><p>How can data help your non-profit? Here are three main ways:</p><h3>1. IDENTIFY NEEDS</h3><p>Imagine you want to improve education for underserved populations. Well, what populations are underserved? How is that disadvantage affecting them? What are the long-term consequences of having to attend less well-funded schools?</p><p>You may have a feel for the answers to these, but if you’re trying to pitch the concept to investors, having actual tangible data will be a lot more persuasive than common sense and your gut feelings. With the right data, you could demonstrate definitively that some populations are getting lower test scores, and you could identify contributing factors. You could even use machine learning to quantify the potential impact of your proposed interventions. All of this will give your potential funders a sense that you (and by extension, they) are addressing a concrete issue in a way that will get real results. Which means they’ll be much more likely to fund your project.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/992/1*Vad8_xttFEXpA0288zJ7sQ.png" /></figure><p>Identifying needs also gives you the potential to narrow the focus of your work. Maybe you want to improve education, but looking at the data shows you that educational weaknesses are most prevalent in elementary schools and among people whose parents didn’t go to college (for example). Well, now you can carve out a niche and tell a more vivid story with your work. You can paint the picture of a student whose parents are struggling to help them because of their own educational gaps. You can target potential investors who are themselves first-generation college students. You can propose interventions that specifically help your population, like providing educational aids to the parents of these students. All of these would give your organization a more clear identity and a more concrete mission.</p><p>To sum it all up, data can help your non-profit to identify real needs in the community and think creatively about how to address them. This, in turn, helps you get real results and drive further funding.</p><h3>2. REFINE PROCESSES</h3><p>Ok, so now you’ve got yourself started and you’re doing some good work in the community. Nice! The question you can start asking yourself here is — how are we doing this work?</p><p>Humanity’s capacity to organize is what allowed our species to rise above the apes and become the dominant species on the planet. But it’s still profoundly imperfect, and every organization is probably wasting resources on any number of erroneous tasks. By exploring the data, you can streamline and refine the way your non-profit functions so that you spend less time on minutiae and more time on your mission — helping the community.</p><p>This could be as simple as moving your data from a paper filing system to a digital one; that’ll take some data warehousing know-how, but it’ll greatly improve your workflows. Or maybe you see that whenever a certain issue comes up, the email chains tend to be 3 times as long as the average. Well, maybe we need to put an official process in place to handle those cases so that people don’t spend forever negotiating the issue themselves.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pJoY1MGPJtgVBJrx7mZgNQ.png" /></figure><p>You can also see what’s not working. Maybe one of your case workers usually has a great record but they’ve been working with a certain family for a long time without getting results. In such a case, you could investigate why this particular case is proving difficult; maybe another case worker has a different style that would be better suited to it. Or maybe you find that on days when you don’t put out coffee, the number of people coming to the shelter is typically 10% lower than normal. That’s something you may not be able to detect just by being there, but it’s an easy data point to measure, then change, and thus increase your organization’s impact.</p><h3>3. DEMONSTRATE VALUE</h3><p>Great, so now you’ve identified a need and you’ve got some great techniques to help meet it. And you’ve been plugging along for a while, but now it’s time to expand or to pump up your fundraising. Don’t worry, the data has your back on this one too.</p><p>Imagine two grant proposals from education-oriented non-profits. In one of them, the author writes that their organization ‘did great work’ and ‘made big contributions’ to improve test scores for first-generation college students. In the other, the organization says the same things, but also provides a number of different graphs and tables to demonstrate that thanks to their work, test scores for first-generation college students improved by 25% overall. Who would you rather fund? It’s a no-brainer.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*540CDEdvU0POJyQnWe06Yg.png" /></figure><p>This kind of before-and-after comparison can prove to potential funders that you know what you are doing and can get results. But it also shows that you are making an effort to measure your impact and improve. This demonstrates a greater potential for future growth as well as showing that you are able to get results now.</p><p>And of course, it’s not always about investors. You can also use data to pat your team on the back and show them that their work really makes a difference. That, after all, is why you’re in the non-profit business, and being able to demonstrate that to your team and to yourself can provide a great morale boost and energize your entire organization.</p><h3>CONCLUSION</h3><p>Data can help your non-profit identify real needs, refine its processes, and give concrete proof of its community contribution.</p><p>To sum it up, I’ll leave you with a little analogy. The difference between an organization that uses its data intelligently and one that runs mostly by gut instincts is like the difference between a physical conversation in person and a conversation via text. In person, you can see how your words impact your conversation partner based on a whole spectrum of inputs, from their face to their body language to their tone. You can intuitively adjust your own tone and body language to suit the situation, and if you need to help them, you can do anything from giving them a hug to handing them a tissue. On the other hand, if you’re just texting, then you get just the flat written text, with no other cues. It can be hard to tell what people are really thinking or feeling, and even harder to provide meaningful help except with the most basic ‘sorry to hear that’ kind of messages.</p><p>I’d much rather be the organization actually talking to my clients than the one texting them from miles away.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1b4d1dd12e54" width="1" height="1" alt=""><hr><p><a href="https://medium.com/social-impact-analytics/how-data-can-boost-your-non-profit-1b4d1dd12e54">How Data Can Boost Your Non-Profit</a> was originally published in <a href="https://medium.com/social-impact-analytics">Social Impact Analytics</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A Quick Guide to Journey & Service Mapping]]></title>
            <link>https://medium.com/social-impact-analytics/a-quick-guide-to-journey-service-mapping-4fed4e6f3160?source=rss----4839bfa294fe---4</link>
            <guid isPermaLink="false">https://medium.com/p/4fed4e6f3160</guid>
            <category><![CDATA[ux-design]]></category>
            <category><![CDATA[user-experience-research]]></category>
            <category><![CDATA[user-journey-mapping]]></category>
            <category><![CDATA[business-process]]></category>
            <category><![CDATA[journey-mapping]]></category>
            <dc:creator><![CDATA[Robin Lee Nunnally]]></dc:creator>
            <pubDate>Wed, 31 Mar 2021 15:01:48 GMT</pubDate>
            <atom:updated>2021-03-31T16:49:05.654Z</atom:updated>
            <content:encoded><![CDATA[<h4>Identifying the client’s pain points visually for clarity and solution brainstorming</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*npW0o7wroWZpGdRvx6sm0g.png" /></figure><p>There are many different ways to create storyboards that reflect a client’s experience. Recently, I was asked to create a “business process map” showing the user’s experience — a “visual map that people can see the user paths and quickly see how many places human intervention is needed and where we can automate processes.”</p><p>I created a hybrid journey map + service map for <a href="https://www.siainstitute.org/">Social Impact Analytics Institute</a> for a nonprofit client of theirs. This way, we’d be able to show not only the touchpoint of the user’s activity and steps needed to perform their tasks (behind the scenes), but also show any emotional reactions they had in regards to their work flow daily.</p><p>Below is my personal step by step process for building out such a map.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*XuJ3zImWDN3e1V1o" /><figcaption>Photo by <a href="https://unsplash.com/@galex?utm_source=medium&amp;utm_medium=referral">Alex Ghizila</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h4>Review user interviews and dissect the information</h4><p>It’s one thing to record a user interview, but I always find transcribing everything down on “paper” (in my case, Google Docs) always allows me to clearly see every detail possible surrounding the client’s story.</p><p>After going through with a set of headphones and typing out every little word, I then start to highlight sections in three different colors:</p><ul><li>one for <strong>Positive experiences</strong> (<em>yay! This is working well for the client/wins</em>)</li><li>one for <strong>User Pain Points </strong>(<em>frustrations, etc</em>)</li><li>one for <strong>“interesting insights”</strong> (<em>these might just be usability notes or perhaps a suggestion that the user makes on how THEY think the system could be improved</em>)</li></ul><p>If creating a Service Map, I also highlight or bold every single major “step” in the process. Since the major steps in this particular action goal had many parts to each one, I decided to name them “phases”, with each phase having steps and potential sub-steps that get broken down in the map.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IhXwr3aWT3cQ-iWeGndsnw.png" /><figcaption>In the above example, I use BLUE to highlight steps in the process, YELLOW represents key pieces of information/needs, and ORANGE represents user pain points.</figcaption></figure><p>From here, we start to map out the points in an order of operations flow.</p><h4>Mapping out the business steps</h4><p>For the purposes of showing the business process from the user’s point of view, at the top of my map, <strong>I listed the different steps or “phases”</strong>, as I called them. Because the client was using so many tools to achieve their goal, I also felt it was important to <strong>note what software/tools they had to use</strong> depending upon the phase in their process.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Gk572xgrx9QIW_L7aYfT1Q.png" /></figure><p>Finally, I listed out the <strong>specific sub steps within phase/step</strong>, starting from the moment the new client comes into the door of the business.</p><h4>Mapping out the behind-the-scenes details for each step</h4><p>These details were mostly pulled from my “important details/insights” highlights in the interview transcriptions. While this mapping process might look a little different for everyone, I also added some little <strong>“side note” post-it’s</strong> along the timeline as well; these often featured information that I felt were “<strong>must-have’s/requirements</strong>” to complete this specific action item.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bUEzuokRawPUEMMJhsOGjw.png" /></figure><p>For example in the image above, under “Employee asks the client to read the document, fill it out, and sign it”, I added a post it note that clarifies that grants and banks require a wet signature, which directly may impact our decision-making when we begin the brainstorming phase for any sort of process re-design or process automation. We wouldn’t want to go through a lot of work redesigning something and suggesting it later on down the line for our client, only to have them let us know that we missed a certain constriction or design perimeter from the interview.</p><h4>Mapping out the emotional experience of the user’s process</h4><p>Finally, I start to tackle the journey map part of this endeavor, by <strong>pulling my pain points AS WELL AS the positive experiences from the transcriptions</strong>, <strong>and starting to list them along the timeline map</strong> depending upon what part of the process they occur.</p><p>After pulling all these qualitative data points, you’ll want to<strong> start to map out roughly an emotional attachment to them </strong>(were they a “high” or a “low”), as was expressed from the user interview. This is one of the biggest reasons why recording your zoom video chats with users is super important to be able to refer back to later. In these videos, you can see and hear signs of emotional changes that you can’t necessarily interpret from written dialogue; things like if the tone of voice goes down or sounds “annoyed” when the user is talking about their experience, or if they visibly roll their eyes or give a look of frustration in their facial expressions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*raxOBUQOJmO-ReYZtxg54w.png" /></figure><p>Taking those emotional reaction signs, you’ll want to start to map out a line graph, showing the interpreted highs and lows of the user’s experiences. Being that these are qualitative data points, and you, as another human being, are assigning placements for them on an “emotional response” map based on your interpretation, this is not a perfectly scientific method. Instead, this line graph acts as a rough visual map to represent an experience of your client, clearly showing where their experiences start to go down in the process, or when things are working really well for them and they are happy, all dependent on whether they are higher (positive) or lower (negative) than the x-axis line.</p><p>In the end, we end up with something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ae4W6ixM4h6S6fYN_tpVkw.png" /><figcaption>screenshot of finished Journey/Service Map, created by SIAi volunteer Robin Nunnally of RobinLeeDesigns.com</figcaption></figure><p>I hope this breakdown of how I create this sort of map has been helpful for you! Again, this sort of mapping can represent a lot of different types of data, so it really just comes down to what your team and client needs are.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4fed4e6f3160" width="1" height="1" alt=""><hr><p><a href="https://medium.com/social-impact-analytics/a-quick-guide-to-journey-service-mapping-4fed4e6f3160">A Quick Guide to Journey &amp; Service Mapping</a> was originally published in <a href="https://medium.com/social-impact-analytics">Social Impact Analytics</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Comparing 4 methods for pdf text extraction in python]]></title>
            <link>https://medium.com/social-impact-analytics/comparing-4-methods-for-pdf-text-extraction-in-python-fd34531034f?source=rss----4839bfa294fe---4</link>
            <guid isPermaLink="false">https://medium.com/p/fd34531034f</guid>
            <category><![CDATA[nlp]]></category>
            <category><![CDATA[social-impact]]></category>
            <category><![CDATA[pdf]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[nonprofit]]></category>
            <dc:creator><![CDATA[Jeanna Schoonmaker]]></dc:creator>
            <pubDate>Wed, 24 Mar 2021 16:46:11 GMT</pubDate>
            <atom:updated>2021-03-24T16:46:11.714Z</atom:updated>
            <content:encoded><![CDATA[<p>Accuracy and processing time for PyPdf2, PdfMiner.six, Grobid, and PyMuPdf</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XFXIoB2tmyCdKmdzlvKl8Q.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@imandrewpons?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Andrew Pons</a> on <a href="https://medium.com/?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p><em>In comparing 4 python packages for pdf text extraction, PyMuPdf was found to be an optimum choice due to its low Levenshtein distance, high cosine and tf-idf similarity, and fast processing time, though all 4 packages performed very well in general and Grobid produced the cleanest text output. All code provided at github link at the end of the article.</em></p><p>At Social Impact Analytics Institute, we are working to gather information and find patterns in the collected data about social issues. Many articles and primary sources of information are stored as pdfs.</p><p>Despite Portable Document Format, or pdf, being one of the most common formats for document storage, it is not standardized. Pdfs can vary from being scanned copies of old documents to being computer-generated articles, which affects how well a program can “read” the text within a pdf. Since SIAi’s text data will be used for NLP, sentiment analysis, and further data exploration, it is critical that the extracted text be as accurate as possible. Since we anticipate needing to process thousands of pdfs, it’s also important that our process be time-friendly. We compared 4 open-source methods in python for text extraction from pdfs with these guidelines in mind.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*sT5ufsS7eoT8dm58GvEb-A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/250/1*5pAYmoW2UP5b8KR3WGKtIQ.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dh-lPy0R0XCnQ8k96D9bhQ.jpeg" /></figure><p>Three of the packages tested — PyPdf2, PdfMiner.six, and PyMuPdf — can be pip installed. Grobid, which stands for “GeneRation Of BIbliographic Data,” requires additional installation steps, which are clearly laid out in its documentation: <a href="https://grobid.readthedocs.io/en/latest/Install-Grobid/">https://grobid.readthedocs.io/en/latest/Install-Grobid/</a> Grobid uses machine learning to process pdfs into xml files which can then be processed for text extraction. This is a multi-step task, which makes it a bit of an outlier in this comparison, but we feel its inclusion is warranted due to the nature of its output as discussed below.</p><p>We used a file called “Threat Assessment in the Campus Setting,” which can be found at this link: <a href="https://schoolshooters.info/sites/default/files/2014-NaBITA-Whitepaper-Text-with-Graphics.pdf">https://schoolshooters.info/sites/default/files/2014-NaBITA-Whitepaper-Text-with-Graphics.pdf</a> to compare these methods. This file seemed representative of a typical pdf article due to its use of graphics, footnotes, bulleted lists, etc (thumbnails of sample pages shown below). The file was converted to .txt type to use as a baseline for comparison. Pdf and txt versions of this file, as well as the xml version created through the Grobid process, can be found in the github link at the end of this article.</p><figure><img alt="Thumbnails of a pdf document" src="https://cdn-images-1.medium.com/max/1024/1*kwcXPPhKKIKXp79hzAYjMQ.png" /></figure><p>Each python package was evaluated by comparing its text output with the baseline .txt file. The time it took each process to run inside a jupyter notebook cell was also measured and compared. As can be seen in the following code, some options have multiple steps for the pdf to go through, while others are more straightforward. In each case, we referred to the documentation for the python package to ensure we used the correct steps to extract text.</p><p><strong>PyMuPdf text processing code:</strong></p><pre>import sys, fitz<br>fname = &#39;./2014-NaBITA-Whitepaper-Text-with-Graphics.pdf&#39;<br>doc = fitz.open(fname)  <br>text = &#39;&#39;<br>for page in doc:  <br>    text += page.getText() <br><br>pymupdf_test = text</pre><p><strong>Pdfminer.six text processing code:</strong></p><pre>def pdf_to_txt(path):<br>    from io import StringIO<br><br>    from pdfminer.converter import TextConverter<br>    from pdfminer.layout import LAParams<br>    from pdfminer.pdfdocument import PDFDocument<br>    from pdfminer.pdfinterp import PDFResourceManager, PDFPageInterpreter<br>    from pdfminer.pdfpage import PDFPage<br>    from pdfminer.pdfparser import PDFParser<br><br>    output_string = StringIO()<br>    with open(path, &#39;rb&#39;) as in_file:<br>        parser = PDFParser(in_file)<br>        doc = PDFDocument(parser)<br>        rsrcmgr = PDFResourceManager()<br>        device = TextConverter(rsrcmgr, output_string, laparams=LAParams())<br>        interpreter = PDFPageInterpreter(rsrcmgr, device)<br>        for page in PDFPage.create_pages(doc):<br>            interpreter.process_page(page)<br>    text = str(output_string.getvalue())<br>    return text<br><br>file = &#39;./2014-NaBITA-Whitepaper-Text-with-Graphics.pdf&#39;<br><br>pdfminersix_test = pdf_to_txt(file)</pre><p>The text outputs from each package were then compared with the baseline .txt file and used to calculate the <a href="https://en.wikipedia.org/wiki/Levenshtein_distance">Levenshtein distance</a>, <a href="https://en.wikipedia.org/wiki/Cosine_similarity">Cosine similarity</a>, and <a href="https://www.jeremyjordan.me/identifying-related-bodies-of-text-using-tf-idf-vectorization/">Tf-idf similarity</a>.</p><p>An in-depth explanation of each of the measurements can be found at the links provided, but in general:</p><ol><li>Levenshtein distance is measured by counting each character difference between one string and another, with a desired output of zero. This would mean there are zero differences between the characters and spacing in one string and another.</li><li>Our Cosine similarity process uses a word count to create a vector for each string, then measures the cosine of the angle between vectors to determine how similar word counts between the two strings are.</li><li>Tf-idf similarity measures for the similarity in frequency of words between strings. In both cosine and tf-idf similarity, the desired output is 1.0, meaning the strings are the same in word count and word frequency.</li></ol><p>A note about Levenshtein distances and Grobid — when the .txt file was created from our source article, it kept ALL text from the original article in place, including page numbers, headers, footers, etc., exactly in the place they were found on the page. The process of converting the file to .txt, as well as the process to extract text from pdfs using most of these python methods, doesn’t classify the different parts of the document. Instead, it keeps everything, which results in page numbers inserted into the middle of sentences, as shown by the page number “2” being included in the sentence here (emphasis added):</p><blockquote>“NaBITA has come to realize over the last five years that this essential function can be more accurately, affordably and accessibly provided <strong>within and by 2 the</strong> team through the SIVRA-35.”</blockquote><p>While Grobid’s Levenshtein distance looks high in comparison to the other text extraction methods, it is worth noting that Grobid’s machine learning and computer vision approach to categorizing the text from a document into an xml output separates the page numbers, headers, and footers from the text, and doesn’t include them in the text output. This makes the Grobid Levenshtein distance high when compared to the .txt file, but also means <strong>the Grobid text output was actually the cleanest because it did not include page numbers and other noise</strong>. Despite the complexity associated with installing and processing pdfs using Grobid, its clean text output makes it a very good option when working with pdfs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BFoi9AWXCakCZrzFl4DRDA.png" /></figure><p>In the results table, the baseline_string row compared the txt file with itself, resulting in a perfect score for Levenshtein distance, cosine and tf-idf similarity, which makes sense since the two documents being compared in this case were identical. For processed pdf files, PdfMiner.six had the lowest Levenshtein distance. PdfMiner.six and PyMuPdf have identical tf-idf and cosine similarity scores, despite PyMuPdf having a slightly higher Levenshtein distance. This likely means the difference between the two Levenshtein distances is based on spaces or characters, but that both methods extracted the words within the text similarly well. However, Pdfminer.six took nearly 2.5 seconds to run while PyMuPdf processed the pdf in 42 milliseconds. While 2.5 seconds does not sound like much, when multiplied by hundreds or thousands of documents, it would be tough to justify using a process that takes 6 times as long to complete when other measurements are similar.</p><p>Ultimately, all of the methods tested produced very accurate text results in relatively short amounts of time and would work well for most use cases. The full code for all steps described in these tests can be found here: <a href="https://github.com/JSchoonmaker/PDF-Text-Extraction">https://github.com/JSchoonmaker/PDF-Text-Extraction</a></p><p>Once you’ve extracted text from pdfs, an important next step could include spell-checking — check out SIAi team member Elisa Ponte’s article about python packages for spell checking here: <a href="https://medium.com/social-impact-analytics/spell-checking-computer-extracted-text-from-pdfs-9390c05bb2e5">https://medium.com/social-impact-analytics/spell-checking-computer-extracted-text-from-pdfs-9390c05bb2e5</a></p><p>Visit <a href="http://www.siainsitute.org/">www.siainsitute.org</a> to learn more about the research we are doing at Social Impact Analytics Institute.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fd34531034f" width="1" height="1" alt=""><hr><p><a href="https://medium.com/social-impact-analytics/comparing-4-methods-for-pdf-text-extraction-in-python-fd34531034f">Comparing 4 methods for pdf text extraction in python</a> was originally published in <a href="https://medium.com/social-impact-analytics">Social Impact Analytics</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Spell Checking Computer-Extracted Text from PDFs]]></title>
            <link>https://medium.com/social-impact-analytics/spell-checking-computer-extracted-text-from-pdfs-9390c05bb2e5?source=rss----4839bfa294fe---4</link>
            <guid isPermaLink="false">https://medium.com/p/9390c05bb2e5</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[spell-check]]></category>
            <category><![CDATA[social-impact]]></category>
            <category><![CDATA[pdf-extraction]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[Elisa Ponte]]></dc:creator>
            <pubDate>Tue, 09 Feb 2021 22:17:23 GMT</pubDate>
            <atom:updated>2021-02-09T22:17:23.295Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oLG9idgCc8quCTlUvg9O3g.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@aaronburden?utm_source=medium&amp;utm_medium=referral">Aaron Burden</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>When you read a low-quality PDF, a little common sense is usually all you need. But since common sense isn’t exactly one of a computer’s greatest assets, automated PDF extraction often needs to be followed by some sort of spell checking to correct any mistranscribed text.</p><p>To determine the best way to correct misspellings caused by computer text extraction, I compared the effectiveness of two main types of spell checkers: one that finds all the misspelled words in a text and corrects them individually, and one that takes the text in as a whole and recommends changes with the help of context.</p><p>For testing purposes, I wrote a function to induce misspellings similar to those that appear in text extracted from PDFs. The function randomly selects a character from the text until it matches a key in the dictionary of commonly mistranscribed letters and it replaces it with its corresponding value (if it randomly falls upon a space, then it removes the space, concatenating the words). How many characters get replaced is controlled by the misspell_rating parameter.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UeNo5P6VfpEaF9CR9lRzgA.png" /></figure><p><strong>Individual Word Correction</strong></p><p>Naturally, there are many possible implementations of this first spell checking approach centered around individual word correction, so I came up with three functions to compare: the first was a combination of <a href="https://pypi.org/project/pyspellchecker/">pyspellchecker</a> and <a href="https://github.com/keredson/wordninja">wordninja</a>, the second was a combination of pyspellcheker and <a href="https://pypi.org/project/symspellpy/">symspellpy</a>, and the third was an implementation of <a href="https://pypi.org/project/symspellpy/">symspellpy</a> on its own.</p><p>I ran all three functions on texts passed through the create_misspelling function and compared their Levenshtein distances with the original text to gauge their effectiveness. All improved the text, but the third function, symspellpy (which I will from now on refer to as “symspell”), outperformed the two other functions both in terms of time and accuracy.</p><p><strong>How Symspell Function Works</strong></p><p>The symspell function first tokenizes the text and creates a list of the proper nouns using <a href="https://spacy.io/usage/linguistic-features">Spacy POS tagging</a>. Then it adds all the misspelled words (those not present in the frequency dictionary and the proper nouns list) to a list that is passed on to be checked. This is facilitated either by symspell’s default frequency dictionary from the pkg_resources or by a custom dictionary in the user’s directory, which can easily be altered to include new words and frequencies. If the percentage of misspelled words is below the threshold parameter, then the code breaks inferring the text is mostly clean and spell checking would do more harm than good by changing words that are already correct. If the threshold is met, however, the symspell library decides whether each component of the misspelled list is a single misspelled word, a combination of several correctly-spelled words, or a combination of many misspelled words, and substitutes the resulting suggestion into the text.</p><p><strong>Symspell code</strong> (some helper functions are not included, see the link at the bottom for the complete code):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/752/1*U5M8TaeBxXhVsVH3EE3Izg.png" /></figure><p><strong>Correction with Context</strong></p><p>To see if a more holistic approach would be better suited for the task of correcting computer-extracted text than the symspell function, I used <a href="https://textblob.readthedocs.io/en/dev/">textblob</a>’s spell checker, which uses context to suggest corrections.</p><p><strong>Textblob Code:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BXogwS5XEQimVQNwUv5ikA.png" /></figure><p><strong>Results</strong></p><p>Testing the effectiveness of the symspell checker and textblob checker on texts altered by the create_misspellings function revealed a clear winner. With a misspell_rating of 0.02, symspell corrected over 30% of the words, while textblob made the text more different from the original. And with a misspell_rating of 0.08, symspell corrected about 25% of the words while textblob corrected only 15%.</p><p>There was also a huge difference in speed. Symspell finished the 0.02 test for ten articles (~70,000 words total) in one minute and the 0.08 test on the same length of text in three minutes. Textblob, on the other hand, finished the same tasks in 20 minutes and 55 minutes, respectively. That’s about 20 times slower.</p><p><strong>Textblob Remarks:</strong></p><p>Looking at specific incidents in testing, we can see why textblob is not wonderfully suited for correcting computer-induced mistakes without supervision. The main issue is that textblob often changes proper nouns or words that do not seem to fit in a traditional context unnecessarily (i.e. “Sandy Hook” becomes “Bandy Took”). Speed is also a big problem considering that, in this context, the correction quality does not make up the checker’s slowness.</p><p><strong>Symspell Remarks:</strong></p><p>Like textblob, symspell sometimes “corrects” words that are already correct, but more often than not, it does the opposite, skipping over words present in the dictionary that don’t make very much sense in context. This more conservative approach can be frustrating when corrections seem obvious in context, but it reduces the spell checker’s ability to drastically alter a passage’s meaning for the worse.</p><p>Another issue with symspell involves numbers and special characters. The spell checker currently ignores word tokens that contain only special characters and numbers and strips away the non-alphabetical characters from words containing both letters and special characters, proposing a suggestion based on the resulting letters. This works well for words such as “te5ting”, but not so great for things like coordinates (the symspell function currently corrects “39°57′37″N 76°05′04″W ” to “a a”).</p><p><strong>Conclusion:</strong></p><p>Although symspell has its drawbacks, the flexibility from which most of its problems stem can also be an advantage. For example, if you know your text contains lots of numbers and special characters, then you can add code to make the spell checker only check words that contain a certain percentage of letters. If you want to make a certain word suggestion more probable than another, you can go into your frequency dictionary and change the corresponding entry values. So, while textblob does a great job in traditional settings correcting human misspellings, the symspell function is a great baseline option if you want more control over what gets corrected and how.</p><p>The code for my latest implementation of symspell can be found <a href="https://github.com/elisaponte/computer_extracted_text_spell_check">here</a>.</p><p>Elisa Ponte is a Junior Data Scientist at Social Impact Analytics Institute working in natural language processing.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9390c05bb2e5" width="1" height="1" alt=""><hr><p><a href="https://medium.com/social-impact-analytics/spell-checking-computer-extracted-text-from-pdfs-9390c05bb2e5">Spell Checking Computer-Extracted Text from PDFs</a> was originally published in <a href="https://medium.com/social-impact-analytics">Social Impact Analytics</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>