<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Natural Language on Andy Ibanez</title><link>https://www.andyibanez.com/tags/natural-language/</link><description>Recent content in Natural Language on Andy Ibanez</description><generator>Hugo</generator><language>en-us</language><lastBuildDate>Wed, 04 Mar 2020 07:00:00 -0400</lastBuildDate><atom:link href="https://www.andyibanez.com/tags/natural-language/index.xml" rel="self" type="application/rss+xml"/><item><title>Finding Related Words with NLEmbedding</title><link>https://www.andyibanez.com/posts/using-nlembeddings/</link><pubDate>Wed, 04 Mar 2020 07:00:00 -0400</pubDate><guid>https://www.andyibanez.com/posts/using-nlembeddings/</guid><description>&lt;p&gt;There may be cases in which you need to find related words to others. With the &lt;a href="https://developer.apple.com/documentation/naturallanguage/nlembedding"&gt;&lt;code&gt;NSLEmbedding&lt;/code&gt;&lt;/a&gt; class, you can find related strings based on the proximity of their vectors.&lt;/p&gt;
&lt;h1 id="using-nlembedding"&gt;Using NLEmbedding&lt;/h1&gt;
&lt;p&gt;Using &lt;code&gt;NLEmbedding&lt;/code&gt; is very straight forward. A simple task is to get an array of related words, which come as an array of &lt;code&gt;(String, NLDistance)&lt;/code&gt; back.&lt;/p&gt;
&lt;p&gt;The distance between words tells you how &amp;ldquo;related&amp;rdquo; they are&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#cdd6f4;background-color:#1e1e2e;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-swift" data-lang="swift"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f38ba8"&gt;let&lt;/span&gt; &lt;span style="color:#f5e0dc"&gt;embedding&lt;/span&gt; = NLEmbedding.wordEmbedding(&lt;span style="color:#cba6f7"&gt;for&lt;/span&gt;: .english)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f38ba8"&gt;let&lt;/span&gt; &lt;span style="color:#f5e0dc"&gt;foundWords&lt;/span&gt; = embedding!.neighbors(&lt;span style="color:#cba6f7"&gt;for&lt;/span&gt;: &lt;span style="color:#a6e3a1"&gt;&amp;#34;family&amp;#34;&lt;/span&gt;, maximumCount: &lt;span style="color:#fab387"&gt;3&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#89dceb"&gt;print&lt;/span&gt;(foundWords)
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;In this example, it will print:&lt;/p&gt;</description></item><item><title>Analyzing Natural Language Text with NLTagger</title><link>https://www.andyibanez.com/posts/analyzing-text-nltagger/</link><pubDate>Wed, 26 Feb 2020 07:00:00 -0400</pubDate><guid>https://www.andyibanez.com/posts/analyzing-text-nltagger/</guid><description>&lt;p&gt;In the past few weeks, we have explored how we can &lt;a href="https://www.andyibanez.com/posts/tokenizing-nltokenizer/"&gt;tokenize natural language text&lt;/a&gt; and how to &lt;a href="https://www.andyibanez.com/posts/recognizing-language-nllanguagerecognizer/"&gt;recognize the language a natural language text is written in&lt;/a&gt;. This week we will continue exploring more natural language APIs provided by the &lt;code&gt;NaturalLanguage&lt;/code&gt; framework. We will learn about the &lt;a href="https://developer.apple.com/documentation/naturallanguage/nltagger"&gt;NLTagger&lt;/a&gt; class, which allows us to to analyze natural language text to find parts of speech, lexical classes, lemma, scripts, and more. This API, introduced in iOS 12, implements machine learning to work, and just like the other &lt;code&gt;NaturalLanguage&lt;/code&gt; classes, is very easy to use.&lt;/p&gt;</description></item><item><title>Recognizing the language in a Natural Language Text with NLanguageRecognizer</title><link>https://www.andyibanez.com/posts/recognizing-language-nllanguagerecognizer/</link><pubDate>Wed, 19 Feb 2020 07:00:00 -0400</pubDate><guid>https://www.andyibanez.com/posts/recognizing-language-nllanguagerecognizer/</guid><description>&lt;p&gt;Continuing my trend of writing about language processing, today I want to discuss about identifying the language of a body of text. This is an interesting task we can do thanks, once again, to Apple&amp;rsquo;s investment in APIs linked to machine learning.&lt;/p&gt;
&lt;p&gt;Today we will explore the &lt;a href="https://developer.apple.com/documentation/naturallanguage/nllanguagerecognizer"&gt;&lt;code&gt;NLLanguageRecognizer&lt;/code&gt;&lt;/a&gt; object. Introduced in iOS 12, this class can do a lot of language recognizing, from detecting the &amp;ldquo;dominant language&amp;rdquo; of a string, to all the possible languages.&lt;/p&gt;</description></item><item><title>Tokenizing Natural Language into Semantic Units in iOS</title><link>https://www.andyibanez.com/posts/tokenizing-nltokenizer/</link><pubDate>Wed, 12 Feb 2020 07:00:00 -0400</pubDate><guid>https://www.andyibanez.com/posts/tokenizing-nltokenizer/</guid><description>&lt;p&gt;Working with Natural Language is possible thanks to machine learning. Starting on iOS 12, Apple has provided many APIs just for this task. In this article we will explore how to use &lt;a href="https://developer.apple.com/documentation/naturallanguage/nltokenizer"&gt;&lt;code&gt;NLTokenizer&lt;/code&gt;&lt;/a&gt; to separate natural language text into its proper units.&lt;/p&gt;
&lt;h1 id="introduction-to-natural-language-tokenizing"&gt;Introduction to Natural Language Tokenizing&lt;/h1&gt;
&lt;p&gt;If you are not familiar with the inner workings of Natural Language processing, tokenizing simply means that we separate a string and analyze it to find its semantic units. If you are writing a program that processes text, you may be tempted to split the string using a separator. For example, if you wanted to get all the words in a natural sentence string in an array, you would write something like this:&lt;/p&gt;</description></item><item><title>Matching Natural Language Text for Predefined Data Patterns on Apple's Devices</title><link>https://www.andyibanez.com/posts/matching-nl-nsdatadetector/</link><pubDate>Wed, 05 Feb 2020 07:00:00 -0400</pubDate><guid>https://www.andyibanez.com/posts/matching-nl-nsdatadetector/</guid><description>&lt;p&gt;iOS has a lot of APIs that deal with natural language detection. One such class is &lt;a href="https://developer.apple.com/documentation/foundation/nsdatadetector"&gt;&lt;code&gt;NSDataDetector&lt;/code&gt;&lt;/a&gt;. This class allows you to match different kinds of data in text, including dates, time, links, and more. This class, actually introduced a very long time ago (in the iOS 4.0 days!) makes it very easy to find this kind of data in strings. In this article we will explore how to use this very old class - whose documentation is Objective-C only at this time - in Swift, and how to do common tasks with it.&lt;/p&gt;</description></item></channel></rss>