{"id":1123,"date":"2018-08-30T21:12:05","date_gmt":"2018-08-30T19:12:05","guid":{"rendered":"http:\/\/www.albertopasca.it\/whiletrue\/?p=1123"},"modified":"2018-09-16T16:15:10","modified_gmt":"2018-09-16T14:15:10","slug":"swift-natural-language-recognizer","status":"publish","type":"post","link":"https:\/\/www.albertopasca.it\/whiletrue\/swift-natural-language-recognizer\/","title":{"rendered":"Swift &#8211; Natural language recognizer"},"content":{"rendered":"<p>Hi!<\/p>\n<p>with <strong><a href=\"https:\/\/www.apple.com\/it\/ios\/ios-12-preview\/\" target=\"_blank\" rel=\"noopener\">iOS 12<\/a><\/strong>, Apple released a new framework for language recognition and other interesting stuff. Is called <strong><a href=\"https:\/\/developer.apple.com\/documentation\/naturallanguage\" target=\"_blank\" rel=\"noopener\">NLLanguageRecognizer<\/a><\/strong>.<\/p>\n<p><img data-recalc-dims=\"1\" decoding=\"async\" class=\"size-full\" src=\"https:\/\/i0.wp.com\/www.albertopasca.it\/whiletrue\/wp-content\/uploads\/2018\/08\/Schermata-2018-08-08-alle-20.06.45.png\" \/><\/p>\n<div class=\"topic-container section-content row\">\n<div id=\"topic-content\" class=\"topic-content column large-9 medium-9 small-12\">\n<section id=\"overview\" class=\"section\">\n<div class=\"formatted-content\">\n<div>\n<blockquote><p>Use the Natural Language framework to perform tasks like language and script identification, tokenization, lemmatization, parts-of-speech tagging, and named entity recognition. You can also use this framework with\u00a0Create ML\u00a0to train and deploy custom natural language models.<\/p><\/blockquote>\n<\/div>\n<\/div>\n<\/section>\n<p><!--more--><\/p>\n<\/div>\n<\/div>\n<p>This framework provides a\u00a0high-level API for lots of language detection features using text.<\/p>\n<h6>Let&#8217;s see some example:<\/h6>\n<pre class=\"p1\">\u3053\u3093\u306b\u3061\u306f\u3001\u79c1\u306f\u30a2\u30eb\u30d9\u30eb\u30c8\u3067\u3059\u3001\u79c1\u306f\u30a4\u30bf\u30ea\u30a2\u306b\u4f4f\u3093\u3067\u3044\u3066\u3001\u79c1\u306f\u4e0d\u660e\u306a\u8a00\u8a9e\u3067\u66f8\u3044\u3066\u3044\u307e\u3059\u3002<\/pre>\n<ul>\n<li>Which language is this?<\/li>\n<li>How many words contain this phrase?<\/li>\n<li>There are names inside? Places? Company names?<\/li>\n<\/ul>\n<p>Who knows. Me not.<\/p>\n<p>Answers:<\/p>\n<ol>\n<li><strong>JA<\/strong>, or better JAPANESE<\/li>\n<li><strong>23<\/strong> words in this phrase<\/li>\n<li>The english\u00a0translations is &#8220;Hi, I&#8217;m <strong>Alberto<\/strong>, I live in <strong>Italy<\/strong> and I write in an unknown language.&#8221;, so yes, there is a name and a place inside.<\/li>\n<\/ol>\n<hr \/>\n<p>Let&#8217;s do it to the new iOS\/macOS common framework, <strong>NLNaturalLanguage<\/strong> to see how it works.<\/p>\n<p>Examine this phrase:<\/p>\n<pre class=\"p1\"><span class=\"s1\">let<\/span><span class=\"s2\"> string = <\/span>\"<span style=\"color: #339966;\">Ciao, sono Alberto, vivo in Italia e scrivo in<\/span> <span style=\"color: #ff0000;\">an unknown language<\/span>. <span style=\"color: #339966;\">Mi piace la Coca-Cola.<\/span>\"<\/pre>\n<p>it&#8217;s mixed, <em>ITALIAN<\/em> \/ <em>ENGLISH<\/em>. We can use this as a good\u00a0example.<\/p>\n<h6>DETECTING LANGUAGE(s)<\/h6>\n<pre>import NaturalLanguage\u2029\u2029\r\n\r\nlet string = \"Ciao, sono Alberto, vivo a Bergamo e scrivo in an unknown language. Mi piace la CocaCola.\"\r\n\r\n\u2029\u2029\/\/ create a new recognizer\u2029 \r\nlet languageRecognizer = NLLanguageRecognizer()\u2029\u2029 \r\n\/\/ that should read your string\u2029 \r\nlanguageRecognizer.processString(string)\u2029\u2029 \r\n  \r\n\/\/ get eventually any language hypoteses\u2029 \r\nlet hypoteses = languageRecognizer.languageHypotheses(withMaximum: 2) \/\/2\u2029\u2029 \r\n  \r\n\/\/ get the dominant language of the phrase\u2029 \r\nlet language\u00a0 = languageRecognizer.dominantLanguage!.rawValue \r\n  \r\n\u2029\u2029print(\"First language is\u00a0 : \\(language)\")\u2029 \r\nprint(\"Other languages are: \\(hypoteses)\")<\/pre>\n<p>output in console:<\/p>\n<pre class=\"p1\"><span class=\"s1\">First language is<\/span><span class=\"s1\"><span class=\"Apple-converted-space\">\u00a0 <\/span><\/span><span class=\"s1\">: it<\/span>\u2029<span class=\"s1\">Other languages are:   \r\n[__C.NLLanguage(_rawValue: <\/span><span class=\"s1\"><strong>it<\/strong><\/span><span class=\"s1\">): <\/span><span class=\"s1\"><strong>0.9752411842346191<\/strong><\/span><span class=\"s1\">,   \r\n__C.NLLanguage(_rawValue: <\/span><span class=\"s1\"><strong>en<\/strong><\/span><span class=\"s1\">): <\/span><span class=\"s1\"><strong>0.009950380772352219<\/strong><\/span><span class=\"s1\">]<\/span><\/pre>\n<p>We receive the languages and the percentage of the confidence. Good. Italian is about <strong>0.97%<\/strong> so we can trust\u00a0the algorithm.<\/p>\n<hr \/>\n<h6>TOKENIZE A TEXT:<\/h6>\n<p>Let&#8217;s count the words (or the paragraph, or the sentences, or the document&#8230;) using\u00a0<strong><a href=\"https:\/\/developer.apple.com\/documentation\/naturallanguage\/nltokenizer\" target=\"_blank\" rel=\"noopener\"><span class=\"s2\">NLTokenizer<\/span><\/a><\/strong>:<\/p>\n<pre class=\"p1\"><span class=\"s1\">\/\/ create a new tokenizer<\/span>\u2029  \r\n<span class=\"s1\">\/\/ choose your unit (word, paragraph, sentences, document)<\/span>\u2029  \r\n<span class=\"s1\">let<\/span> tokenizer = <span class=\"s2\">NLTokenizer<\/span>(unit: .<span class=\"s1\">word<\/span>)  \r\n  \r\n\u2029\u2029\/\/ set your language (or use the discovered one...)\u2029  \r\n<span class=\"s3\">tokenizer<\/span><span class=\"s4\">.<\/span><span class=\"s5\">setLanguage<\/span><span class=\"s4\">( .<\/span><span class=\"s3\">italian<\/span><span class=\"s4\"> )  <\/span>\/\/<em>NLLanguage(language) )<\/em>\u2029\u2029  \r\n  \r\n\/\/ link your string  \r\n\u2029tokenizer<span class=\"s4\">.<\/span>string<span class=\"s4\"> = <\/span>string\u2029\u2029  \r\n  \r\n\/\/ get tokens\u2029  \r\n<span class=\"s1\">let<\/span><span class=\"s4\"> tokens = <\/span>tokenizer<span class=\"s4\">.<\/span><span class=\"s5\">tokens<\/span><span class=\"s4\">(for: <\/span>string<span class=\"s4\">.<\/span>startIndex<span class=\"s4\">..&lt;<\/span>string<span class=\"s4\">.<\/span>endIndex<span class=\"s4\">)<\/span>\u2029\u2029  \r\n<span class=\"s5\">  \r\nprint<\/span><span class=\"s4\">( <\/span><span class=\"s6\">\"Words: <\/span><span class=\"s4\">\\<\/span><span class=\"s6\">(<\/span>tokens<span class=\"s4\">.<\/span>count<span class=\"s6\">)\"<\/span><span class=\"s4\"> )  \r\n<\/span>\u2029<span class=\"s4\">\/\/ <\/span><strong><span class=\"s1\">Words: 12 . <\/span><\/strong><\/pre>\n<h6>EXTRACT pieces of information:<\/h6>\n<p>Another cool feature is related to <strong>TAG<\/strong>, to extract tagged informations like, people names, city, places and organization names, using <strong><a href=\"https:\/\/developer.apple.com\/documentation\/naturallanguage\/nltagger?language=objc\" target=\"_blank\" rel=\"noopener\">NLTagger<\/a><\/strong>.<\/p>\n<p>Let&#8217;s see how:<\/p>\n<pre class=\"p1\"><span class=\"s1\">\/\/ create a tagger\r\n<\/span>\u2029<span class=\"s1\">let<\/span> tagger = <strong><span class=\"s2\">NLTagger<\/span><\/strong>(tagSchemes: [.<span class=\"s3\">nameType<\/span>])\u2029\u2029\r\n\r\n\/\/ set the text\r\n\u2029tagger<span class=\"s4\">.<\/span>string<span class=\"s4\"> = <\/span>string\r\n\r\n\u2029\u2029\/\/ select the options\r\n\u2029<span class=\"s1\">let<\/span><span class=\"s2\"> options: <\/span>NLTagger<span class=\"s2\">.<\/span>Options<span class=\"s2\"> = [<\/span>\u2029<span class=\"s2\"><span class=\"Apple-converted-space\">\u00a0 \r\n<\/span><\/span><span class=\"s2\">  .<\/span>omitPunctuation<span class=\"s2\">,<\/span>\u2029<span class=\"s2\"><span class=\"Apple-converted-space\">\u00a0 \r\n<\/span><\/span><span class=\"s2\">  .<\/span>omitWhitespace<span class=\"s2\">,<\/span>\u2029<span class=\"s2\"><span class=\"Apple-converted-space\"> \u00a0\r\n<\/span><\/span><span class=\"s2\">  .<\/span>omitOther<span class=\"s2\">,<\/span>\u2029<span class=\"s2\">  \r\n  .<\/span>joinNames\u2029]\u2029\u2029\r\n\r\n\/\/ and the tag to extract\r\n\u2029<span class=\"s1\">let<\/span> tags: [<strong><span class=\"s3\">NLTag<\/span><\/strong>] = [\u2029<span class=\"s2\"><span class=\"Apple-converted-space\">\u00a0\r\n<\/span><\/span><span class=\"s2\">  .<\/span>personalName<span class=\"s2\">,<\/span>\u2029<span class=\"s2\"> \r\n  .<\/span>placeName<span class=\"s2\">,<\/span>\u2029<span class=\"s2\"> \r\n  .<\/span>organizationName\u2029 \/\/ and much more...\u2029]\r\n\r\n\u2029\u2029\/\/ create all the tags\u2029\r\n<span class=\"s1\">let<\/span> tags = <span class=\"s2\">tagger<\/span>.<span class=\"s3\">tags<\/span>(<span class=\"s4\"><span class=\"Apple-converted-space\">\u00a0<\/span><\/span>\u2029<span class=\"s4\">  \r\n  in: <\/span>string<span class=\"s4\">.<\/span>startIndex<span class=\"s4\">..&lt;<\/span>string<span class=\"s4\">.<\/span>endIndex<span class=\"s4\">,<\/span>\u2029  \r\n  unit: .<span class=\"s1\">word<\/span>,\u2029  \r\n  scheme: .<span class=\"s2\">nameType<\/span>,\u2029  \r\n  options: <span class=\"s1\">options<\/span>) { tag, tokenRange <span class=\"s2\">in<\/span>\u2029<span class=\"s2\">    \r\n    if<\/span> <span class=\"s2\">let<\/span> tag = tag, <span class=\"s1\">tags<\/span>.<span class=\"s3\">contains<\/span>(tag) {\u2029<span class=\"s3\">      \r\n        print<\/span>(<span class=\"s4\">\"<\/span>\\<span class=\"s4\">(<\/span>tag.<span class=\"s1\">rawValue<\/span><span class=\"s4\">) -&gt; <\/span>\\<span class=\"s4\">(<\/span><span class=\"s1\">string<\/span>[tokenRange]<span class=\"s4\">)\"<\/span>)\u2029    \r\n    }\u2029    \r\n  return true\u2029\r\n}<\/pre>\n<p>The result is nice&#8230; with mixed languages happens something strange, but it&#8217;s ok.<\/p>\n<pre class=\"p1\"><span class=\"s1\">PersonalName -&gt; <\/span><span class=\"s1\"><strong>Alberto<\/strong><\/span>\u2029\r\n<span class=\"s1\">PlaceName -&gt; <\/span><span class=\"s1\"><strong>Bergamo<\/strong><\/span>\u2029\r\n<strong><span class=\"s1\" style=\"color: #ff0000;\">OrganizationName -&gt; an unknown language\r\n<\/span><\/strong>\u2029<span class=\"s1\">OrganizationName -&gt; <\/span><span class=\"s1\"><strong>CocaCola<\/strong><\/span><\/pre>\n<h6>EXTRA<\/h6>\n<p>You are able to know the language of the phrase so, you can easily speech the text in the real and in the correct language using <strong><a href=\"https:\/\/developer.apple.com\/documentation\/avfoundation\/avspeechsynthesizer\" target=\"_blank\" rel=\"noopener\">AVSpeechSynthesizer<\/a><\/strong>!<\/p>\n<pre>let speechUtterance = AVSpeechUtterance(string: string)\u2029\r\n\r\n\/\/speechUtterance.rate = 0.7\u2029\r\nspeechUtterance.volume = 1.0\u2029\u2029\r\n\r\n\/\/ set your discovered language\u2029\r\n<em>speechUtterance.voice = AVSpeechSynthesisVoice(language: <strong>language<\/strong>)<\/em>\u2029\u2029\r\n\r\nspeechSynthesizer.speakUtterance(speechUtterance)<\/pre>\n<p>Instead of using these old techniques that make me laugh now&#8230; \ud83d\ude09<\/p>\n<blockquote class=\"wp-embedded-content\" data-secret=\"Nn2sxlgsFV\"><p><a href=\"https:\/\/www.albertopasca.it\/whiletrue\/objectivec-text-to-speech-with-google-translate\/\">[ObjectiveC] Text to Speech with Google Translate<\/a><\/p><\/blockquote>\n<p><iframe loading=\"lazy\" class=\"wp-embedded-content\" sandbox=\"allow-scripts\" security=\"restricted\" style=\"position: absolute; clip: rect(1px, 1px, 1px, 1px);\" title=\"&#8220;[ObjectiveC] Text to Speech with Google Translate&#8221; &#8212; while (true) {\u00a0}\" src=\"https:\/\/www.albertopasca.it\/whiletrue\/objectivec-text-to-speech-with-google-translate\/embed\/#?secret=iDQMAPdD1Z#?secret=Nn2sxlgsFV\" data-secret=\"Nn2sxlgsFV\" width=\"500\" height=\"282\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe><\/p>\n<blockquote class=\"wp-embedded-content\" data-secret=\"HIL0S8SaJN\"><p><a href=\"https:\/\/www.albertopasca.it\/whiletrue\/objective-c-use-google-speech-on-iphone\/\">[Objective-C] Use Google speech on iPhone<\/a><\/p><\/blockquote>\n<p><iframe loading=\"lazy\" class=\"wp-embedded-content\" sandbox=\"allow-scripts\" security=\"restricted\" style=\"position: absolute; clip: rect(1px, 1px, 1px, 1px);\" title=\"&#8220;[Objective-C] Use Google speech on iPhone&#8221; &#8212; while (true) {\u00a0}\" src=\"https:\/\/www.albertopasca.it\/whiletrue\/objective-c-use-google-speech-on-iphone\/embed\/#?secret=2jchRS8zNK#?secret=HIL0S8SaJN\" data-secret=\"HIL0S8SaJN\" width=\"500\" height=\"282\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe><\/p>\n<blockquote class=\"wp-embedded-content\" data-secret=\"TapeCSqG4e\"><p><a href=\"https:\/\/www.albertopasca.it\/whiletrue\/objc-tesla-speech-for-osx\/\">ObjC \u2013 Tesla speech for OSX<\/a><\/p><\/blockquote>\n<p><iframe loading=\"lazy\" class=\"wp-embedded-content\" sandbox=\"allow-scripts\" security=\"restricted\" style=\"position: absolute; clip: rect(1px, 1px, 1px, 1px);\" title=\"&#8220;ObjC \u2013 Tesla speech for OSX&#8221; &#8212; while (true) {\u00a0}\" src=\"https:\/\/www.albertopasca.it\/whiletrue\/objc-tesla-speech-for-osx\/embed\/#?secret=v1JmAqM1FJ#?secret=TapeCSqG4e\" data-secret=\"TapeCSqG4e\" width=\"500\" height=\"282\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe><\/p>\n<p>And that&#8217;s all for now.<\/p>\n<p>Go deeper into\u00a0this framework because is very interesting.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hi! with iOS 12, Apple released a new framework for language recognition and other interesting stuff. Is called NLLanguageRecognizer. Use the Natural Language framework to perform tasks like language and script identification, tokenization, lemmatization, parts-of-speech tagging, and named entity recognition. You can also use this framework with\u00a0Create ML\u00a0to train and deploy custom natural language models.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[1],"tags":[710,702,717,714,708,700,704,705,718,703,701,711,709,713,716,706,712,313,222,46,715,707,255,223,302,401],"class_list":["post-1123","post","type-post","status-publish","format-standard","hentry","category-generic","tag-extract","tag-hypoteses","tag-ios12","tag-language","tag-names","tag-natural-language","tag-nltag","tag-nltagger","tag-nltagscheme","tag-nltokenizer","tag-nsnaturallanguagerecognizer","tag-ocr","tag-organization","tag-paragraph","tag-place","tag-puntuaction","tag-recognize","tag-speech","tag-string","tag-swift","tag-synthetize","tag-tags","tag-text","tag-token","tag-whitespace","tag-words"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.7 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Swift - Natural language recognizer - while (true) {\u00a0}<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"http:\/\/www.albertopasca.it\/whiletrue\/swift-natural-language-recognizer\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Swift - Natural language recognizer - while (true) {\u00a0}\" \/>\n<meta property=\"og:description\" content=\"Hi! with iOS 12, Apple released a new framework for language recognition and other interesting stuff. Is called NLLanguageRecognizer. Use the Natural Language framework to perform tasks like language and script identification, tokenization, lemmatization, parts-of-speech tagging, and named entity recognition. You can also use this framework with\u00a0Create ML\u00a0to train and deploy custom natural language models.\" \/>\n<meta property=\"og:url\" content=\"http:\/\/www.albertopasca.it\/whiletrue\/swift-natural-language-recognizer\/\" \/>\n<meta property=\"og:site_name\" content=\"while (true) {\u00a0}\" \/>\n<meta property=\"article:published_time\" content=\"2018-08-30T19:12:05+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2018-09-16T14:15:10+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/www.albertopasca.it\/whiletrue\/wp-content\/uploads\/2018\/08\/Schermata-2018-08-08-alle-20.06.45.png\" \/>\n<meta name=\"author\" content=\"Alberto Pasca\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@lupasca\" \/>\n<meta name=\"twitter:site\" content=\"@lupasca\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Alberto Pasca\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"http:\\\/\\\/www.albertopasca.it\\\/whiletrue\\\/swift-natural-language-recognizer\\\/#article\",\"isPartOf\":{\"@id\":\"http:\\\/\\\/www.albertopasca.it\\\/whiletrue\\\/swift-natural-language-recognizer\\\/\"},\"author\":{\"name\":\"Alberto Pasca\",\"@id\":\"https:\\\/\\\/www.albertopasca.it\\\/whiletrue\\\/#\\\/schema\\\/person\\\/d3cf0df774eb4aac797f246a795e9fac\"},\"headline\":\"Swift &#8211; Natural language recognizer\",\"datePublished\":\"2018-08-30T19:12:05+00:00\",\"dateModified\":\"2018-09-16T14:15:10+00:00\",\"mainEntityOfPage\":{\"@id\":\"http:\\\/\\\/www.albertopasca.it\\\/whiletrue\\\/swift-natural-language-recognizer\\\/\"},\"wordCount\":332,\"publisher\":{\"@id\":\"https:\\\/\\\/www.albertopasca.it\\\/whiletrue\\\/#\\\/schema\\\/person\\\/d3cf0df774eb4aac797f246a795e9fac\"},\"image\":{\"@id\":\"http:\\\/\\\/www.albertopasca.it\\\/whiletrue\\\/swift-natural-language-recognizer\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/www.albertopasca.it\\\/whiletrue\\\/wp-content\\\/uploads\\\/2018\\\/08\\\/Schermata-2018-08-08-alle-20.06.45.png\",\"keywords\":[\"extract\",\"hypoteses\",\"ios12\",\"language\",\"names\",\"natural language\",\"nltag\",\"nltagger\",\"NLTagScheme\",\"nltokenizer\",\"nsnaturallanguagerecognizer\",\"ocr\",\"organization\",\"paragraph\",\"place\",\"puntuaction\",\"recognize\",\"speech\",\"string\",\"swift\",\"synthetize\",\"tags\",\"text\",\"token\",\"whitespace\",\"words\"],\"articleSection\":[\"generic\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"http:\\\/\\\/www.albertopasca.it\\\/whiletrue\\\/swift-natural-language-recognizer\\\/\",\"url\":\"http:\\\/\\\/www.albertopasca.it\\\/whiletrue\\\/swift-natural-language-recognizer\\\/\",\"name\":\"Swift - Natural language recognizer - while (true) {\u00a0}\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.albertopasca.it\\\/whiletrue\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"http:\\\/\\\/www.albertopasca.it\\\/whiletrue\\\/swift-natural-language-recognizer\\\/#primaryimage\"},\"image\":{\"@id\":\"http:\\\/\\\/www.albertopasca.it\\\/whiletrue\\\/swift-natural-language-recognizer\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/www.albertopasca.it\\\/whiletrue\\\/wp-content\\\/uploads\\\/2018\\\/08\\\/Schermata-2018-08-08-alle-20.06.45.png\",\"datePublished\":\"2018-08-30T19:12:05+00:00\",\"dateModified\":\"2018-09-16T14:15:10+00:00\",\"breadcrumb\":{\"@id\":\"http:\\\/\\\/www.albertopasca.it\\\/whiletrue\\\/swift-natural-language-recognizer\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"http:\\\/\\\/www.albertopasca.it\\\/whiletrue\\\/swift-natural-language-recognizer\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"http:\\\/\\\/www.albertopasca.it\\\/whiletrue\\\/swift-natural-language-recognizer\\\/#primaryimage\",\"url\":\"https:\\\/\\\/i0.wp.com\\\/www.albertopasca.it\\\/whiletrue\\\/wp-content\\\/uploads\\\/2018\\\/08\\\/Schermata-2018-08-08-alle-20.06.45.png?fit=1110%2C796&ssl=1\",\"contentUrl\":\"https:\\\/\\\/i0.wp.com\\\/www.albertopasca.it\\\/whiletrue\\\/wp-content\\\/uploads\\\/2018\\\/08\\\/Schermata-2018-08-08-alle-20.06.45.png?fit=1110%2C796&ssl=1\",\"width\":1110,\"height\":796,\"caption\":\"swift, ios12, natural language, machine learining\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"http:\\\/\\\/www.albertopasca.it\\\/whiletrue\\\/swift-natural-language-recognizer\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.albertopasca.it\\\/whiletrue\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Swift &#8211; Natural language recognizer\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.albertopasca.it\\\/whiletrue\\\/#website\",\"url\":\"https:\\\/\\\/www.albertopasca.it\\\/whiletrue\\\/\",\"name\":\"while (true) {\u00a0}\",\"description\":\"notes from a developer, tutorials, how-to, ideas\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.albertopasca.it\\\/whiletrue\\\/#\\\/schema\\\/person\\\/d3cf0df774eb4aac797f246a795e9fac\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.albertopasca.it\\\/whiletrue\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/www.albertopasca.it\\\/whiletrue\\\/#\\\/schema\\\/person\\\/d3cf0df774eb4aac797f246a795e9fac\",\"name\":\"Alberto Pasca\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/4d8fe43c412d0bb34a71c41f60dce53eff3afc027853cbfd20bee6ddc7e93f35?s=96&d=retro&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/4d8fe43c412d0bb34a71c41f60dce53eff3afc027853cbfd20bee6ddc7e93f35?s=96&d=retro&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/4d8fe43c412d0bb34a71c41f60dce53eff3afc027853cbfd20bee6ddc7e93f35?s=96&d=retro&r=g\",\"caption\":\"Alberto Pasca\"},\"logo\":{\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/4d8fe43c412d0bb34a71c41f60dce53eff3afc027853cbfd20bee6ddc7e93f35?s=96&d=retro&r=g\"},\"description\":\"Software engineer @ Pirelli &amp; C. S.p.A. with a strong passion for mobile \uf8ff development, security, and connected things.\",\"sameAs\":[\"https:\\\/\\\/www.albertopasca.it\",\"albertopasca\",\"https:\\\/\\\/x.com\\\/lupasca\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Swift - Natural language recognizer - while (true) {\u00a0}","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"http:\/\/www.albertopasca.it\/whiletrue\/swift-natural-language-recognizer\/","og_locale":"en_US","og_type":"article","og_title":"Swift - Natural language recognizer - while (true) {\u00a0}","og_description":"Hi! with iOS 12, Apple released a new framework for language recognition and other interesting stuff. Is called NLLanguageRecognizer. Use the Natural Language framework to perform tasks like language and script identification, tokenization, lemmatization, parts-of-speech tagging, and named entity recognition. You can also use this framework with\u00a0Create ML\u00a0to train and deploy custom natural language models.","og_url":"http:\/\/www.albertopasca.it\/whiletrue\/swift-natural-language-recognizer\/","og_site_name":"while (true) {\u00a0}","article_published_time":"2018-08-30T19:12:05+00:00","article_modified_time":"2018-09-16T14:15:10+00:00","og_image":[{"url":"http:\/\/www.albertopasca.it\/whiletrue\/wp-content\/uploads\/2018\/08\/Schermata-2018-08-08-alle-20.06.45.png","type":"","width":"","height":""}],"author":"Alberto Pasca","twitter_card":"summary_large_image","twitter_creator":"@lupasca","twitter_site":"@lupasca","twitter_misc":{"Written by":"Alberto Pasca","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"http:\/\/www.albertopasca.it\/whiletrue\/swift-natural-language-recognizer\/#article","isPartOf":{"@id":"http:\/\/www.albertopasca.it\/whiletrue\/swift-natural-language-recognizer\/"},"author":{"name":"Alberto Pasca","@id":"https:\/\/www.albertopasca.it\/whiletrue\/#\/schema\/person\/d3cf0df774eb4aac797f246a795e9fac"},"headline":"Swift &#8211; Natural language recognizer","datePublished":"2018-08-30T19:12:05+00:00","dateModified":"2018-09-16T14:15:10+00:00","mainEntityOfPage":{"@id":"http:\/\/www.albertopasca.it\/whiletrue\/swift-natural-language-recognizer\/"},"wordCount":332,"publisher":{"@id":"https:\/\/www.albertopasca.it\/whiletrue\/#\/schema\/person\/d3cf0df774eb4aac797f246a795e9fac"},"image":{"@id":"http:\/\/www.albertopasca.it\/whiletrue\/swift-natural-language-recognizer\/#primaryimage"},"thumbnailUrl":"http:\/\/www.albertopasca.it\/whiletrue\/wp-content\/uploads\/2018\/08\/Schermata-2018-08-08-alle-20.06.45.png","keywords":["extract","hypoteses","ios12","language","names","natural language","nltag","nltagger","NLTagScheme","nltokenizer","nsnaturallanguagerecognizer","ocr","organization","paragraph","place","puntuaction","recognize","speech","string","swift","synthetize","tags","text","token","whitespace","words"],"articleSection":["generic"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"http:\/\/www.albertopasca.it\/whiletrue\/swift-natural-language-recognizer\/","url":"http:\/\/www.albertopasca.it\/whiletrue\/swift-natural-language-recognizer\/","name":"Swift - Natural language recognizer - while (true) {\u00a0}","isPartOf":{"@id":"https:\/\/www.albertopasca.it\/whiletrue\/#website"},"primaryImageOfPage":{"@id":"http:\/\/www.albertopasca.it\/whiletrue\/swift-natural-language-recognizer\/#primaryimage"},"image":{"@id":"http:\/\/www.albertopasca.it\/whiletrue\/swift-natural-language-recognizer\/#primaryimage"},"thumbnailUrl":"http:\/\/www.albertopasca.it\/whiletrue\/wp-content\/uploads\/2018\/08\/Schermata-2018-08-08-alle-20.06.45.png","datePublished":"2018-08-30T19:12:05+00:00","dateModified":"2018-09-16T14:15:10+00:00","breadcrumb":{"@id":"http:\/\/www.albertopasca.it\/whiletrue\/swift-natural-language-recognizer\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["http:\/\/www.albertopasca.it\/whiletrue\/swift-natural-language-recognizer\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"http:\/\/www.albertopasca.it\/whiletrue\/swift-natural-language-recognizer\/#primaryimage","url":"https:\/\/i0.wp.com\/www.albertopasca.it\/whiletrue\/wp-content\/uploads\/2018\/08\/Schermata-2018-08-08-alle-20.06.45.png?fit=1110%2C796&ssl=1","contentUrl":"https:\/\/i0.wp.com\/www.albertopasca.it\/whiletrue\/wp-content\/uploads\/2018\/08\/Schermata-2018-08-08-alle-20.06.45.png?fit=1110%2C796&ssl=1","width":1110,"height":796,"caption":"swift, ios12, natural language, machine learining"},{"@type":"BreadcrumbList","@id":"http:\/\/www.albertopasca.it\/whiletrue\/swift-natural-language-recognizer\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.albertopasca.it\/whiletrue\/"},{"@type":"ListItem","position":2,"name":"Swift &#8211; Natural language recognizer"}]},{"@type":"WebSite","@id":"https:\/\/www.albertopasca.it\/whiletrue\/#website","url":"https:\/\/www.albertopasca.it\/whiletrue\/","name":"while (true) {\u00a0}","description":"notes from a developer, tutorials, how-to, ideas","publisher":{"@id":"https:\/\/www.albertopasca.it\/whiletrue\/#\/schema\/person\/d3cf0df774eb4aac797f246a795e9fac"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.albertopasca.it\/whiletrue\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/www.albertopasca.it\/whiletrue\/#\/schema\/person\/d3cf0df774eb4aac797f246a795e9fac","name":"Alberto Pasca","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/4d8fe43c412d0bb34a71c41f60dce53eff3afc027853cbfd20bee6ddc7e93f35?s=96&d=retro&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/4d8fe43c412d0bb34a71c41f60dce53eff3afc027853cbfd20bee6ddc7e93f35?s=96&d=retro&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/4d8fe43c412d0bb34a71c41f60dce53eff3afc027853cbfd20bee6ddc7e93f35?s=96&d=retro&r=g","caption":"Alberto Pasca"},"logo":{"@id":"https:\/\/secure.gravatar.com\/avatar\/4d8fe43c412d0bb34a71c41f60dce53eff3afc027853cbfd20bee6ddc7e93f35?s=96&d=retro&r=g"},"description":"Software engineer @ Pirelli &amp; C. S.p.A. with a strong passion for mobile \uf8ff development, security, and connected things.","sameAs":["https:\/\/www.albertopasca.it","albertopasca","https:\/\/x.com\/lupasca"]}]}},"jetpack_publicize_connections":[],"jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"jetpack-related-posts":[],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/www.albertopasca.it\/whiletrue\/wp-json\/wp\/v2\/posts\/1123","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.albertopasca.it\/whiletrue\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.albertopasca.it\/whiletrue\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.albertopasca.it\/whiletrue\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.albertopasca.it\/whiletrue\/wp-json\/wp\/v2\/comments?post=1123"}],"version-history":[{"count":12,"href":"https:\/\/www.albertopasca.it\/whiletrue\/wp-json\/wp\/v2\/posts\/1123\/revisions"}],"predecessor-version":[{"id":1210,"href":"https:\/\/www.albertopasca.it\/whiletrue\/wp-json\/wp\/v2\/posts\/1123\/revisions\/1210"}],"wp:attachment":[{"href":"https:\/\/www.albertopasca.it\/whiletrue\/wp-json\/wp\/v2\/media?parent=1123"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.albertopasca.it\/whiletrue\/wp-json\/wp\/v2\/categories?post=1123"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.albertopasca.it\/whiletrue\/wp-json\/wp\/v2\/tags?post=1123"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}