208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal...

Post on 07-Sep-2020

1 views 0 download

Transcript of 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal...

WWDC17

copy 2017 Apple Inc All rights reserved Redistribution or public display not permitted without written permission from Apple

Vivek Kumar Rangarajan Sridhar Software Engineering Manager Doug Davidson Senior Engineer

bullNatural Language Processing bulland your Apps bull Session 208

App Frameworks

Goal

Goal

Goal

Natural language input typed text

recognized handwriting

transcribed speech

Goal

Natural language output typed text

recognized handwriting

transcribed speech

Goal

NLP

Natural language text typed

recognized handwriting

transcribed speech

Confer intelligence

NLP APIs

NLP APIs

NLP APIs

NLP APIs

NLP APIs

Natural Language Processing

Natural Language Processing

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Processing

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Processing

Natural language text typed

recognized handwriting

transcribed speech

Extract information

Confer intelligence

Natural Language Processing

Processing

Natural language text typed

recognized handwriting

transcribed speech

Extract information

Confer intelligence

Natural Language Processing

Natural language text typed

recognized handwriting

transcribed speech

Confer intelligence

Natural Language Processing

Natural language text typed

recognized handwriting

transcribed speech

Detect language

Language identification

Natural Language Processing

Welcome to our talk on Natural Language ProcessingBienvenidos a nuestra plaacutetica sobre Procesamiento de Lenguaje Natural

Willkommen zu unserem Vortrag uumlber Verarbeitung natuumlrlicher Sprache欢迎参加我们关于自然语言处理理的讲座

हमारी पराकितक भाषा परससकरण भाषण म आपका सवागत ह

Natural language text typed

recognized handwriting

transcribed speech

Detect language

Language identification

Natural Language Processing

Tokenize text

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Natural Language Processing

Mr Tim Cook presided over the earnings report of Apple Inc on Tuesday

Tokenize text

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Natural Language Processing

星期二蒂姆middot库克先生主持了了苹果公司的财报会议

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Tokenize text

Natural Language Processing

星期二蒂姆middot库克 先生 主持 了了 苹果公司 的 财报 会议

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Tokenize text

Natural Language Processing

Assign parts of speech

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Natural Language Processing

Mr Tim Cook presided over the earnings report of Apple Inc on Tuesday Noun PUNCTNounNNP NNP PPNoun NounPPNounVerb PP DT Noun

Assign parts of speech

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Natural Language Processing

Lemmatize text

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Natural Language Processing

Mr Tim Cook presided over the earnings report of Apple The stock was up 3 after hours

Lemmatize text

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Natural Language Processing

Mr Tim Cook presided over the earnings report of Apple The stock was up 3 after hoursVerb NounVerb

preside hourbe

Lemmatize text

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Natural Language Processing

Named entity recognition

Extract entities

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Mr Tim Cook presided over the earnings report of Apple Inc on Tuesday

Natural Language Processing

Mr Tim Cook presided over the earnings report of Apple Inc on TuesdayPER ORG

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Extract entities

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Confer intelligence

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Linguistics

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Confer intelligence

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Linguistics Machine learning

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Confer intelligence

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Linguistics Machine learning

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Confer intelligence

Natural language text typed

recognized handwriting

transcribed speech

NLP APIs

Enough Tell me how to use them

NLP APIs

NLP APIs

NSLinguisticTagger

NSLinguisticTagger

Class in foundation

Segment and tag text

Linguistic tasks tagSchemes

NSLinguisticTagger

Class in foundation

Segment and tag text

Linguistic tasks tagSchemes

NSLinguisticTaggerNEW

NSLinguisticTagger

Tagging units

NEW

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

Units and schemes

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

Units and schemes

NEW

class func availableTagSchemes (for unit NSLinguisticTaggerUnit language String) -gt [NSLinguisticTagScheme]

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

Units and schemes

NEW

class func availableTagSchemes (for unit NSLinguisticTaggerUnit language String) -gt [NSLinguisticTagScheme]

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTaggerNEW

NSLinguisticTagger

dominantLanguage

NEW

NSLinguisticTagger

dominantLanguage

Swift 4 named types for tags and tagSchemes

NEW

NSLinguisticTagger

dominantLanguage

Swift 4 named types for tags and tagSchemes

Improved performance

Higher accuracy

Additional language support

NEW

Winnow and Whisk

Winnow and Whisk

Winnow and Whisk

Winnow Tag photos with descriptions

Winnow Tag photos with descriptions

Winnow Tag photos with descriptions

We hiked to the top and then ran down Lizzie won

Kids partied with all the goodieshellip

Die Kleinen haben friedlich zusammen gespielt

July 4th 2016hellipsummer parties at the

Holdenrsquos begin

Winnow Search for pictures

Winnow Search for pictures

Hike

Winnow Search for pictures

Hike No results

Winnow Improve search experience using NLP

Winnow Improve search experience using NLP

Hike

Winnow Improve search experience using NLP

We hiked to the top and then ran down Lizzie won

Great hikes make great pics

The hiking boysHolden family loves hiking and also posing for pictures

Hike

Winnow

Winnow

Winnow

NLP

Language identification

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

bullDemo

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Tim Cook Apple Stevie Wonder Cupertino Angela Ahrendts Bruce Wayne Thomas Vintberg

Pharrell NYU

Whisk

Whisk

Whisk

Whisk

NLP

Language identification

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

bullDemo

Why should you use the NLP APIs

Homogeneous Text Processing

Homogeneous Text Processing

NLP APIs

Natural language text typed

recognized handwriting

transcribed speech

Consistent text processing

Consistent user experience

Privacy

Privacy

On-device machine learning

User data stays on-device

Performance

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Chinese tokenization is 30 faster on iOS

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Named Entity Recognition 80 faster on iOS

Performance

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

40000 tokenssec

65000 tokenssec

Named Entity Recognition

Language Support

Language Support

Language identification 29 scripts 52 languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Accuracy

Accuracy

0

20

40

60

80

100

Part of speech

Named entity recognition

English Spanish

Debugging Hints

Debugging Hints

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Explicitly set language if known

Summary

NLP APIsmdashNSLinguisticTagger bull Support for new units bull Faster bull Higher accuracy bull More languages

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

Goal

Goal

Goal

Natural language input typed text

recognized handwriting

transcribed speech

Goal

Natural language output typed text

recognized handwriting

transcribed speech

Goal

NLP

Natural language text typed

recognized handwriting

transcribed speech

Confer intelligence

NLP APIs

NLP APIs

NLP APIs

NLP APIs

NLP APIs

Natural Language Processing

Natural Language Processing

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Processing

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Processing

Natural language text typed

recognized handwriting

transcribed speech

Extract information

Confer intelligence

Natural Language Processing

Processing

Natural language text typed

recognized handwriting

transcribed speech

Extract information

Confer intelligence

Natural Language Processing

Natural language text typed

recognized handwriting

transcribed speech

Confer intelligence

Natural Language Processing

Natural language text typed

recognized handwriting

transcribed speech

Detect language

Language identification

Natural Language Processing

Welcome to our talk on Natural Language ProcessingBienvenidos a nuestra plaacutetica sobre Procesamiento de Lenguaje Natural

Willkommen zu unserem Vortrag uumlber Verarbeitung natuumlrlicher Sprache欢迎参加我们关于自然语言处理理的讲座

हमारी पराकितक भाषा परससकरण भाषण म आपका सवागत ह

Natural language text typed

recognized handwriting

transcribed speech

Detect language

Language identification

Natural Language Processing

Tokenize text

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Natural Language Processing

Mr Tim Cook presided over the earnings report of Apple Inc on Tuesday

Tokenize text

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Natural Language Processing

星期二蒂姆middot库克先生主持了了苹果公司的财报会议

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Tokenize text

Natural Language Processing

星期二蒂姆middot库克 先生 主持 了了 苹果公司 的 财报 会议

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Tokenize text

Natural Language Processing

Assign parts of speech

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Natural Language Processing

Mr Tim Cook presided over the earnings report of Apple Inc on Tuesday Noun PUNCTNounNNP NNP PPNoun NounPPNounVerb PP DT Noun

Assign parts of speech

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Natural Language Processing

Lemmatize text

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Natural Language Processing

Mr Tim Cook presided over the earnings report of Apple The stock was up 3 after hours

Lemmatize text

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Natural Language Processing

Mr Tim Cook presided over the earnings report of Apple The stock was up 3 after hoursVerb NounVerb

preside hourbe

Lemmatize text

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Natural Language Processing

Named entity recognition

Extract entities

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Mr Tim Cook presided over the earnings report of Apple Inc on Tuesday

Natural Language Processing

Mr Tim Cook presided over the earnings report of Apple Inc on TuesdayPER ORG

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Extract entities

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Confer intelligence

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Linguistics

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Confer intelligence

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Linguistics Machine learning

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Confer intelligence

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Linguistics Machine learning

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Confer intelligence

Natural language text typed

recognized handwriting

transcribed speech

NLP APIs

Enough Tell me how to use them

NLP APIs

NLP APIs

NSLinguisticTagger

NSLinguisticTagger

Class in foundation

Segment and tag text

Linguistic tasks tagSchemes

NSLinguisticTagger

Class in foundation

Segment and tag text

Linguistic tasks tagSchemes

NSLinguisticTaggerNEW

NSLinguisticTagger

Tagging units

NEW

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

Units and schemes

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

Units and schemes

NEW

class func availableTagSchemes (for unit NSLinguisticTaggerUnit language String) -gt [NSLinguisticTagScheme]

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

Units and schemes

NEW

class func availableTagSchemes (for unit NSLinguisticTaggerUnit language String) -gt [NSLinguisticTagScheme]

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTaggerNEW

NSLinguisticTagger

dominantLanguage

NEW

NSLinguisticTagger

dominantLanguage

Swift 4 named types for tags and tagSchemes

NEW

NSLinguisticTagger

dominantLanguage

Swift 4 named types for tags and tagSchemes

Improved performance

Higher accuracy

Additional language support

NEW

Winnow and Whisk

Winnow and Whisk

Winnow and Whisk

Winnow Tag photos with descriptions

Winnow Tag photos with descriptions

Winnow Tag photos with descriptions

We hiked to the top and then ran down Lizzie won

Kids partied with all the goodieshellip

Die Kleinen haben friedlich zusammen gespielt

July 4th 2016hellipsummer parties at the

Holdenrsquos begin

Winnow Search for pictures

Winnow Search for pictures

Hike

Winnow Search for pictures

Hike No results

Winnow Improve search experience using NLP

Winnow Improve search experience using NLP

Hike

Winnow Improve search experience using NLP

We hiked to the top and then ran down Lizzie won

Great hikes make great pics

The hiking boysHolden family loves hiking and also posing for pictures

Hike

Winnow

Winnow

Winnow

NLP

Language identification

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

bullDemo

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Tim Cook Apple Stevie Wonder Cupertino Angela Ahrendts Bruce Wayne Thomas Vintberg

Pharrell NYU

Whisk

Whisk

Whisk

Whisk

NLP

Language identification

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

bullDemo

Why should you use the NLP APIs

Homogeneous Text Processing

Homogeneous Text Processing

NLP APIs

Natural language text typed

recognized handwriting

transcribed speech

Consistent text processing

Consistent user experience

Privacy

Privacy

On-device machine learning

User data stays on-device

Performance

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Chinese tokenization is 30 faster on iOS

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Named Entity Recognition 80 faster on iOS

Performance

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

40000 tokenssec

65000 tokenssec

Named Entity Recognition

Language Support

Language Support

Language identification 29 scripts 52 languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Accuracy

Accuracy

0

20

40

60

80

100

Part of speech

Named entity recognition

English Spanish

Debugging Hints

Debugging Hints

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Explicitly set language if known

Summary

NLP APIsmdashNSLinguisticTagger bull Support for new units bull Faster bull Higher accuracy bull More languages

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

Goal

Goal

Natural language input typed text

recognized handwriting

transcribed speech

Goal

Natural language output typed text

recognized handwriting

transcribed speech

Goal

NLP

Natural language text typed

recognized handwriting

transcribed speech

Confer intelligence

NLP APIs

NLP APIs

NLP APIs

NLP APIs

NLP APIs

Natural Language Processing

Natural Language Processing

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Processing

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Processing

Natural language text typed

recognized handwriting

transcribed speech

Extract information

Confer intelligence

Natural Language Processing

Processing

Natural language text typed

recognized handwriting

transcribed speech

Extract information

Confer intelligence

Natural Language Processing

Natural language text typed

recognized handwriting

transcribed speech

Confer intelligence

Natural Language Processing

Natural language text typed

recognized handwriting

transcribed speech

Detect language

Language identification

Natural Language Processing

Welcome to our talk on Natural Language ProcessingBienvenidos a nuestra plaacutetica sobre Procesamiento de Lenguaje Natural

Willkommen zu unserem Vortrag uumlber Verarbeitung natuumlrlicher Sprache欢迎参加我们关于自然语言处理理的讲座

हमारी पराकितक भाषा परससकरण भाषण म आपका सवागत ह

Natural language text typed

recognized handwriting

transcribed speech

Detect language

Language identification

Natural Language Processing

Tokenize text

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Natural Language Processing

Mr Tim Cook presided over the earnings report of Apple Inc on Tuesday

Tokenize text

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Natural Language Processing

星期二蒂姆middot库克先生主持了了苹果公司的财报会议

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Tokenize text

Natural Language Processing

星期二蒂姆middot库克 先生 主持 了了 苹果公司 的 财报 会议

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Tokenize text

Natural Language Processing

Assign parts of speech

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Natural Language Processing

Mr Tim Cook presided over the earnings report of Apple Inc on Tuesday Noun PUNCTNounNNP NNP PPNoun NounPPNounVerb PP DT Noun

Assign parts of speech

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Natural Language Processing

Lemmatize text

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Natural Language Processing

Mr Tim Cook presided over the earnings report of Apple The stock was up 3 after hours

Lemmatize text

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Natural Language Processing

Mr Tim Cook presided over the earnings report of Apple The stock was up 3 after hoursVerb NounVerb

preside hourbe

Lemmatize text

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Natural Language Processing

Named entity recognition

Extract entities

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Mr Tim Cook presided over the earnings report of Apple Inc on Tuesday

Natural Language Processing

Mr Tim Cook presided over the earnings report of Apple Inc on TuesdayPER ORG

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Extract entities

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Confer intelligence

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Linguistics

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Confer intelligence

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Linguistics Machine learning

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Confer intelligence

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Linguistics Machine learning

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Confer intelligence

Natural language text typed

recognized handwriting

transcribed speech

NLP APIs

Enough Tell me how to use them

NLP APIs

NLP APIs

NSLinguisticTagger

NSLinguisticTagger

Class in foundation

Segment and tag text

Linguistic tasks tagSchemes

NSLinguisticTagger

Class in foundation

Segment and tag text

Linguistic tasks tagSchemes

NSLinguisticTaggerNEW

NSLinguisticTagger

Tagging units

NEW

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

Units and schemes

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

Units and schemes

NEW

class func availableTagSchemes (for unit NSLinguisticTaggerUnit language String) -gt [NSLinguisticTagScheme]

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

Units and schemes

NEW

class func availableTagSchemes (for unit NSLinguisticTaggerUnit language String) -gt [NSLinguisticTagScheme]

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTaggerNEW

NSLinguisticTagger

dominantLanguage

NEW

NSLinguisticTagger

dominantLanguage

Swift 4 named types for tags and tagSchemes

NEW

NSLinguisticTagger

dominantLanguage

Swift 4 named types for tags and tagSchemes

Improved performance

Higher accuracy

Additional language support

NEW

Winnow and Whisk

Winnow and Whisk

Winnow and Whisk

Winnow Tag photos with descriptions

Winnow Tag photos with descriptions

Winnow Tag photos with descriptions

We hiked to the top and then ran down Lizzie won

Kids partied with all the goodieshellip

Die Kleinen haben friedlich zusammen gespielt

July 4th 2016hellipsummer parties at the

Holdenrsquos begin

Winnow Search for pictures

Winnow Search for pictures

Hike

Winnow Search for pictures

Hike No results

Winnow Improve search experience using NLP

Winnow Improve search experience using NLP

Hike

Winnow Improve search experience using NLP

We hiked to the top and then ran down Lizzie won

Great hikes make great pics

The hiking boysHolden family loves hiking and also posing for pictures

Hike

Winnow

Winnow

Winnow

NLP

Language identification

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

bullDemo

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Tim Cook Apple Stevie Wonder Cupertino Angela Ahrendts Bruce Wayne Thomas Vintberg

Pharrell NYU

Whisk

Whisk

Whisk

Whisk

NLP

Language identification

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

bullDemo

Why should you use the NLP APIs

Homogeneous Text Processing

Homogeneous Text Processing

NLP APIs

Natural language text typed

recognized handwriting

transcribed speech

Consistent text processing

Consistent user experience

Privacy

Privacy

On-device machine learning

User data stays on-device

Performance

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Chinese tokenization is 30 faster on iOS

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Named Entity Recognition 80 faster on iOS

Performance

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

40000 tokenssec

65000 tokenssec

Named Entity Recognition

Language Support

Language Support

Language identification 29 scripts 52 languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Accuracy

Accuracy

0

20

40

60

80

100

Part of speech

Named entity recognition

English Spanish

Debugging Hints

Debugging Hints

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Explicitly set language if known

Summary

NLP APIsmdashNSLinguisticTagger bull Support for new units bull Faster bull Higher accuracy bull More languages

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

Goal

Natural language input typed text

recognized handwriting

transcribed speech

Goal

Natural language output typed text

recognized handwriting

transcribed speech

Goal

NLP

Natural language text typed

recognized handwriting

transcribed speech

Confer intelligence

NLP APIs

NLP APIs

NLP APIs

NLP APIs

NLP APIs

Natural Language Processing

Natural Language Processing

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Processing

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Processing

Natural language text typed

recognized handwriting

transcribed speech

Extract information

Confer intelligence

Natural Language Processing

Processing

Natural language text typed

recognized handwriting

transcribed speech

Extract information

Confer intelligence

Natural Language Processing

Natural language text typed

recognized handwriting

transcribed speech

Confer intelligence

Natural Language Processing

Natural language text typed

recognized handwriting

transcribed speech

Detect language

Language identification

Natural Language Processing

Welcome to our talk on Natural Language ProcessingBienvenidos a nuestra plaacutetica sobre Procesamiento de Lenguaje Natural

Willkommen zu unserem Vortrag uumlber Verarbeitung natuumlrlicher Sprache欢迎参加我们关于自然语言处理理的讲座

हमारी पराकितक भाषा परससकरण भाषण म आपका सवागत ह

Natural language text typed

recognized handwriting

transcribed speech

Detect language

Language identification

Natural Language Processing

Tokenize text

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Natural Language Processing

Mr Tim Cook presided over the earnings report of Apple Inc on Tuesday

Tokenize text

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Natural Language Processing

星期二蒂姆middot库克先生主持了了苹果公司的财报会议

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Tokenize text

Natural Language Processing

星期二蒂姆middot库克 先生 主持 了了 苹果公司 的 财报 会议

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Tokenize text

Natural Language Processing

Assign parts of speech

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Natural Language Processing

Mr Tim Cook presided over the earnings report of Apple Inc on Tuesday Noun PUNCTNounNNP NNP PPNoun NounPPNounVerb PP DT Noun

Assign parts of speech

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Natural Language Processing

Lemmatize text

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Natural Language Processing

Mr Tim Cook presided over the earnings report of Apple The stock was up 3 after hours

Lemmatize text

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Natural Language Processing

Mr Tim Cook presided over the earnings report of Apple The stock was up 3 after hoursVerb NounVerb

preside hourbe

Lemmatize text

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Natural Language Processing

Named entity recognition

Extract entities

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Mr Tim Cook presided over the earnings report of Apple Inc on Tuesday

Natural Language Processing

Mr Tim Cook presided over the earnings report of Apple Inc on TuesdayPER ORG

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Extract entities

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Confer intelligence

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Linguistics

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Confer intelligence

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Linguistics Machine learning

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Confer intelligence

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Linguistics Machine learning

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Confer intelligence

Natural language text typed

recognized handwriting

transcribed speech

NLP APIs

Enough Tell me how to use them

NLP APIs

NLP APIs

NSLinguisticTagger

NSLinguisticTagger

Class in foundation

Segment and tag text

Linguistic tasks tagSchemes

NSLinguisticTagger

Class in foundation

Segment and tag text

Linguistic tasks tagSchemes

NSLinguisticTaggerNEW

NSLinguisticTagger

Tagging units

NEW

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

Units and schemes

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

Units and schemes

NEW

class func availableTagSchemes (for unit NSLinguisticTaggerUnit language String) -gt [NSLinguisticTagScheme]

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

Units and schemes

NEW

class func availableTagSchemes (for unit NSLinguisticTaggerUnit language String) -gt [NSLinguisticTagScheme]

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTaggerNEW

NSLinguisticTagger

dominantLanguage

NEW

NSLinguisticTagger

dominantLanguage

Swift 4 named types for tags and tagSchemes

NEW

NSLinguisticTagger

dominantLanguage

Swift 4 named types for tags and tagSchemes

Improved performance

Higher accuracy

Additional language support

NEW

Winnow and Whisk

Winnow and Whisk

Winnow and Whisk

Winnow Tag photos with descriptions

Winnow Tag photos with descriptions

Winnow Tag photos with descriptions

We hiked to the top and then ran down Lizzie won

Kids partied with all the goodieshellip

Die Kleinen haben friedlich zusammen gespielt

July 4th 2016hellipsummer parties at the

Holdenrsquos begin

Winnow Search for pictures

Winnow Search for pictures

Hike

Winnow Search for pictures

Hike No results

Winnow Improve search experience using NLP

Winnow Improve search experience using NLP

Hike

Winnow Improve search experience using NLP

We hiked to the top and then ran down Lizzie won

Great hikes make great pics

The hiking boysHolden family loves hiking and also posing for pictures

Hike

Winnow

Winnow

Winnow

NLP

Language identification

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

bullDemo

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Tim Cook Apple Stevie Wonder Cupertino Angela Ahrendts Bruce Wayne Thomas Vintberg

Pharrell NYU

Whisk

Whisk

Whisk

Whisk

NLP

Language identification

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

bullDemo

Why should you use the NLP APIs

Homogeneous Text Processing

Homogeneous Text Processing

NLP APIs

Natural language text typed

recognized handwriting

transcribed speech

Consistent text processing

Consistent user experience

Privacy

Privacy

On-device machine learning

User data stays on-device

Performance

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Chinese tokenization is 30 faster on iOS

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Named Entity Recognition 80 faster on iOS

Performance

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

40000 tokenssec

65000 tokenssec

Named Entity Recognition

Language Support

Language Support

Language identification 29 scripts 52 languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Accuracy

Accuracy

0

20

40

60

80

100

Part of speech

Named entity recognition

English Spanish

Debugging Hints

Debugging Hints

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Explicitly set language if known

Summary

NLP APIsmdashNSLinguisticTagger bull Support for new units bull Faster bull Higher accuracy bull More languages

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

Goal

Natural language output typed text

recognized handwriting

transcribed speech

Goal

NLP

Natural language text typed

recognized handwriting

transcribed speech

Confer intelligence

NLP APIs

NLP APIs

NLP APIs

NLP APIs

NLP APIs

Natural Language Processing

Natural Language Processing

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Processing

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Processing

Natural language text typed

recognized handwriting

transcribed speech

Extract information

Confer intelligence

Natural Language Processing

Processing

Natural language text typed

recognized handwriting

transcribed speech

Extract information

Confer intelligence

Natural Language Processing

Natural language text typed

recognized handwriting

transcribed speech

Confer intelligence

Natural Language Processing

Natural language text typed

recognized handwriting

transcribed speech

Detect language

Language identification

Natural Language Processing

Welcome to our talk on Natural Language ProcessingBienvenidos a nuestra plaacutetica sobre Procesamiento de Lenguaje Natural

Willkommen zu unserem Vortrag uumlber Verarbeitung natuumlrlicher Sprache欢迎参加我们关于自然语言处理理的讲座

हमारी पराकितक भाषा परससकरण भाषण म आपका सवागत ह

Natural language text typed

recognized handwriting

transcribed speech

Detect language

Language identification

Natural Language Processing

Tokenize text

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Natural Language Processing

Mr Tim Cook presided over the earnings report of Apple Inc on Tuesday

Tokenize text

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Natural Language Processing

星期二蒂姆middot库克先生主持了了苹果公司的财报会议

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Tokenize text

Natural Language Processing

星期二蒂姆middot库克 先生 主持 了了 苹果公司 的 财报 会议

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Tokenize text

Natural Language Processing

Assign parts of speech

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Natural Language Processing

Mr Tim Cook presided over the earnings report of Apple Inc on Tuesday Noun PUNCTNounNNP NNP PPNoun NounPPNounVerb PP DT Noun

Assign parts of speech

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Natural Language Processing

Lemmatize text

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Natural Language Processing

Mr Tim Cook presided over the earnings report of Apple The stock was up 3 after hours

Lemmatize text

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Natural Language Processing

Mr Tim Cook presided over the earnings report of Apple The stock was up 3 after hoursVerb NounVerb

preside hourbe

Lemmatize text

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Natural Language Processing

Named entity recognition

Extract entities

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Mr Tim Cook presided over the earnings report of Apple Inc on Tuesday

Natural Language Processing

Mr Tim Cook presided over the earnings report of Apple Inc on TuesdayPER ORG

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Extract entities

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Confer intelligence

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Linguistics

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Confer intelligence

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Linguistics Machine learning

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Confer intelligence

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Linguistics Machine learning

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Confer intelligence

Natural language text typed

recognized handwriting

transcribed speech

NLP APIs

Enough Tell me how to use them

NLP APIs

NLP APIs

NSLinguisticTagger

NSLinguisticTagger

Class in foundation

Segment and tag text

Linguistic tasks tagSchemes

NSLinguisticTagger

Class in foundation

Segment and tag text

Linguistic tasks tagSchemes

NSLinguisticTaggerNEW

NSLinguisticTagger

Tagging units

NEW

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

Units and schemes

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

Units and schemes

NEW

class func availableTagSchemes (for unit NSLinguisticTaggerUnit language String) -gt [NSLinguisticTagScheme]

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

Units and schemes

NEW

class func availableTagSchemes (for unit NSLinguisticTaggerUnit language String) -gt [NSLinguisticTagScheme]

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTaggerNEW

NSLinguisticTagger

dominantLanguage

NEW

NSLinguisticTagger

dominantLanguage

Swift 4 named types for tags and tagSchemes

NEW

NSLinguisticTagger

dominantLanguage

Swift 4 named types for tags and tagSchemes

Improved performance

Higher accuracy

Additional language support

NEW

Winnow and Whisk

Winnow and Whisk

Winnow and Whisk

Winnow Tag photos with descriptions

Winnow Tag photos with descriptions

Winnow Tag photos with descriptions

We hiked to the top and then ran down Lizzie won

Kids partied with all the goodieshellip

Die Kleinen haben friedlich zusammen gespielt

July 4th 2016hellipsummer parties at the

Holdenrsquos begin

Winnow Search for pictures

Winnow Search for pictures

Hike

Winnow Search for pictures

Hike No results

Winnow Improve search experience using NLP

Winnow Improve search experience using NLP

Hike

Winnow Improve search experience using NLP

We hiked to the top and then ran down Lizzie won

Great hikes make great pics

The hiking boysHolden family loves hiking and also posing for pictures

Hike

Winnow

Winnow

Winnow

NLP

Language identification

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

bullDemo

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Tim Cook Apple Stevie Wonder Cupertino Angela Ahrendts Bruce Wayne Thomas Vintberg

Pharrell NYU

Whisk

Whisk

Whisk

Whisk

NLP

Language identification

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

bullDemo

Why should you use the NLP APIs

Homogeneous Text Processing

Homogeneous Text Processing

NLP APIs

Natural language text typed

recognized handwriting

transcribed speech

Consistent text processing

Consistent user experience

Privacy

Privacy

On-device machine learning

User data stays on-device

Performance

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Chinese tokenization is 30 faster on iOS

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Named Entity Recognition 80 faster on iOS

Performance

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

40000 tokenssec

65000 tokenssec

Named Entity Recognition

Language Support

Language Support

Language identification 29 scripts 52 languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Accuracy

Accuracy

0

20

40

60

80

100

Part of speech

Named entity recognition

English Spanish

Debugging Hints

Debugging Hints

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Explicitly set language if known

Summary

NLP APIsmdashNSLinguisticTagger bull Support for new units bull Faster bull Higher accuracy bull More languages

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

Goal

NLP

Natural language text typed

recognized handwriting

transcribed speech

Confer intelligence

NLP APIs

NLP APIs

NLP APIs

NLP APIs

NLP APIs

Natural Language Processing

Natural Language Processing

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Processing

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Processing

Natural language text typed

recognized handwriting

transcribed speech

Extract information

Confer intelligence

Natural Language Processing

Processing

Natural language text typed

recognized handwriting

transcribed speech

Extract information

Confer intelligence

Natural Language Processing

Natural language text typed

recognized handwriting

transcribed speech

Confer intelligence

Natural Language Processing

Natural language text typed

recognized handwriting

transcribed speech

Detect language

Language identification

Natural Language Processing

Welcome to our talk on Natural Language ProcessingBienvenidos a nuestra plaacutetica sobre Procesamiento de Lenguaje Natural

Willkommen zu unserem Vortrag uumlber Verarbeitung natuumlrlicher Sprache欢迎参加我们关于自然语言处理理的讲座

हमारी पराकितक भाषा परससकरण भाषण म आपका सवागत ह

Natural language text typed

recognized handwriting

transcribed speech

Detect language

Language identification

Natural Language Processing

Tokenize text

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Natural Language Processing

Mr Tim Cook presided over the earnings report of Apple Inc on Tuesday

Tokenize text

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Natural Language Processing

星期二蒂姆middot库克先生主持了了苹果公司的财报会议

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Tokenize text

Natural Language Processing

星期二蒂姆middot库克 先生 主持 了了 苹果公司 的 财报 会议

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Tokenize text

Natural Language Processing

Assign parts of speech

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Natural Language Processing

Mr Tim Cook presided over the earnings report of Apple Inc on Tuesday Noun PUNCTNounNNP NNP PPNoun NounPPNounVerb PP DT Noun

Assign parts of speech

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Natural Language Processing

Lemmatize text

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Natural Language Processing

Mr Tim Cook presided over the earnings report of Apple The stock was up 3 after hours

Lemmatize text

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Natural Language Processing

Mr Tim Cook presided over the earnings report of Apple The stock was up 3 after hoursVerb NounVerb

preside hourbe

Lemmatize text

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Natural Language Processing

Named entity recognition

Extract entities

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Mr Tim Cook presided over the earnings report of Apple Inc on Tuesday

Natural Language Processing

Mr Tim Cook presided over the earnings report of Apple Inc on TuesdayPER ORG

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Extract entities

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Confer intelligence

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Linguistics

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Confer intelligence

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Linguistics Machine learning

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Confer intelligence

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Linguistics Machine learning

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Confer intelligence

Natural language text typed

recognized handwriting

transcribed speech

NLP APIs

Enough Tell me how to use them

NLP APIs

NLP APIs

NSLinguisticTagger

NSLinguisticTagger

Class in foundation

Segment and tag text

Linguistic tasks tagSchemes

NSLinguisticTagger

Class in foundation

Segment and tag text

Linguistic tasks tagSchemes

NSLinguisticTaggerNEW

NSLinguisticTagger

Tagging units

NEW

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

Units and schemes

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

Units and schemes

NEW

class func availableTagSchemes (for unit NSLinguisticTaggerUnit language String) -gt [NSLinguisticTagScheme]

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

Units and schemes

NEW

class func availableTagSchemes (for unit NSLinguisticTaggerUnit language String) -gt [NSLinguisticTagScheme]

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTaggerNEW

NSLinguisticTagger

dominantLanguage

NEW

NSLinguisticTagger

dominantLanguage

Swift 4 named types for tags and tagSchemes

NEW

NSLinguisticTagger

dominantLanguage

Swift 4 named types for tags and tagSchemes

Improved performance

Higher accuracy

Additional language support

NEW

Winnow and Whisk

Winnow and Whisk

Winnow and Whisk

Winnow Tag photos with descriptions

Winnow Tag photos with descriptions

Winnow Tag photos with descriptions

We hiked to the top and then ran down Lizzie won

Kids partied with all the goodieshellip

Die Kleinen haben friedlich zusammen gespielt

July 4th 2016hellipsummer parties at the

Holdenrsquos begin

Winnow Search for pictures

Winnow Search for pictures

Hike

Winnow Search for pictures

Hike No results

Winnow Improve search experience using NLP

Winnow Improve search experience using NLP

Hike

Winnow Improve search experience using NLP

We hiked to the top and then ran down Lizzie won

Great hikes make great pics

The hiking boysHolden family loves hiking and also posing for pictures

Hike

Winnow

Winnow

Winnow

NLP

Language identification

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

bullDemo

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Tim Cook Apple Stevie Wonder Cupertino Angela Ahrendts Bruce Wayne Thomas Vintberg

Pharrell NYU

Whisk

Whisk

Whisk

Whisk

NLP

Language identification

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

bullDemo

Why should you use the NLP APIs

Homogeneous Text Processing

Homogeneous Text Processing

NLP APIs

Natural language text typed

recognized handwriting

transcribed speech

Consistent text processing

Consistent user experience

Privacy

Privacy

On-device machine learning

User data stays on-device

Performance

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Chinese tokenization is 30 faster on iOS

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Named Entity Recognition 80 faster on iOS

Performance

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

40000 tokenssec

65000 tokenssec

Named Entity Recognition

Language Support

Language Support

Language identification 29 scripts 52 languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Accuracy

Accuracy

0

20

40

60

80

100

Part of speech

Named entity recognition

English Spanish

Debugging Hints

Debugging Hints

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Explicitly set language if known

Summary

NLP APIsmdashNSLinguisticTagger bull Support for new units bull Faster bull Higher accuracy bull More languages

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

NLP APIs

NLP APIs

NLP APIs

NLP APIs

NLP APIs

Natural Language Processing

Natural Language Processing

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Processing

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Processing

Natural language text typed

recognized handwriting

transcribed speech

Extract information

Confer intelligence

Natural Language Processing

Processing

Natural language text typed

recognized handwriting

transcribed speech

Extract information

Confer intelligence

Natural Language Processing

Natural language text typed

recognized handwriting

transcribed speech

Confer intelligence

Natural Language Processing

Natural language text typed

recognized handwriting

transcribed speech

Detect language

Language identification

Natural Language Processing

Welcome to our talk on Natural Language ProcessingBienvenidos a nuestra plaacutetica sobre Procesamiento de Lenguaje Natural

Willkommen zu unserem Vortrag uumlber Verarbeitung natuumlrlicher Sprache欢迎参加我们关于自然语言处理理的讲座

हमारी पराकितक भाषा परससकरण भाषण म आपका सवागत ह

Natural language text typed

recognized handwriting

transcribed speech

Detect language

Language identification

Natural Language Processing

Tokenize text

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Natural Language Processing

Mr Tim Cook presided over the earnings report of Apple Inc on Tuesday

Tokenize text

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Natural Language Processing

星期二蒂姆middot库克先生主持了了苹果公司的财报会议

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Tokenize text

Natural Language Processing

星期二蒂姆middot库克 先生 主持 了了 苹果公司 的 财报 会议

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Tokenize text

Natural Language Processing

Assign parts of speech

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Natural Language Processing

Mr Tim Cook presided over the earnings report of Apple Inc on Tuesday Noun PUNCTNounNNP NNP PPNoun NounPPNounVerb PP DT Noun

Assign parts of speech

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Natural Language Processing

Lemmatize text

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Natural Language Processing

Mr Tim Cook presided over the earnings report of Apple The stock was up 3 after hours

Lemmatize text

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Natural Language Processing

Mr Tim Cook presided over the earnings report of Apple The stock was up 3 after hoursVerb NounVerb

preside hourbe

Lemmatize text

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Natural Language Processing

Named entity recognition

Extract entities

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Mr Tim Cook presided over the earnings report of Apple Inc on Tuesday

Natural Language Processing

Mr Tim Cook presided over the earnings report of Apple Inc on TuesdayPER ORG

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Extract entities

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Confer intelligence

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Linguistics

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Confer intelligence

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Linguistics Machine learning

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Confer intelligence

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Linguistics Machine learning

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Confer intelligence

Natural language text typed

recognized handwriting

transcribed speech

NLP APIs

Enough Tell me how to use them

NLP APIs

NLP APIs

NSLinguisticTagger

NSLinguisticTagger

Class in foundation

Segment and tag text

Linguistic tasks tagSchemes

NSLinguisticTagger

Class in foundation

Segment and tag text

Linguistic tasks tagSchemes

NSLinguisticTaggerNEW

NSLinguisticTagger

Tagging units

NEW

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

Units and schemes

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

Units and schemes

NEW

class func availableTagSchemes (for unit NSLinguisticTaggerUnit language String) -gt [NSLinguisticTagScheme]

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

Units and schemes

NEW

class func availableTagSchemes (for unit NSLinguisticTaggerUnit language String) -gt [NSLinguisticTagScheme]

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTaggerNEW

NSLinguisticTagger

dominantLanguage

NEW

NSLinguisticTagger

dominantLanguage

Swift 4 named types for tags and tagSchemes

NEW

NSLinguisticTagger

dominantLanguage

Swift 4 named types for tags and tagSchemes

Improved performance

Higher accuracy

Additional language support

NEW

Winnow and Whisk

Winnow and Whisk

Winnow and Whisk

Winnow Tag photos with descriptions

Winnow Tag photos with descriptions

Winnow Tag photos with descriptions

We hiked to the top and then ran down Lizzie won

Kids partied with all the goodieshellip

Die Kleinen haben friedlich zusammen gespielt

July 4th 2016hellipsummer parties at the

Holdenrsquos begin

Winnow Search for pictures

Winnow Search for pictures

Hike

Winnow Search for pictures

Hike No results

Winnow Improve search experience using NLP

Winnow Improve search experience using NLP

Hike

Winnow Improve search experience using NLP

We hiked to the top and then ran down Lizzie won

Great hikes make great pics

The hiking boysHolden family loves hiking and also posing for pictures

Hike

Winnow

Winnow

Winnow

NLP

Language identification

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

bullDemo

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Tim Cook Apple Stevie Wonder Cupertino Angela Ahrendts Bruce Wayne Thomas Vintberg

Pharrell NYU

Whisk

Whisk

Whisk

Whisk

NLP

Language identification

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

bullDemo

Why should you use the NLP APIs

Homogeneous Text Processing

Homogeneous Text Processing

NLP APIs

Natural language text typed

recognized handwriting

transcribed speech

Consistent text processing

Consistent user experience

Privacy

Privacy

On-device machine learning

User data stays on-device

Performance

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Chinese tokenization is 30 faster on iOS

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Named Entity Recognition 80 faster on iOS

Performance

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

40000 tokenssec

65000 tokenssec

Named Entity Recognition

Language Support

Language Support

Language identification 29 scripts 52 languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Accuracy

Accuracy

0

20

40

60

80

100

Part of speech

Named entity recognition

English Spanish

Debugging Hints

Debugging Hints

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Explicitly set language if known

Summary

NLP APIsmdashNSLinguisticTagger bull Support for new units bull Faster bull Higher accuracy bull More languages

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

NLP APIs

NLP APIs

NLP APIs

NLP APIs

Natural Language Processing

Natural Language Processing

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Processing

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Processing

Natural language text typed

recognized handwriting

transcribed speech

Extract information

Confer intelligence

Natural Language Processing

Processing

Natural language text typed

recognized handwriting

transcribed speech

Extract information

Confer intelligence

Natural Language Processing

Natural language text typed

recognized handwriting

transcribed speech

Confer intelligence

Natural Language Processing

Natural language text typed

recognized handwriting

transcribed speech

Detect language

Language identification

Natural Language Processing

Welcome to our talk on Natural Language ProcessingBienvenidos a nuestra plaacutetica sobre Procesamiento de Lenguaje Natural

Willkommen zu unserem Vortrag uumlber Verarbeitung natuumlrlicher Sprache欢迎参加我们关于自然语言处理理的讲座

हमारी पराकितक भाषा परससकरण भाषण म आपका सवागत ह

Natural language text typed

recognized handwriting

transcribed speech

Detect language

Language identification

Natural Language Processing

Tokenize text

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Natural Language Processing

Mr Tim Cook presided over the earnings report of Apple Inc on Tuesday

Tokenize text

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Natural Language Processing

星期二蒂姆middot库克先生主持了了苹果公司的财报会议

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Tokenize text

Natural Language Processing

星期二蒂姆middot库克 先生 主持 了了 苹果公司 的 财报 会议

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Tokenize text

Natural Language Processing

Assign parts of speech

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Natural Language Processing

Mr Tim Cook presided over the earnings report of Apple Inc on Tuesday Noun PUNCTNounNNP NNP PPNoun NounPPNounVerb PP DT Noun

Assign parts of speech

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Natural Language Processing

Lemmatize text

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Natural Language Processing

Mr Tim Cook presided over the earnings report of Apple The stock was up 3 after hours

Lemmatize text

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Natural Language Processing

Mr Tim Cook presided over the earnings report of Apple The stock was up 3 after hoursVerb NounVerb

preside hourbe

Lemmatize text

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Natural Language Processing

Named entity recognition

Extract entities

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Mr Tim Cook presided over the earnings report of Apple Inc on Tuesday

Natural Language Processing

Mr Tim Cook presided over the earnings report of Apple Inc on TuesdayPER ORG

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Extract entities

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Confer intelligence

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Linguistics

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Confer intelligence

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Linguistics Machine learning

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Confer intelligence

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Linguistics Machine learning

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Confer intelligence

Natural language text typed

recognized handwriting

transcribed speech

NLP APIs

Enough Tell me how to use them

NLP APIs

NLP APIs

NSLinguisticTagger

NSLinguisticTagger

Class in foundation

Segment and tag text

Linguistic tasks tagSchemes

NSLinguisticTagger

Class in foundation

Segment and tag text

Linguistic tasks tagSchemes

NSLinguisticTaggerNEW

NSLinguisticTagger

Tagging units

NEW

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

Units and schemes

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

Units and schemes

NEW

class func availableTagSchemes (for unit NSLinguisticTaggerUnit language String) -gt [NSLinguisticTagScheme]

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

Units and schemes

NEW

class func availableTagSchemes (for unit NSLinguisticTaggerUnit language String) -gt [NSLinguisticTagScheme]

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTaggerNEW

NSLinguisticTagger

dominantLanguage

NEW

NSLinguisticTagger

dominantLanguage

Swift 4 named types for tags and tagSchemes

NEW

NSLinguisticTagger

dominantLanguage

Swift 4 named types for tags and tagSchemes

Improved performance

Higher accuracy

Additional language support

NEW

Winnow and Whisk

Winnow and Whisk

Winnow and Whisk

Winnow Tag photos with descriptions

Winnow Tag photos with descriptions

Winnow Tag photos with descriptions

We hiked to the top and then ran down Lizzie won

Kids partied with all the goodieshellip

Die Kleinen haben friedlich zusammen gespielt

July 4th 2016hellipsummer parties at the

Holdenrsquos begin

Winnow Search for pictures

Winnow Search for pictures

Hike

Winnow Search for pictures

Hike No results

Winnow Improve search experience using NLP

Winnow Improve search experience using NLP

Hike

Winnow Improve search experience using NLP

We hiked to the top and then ran down Lizzie won

Great hikes make great pics

The hiking boysHolden family loves hiking and also posing for pictures

Hike

Winnow

Winnow

Winnow

NLP

Language identification

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

bullDemo

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Tim Cook Apple Stevie Wonder Cupertino Angela Ahrendts Bruce Wayne Thomas Vintberg

Pharrell NYU

Whisk

Whisk

Whisk

Whisk

NLP

Language identification

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

bullDemo

Why should you use the NLP APIs

Homogeneous Text Processing

Homogeneous Text Processing

NLP APIs

Natural language text typed

recognized handwriting

transcribed speech

Consistent text processing

Consistent user experience

Privacy

Privacy

On-device machine learning

User data stays on-device

Performance

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Chinese tokenization is 30 faster on iOS

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Named Entity Recognition 80 faster on iOS

Performance

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

40000 tokenssec

65000 tokenssec

Named Entity Recognition

Language Support

Language Support

Language identification 29 scripts 52 languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Accuracy

Accuracy

0

20

40

60

80

100

Part of speech

Named entity recognition

English Spanish

Debugging Hints

Debugging Hints

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Explicitly set language if known

Summary

NLP APIsmdashNSLinguisticTagger bull Support for new units bull Faster bull Higher accuracy bull More languages

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

NLP APIs

NLP APIs

NLP APIs

Natural Language Processing

Natural Language Processing

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Processing

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Processing

Natural language text typed

recognized handwriting

transcribed speech

Extract information

Confer intelligence

Natural Language Processing

Processing

Natural language text typed

recognized handwriting

transcribed speech

Extract information

Confer intelligence

Natural Language Processing

Natural language text typed

recognized handwriting

transcribed speech

Confer intelligence

Natural Language Processing

Natural language text typed

recognized handwriting

transcribed speech

Detect language

Language identification

Natural Language Processing

Welcome to our talk on Natural Language ProcessingBienvenidos a nuestra plaacutetica sobre Procesamiento de Lenguaje Natural

Willkommen zu unserem Vortrag uumlber Verarbeitung natuumlrlicher Sprache欢迎参加我们关于自然语言处理理的讲座

हमारी पराकितक भाषा परससकरण भाषण म आपका सवागत ह

Natural language text typed

recognized handwriting

transcribed speech

Detect language

Language identification

Natural Language Processing

Tokenize text

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Natural Language Processing

Mr Tim Cook presided over the earnings report of Apple Inc on Tuesday

Tokenize text

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Natural Language Processing

星期二蒂姆middot库克先生主持了了苹果公司的财报会议

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Tokenize text

Natural Language Processing

星期二蒂姆middot库克 先生 主持 了了 苹果公司 的 财报 会议

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Tokenize text

Natural Language Processing

Assign parts of speech

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Natural Language Processing

Mr Tim Cook presided over the earnings report of Apple Inc on Tuesday Noun PUNCTNounNNP NNP PPNoun NounPPNounVerb PP DT Noun

Assign parts of speech

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Natural Language Processing

Lemmatize text

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Natural Language Processing

Mr Tim Cook presided over the earnings report of Apple The stock was up 3 after hours

Lemmatize text

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Natural Language Processing

Mr Tim Cook presided over the earnings report of Apple The stock was up 3 after hoursVerb NounVerb

preside hourbe

Lemmatize text

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Natural Language Processing

Named entity recognition

Extract entities

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Mr Tim Cook presided over the earnings report of Apple Inc on Tuesday

Natural Language Processing

Mr Tim Cook presided over the earnings report of Apple Inc on TuesdayPER ORG

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Extract entities

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Confer intelligence

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Linguistics

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Confer intelligence

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Linguistics Machine learning

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Confer intelligence

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Linguistics Machine learning

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Confer intelligence

Natural language text typed

recognized handwriting

transcribed speech

NLP APIs

Enough Tell me how to use them

NLP APIs

NLP APIs

NSLinguisticTagger

NSLinguisticTagger

Class in foundation

Segment and tag text

Linguistic tasks tagSchemes

NSLinguisticTagger

Class in foundation

Segment and tag text

Linguistic tasks tagSchemes

NSLinguisticTaggerNEW

NSLinguisticTagger

Tagging units

NEW

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

Units and schemes

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

Units and schemes

NEW

class func availableTagSchemes (for unit NSLinguisticTaggerUnit language String) -gt [NSLinguisticTagScheme]

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

Units and schemes

NEW

class func availableTagSchemes (for unit NSLinguisticTaggerUnit language String) -gt [NSLinguisticTagScheme]

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTaggerNEW

NSLinguisticTagger

dominantLanguage

NEW

NSLinguisticTagger

dominantLanguage

Swift 4 named types for tags and tagSchemes

NEW

NSLinguisticTagger

dominantLanguage

Swift 4 named types for tags and tagSchemes

Improved performance

Higher accuracy

Additional language support

NEW

Winnow and Whisk

Winnow and Whisk

Winnow and Whisk

Winnow Tag photos with descriptions

Winnow Tag photos with descriptions

Winnow Tag photos with descriptions

We hiked to the top and then ran down Lizzie won

Kids partied with all the goodieshellip

Die Kleinen haben friedlich zusammen gespielt

July 4th 2016hellipsummer parties at the

Holdenrsquos begin

Winnow Search for pictures

Winnow Search for pictures

Hike

Winnow Search for pictures

Hike No results

Winnow Improve search experience using NLP

Winnow Improve search experience using NLP

Hike

Winnow Improve search experience using NLP

We hiked to the top and then ran down Lizzie won

Great hikes make great pics

The hiking boysHolden family loves hiking and also posing for pictures

Hike

Winnow

Winnow

Winnow

NLP

Language identification

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

bullDemo

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Tim Cook Apple Stevie Wonder Cupertino Angela Ahrendts Bruce Wayne Thomas Vintberg

Pharrell NYU

Whisk

Whisk

Whisk

Whisk

NLP

Language identification

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

bullDemo

Why should you use the NLP APIs

Homogeneous Text Processing

Homogeneous Text Processing

NLP APIs

Natural language text typed

recognized handwriting

transcribed speech

Consistent text processing

Consistent user experience

Privacy

Privacy

On-device machine learning

User data stays on-device

Performance

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Chinese tokenization is 30 faster on iOS

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Named Entity Recognition 80 faster on iOS

Performance

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

40000 tokenssec

65000 tokenssec

Named Entity Recognition

Language Support

Language Support

Language identification 29 scripts 52 languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Accuracy

Accuracy

0

20

40

60

80

100

Part of speech

Named entity recognition

English Spanish

Debugging Hints

Debugging Hints

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Explicitly set language if known

Summary

NLP APIsmdashNSLinguisticTagger bull Support for new units bull Faster bull Higher accuracy bull More languages

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

NLP APIs

NLP APIs

Natural Language Processing

Natural Language Processing

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Processing

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Processing

Natural language text typed

recognized handwriting

transcribed speech

Extract information

Confer intelligence

Natural Language Processing

Processing

Natural language text typed

recognized handwriting

transcribed speech

Extract information

Confer intelligence

Natural Language Processing

Natural language text typed

recognized handwriting

transcribed speech

Confer intelligence

Natural Language Processing

Natural language text typed

recognized handwriting

transcribed speech

Detect language

Language identification

Natural Language Processing

Welcome to our talk on Natural Language ProcessingBienvenidos a nuestra plaacutetica sobre Procesamiento de Lenguaje Natural

Willkommen zu unserem Vortrag uumlber Verarbeitung natuumlrlicher Sprache欢迎参加我们关于自然语言处理理的讲座

हमारी पराकितक भाषा परससकरण भाषण म आपका सवागत ह

Natural language text typed

recognized handwriting

transcribed speech

Detect language

Language identification

Natural Language Processing

Tokenize text

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Natural Language Processing

Mr Tim Cook presided over the earnings report of Apple Inc on Tuesday

Tokenize text

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Natural Language Processing

星期二蒂姆middot库克先生主持了了苹果公司的财报会议

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Tokenize text

Natural Language Processing

星期二蒂姆middot库克 先生 主持 了了 苹果公司 的 财报 会议

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Tokenize text

Natural Language Processing

Assign parts of speech

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Natural Language Processing

Mr Tim Cook presided over the earnings report of Apple Inc on Tuesday Noun PUNCTNounNNP NNP PPNoun NounPPNounVerb PP DT Noun

Assign parts of speech

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Natural Language Processing

Lemmatize text

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Natural Language Processing

Mr Tim Cook presided over the earnings report of Apple The stock was up 3 after hours

Lemmatize text

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Natural Language Processing

Mr Tim Cook presided over the earnings report of Apple The stock was up 3 after hoursVerb NounVerb

preside hourbe

Lemmatize text

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Natural Language Processing

Named entity recognition

Extract entities

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Mr Tim Cook presided over the earnings report of Apple Inc on Tuesday

Natural Language Processing

Mr Tim Cook presided over the earnings report of Apple Inc on TuesdayPER ORG

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Extract entities

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Confer intelligence

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Linguistics

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Confer intelligence

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Linguistics Machine learning

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Confer intelligence

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Linguistics Machine learning

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Confer intelligence

Natural language text typed

recognized handwriting

transcribed speech

NLP APIs

Enough Tell me how to use them

NLP APIs

NLP APIs

NSLinguisticTagger

NSLinguisticTagger

Class in foundation

Segment and tag text

Linguistic tasks tagSchemes

NSLinguisticTagger

Class in foundation

Segment and tag text

Linguistic tasks tagSchemes

NSLinguisticTaggerNEW

NSLinguisticTagger

Tagging units

NEW

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

Units and schemes

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

Units and schemes

NEW

class func availableTagSchemes (for unit NSLinguisticTaggerUnit language String) -gt [NSLinguisticTagScheme]

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

Units and schemes

NEW

class func availableTagSchemes (for unit NSLinguisticTaggerUnit language String) -gt [NSLinguisticTagScheme]

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTaggerNEW

NSLinguisticTagger

dominantLanguage

NEW

NSLinguisticTagger

dominantLanguage

Swift 4 named types for tags and tagSchemes

NEW

NSLinguisticTagger

dominantLanguage

Swift 4 named types for tags and tagSchemes

Improved performance

Higher accuracy

Additional language support

NEW

Winnow and Whisk

Winnow and Whisk

Winnow and Whisk

Winnow Tag photos with descriptions

Winnow Tag photos with descriptions

Winnow Tag photos with descriptions

We hiked to the top and then ran down Lizzie won

Kids partied with all the goodieshellip

Die Kleinen haben friedlich zusammen gespielt

July 4th 2016hellipsummer parties at the

Holdenrsquos begin

Winnow Search for pictures

Winnow Search for pictures

Hike

Winnow Search for pictures

Hike No results

Winnow Improve search experience using NLP

Winnow Improve search experience using NLP

Hike

Winnow Improve search experience using NLP

We hiked to the top and then ran down Lizzie won

Great hikes make great pics

The hiking boysHolden family loves hiking and also posing for pictures

Hike

Winnow

Winnow

Winnow

NLP

Language identification

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

bullDemo

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Tim Cook Apple Stevie Wonder Cupertino Angela Ahrendts Bruce Wayne Thomas Vintberg

Pharrell NYU

Whisk

Whisk

Whisk

Whisk

NLP

Language identification

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

bullDemo

Why should you use the NLP APIs

Homogeneous Text Processing

Homogeneous Text Processing

NLP APIs

Natural language text typed

recognized handwriting

transcribed speech

Consistent text processing

Consistent user experience

Privacy

Privacy

On-device machine learning

User data stays on-device

Performance

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Chinese tokenization is 30 faster on iOS

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Named Entity Recognition 80 faster on iOS

Performance

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

40000 tokenssec

65000 tokenssec

Named Entity Recognition

Language Support

Language Support

Language identification 29 scripts 52 languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Accuracy

Accuracy

0

20

40

60

80

100

Part of speech

Named entity recognition

English Spanish

Debugging Hints

Debugging Hints

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Explicitly set language if known

Summary

NLP APIsmdashNSLinguisticTagger bull Support for new units bull Faster bull Higher accuracy bull More languages

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

NLP APIs

Natural Language Processing

Natural Language Processing

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Processing

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Processing

Natural language text typed

recognized handwriting

transcribed speech

Extract information

Confer intelligence

Natural Language Processing

Processing

Natural language text typed

recognized handwriting

transcribed speech

Extract information

Confer intelligence

Natural Language Processing

Natural language text typed

recognized handwriting

transcribed speech

Confer intelligence

Natural Language Processing

Natural language text typed

recognized handwriting

transcribed speech

Detect language

Language identification

Natural Language Processing

Welcome to our talk on Natural Language ProcessingBienvenidos a nuestra plaacutetica sobre Procesamiento de Lenguaje Natural

Willkommen zu unserem Vortrag uumlber Verarbeitung natuumlrlicher Sprache欢迎参加我们关于自然语言处理理的讲座

हमारी पराकितक भाषा परससकरण भाषण म आपका सवागत ह

Natural language text typed

recognized handwriting

transcribed speech

Detect language

Language identification

Natural Language Processing

Tokenize text

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Natural Language Processing

Mr Tim Cook presided over the earnings report of Apple Inc on Tuesday

Tokenize text

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Natural Language Processing

星期二蒂姆middot库克先生主持了了苹果公司的财报会议

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Tokenize text

Natural Language Processing

星期二蒂姆middot库克 先生 主持 了了 苹果公司 的 财报 会议

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Tokenize text

Natural Language Processing

Assign parts of speech

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Natural Language Processing

Mr Tim Cook presided over the earnings report of Apple Inc on Tuesday Noun PUNCTNounNNP NNP PPNoun NounPPNounVerb PP DT Noun

Assign parts of speech

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Natural Language Processing

Lemmatize text

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Natural Language Processing

Mr Tim Cook presided over the earnings report of Apple The stock was up 3 after hours

Lemmatize text

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Natural Language Processing

Mr Tim Cook presided over the earnings report of Apple The stock was up 3 after hoursVerb NounVerb

preside hourbe

Lemmatize text

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Natural Language Processing

Named entity recognition

Extract entities

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Mr Tim Cook presided over the earnings report of Apple Inc on Tuesday

Natural Language Processing

Mr Tim Cook presided over the earnings report of Apple Inc on TuesdayPER ORG

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Extract entities

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Confer intelligence

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Linguistics

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Confer intelligence

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Linguistics Machine learning

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Confer intelligence

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Linguistics Machine learning

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Confer intelligence

Natural language text typed

recognized handwriting

transcribed speech

NLP APIs

Enough Tell me how to use them

NLP APIs

NLP APIs

NSLinguisticTagger

NSLinguisticTagger

Class in foundation

Segment and tag text

Linguistic tasks tagSchemes

NSLinguisticTagger

Class in foundation

Segment and tag text

Linguistic tasks tagSchemes

NSLinguisticTaggerNEW

NSLinguisticTagger

Tagging units

NEW

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

Units and schemes

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

Units and schemes

NEW

class func availableTagSchemes (for unit NSLinguisticTaggerUnit language String) -gt [NSLinguisticTagScheme]

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

Units and schemes

NEW

class func availableTagSchemes (for unit NSLinguisticTaggerUnit language String) -gt [NSLinguisticTagScheme]

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTaggerNEW

NSLinguisticTagger

dominantLanguage

NEW

NSLinguisticTagger

dominantLanguage

Swift 4 named types for tags and tagSchemes

NEW

NSLinguisticTagger

dominantLanguage

Swift 4 named types for tags and tagSchemes

Improved performance

Higher accuracy

Additional language support

NEW

Winnow and Whisk

Winnow and Whisk

Winnow and Whisk

Winnow Tag photos with descriptions

Winnow Tag photos with descriptions

Winnow Tag photos with descriptions

We hiked to the top and then ran down Lizzie won

Kids partied with all the goodieshellip

Die Kleinen haben friedlich zusammen gespielt

July 4th 2016hellipsummer parties at the

Holdenrsquos begin

Winnow Search for pictures

Winnow Search for pictures

Hike

Winnow Search for pictures

Hike No results

Winnow Improve search experience using NLP

Winnow Improve search experience using NLP

Hike

Winnow Improve search experience using NLP

We hiked to the top and then ran down Lizzie won

Great hikes make great pics

The hiking boysHolden family loves hiking and also posing for pictures

Hike

Winnow

Winnow

Winnow

NLP

Language identification

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

bullDemo

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Tim Cook Apple Stevie Wonder Cupertino Angela Ahrendts Bruce Wayne Thomas Vintberg

Pharrell NYU

Whisk

Whisk

Whisk

Whisk

NLP

Language identification

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

bullDemo

Why should you use the NLP APIs

Homogeneous Text Processing

Homogeneous Text Processing

NLP APIs

Natural language text typed

recognized handwriting

transcribed speech

Consistent text processing

Consistent user experience

Privacy

Privacy

On-device machine learning

User data stays on-device

Performance

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Chinese tokenization is 30 faster on iOS

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Named Entity Recognition 80 faster on iOS

Performance

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

40000 tokenssec

65000 tokenssec

Named Entity Recognition

Language Support

Language Support

Language identification 29 scripts 52 languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Accuracy

Accuracy

0

20

40

60

80

100

Part of speech

Named entity recognition

English Spanish

Debugging Hints

Debugging Hints

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Explicitly set language if known

Summary

NLP APIsmdashNSLinguisticTagger bull Support for new units bull Faster bull Higher accuracy bull More languages

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

Natural Language Processing

Natural Language Processing

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Processing

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Processing

Natural language text typed

recognized handwriting

transcribed speech

Extract information

Confer intelligence

Natural Language Processing

Processing

Natural language text typed

recognized handwriting

transcribed speech

Extract information

Confer intelligence

Natural Language Processing

Natural language text typed

recognized handwriting

transcribed speech

Confer intelligence

Natural Language Processing

Natural language text typed

recognized handwriting

transcribed speech

Detect language

Language identification

Natural Language Processing

Welcome to our talk on Natural Language ProcessingBienvenidos a nuestra plaacutetica sobre Procesamiento de Lenguaje Natural

Willkommen zu unserem Vortrag uumlber Verarbeitung natuumlrlicher Sprache欢迎参加我们关于自然语言处理理的讲座

हमारी पराकितक भाषा परससकरण भाषण म आपका सवागत ह

Natural language text typed

recognized handwriting

transcribed speech

Detect language

Language identification

Natural Language Processing

Tokenize text

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Natural Language Processing

Mr Tim Cook presided over the earnings report of Apple Inc on Tuesday

Tokenize text

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Natural Language Processing

星期二蒂姆middot库克先生主持了了苹果公司的财报会议

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Tokenize text

Natural Language Processing

星期二蒂姆middot库克 先生 主持 了了 苹果公司 的 财报 会议

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Tokenize text

Natural Language Processing

Assign parts of speech

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Natural Language Processing

Mr Tim Cook presided over the earnings report of Apple Inc on Tuesday Noun PUNCTNounNNP NNP PPNoun NounPPNounVerb PP DT Noun

Assign parts of speech

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Natural Language Processing

Lemmatize text

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Natural Language Processing

Mr Tim Cook presided over the earnings report of Apple The stock was up 3 after hours

Lemmatize text

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Natural Language Processing

Mr Tim Cook presided over the earnings report of Apple The stock was up 3 after hoursVerb NounVerb

preside hourbe

Lemmatize text

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Natural Language Processing

Named entity recognition

Extract entities

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Mr Tim Cook presided over the earnings report of Apple Inc on Tuesday

Natural Language Processing

Mr Tim Cook presided over the earnings report of Apple Inc on TuesdayPER ORG

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Extract entities

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Confer intelligence

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Linguistics

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Confer intelligence

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Linguistics Machine learning

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Confer intelligence

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Linguistics Machine learning

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Confer intelligence

Natural language text typed

recognized handwriting

transcribed speech

NLP APIs

Enough Tell me how to use them

NLP APIs

NLP APIs

NSLinguisticTagger

NSLinguisticTagger

Class in foundation

Segment and tag text

Linguistic tasks tagSchemes

NSLinguisticTagger

Class in foundation

Segment and tag text

Linguistic tasks tagSchemes

NSLinguisticTaggerNEW

NSLinguisticTagger

Tagging units

NEW

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

Units and schemes

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

Units and schemes

NEW

class func availableTagSchemes (for unit NSLinguisticTaggerUnit language String) -gt [NSLinguisticTagScheme]

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

Units and schemes

NEW

class func availableTagSchemes (for unit NSLinguisticTaggerUnit language String) -gt [NSLinguisticTagScheme]

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTaggerNEW

NSLinguisticTagger

dominantLanguage

NEW

NSLinguisticTagger

dominantLanguage

Swift 4 named types for tags and tagSchemes

NEW

NSLinguisticTagger

dominantLanguage

Swift 4 named types for tags and tagSchemes

Improved performance

Higher accuracy

Additional language support

NEW

Winnow and Whisk

Winnow and Whisk

Winnow and Whisk

Winnow Tag photos with descriptions

Winnow Tag photos with descriptions

Winnow Tag photos with descriptions

We hiked to the top and then ran down Lizzie won

Kids partied with all the goodieshellip

Die Kleinen haben friedlich zusammen gespielt

July 4th 2016hellipsummer parties at the

Holdenrsquos begin

Winnow Search for pictures

Winnow Search for pictures

Hike

Winnow Search for pictures

Hike No results

Winnow Improve search experience using NLP

Winnow Improve search experience using NLP

Hike

Winnow Improve search experience using NLP

We hiked to the top and then ran down Lizzie won

Great hikes make great pics

The hiking boysHolden family loves hiking and also posing for pictures

Hike

Winnow

Winnow

Winnow

NLP

Language identification

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

bullDemo

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Tim Cook Apple Stevie Wonder Cupertino Angela Ahrendts Bruce Wayne Thomas Vintberg

Pharrell NYU

Whisk

Whisk

Whisk

Whisk

NLP

Language identification

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

bullDemo

Why should you use the NLP APIs

Homogeneous Text Processing

Homogeneous Text Processing

NLP APIs

Natural language text typed

recognized handwriting

transcribed speech

Consistent text processing

Consistent user experience

Privacy

Privacy

On-device machine learning

User data stays on-device

Performance

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Chinese tokenization is 30 faster on iOS

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Named Entity Recognition 80 faster on iOS

Performance

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

40000 tokenssec

65000 tokenssec

Named Entity Recognition

Language Support

Language Support

Language identification 29 scripts 52 languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Accuracy

Accuracy

0

20

40

60

80

100

Part of speech

Named entity recognition

English Spanish

Debugging Hints

Debugging Hints

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Explicitly set language if known

Summary

NLP APIsmdashNSLinguisticTagger bull Support for new units bull Faster bull Higher accuracy bull More languages

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

Natural Language Processing

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Processing

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Processing

Natural language text typed

recognized handwriting

transcribed speech

Extract information

Confer intelligence

Natural Language Processing

Processing

Natural language text typed

recognized handwriting

transcribed speech

Extract information

Confer intelligence

Natural Language Processing

Natural language text typed

recognized handwriting

transcribed speech

Confer intelligence

Natural Language Processing

Natural language text typed

recognized handwriting

transcribed speech

Detect language

Language identification

Natural Language Processing

Welcome to our talk on Natural Language ProcessingBienvenidos a nuestra plaacutetica sobre Procesamiento de Lenguaje Natural

Willkommen zu unserem Vortrag uumlber Verarbeitung natuumlrlicher Sprache欢迎参加我们关于自然语言处理理的讲座

हमारी पराकितक भाषा परससकरण भाषण म आपका सवागत ह

Natural language text typed

recognized handwriting

transcribed speech

Detect language

Language identification

Natural Language Processing

Tokenize text

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Natural Language Processing

Mr Tim Cook presided over the earnings report of Apple Inc on Tuesday

Tokenize text

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Natural Language Processing

星期二蒂姆middot库克先生主持了了苹果公司的财报会议

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Tokenize text

Natural Language Processing

星期二蒂姆middot库克 先生 主持 了了 苹果公司 的 财报 会议

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Tokenize text

Natural Language Processing

Assign parts of speech

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Natural Language Processing

Mr Tim Cook presided over the earnings report of Apple Inc on Tuesday Noun PUNCTNounNNP NNP PPNoun NounPPNounVerb PP DT Noun

Assign parts of speech

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Natural Language Processing

Lemmatize text

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Natural Language Processing

Mr Tim Cook presided over the earnings report of Apple The stock was up 3 after hours

Lemmatize text

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Natural Language Processing

Mr Tim Cook presided over the earnings report of Apple The stock was up 3 after hoursVerb NounVerb

preside hourbe

Lemmatize text

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Natural Language Processing

Named entity recognition

Extract entities

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Mr Tim Cook presided over the earnings report of Apple Inc on Tuesday

Natural Language Processing

Mr Tim Cook presided over the earnings report of Apple Inc on TuesdayPER ORG

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Extract entities

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Confer intelligence

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Linguistics

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Confer intelligence

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Linguistics Machine learning

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Confer intelligence

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Linguistics Machine learning

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Confer intelligence

Natural language text typed

recognized handwriting

transcribed speech

NLP APIs

Enough Tell me how to use them

NLP APIs

NLP APIs

NSLinguisticTagger

NSLinguisticTagger

Class in foundation

Segment and tag text

Linguistic tasks tagSchemes

NSLinguisticTagger

Class in foundation

Segment and tag text

Linguistic tasks tagSchemes

NSLinguisticTaggerNEW

NSLinguisticTagger

Tagging units

NEW

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

Units and schemes

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

Units and schemes

NEW

class func availableTagSchemes (for unit NSLinguisticTaggerUnit language String) -gt [NSLinguisticTagScheme]

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

Units and schemes

NEW

class func availableTagSchemes (for unit NSLinguisticTaggerUnit language String) -gt [NSLinguisticTagScheme]

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTaggerNEW

NSLinguisticTagger

dominantLanguage

NEW

NSLinguisticTagger

dominantLanguage

Swift 4 named types for tags and tagSchemes

NEW

NSLinguisticTagger

dominantLanguage

Swift 4 named types for tags and tagSchemes

Improved performance

Higher accuracy

Additional language support

NEW

Winnow and Whisk

Winnow and Whisk

Winnow and Whisk

Winnow Tag photos with descriptions

Winnow Tag photos with descriptions

Winnow Tag photos with descriptions

We hiked to the top and then ran down Lizzie won

Kids partied with all the goodieshellip

Die Kleinen haben friedlich zusammen gespielt

July 4th 2016hellipsummer parties at the

Holdenrsquos begin

Winnow Search for pictures

Winnow Search for pictures

Hike

Winnow Search for pictures

Hike No results

Winnow Improve search experience using NLP

Winnow Improve search experience using NLP

Hike

Winnow Improve search experience using NLP

We hiked to the top and then ran down Lizzie won

Great hikes make great pics

The hiking boysHolden family loves hiking and also posing for pictures

Hike

Winnow

Winnow

Winnow

NLP

Language identification

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

bullDemo

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Tim Cook Apple Stevie Wonder Cupertino Angela Ahrendts Bruce Wayne Thomas Vintberg

Pharrell NYU

Whisk

Whisk

Whisk

Whisk

NLP

Language identification

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

bullDemo

Why should you use the NLP APIs

Homogeneous Text Processing

Homogeneous Text Processing

NLP APIs

Natural language text typed

recognized handwriting

transcribed speech

Consistent text processing

Consistent user experience

Privacy

Privacy

On-device machine learning

User data stays on-device

Performance

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Chinese tokenization is 30 faster on iOS

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Named Entity Recognition 80 faster on iOS

Performance

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

40000 tokenssec

65000 tokenssec

Named Entity Recognition

Language Support

Language Support

Language identification 29 scripts 52 languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Accuracy

Accuracy

0

20

40

60

80

100

Part of speech

Named entity recognition

English Spanish

Debugging Hints

Debugging Hints

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Explicitly set language if known

Summary

NLP APIsmdashNSLinguisticTagger bull Support for new units bull Faster bull Higher accuracy bull More languages

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

Natural Language Processing

Processing

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Processing

Natural language text typed

recognized handwriting

transcribed speech

Extract information

Confer intelligence

Natural Language Processing

Processing

Natural language text typed

recognized handwriting

transcribed speech

Extract information

Confer intelligence

Natural Language Processing

Natural language text typed

recognized handwriting

transcribed speech

Confer intelligence

Natural Language Processing

Natural language text typed

recognized handwriting

transcribed speech

Detect language

Language identification

Natural Language Processing

Welcome to our talk on Natural Language ProcessingBienvenidos a nuestra plaacutetica sobre Procesamiento de Lenguaje Natural

Willkommen zu unserem Vortrag uumlber Verarbeitung natuumlrlicher Sprache欢迎参加我们关于自然语言处理理的讲座

हमारी पराकितक भाषा परससकरण भाषण म आपका सवागत ह

Natural language text typed

recognized handwriting

transcribed speech

Detect language

Language identification

Natural Language Processing

Tokenize text

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Natural Language Processing

Mr Tim Cook presided over the earnings report of Apple Inc on Tuesday

Tokenize text

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Natural Language Processing

星期二蒂姆middot库克先生主持了了苹果公司的财报会议

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Tokenize text

Natural Language Processing

星期二蒂姆middot库克 先生 主持 了了 苹果公司 的 财报 会议

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Tokenize text

Natural Language Processing

Assign parts of speech

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Natural Language Processing

Mr Tim Cook presided over the earnings report of Apple Inc on Tuesday Noun PUNCTNounNNP NNP PPNoun NounPPNounVerb PP DT Noun

Assign parts of speech

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Natural Language Processing

Lemmatize text

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Natural Language Processing

Mr Tim Cook presided over the earnings report of Apple The stock was up 3 after hours

Lemmatize text

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Natural Language Processing

Mr Tim Cook presided over the earnings report of Apple The stock was up 3 after hoursVerb NounVerb

preside hourbe

Lemmatize text

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Natural Language Processing

Named entity recognition

Extract entities

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Mr Tim Cook presided over the earnings report of Apple Inc on Tuesday

Natural Language Processing

Mr Tim Cook presided over the earnings report of Apple Inc on TuesdayPER ORG

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Extract entities

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Confer intelligence

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Linguistics

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Confer intelligence

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Linguistics Machine learning

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Confer intelligence

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Linguistics Machine learning

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Confer intelligence

Natural language text typed

recognized handwriting

transcribed speech

NLP APIs

Enough Tell me how to use them

NLP APIs

NLP APIs

NSLinguisticTagger

NSLinguisticTagger

Class in foundation

Segment and tag text

Linguistic tasks tagSchemes

NSLinguisticTagger

Class in foundation

Segment and tag text

Linguistic tasks tagSchemes

NSLinguisticTaggerNEW

NSLinguisticTagger

Tagging units

NEW

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

Units and schemes

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

Units and schemes

NEW

class func availableTagSchemes (for unit NSLinguisticTaggerUnit language String) -gt [NSLinguisticTagScheme]

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

Units and schemes

NEW

class func availableTagSchemes (for unit NSLinguisticTaggerUnit language String) -gt [NSLinguisticTagScheme]

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTaggerNEW

NSLinguisticTagger

dominantLanguage

NEW

NSLinguisticTagger

dominantLanguage

Swift 4 named types for tags and tagSchemes

NEW

NSLinguisticTagger

dominantLanguage

Swift 4 named types for tags and tagSchemes

Improved performance

Higher accuracy

Additional language support

NEW

Winnow and Whisk

Winnow and Whisk

Winnow and Whisk

Winnow Tag photos with descriptions

Winnow Tag photos with descriptions

Winnow Tag photos with descriptions

We hiked to the top and then ran down Lizzie won

Kids partied with all the goodieshellip

Die Kleinen haben friedlich zusammen gespielt

July 4th 2016hellipsummer parties at the

Holdenrsquos begin

Winnow Search for pictures

Winnow Search for pictures

Hike

Winnow Search for pictures

Hike No results

Winnow Improve search experience using NLP

Winnow Improve search experience using NLP

Hike

Winnow Improve search experience using NLP

We hiked to the top and then ran down Lizzie won

Great hikes make great pics

The hiking boysHolden family loves hiking and also posing for pictures

Hike

Winnow

Winnow

Winnow

NLP

Language identification

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

bullDemo

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Tim Cook Apple Stevie Wonder Cupertino Angela Ahrendts Bruce Wayne Thomas Vintberg

Pharrell NYU

Whisk

Whisk

Whisk

Whisk

NLP

Language identification

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

bullDemo

Why should you use the NLP APIs

Homogeneous Text Processing

Homogeneous Text Processing

NLP APIs

Natural language text typed

recognized handwriting

transcribed speech

Consistent text processing

Consistent user experience

Privacy

Privacy

On-device machine learning

User data stays on-device

Performance

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Chinese tokenization is 30 faster on iOS

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Named Entity Recognition 80 faster on iOS

Performance

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

40000 tokenssec

65000 tokenssec

Named Entity Recognition

Language Support

Language Support

Language identification 29 scripts 52 languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Accuracy

Accuracy

0

20

40

60

80

100

Part of speech

Named entity recognition

English Spanish

Debugging Hints

Debugging Hints

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Explicitly set language if known

Summary

NLP APIsmdashNSLinguisticTagger bull Support for new units bull Faster bull Higher accuracy bull More languages

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

Natural Language Processing

Processing

Natural language text typed

recognized handwriting

transcribed speech

Extract information

Confer intelligence

Natural Language Processing

Processing

Natural language text typed

recognized handwriting

transcribed speech

Extract information

Confer intelligence

Natural Language Processing

Natural language text typed

recognized handwriting

transcribed speech

Confer intelligence

Natural Language Processing

Natural language text typed

recognized handwriting

transcribed speech

Detect language

Language identification

Natural Language Processing

Welcome to our talk on Natural Language ProcessingBienvenidos a nuestra plaacutetica sobre Procesamiento de Lenguaje Natural

Willkommen zu unserem Vortrag uumlber Verarbeitung natuumlrlicher Sprache欢迎参加我们关于自然语言处理理的讲座

हमारी पराकितक भाषा परससकरण भाषण म आपका सवागत ह

Natural language text typed

recognized handwriting

transcribed speech

Detect language

Language identification

Natural Language Processing

Tokenize text

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Natural Language Processing

Mr Tim Cook presided over the earnings report of Apple Inc on Tuesday

Tokenize text

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Natural Language Processing

星期二蒂姆middot库克先生主持了了苹果公司的财报会议

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Tokenize text

Natural Language Processing

星期二蒂姆middot库克 先生 主持 了了 苹果公司 的 财报 会议

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Tokenize text

Natural Language Processing

Assign parts of speech

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Natural Language Processing

Mr Tim Cook presided over the earnings report of Apple Inc on Tuesday Noun PUNCTNounNNP NNP PPNoun NounPPNounVerb PP DT Noun

Assign parts of speech

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Natural Language Processing

Lemmatize text

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Natural Language Processing

Mr Tim Cook presided over the earnings report of Apple The stock was up 3 after hours

Lemmatize text

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Natural Language Processing

Mr Tim Cook presided over the earnings report of Apple The stock was up 3 after hoursVerb NounVerb

preside hourbe

Lemmatize text

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Natural Language Processing

Named entity recognition

Extract entities

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Mr Tim Cook presided over the earnings report of Apple Inc on Tuesday

Natural Language Processing

Mr Tim Cook presided over the earnings report of Apple Inc on TuesdayPER ORG

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Extract entities

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Confer intelligence

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Linguistics

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Confer intelligence

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Linguistics Machine learning

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Confer intelligence

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Linguistics Machine learning

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Confer intelligence

Natural language text typed

recognized handwriting

transcribed speech

NLP APIs

Enough Tell me how to use them

NLP APIs

NLP APIs

NSLinguisticTagger

NSLinguisticTagger

Class in foundation

Segment and tag text

Linguistic tasks tagSchemes

NSLinguisticTagger

Class in foundation

Segment and tag text

Linguistic tasks tagSchemes

NSLinguisticTaggerNEW

NSLinguisticTagger

Tagging units

NEW

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

Units and schemes

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

Units and schemes

NEW

class func availableTagSchemes (for unit NSLinguisticTaggerUnit language String) -gt [NSLinguisticTagScheme]

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

Units and schemes

NEW

class func availableTagSchemes (for unit NSLinguisticTaggerUnit language String) -gt [NSLinguisticTagScheme]

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTaggerNEW

NSLinguisticTagger

dominantLanguage

NEW

NSLinguisticTagger

dominantLanguage

Swift 4 named types for tags and tagSchemes

NEW

NSLinguisticTagger

dominantLanguage

Swift 4 named types for tags and tagSchemes

Improved performance

Higher accuracy

Additional language support

NEW

Winnow and Whisk

Winnow and Whisk

Winnow and Whisk

Winnow Tag photos with descriptions

Winnow Tag photos with descriptions

Winnow Tag photos with descriptions

We hiked to the top and then ran down Lizzie won

Kids partied with all the goodieshellip

Die Kleinen haben friedlich zusammen gespielt

July 4th 2016hellipsummer parties at the

Holdenrsquos begin

Winnow Search for pictures

Winnow Search for pictures

Hike

Winnow Search for pictures

Hike No results

Winnow Improve search experience using NLP

Winnow Improve search experience using NLP

Hike

Winnow Improve search experience using NLP

We hiked to the top and then ran down Lizzie won

Great hikes make great pics

The hiking boysHolden family loves hiking and also posing for pictures

Hike

Winnow

Winnow

Winnow

NLP

Language identification

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

bullDemo

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Tim Cook Apple Stevie Wonder Cupertino Angela Ahrendts Bruce Wayne Thomas Vintberg

Pharrell NYU

Whisk

Whisk

Whisk

Whisk

NLP

Language identification

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

bullDemo

Why should you use the NLP APIs

Homogeneous Text Processing

Homogeneous Text Processing

NLP APIs

Natural language text typed

recognized handwriting

transcribed speech

Consistent text processing

Consistent user experience

Privacy

Privacy

On-device machine learning

User data stays on-device

Performance

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Chinese tokenization is 30 faster on iOS

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Named Entity Recognition 80 faster on iOS

Performance

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

40000 tokenssec

65000 tokenssec

Named Entity Recognition

Language Support

Language Support

Language identification 29 scripts 52 languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Accuracy

Accuracy

0

20

40

60

80

100

Part of speech

Named entity recognition

English Spanish

Debugging Hints

Debugging Hints

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Explicitly set language if known

Summary

NLP APIsmdashNSLinguisticTagger bull Support for new units bull Faster bull Higher accuracy bull More languages

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

Natural Language Processing

Processing

Natural language text typed

recognized handwriting

transcribed speech

Extract information

Confer intelligence

Natural Language Processing

Natural language text typed

recognized handwriting

transcribed speech

Confer intelligence

Natural Language Processing

Natural language text typed

recognized handwriting

transcribed speech

Detect language

Language identification

Natural Language Processing

Welcome to our talk on Natural Language ProcessingBienvenidos a nuestra plaacutetica sobre Procesamiento de Lenguaje Natural

Willkommen zu unserem Vortrag uumlber Verarbeitung natuumlrlicher Sprache欢迎参加我们关于自然语言处理理的讲座

हमारी पराकितक भाषा परससकरण भाषण म आपका सवागत ह

Natural language text typed

recognized handwriting

transcribed speech

Detect language

Language identification

Natural Language Processing

Tokenize text

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Natural Language Processing

Mr Tim Cook presided over the earnings report of Apple Inc on Tuesday

Tokenize text

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Natural Language Processing

星期二蒂姆middot库克先生主持了了苹果公司的财报会议

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Tokenize text

Natural Language Processing

星期二蒂姆middot库克 先生 主持 了了 苹果公司 的 财报 会议

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Tokenize text

Natural Language Processing

Assign parts of speech

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Natural Language Processing

Mr Tim Cook presided over the earnings report of Apple Inc on Tuesday Noun PUNCTNounNNP NNP PPNoun NounPPNounVerb PP DT Noun

Assign parts of speech

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Natural Language Processing

Lemmatize text

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Natural Language Processing

Mr Tim Cook presided over the earnings report of Apple The stock was up 3 after hours

Lemmatize text

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Natural Language Processing

Mr Tim Cook presided over the earnings report of Apple The stock was up 3 after hoursVerb NounVerb

preside hourbe

Lemmatize text

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Natural Language Processing

Named entity recognition

Extract entities

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Mr Tim Cook presided over the earnings report of Apple Inc on Tuesday

Natural Language Processing

Mr Tim Cook presided over the earnings report of Apple Inc on TuesdayPER ORG

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Extract entities

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Confer intelligence

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Linguistics

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Confer intelligence

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Linguistics Machine learning

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Confer intelligence

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Linguistics Machine learning

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Confer intelligence

Natural language text typed

recognized handwriting

transcribed speech

NLP APIs

Enough Tell me how to use them

NLP APIs

NLP APIs

NSLinguisticTagger

NSLinguisticTagger

Class in foundation

Segment and tag text

Linguistic tasks tagSchemes

NSLinguisticTagger

Class in foundation

Segment and tag text

Linguistic tasks tagSchemes

NSLinguisticTaggerNEW

NSLinguisticTagger

Tagging units

NEW

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

Units and schemes

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

Units and schemes

NEW

class func availableTagSchemes (for unit NSLinguisticTaggerUnit language String) -gt [NSLinguisticTagScheme]

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

Units and schemes

NEW

class func availableTagSchemes (for unit NSLinguisticTaggerUnit language String) -gt [NSLinguisticTagScheme]

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTaggerNEW

NSLinguisticTagger

dominantLanguage

NEW

NSLinguisticTagger

dominantLanguage

Swift 4 named types for tags and tagSchemes

NEW

NSLinguisticTagger

dominantLanguage

Swift 4 named types for tags and tagSchemes

Improved performance

Higher accuracy

Additional language support

NEW

Winnow and Whisk

Winnow and Whisk

Winnow and Whisk

Winnow Tag photos with descriptions

Winnow Tag photos with descriptions

Winnow Tag photos with descriptions

We hiked to the top and then ran down Lizzie won

Kids partied with all the goodieshellip

Die Kleinen haben friedlich zusammen gespielt

July 4th 2016hellipsummer parties at the

Holdenrsquos begin

Winnow Search for pictures

Winnow Search for pictures

Hike

Winnow Search for pictures

Hike No results

Winnow Improve search experience using NLP

Winnow Improve search experience using NLP

Hike

Winnow Improve search experience using NLP

We hiked to the top and then ran down Lizzie won

Great hikes make great pics

The hiking boysHolden family loves hiking and also posing for pictures

Hike

Winnow

Winnow

Winnow

NLP

Language identification

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

bullDemo

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Tim Cook Apple Stevie Wonder Cupertino Angela Ahrendts Bruce Wayne Thomas Vintberg

Pharrell NYU

Whisk

Whisk

Whisk

Whisk

NLP

Language identification

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

bullDemo

Why should you use the NLP APIs

Homogeneous Text Processing

Homogeneous Text Processing

NLP APIs

Natural language text typed

recognized handwriting

transcribed speech

Consistent text processing

Consistent user experience

Privacy

Privacy

On-device machine learning

User data stays on-device

Performance

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Chinese tokenization is 30 faster on iOS

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Named Entity Recognition 80 faster on iOS

Performance

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

40000 tokenssec

65000 tokenssec

Named Entity Recognition

Language Support

Language Support

Language identification 29 scripts 52 languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Accuracy

Accuracy

0

20

40

60

80

100

Part of speech

Named entity recognition

English Spanish

Debugging Hints

Debugging Hints

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Explicitly set language if known

Summary

NLP APIsmdashNSLinguisticTagger bull Support for new units bull Faster bull Higher accuracy bull More languages

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

Natural Language Processing

Natural language text typed

recognized handwriting

transcribed speech

Confer intelligence

Natural Language Processing

Natural language text typed

recognized handwriting

transcribed speech

Detect language

Language identification

Natural Language Processing

Welcome to our talk on Natural Language ProcessingBienvenidos a nuestra plaacutetica sobre Procesamiento de Lenguaje Natural

Willkommen zu unserem Vortrag uumlber Verarbeitung natuumlrlicher Sprache欢迎参加我们关于自然语言处理理的讲座

हमारी पराकितक भाषा परससकरण भाषण म आपका सवागत ह

Natural language text typed

recognized handwriting

transcribed speech

Detect language

Language identification

Natural Language Processing

Tokenize text

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Natural Language Processing

Mr Tim Cook presided over the earnings report of Apple Inc on Tuesday

Tokenize text

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Natural Language Processing

星期二蒂姆middot库克先生主持了了苹果公司的财报会议

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Tokenize text

Natural Language Processing

星期二蒂姆middot库克 先生 主持 了了 苹果公司 的 财报 会议

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Tokenize text

Natural Language Processing

Assign parts of speech

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Natural Language Processing

Mr Tim Cook presided over the earnings report of Apple Inc on Tuesday Noun PUNCTNounNNP NNP PPNoun NounPPNounVerb PP DT Noun

Assign parts of speech

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Natural Language Processing

Lemmatize text

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Natural Language Processing

Mr Tim Cook presided over the earnings report of Apple The stock was up 3 after hours

Lemmatize text

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Natural Language Processing

Mr Tim Cook presided over the earnings report of Apple The stock was up 3 after hoursVerb NounVerb

preside hourbe

Lemmatize text

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Natural Language Processing

Named entity recognition

Extract entities

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Mr Tim Cook presided over the earnings report of Apple Inc on Tuesday

Natural Language Processing

Mr Tim Cook presided over the earnings report of Apple Inc on TuesdayPER ORG

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Extract entities

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Confer intelligence

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Linguistics

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Confer intelligence

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Linguistics Machine learning

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Confer intelligence

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Linguistics Machine learning

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Confer intelligence

Natural language text typed

recognized handwriting

transcribed speech

NLP APIs

Enough Tell me how to use them

NLP APIs

NLP APIs

NSLinguisticTagger

NSLinguisticTagger

Class in foundation

Segment and tag text

Linguistic tasks tagSchemes

NSLinguisticTagger

Class in foundation

Segment and tag text

Linguistic tasks tagSchemes

NSLinguisticTaggerNEW

NSLinguisticTagger

Tagging units

NEW

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

Units and schemes

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

Units and schemes

NEW

class func availableTagSchemes (for unit NSLinguisticTaggerUnit language String) -gt [NSLinguisticTagScheme]

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

Units and schemes

NEW

class func availableTagSchemes (for unit NSLinguisticTaggerUnit language String) -gt [NSLinguisticTagScheme]

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTaggerNEW

NSLinguisticTagger

dominantLanguage

NEW

NSLinguisticTagger

dominantLanguage

Swift 4 named types for tags and tagSchemes

NEW

NSLinguisticTagger

dominantLanguage

Swift 4 named types for tags and tagSchemes

Improved performance

Higher accuracy

Additional language support

NEW

Winnow and Whisk

Winnow and Whisk

Winnow and Whisk

Winnow Tag photos with descriptions

Winnow Tag photos with descriptions

Winnow Tag photos with descriptions

We hiked to the top and then ran down Lizzie won

Kids partied with all the goodieshellip

Die Kleinen haben friedlich zusammen gespielt

July 4th 2016hellipsummer parties at the

Holdenrsquos begin

Winnow Search for pictures

Winnow Search for pictures

Hike

Winnow Search for pictures

Hike No results

Winnow Improve search experience using NLP

Winnow Improve search experience using NLP

Hike

Winnow Improve search experience using NLP

We hiked to the top and then ran down Lizzie won

Great hikes make great pics

The hiking boysHolden family loves hiking and also posing for pictures

Hike

Winnow

Winnow

Winnow

NLP

Language identification

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

bullDemo

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Tim Cook Apple Stevie Wonder Cupertino Angela Ahrendts Bruce Wayne Thomas Vintberg

Pharrell NYU

Whisk

Whisk

Whisk

Whisk

NLP

Language identification

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

bullDemo

Why should you use the NLP APIs

Homogeneous Text Processing

Homogeneous Text Processing

NLP APIs

Natural language text typed

recognized handwriting

transcribed speech

Consistent text processing

Consistent user experience

Privacy

Privacy

On-device machine learning

User data stays on-device

Performance

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Chinese tokenization is 30 faster on iOS

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Named Entity Recognition 80 faster on iOS

Performance

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

40000 tokenssec

65000 tokenssec

Named Entity Recognition

Language Support

Language Support

Language identification 29 scripts 52 languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Accuracy

Accuracy

0

20

40

60

80

100

Part of speech

Named entity recognition

English Spanish

Debugging Hints

Debugging Hints

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Explicitly set language if known

Summary

NLP APIsmdashNSLinguisticTagger bull Support for new units bull Faster bull Higher accuracy bull More languages

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

Natural Language Processing

Natural language text typed

recognized handwriting

transcribed speech

Detect language

Language identification

Natural Language Processing

Welcome to our talk on Natural Language ProcessingBienvenidos a nuestra plaacutetica sobre Procesamiento de Lenguaje Natural

Willkommen zu unserem Vortrag uumlber Verarbeitung natuumlrlicher Sprache欢迎参加我们关于自然语言处理理的讲座

हमारी पराकितक भाषा परससकरण भाषण म आपका सवागत ह

Natural language text typed

recognized handwriting

transcribed speech

Detect language

Language identification

Natural Language Processing

Tokenize text

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Natural Language Processing

Mr Tim Cook presided over the earnings report of Apple Inc on Tuesday

Tokenize text

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Natural Language Processing

星期二蒂姆middot库克先生主持了了苹果公司的财报会议

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Tokenize text

Natural Language Processing

星期二蒂姆middot库克 先生 主持 了了 苹果公司 的 财报 会议

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Tokenize text

Natural Language Processing

Assign parts of speech

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Natural Language Processing

Mr Tim Cook presided over the earnings report of Apple Inc on Tuesday Noun PUNCTNounNNP NNP PPNoun NounPPNounVerb PP DT Noun

Assign parts of speech

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Natural Language Processing

Lemmatize text

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Natural Language Processing

Mr Tim Cook presided over the earnings report of Apple The stock was up 3 after hours

Lemmatize text

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Natural Language Processing

Mr Tim Cook presided over the earnings report of Apple The stock was up 3 after hoursVerb NounVerb

preside hourbe

Lemmatize text

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Natural Language Processing

Named entity recognition

Extract entities

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Mr Tim Cook presided over the earnings report of Apple Inc on Tuesday

Natural Language Processing

Mr Tim Cook presided over the earnings report of Apple Inc on TuesdayPER ORG

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Extract entities

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Confer intelligence

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Linguistics

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Confer intelligence

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Linguistics Machine learning

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Confer intelligence

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Linguistics Machine learning

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Confer intelligence

Natural language text typed

recognized handwriting

transcribed speech

NLP APIs

Enough Tell me how to use them

NLP APIs

NLP APIs

NSLinguisticTagger

NSLinguisticTagger

Class in foundation

Segment and tag text

Linguistic tasks tagSchemes

NSLinguisticTagger

Class in foundation

Segment and tag text

Linguistic tasks tagSchemes

NSLinguisticTaggerNEW

NSLinguisticTagger

Tagging units

NEW

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

Units and schemes

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

Units and schemes

NEW

class func availableTagSchemes (for unit NSLinguisticTaggerUnit language String) -gt [NSLinguisticTagScheme]

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

Units and schemes

NEW

class func availableTagSchemes (for unit NSLinguisticTaggerUnit language String) -gt [NSLinguisticTagScheme]

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTaggerNEW

NSLinguisticTagger

dominantLanguage

NEW

NSLinguisticTagger

dominantLanguage

Swift 4 named types for tags and tagSchemes

NEW

NSLinguisticTagger

dominantLanguage

Swift 4 named types for tags and tagSchemes

Improved performance

Higher accuracy

Additional language support

NEW

Winnow and Whisk

Winnow and Whisk

Winnow and Whisk

Winnow Tag photos with descriptions

Winnow Tag photos with descriptions

Winnow Tag photos with descriptions

We hiked to the top and then ran down Lizzie won

Kids partied with all the goodieshellip

Die Kleinen haben friedlich zusammen gespielt

July 4th 2016hellipsummer parties at the

Holdenrsquos begin

Winnow Search for pictures

Winnow Search for pictures

Hike

Winnow Search for pictures

Hike No results

Winnow Improve search experience using NLP

Winnow Improve search experience using NLP

Hike

Winnow Improve search experience using NLP

We hiked to the top and then ran down Lizzie won

Great hikes make great pics

The hiking boysHolden family loves hiking and also posing for pictures

Hike

Winnow

Winnow

Winnow

NLP

Language identification

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

bullDemo

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Tim Cook Apple Stevie Wonder Cupertino Angela Ahrendts Bruce Wayne Thomas Vintberg

Pharrell NYU

Whisk

Whisk

Whisk

Whisk

NLP

Language identification

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

bullDemo

Why should you use the NLP APIs

Homogeneous Text Processing

Homogeneous Text Processing

NLP APIs

Natural language text typed

recognized handwriting

transcribed speech

Consistent text processing

Consistent user experience

Privacy

Privacy

On-device machine learning

User data stays on-device

Performance

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Chinese tokenization is 30 faster on iOS

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Named Entity Recognition 80 faster on iOS

Performance

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

40000 tokenssec

65000 tokenssec

Named Entity Recognition

Language Support

Language Support

Language identification 29 scripts 52 languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Accuracy

Accuracy

0

20

40

60

80

100

Part of speech

Named entity recognition

English Spanish

Debugging Hints

Debugging Hints

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Explicitly set language if known

Summary

NLP APIsmdashNSLinguisticTagger bull Support for new units bull Faster bull Higher accuracy bull More languages

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

Natural Language Processing

Welcome to our talk on Natural Language ProcessingBienvenidos a nuestra plaacutetica sobre Procesamiento de Lenguaje Natural

Willkommen zu unserem Vortrag uumlber Verarbeitung natuumlrlicher Sprache欢迎参加我们关于自然语言处理理的讲座

हमारी पराकितक भाषा परससकरण भाषण म आपका सवागत ह

Natural language text typed

recognized handwriting

transcribed speech

Detect language

Language identification

Natural Language Processing

Tokenize text

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Natural Language Processing

Mr Tim Cook presided over the earnings report of Apple Inc on Tuesday

Tokenize text

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Natural Language Processing

星期二蒂姆middot库克先生主持了了苹果公司的财报会议

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Tokenize text

Natural Language Processing

星期二蒂姆middot库克 先生 主持 了了 苹果公司 的 财报 会议

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Tokenize text

Natural Language Processing

Assign parts of speech

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Natural Language Processing

Mr Tim Cook presided over the earnings report of Apple Inc on Tuesday Noun PUNCTNounNNP NNP PPNoun NounPPNounVerb PP DT Noun

Assign parts of speech

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Natural Language Processing

Lemmatize text

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Natural Language Processing

Mr Tim Cook presided over the earnings report of Apple The stock was up 3 after hours

Lemmatize text

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Natural Language Processing

Mr Tim Cook presided over the earnings report of Apple The stock was up 3 after hoursVerb NounVerb

preside hourbe

Lemmatize text

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Natural Language Processing

Named entity recognition

Extract entities

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Mr Tim Cook presided over the earnings report of Apple Inc on Tuesday

Natural Language Processing

Mr Tim Cook presided over the earnings report of Apple Inc on TuesdayPER ORG

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Extract entities

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Confer intelligence

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Linguistics

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Confer intelligence

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Linguistics Machine learning

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Confer intelligence

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Linguistics Machine learning

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Confer intelligence

Natural language text typed

recognized handwriting

transcribed speech

NLP APIs

Enough Tell me how to use them

NLP APIs

NLP APIs

NSLinguisticTagger

NSLinguisticTagger

Class in foundation

Segment and tag text

Linguistic tasks tagSchemes

NSLinguisticTagger

Class in foundation

Segment and tag text

Linguistic tasks tagSchemes

NSLinguisticTaggerNEW

NSLinguisticTagger

Tagging units

NEW

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

Units and schemes

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

Units and schemes

NEW

class func availableTagSchemes (for unit NSLinguisticTaggerUnit language String) -gt [NSLinguisticTagScheme]

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

Units and schemes

NEW

class func availableTagSchemes (for unit NSLinguisticTaggerUnit language String) -gt [NSLinguisticTagScheme]

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTaggerNEW

NSLinguisticTagger

dominantLanguage

NEW

NSLinguisticTagger

dominantLanguage

Swift 4 named types for tags and tagSchemes

NEW

NSLinguisticTagger

dominantLanguage

Swift 4 named types for tags and tagSchemes

Improved performance

Higher accuracy

Additional language support

NEW

Winnow and Whisk

Winnow and Whisk

Winnow and Whisk

Winnow Tag photos with descriptions

Winnow Tag photos with descriptions

Winnow Tag photos with descriptions

We hiked to the top and then ran down Lizzie won

Kids partied with all the goodieshellip

Die Kleinen haben friedlich zusammen gespielt

July 4th 2016hellipsummer parties at the

Holdenrsquos begin

Winnow Search for pictures

Winnow Search for pictures

Hike

Winnow Search for pictures

Hike No results

Winnow Improve search experience using NLP

Winnow Improve search experience using NLP

Hike

Winnow Improve search experience using NLP

We hiked to the top and then ran down Lizzie won

Great hikes make great pics

The hiking boysHolden family loves hiking and also posing for pictures

Hike

Winnow

Winnow

Winnow

NLP

Language identification

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

bullDemo

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Tim Cook Apple Stevie Wonder Cupertino Angela Ahrendts Bruce Wayne Thomas Vintberg

Pharrell NYU

Whisk

Whisk

Whisk

Whisk

NLP

Language identification

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

bullDemo

Why should you use the NLP APIs

Homogeneous Text Processing

Homogeneous Text Processing

NLP APIs

Natural language text typed

recognized handwriting

transcribed speech

Consistent text processing

Consistent user experience

Privacy

Privacy

On-device machine learning

User data stays on-device

Performance

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Chinese tokenization is 30 faster on iOS

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Named Entity Recognition 80 faster on iOS

Performance

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

40000 tokenssec

65000 tokenssec

Named Entity Recognition

Language Support

Language Support

Language identification 29 scripts 52 languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Accuracy

Accuracy

0

20

40

60

80

100

Part of speech

Named entity recognition

English Spanish

Debugging Hints

Debugging Hints

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Explicitly set language if known

Summary

NLP APIsmdashNSLinguisticTagger bull Support for new units bull Faster bull Higher accuracy bull More languages

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

Natural Language Processing

Tokenize text

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Natural Language Processing

Mr Tim Cook presided over the earnings report of Apple Inc on Tuesday

Tokenize text

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Natural Language Processing

星期二蒂姆middot库克先生主持了了苹果公司的财报会议

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Tokenize text

Natural Language Processing

星期二蒂姆middot库克 先生 主持 了了 苹果公司 的 财报 会议

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Tokenize text

Natural Language Processing

Assign parts of speech

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Natural Language Processing

Mr Tim Cook presided over the earnings report of Apple Inc on Tuesday Noun PUNCTNounNNP NNP PPNoun NounPPNounVerb PP DT Noun

Assign parts of speech

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Natural Language Processing

Lemmatize text

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Natural Language Processing

Mr Tim Cook presided over the earnings report of Apple The stock was up 3 after hours

Lemmatize text

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Natural Language Processing

Mr Tim Cook presided over the earnings report of Apple The stock was up 3 after hoursVerb NounVerb

preside hourbe

Lemmatize text

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Natural Language Processing

Named entity recognition

Extract entities

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Mr Tim Cook presided over the earnings report of Apple Inc on Tuesday

Natural Language Processing

Mr Tim Cook presided over the earnings report of Apple Inc on TuesdayPER ORG

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Extract entities

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Confer intelligence

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Linguistics

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Confer intelligence

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Linguistics Machine learning

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Confer intelligence

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Linguistics Machine learning

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Confer intelligence

Natural language text typed

recognized handwriting

transcribed speech

NLP APIs

Enough Tell me how to use them

NLP APIs

NLP APIs

NSLinguisticTagger

NSLinguisticTagger

Class in foundation

Segment and tag text

Linguistic tasks tagSchemes

NSLinguisticTagger

Class in foundation

Segment and tag text

Linguistic tasks tagSchemes

NSLinguisticTaggerNEW

NSLinguisticTagger

Tagging units

NEW

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

Units and schemes

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

Units and schemes

NEW

class func availableTagSchemes (for unit NSLinguisticTaggerUnit language String) -gt [NSLinguisticTagScheme]

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

Units and schemes

NEW

class func availableTagSchemes (for unit NSLinguisticTaggerUnit language String) -gt [NSLinguisticTagScheme]

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTaggerNEW

NSLinguisticTagger

dominantLanguage

NEW

NSLinguisticTagger

dominantLanguage

Swift 4 named types for tags and tagSchemes

NEW

NSLinguisticTagger

dominantLanguage

Swift 4 named types for tags and tagSchemes

Improved performance

Higher accuracy

Additional language support

NEW

Winnow and Whisk

Winnow and Whisk

Winnow and Whisk

Winnow Tag photos with descriptions

Winnow Tag photos with descriptions

Winnow Tag photos with descriptions

We hiked to the top and then ran down Lizzie won

Kids partied with all the goodieshellip

Die Kleinen haben friedlich zusammen gespielt

July 4th 2016hellipsummer parties at the

Holdenrsquos begin

Winnow Search for pictures

Winnow Search for pictures

Hike

Winnow Search for pictures

Hike No results

Winnow Improve search experience using NLP

Winnow Improve search experience using NLP

Hike

Winnow Improve search experience using NLP

We hiked to the top and then ran down Lizzie won

Great hikes make great pics

The hiking boysHolden family loves hiking and also posing for pictures

Hike

Winnow

Winnow

Winnow

NLP

Language identification

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

bullDemo

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Tim Cook Apple Stevie Wonder Cupertino Angela Ahrendts Bruce Wayne Thomas Vintberg

Pharrell NYU

Whisk

Whisk

Whisk

Whisk

NLP

Language identification

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

bullDemo

Why should you use the NLP APIs

Homogeneous Text Processing

Homogeneous Text Processing

NLP APIs

Natural language text typed

recognized handwriting

transcribed speech

Consistent text processing

Consistent user experience

Privacy

Privacy

On-device machine learning

User data stays on-device

Performance

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Chinese tokenization is 30 faster on iOS

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Named Entity Recognition 80 faster on iOS

Performance

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

40000 tokenssec

65000 tokenssec

Named Entity Recognition

Language Support

Language Support

Language identification 29 scripts 52 languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Accuracy

Accuracy

0

20

40

60

80

100

Part of speech

Named entity recognition

English Spanish

Debugging Hints

Debugging Hints

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Explicitly set language if known

Summary

NLP APIsmdashNSLinguisticTagger bull Support for new units bull Faster bull Higher accuracy bull More languages

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

Natural Language Processing

Mr Tim Cook presided over the earnings report of Apple Inc on Tuesday

Tokenize text

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Natural Language Processing

星期二蒂姆middot库克先生主持了了苹果公司的财报会议

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Tokenize text

Natural Language Processing

星期二蒂姆middot库克 先生 主持 了了 苹果公司 的 财报 会议

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Tokenize text

Natural Language Processing

Assign parts of speech

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Natural Language Processing

Mr Tim Cook presided over the earnings report of Apple Inc on Tuesday Noun PUNCTNounNNP NNP PPNoun NounPPNounVerb PP DT Noun

Assign parts of speech

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Natural Language Processing

Lemmatize text

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Natural Language Processing

Mr Tim Cook presided over the earnings report of Apple The stock was up 3 after hours

Lemmatize text

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Natural Language Processing

Mr Tim Cook presided over the earnings report of Apple The stock was up 3 after hoursVerb NounVerb

preside hourbe

Lemmatize text

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Natural Language Processing

Named entity recognition

Extract entities

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Mr Tim Cook presided over the earnings report of Apple Inc on Tuesday

Natural Language Processing

Mr Tim Cook presided over the earnings report of Apple Inc on TuesdayPER ORG

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Extract entities

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Confer intelligence

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Linguistics

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Confer intelligence

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Linguistics Machine learning

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Confer intelligence

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Linguistics Machine learning

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Confer intelligence

Natural language text typed

recognized handwriting

transcribed speech

NLP APIs

Enough Tell me how to use them

NLP APIs

NLP APIs

NSLinguisticTagger

NSLinguisticTagger

Class in foundation

Segment and tag text

Linguistic tasks tagSchemes

NSLinguisticTagger

Class in foundation

Segment and tag text

Linguistic tasks tagSchemes

NSLinguisticTaggerNEW

NSLinguisticTagger

Tagging units

NEW

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

Units and schemes

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

Units and schemes

NEW

class func availableTagSchemes (for unit NSLinguisticTaggerUnit language String) -gt [NSLinguisticTagScheme]

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

Units and schemes

NEW

class func availableTagSchemes (for unit NSLinguisticTaggerUnit language String) -gt [NSLinguisticTagScheme]

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTaggerNEW

NSLinguisticTagger

dominantLanguage

NEW

NSLinguisticTagger

dominantLanguage

Swift 4 named types for tags and tagSchemes

NEW

NSLinguisticTagger

dominantLanguage

Swift 4 named types for tags and tagSchemes

Improved performance

Higher accuracy

Additional language support

NEW

Winnow and Whisk

Winnow and Whisk

Winnow and Whisk

Winnow Tag photos with descriptions

Winnow Tag photos with descriptions

Winnow Tag photos with descriptions

We hiked to the top and then ran down Lizzie won

Kids partied with all the goodieshellip

Die Kleinen haben friedlich zusammen gespielt

July 4th 2016hellipsummer parties at the

Holdenrsquos begin

Winnow Search for pictures

Winnow Search for pictures

Hike

Winnow Search for pictures

Hike No results

Winnow Improve search experience using NLP

Winnow Improve search experience using NLP

Hike

Winnow Improve search experience using NLP

We hiked to the top and then ran down Lizzie won

Great hikes make great pics

The hiking boysHolden family loves hiking and also posing for pictures

Hike

Winnow

Winnow

Winnow

NLP

Language identification

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

bullDemo

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Tim Cook Apple Stevie Wonder Cupertino Angela Ahrendts Bruce Wayne Thomas Vintberg

Pharrell NYU

Whisk

Whisk

Whisk

Whisk

NLP

Language identification

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

bullDemo

Why should you use the NLP APIs

Homogeneous Text Processing

Homogeneous Text Processing

NLP APIs

Natural language text typed

recognized handwriting

transcribed speech

Consistent text processing

Consistent user experience

Privacy

Privacy

On-device machine learning

User data stays on-device

Performance

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Chinese tokenization is 30 faster on iOS

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Named Entity Recognition 80 faster on iOS

Performance

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

40000 tokenssec

65000 tokenssec

Named Entity Recognition

Language Support

Language Support

Language identification 29 scripts 52 languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Accuracy

Accuracy

0

20

40

60

80

100

Part of speech

Named entity recognition

English Spanish

Debugging Hints

Debugging Hints

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Explicitly set language if known

Summary

NLP APIsmdashNSLinguisticTagger bull Support for new units bull Faster bull Higher accuracy bull More languages

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

Natural Language Processing

星期二蒂姆middot库克先生主持了了苹果公司的财报会议

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Tokenize text

Natural Language Processing

星期二蒂姆middot库克 先生 主持 了了 苹果公司 的 财报 会议

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Tokenize text

Natural Language Processing

Assign parts of speech

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Natural Language Processing

Mr Tim Cook presided over the earnings report of Apple Inc on Tuesday Noun PUNCTNounNNP NNP PPNoun NounPPNounVerb PP DT Noun

Assign parts of speech

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Natural Language Processing

Lemmatize text

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Natural Language Processing

Mr Tim Cook presided over the earnings report of Apple The stock was up 3 after hours

Lemmatize text

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Natural Language Processing

Mr Tim Cook presided over the earnings report of Apple The stock was up 3 after hoursVerb NounVerb

preside hourbe

Lemmatize text

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Natural Language Processing

Named entity recognition

Extract entities

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Mr Tim Cook presided over the earnings report of Apple Inc on Tuesday

Natural Language Processing

Mr Tim Cook presided over the earnings report of Apple Inc on TuesdayPER ORG

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Extract entities

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Confer intelligence

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Linguistics

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Confer intelligence

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Linguistics Machine learning

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Confer intelligence

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Linguistics Machine learning

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Confer intelligence

Natural language text typed

recognized handwriting

transcribed speech

NLP APIs

Enough Tell me how to use them

NLP APIs

NLP APIs

NSLinguisticTagger

NSLinguisticTagger

Class in foundation

Segment and tag text

Linguistic tasks tagSchemes

NSLinguisticTagger

Class in foundation

Segment and tag text

Linguistic tasks tagSchemes

NSLinguisticTaggerNEW

NSLinguisticTagger

Tagging units

NEW

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

Units and schemes

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

Units and schemes

NEW

class func availableTagSchemes (for unit NSLinguisticTaggerUnit language String) -gt [NSLinguisticTagScheme]

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

Units and schemes

NEW

class func availableTagSchemes (for unit NSLinguisticTaggerUnit language String) -gt [NSLinguisticTagScheme]

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTaggerNEW

NSLinguisticTagger

dominantLanguage

NEW

NSLinguisticTagger

dominantLanguage

Swift 4 named types for tags and tagSchemes

NEW

NSLinguisticTagger

dominantLanguage

Swift 4 named types for tags and tagSchemes

Improved performance

Higher accuracy

Additional language support

NEW

Winnow and Whisk

Winnow and Whisk

Winnow and Whisk

Winnow Tag photos with descriptions

Winnow Tag photos with descriptions

Winnow Tag photos with descriptions

We hiked to the top and then ran down Lizzie won

Kids partied with all the goodieshellip

Die Kleinen haben friedlich zusammen gespielt

July 4th 2016hellipsummer parties at the

Holdenrsquos begin

Winnow Search for pictures

Winnow Search for pictures

Hike

Winnow Search for pictures

Hike No results

Winnow Improve search experience using NLP

Winnow Improve search experience using NLP

Hike

Winnow Improve search experience using NLP

We hiked to the top and then ran down Lizzie won

Great hikes make great pics

The hiking boysHolden family loves hiking and also posing for pictures

Hike

Winnow

Winnow

Winnow

NLP

Language identification

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

bullDemo

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Tim Cook Apple Stevie Wonder Cupertino Angela Ahrendts Bruce Wayne Thomas Vintberg

Pharrell NYU

Whisk

Whisk

Whisk

Whisk

NLP

Language identification

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

bullDemo

Why should you use the NLP APIs

Homogeneous Text Processing

Homogeneous Text Processing

NLP APIs

Natural language text typed

recognized handwriting

transcribed speech

Consistent text processing

Consistent user experience

Privacy

Privacy

On-device machine learning

User data stays on-device

Performance

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Chinese tokenization is 30 faster on iOS

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Named Entity Recognition 80 faster on iOS

Performance

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

40000 tokenssec

65000 tokenssec

Named Entity Recognition

Language Support

Language Support

Language identification 29 scripts 52 languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Accuracy

Accuracy

0

20

40

60

80

100

Part of speech

Named entity recognition

English Spanish

Debugging Hints

Debugging Hints

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Explicitly set language if known

Summary

NLP APIsmdashNSLinguisticTagger bull Support for new units bull Faster bull Higher accuracy bull More languages

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

Natural Language Processing

星期二蒂姆middot库克 先生 主持 了了 苹果公司 的 财报 会议

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Tokenize text

Natural Language Processing

Assign parts of speech

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Natural Language Processing

Mr Tim Cook presided over the earnings report of Apple Inc on Tuesday Noun PUNCTNounNNP NNP PPNoun NounPPNounVerb PP DT Noun

Assign parts of speech

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Natural Language Processing

Lemmatize text

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Natural Language Processing

Mr Tim Cook presided over the earnings report of Apple The stock was up 3 after hours

Lemmatize text

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Natural Language Processing

Mr Tim Cook presided over the earnings report of Apple The stock was up 3 after hoursVerb NounVerb

preside hourbe

Lemmatize text

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Natural Language Processing

Named entity recognition

Extract entities

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Mr Tim Cook presided over the earnings report of Apple Inc on Tuesday

Natural Language Processing

Mr Tim Cook presided over the earnings report of Apple Inc on TuesdayPER ORG

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Extract entities

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Confer intelligence

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Linguistics

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Confer intelligence

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Linguistics Machine learning

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Confer intelligence

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Linguistics Machine learning

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Confer intelligence

Natural language text typed

recognized handwriting

transcribed speech

NLP APIs

Enough Tell me how to use them

NLP APIs

NLP APIs

NSLinguisticTagger

NSLinguisticTagger

Class in foundation

Segment and tag text

Linguistic tasks tagSchemes

NSLinguisticTagger

Class in foundation

Segment and tag text

Linguistic tasks tagSchemes

NSLinguisticTaggerNEW

NSLinguisticTagger

Tagging units

NEW

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

Units and schemes

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

Units and schemes

NEW

class func availableTagSchemes (for unit NSLinguisticTaggerUnit language String) -gt [NSLinguisticTagScheme]

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

Units and schemes

NEW

class func availableTagSchemes (for unit NSLinguisticTaggerUnit language String) -gt [NSLinguisticTagScheme]

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTaggerNEW

NSLinguisticTagger

dominantLanguage

NEW

NSLinguisticTagger

dominantLanguage

Swift 4 named types for tags and tagSchemes

NEW

NSLinguisticTagger

dominantLanguage

Swift 4 named types for tags and tagSchemes

Improved performance

Higher accuracy

Additional language support

NEW

Winnow and Whisk

Winnow and Whisk

Winnow and Whisk

Winnow Tag photos with descriptions

Winnow Tag photos with descriptions

Winnow Tag photos with descriptions

We hiked to the top and then ran down Lizzie won

Kids partied with all the goodieshellip

Die Kleinen haben friedlich zusammen gespielt

July 4th 2016hellipsummer parties at the

Holdenrsquos begin

Winnow Search for pictures

Winnow Search for pictures

Hike

Winnow Search for pictures

Hike No results

Winnow Improve search experience using NLP

Winnow Improve search experience using NLP

Hike

Winnow Improve search experience using NLP

We hiked to the top and then ran down Lizzie won

Great hikes make great pics

The hiking boysHolden family loves hiking and also posing for pictures

Hike

Winnow

Winnow

Winnow

NLP

Language identification

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

bullDemo

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Tim Cook Apple Stevie Wonder Cupertino Angela Ahrendts Bruce Wayne Thomas Vintberg

Pharrell NYU

Whisk

Whisk

Whisk

Whisk

NLP

Language identification

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

bullDemo

Why should you use the NLP APIs

Homogeneous Text Processing

Homogeneous Text Processing

NLP APIs

Natural language text typed

recognized handwriting

transcribed speech

Consistent text processing

Consistent user experience

Privacy

Privacy

On-device machine learning

User data stays on-device

Performance

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Chinese tokenization is 30 faster on iOS

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Named Entity Recognition 80 faster on iOS

Performance

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

40000 tokenssec

65000 tokenssec

Named Entity Recognition

Language Support

Language Support

Language identification 29 scripts 52 languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Accuracy

Accuracy

0

20

40

60

80

100

Part of speech

Named entity recognition

English Spanish

Debugging Hints

Debugging Hints

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Explicitly set language if known

Summary

NLP APIsmdashNSLinguisticTagger bull Support for new units bull Faster bull Higher accuracy bull More languages

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

Natural Language Processing

Assign parts of speech

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Natural Language Processing

Mr Tim Cook presided over the earnings report of Apple Inc on Tuesday Noun PUNCTNounNNP NNP PPNoun NounPPNounVerb PP DT Noun

Assign parts of speech

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Natural Language Processing

Lemmatize text

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Natural Language Processing

Mr Tim Cook presided over the earnings report of Apple The stock was up 3 after hours

Lemmatize text

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Natural Language Processing

Mr Tim Cook presided over the earnings report of Apple The stock was up 3 after hoursVerb NounVerb

preside hourbe

Lemmatize text

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Natural Language Processing

Named entity recognition

Extract entities

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Mr Tim Cook presided over the earnings report of Apple Inc on Tuesday

Natural Language Processing

Mr Tim Cook presided over the earnings report of Apple Inc on TuesdayPER ORG

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Extract entities

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Confer intelligence

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Linguistics

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Confer intelligence

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Linguistics Machine learning

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Confer intelligence

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Linguistics Machine learning

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Confer intelligence

Natural language text typed

recognized handwriting

transcribed speech

NLP APIs

Enough Tell me how to use them

NLP APIs

NLP APIs

NSLinguisticTagger

NSLinguisticTagger

Class in foundation

Segment and tag text

Linguistic tasks tagSchemes

NSLinguisticTagger

Class in foundation

Segment and tag text

Linguistic tasks tagSchemes

NSLinguisticTaggerNEW

NSLinguisticTagger

Tagging units

NEW

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

Units and schemes

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

Units and schemes

NEW

class func availableTagSchemes (for unit NSLinguisticTaggerUnit language String) -gt [NSLinguisticTagScheme]

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

Units and schemes

NEW

class func availableTagSchemes (for unit NSLinguisticTaggerUnit language String) -gt [NSLinguisticTagScheme]

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTaggerNEW

NSLinguisticTagger

dominantLanguage

NEW

NSLinguisticTagger

dominantLanguage

Swift 4 named types for tags and tagSchemes

NEW

NSLinguisticTagger

dominantLanguage

Swift 4 named types for tags and tagSchemes

Improved performance

Higher accuracy

Additional language support

NEW

Winnow and Whisk

Winnow and Whisk

Winnow and Whisk

Winnow Tag photos with descriptions

Winnow Tag photos with descriptions

Winnow Tag photos with descriptions

We hiked to the top and then ran down Lizzie won

Kids partied with all the goodieshellip

Die Kleinen haben friedlich zusammen gespielt

July 4th 2016hellipsummer parties at the

Holdenrsquos begin

Winnow Search for pictures

Winnow Search for pictures

Hike

Winnow Search for pictures

Hike No results

Winnow Improve search experience using NLP

Winnow Improve search experience using NLP

Hike

Winnow Improve search experience using NLP

We hiked to the top and then ran down Lizzie won

Great hikes make great pics

The hiking boysHolden family loves hiking and also posing for pictures

Hike

Winnow

Winnow

Winnow

NLP

Language identification

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

bullDemo

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Tim Cook Apple Stevie Wonder Cupertino Angela Ahrendts Bruce Wayne Thomas Vintberg

Pharrell NYU

Whisk

Whisk

Whisk

Whisk

NLP

Language identification

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

bullDemo

Why should you use the NLP APIs

Homogeneous Text Processing

Homogeneous Text Processing

NLP APIs

Natural language text typed

recognized handwriting

transcribed speech

Consistent text processing

Consistent user experience

Privacy

Privacy

On-device machine learning

User data stays on-device

Performance

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Chinese tokenization is 30 faster on iOS

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Named Entity Recognition 80 faster on iOS

Performance

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

40000 tokenssec

65000 tokenssec

Named Entity Recognition

Language Support

Language Support

Language identification 29 scripts 52 languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Accuracy

Accuracy

0

20

40

60

80

100

Part of speech

Named entity recognition

English Spanish

Debugging Hints

Debugging Hints

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Explicitly set language if known

Summary

NLP APIsmdashNSLinguisticTagger bull Support for new units bull Faster bull Higher accuracy bull More languages

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

Natural Language Processing

Mr Tim Cook presided over the earnings report of Apple Inc on Tuesday Noun PUNCTNounNNP NNP PPNoun NounPPNounVerb PP DT Noun

Assign parts of speech

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Natural Language Processing

Lemmatize text

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Natural Language Processing

Mr Tim Cook presided over the earnings report of Apple The stock was up 3 after hours

Lemmatize text

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Natural Language Processing

Mr Tim Cook presided over the earnings report of Apple The stock was up 3 after hoursVerb NounVerb

preside hourbe

Lemmatize text

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Natural Language Processing

Named entity recognition

Extract entities

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Mr Tim Cook presided over the earnings report of Apple Inc on Tuesday

Natural Language Processing

Mr Tim Cook presided over the earnings report of Apple Inc on TuesdayPER ORG

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Extract entities

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Confer intelligence

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Linguistics

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Confer intelligence

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Linguistics Machine learning

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Confer intelligence

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Linguistics Machine learning

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Confer intelligence

Natural language text typed

recognized handwriting

transcribed speech

NLP APIs

Enough Tell me how to use them

NLP APIs

NLP APIs

NSLinguisticTagger

NSLinguisticTagger

Class in foundation

Segment and tag text

Linguistic tasks tagSchemes

NSLinguisticTagger

Class in foundation

Segment and tag text

Linguistic tasks tagSchemes

NSLinguisticTaggerNEW

NSLinguisticTagger

Tagging units

NEW

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

Units and schemes

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

Units and schemes

NEW

class func availableTagSchemes (for unit NSLinguisticTaggerUnit language String) -gt [NSLinguisticTagScheme]

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

Units and schemes

NEW

class func availableTagSchemes (for unit NSLinguisticTaggerUnit language String) -gt [NSLinguisticTagScheme]

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTaggerNEW

NSLinguisticTagger

dominantLanguage

NEW

NSLinguisticTagger

dominantLanguage

Swift 4 named types for tags and tagSchemes

NEW

NSLinguisticTagger

dominantLanguage

Swift 4 named types for tags and tagSchemes

Improved performance

Higher accuracy

Additional language support

NEW

Winnow and Whisk

Winnow and Whisk

Winnow and Whisk

Winnow Tag photos with descriptions

Winnow Tag photos with descriptions

Winnow Tag photos with descriptions

We hiked to the top and then ran down Lizzie won

Kids partied with all the goodieshellip

Die Kleinen haben friedlich zusammen gespielt

July 4th 2016hellipsummer parties at the

Holdenrsquos begin

Winnow Search for pictures

Winnow Search for pictures

Hike

Winnow Search for pictures

Hike No results

Winnow Improve search experience using NLP

Winnow Improve search experience using NLP

Hike

Winnow Improve search experience using NLP

We hiked to the top and then ran down Lizzie won

Great hikes make great pics

The hiking boysHolden family loves hiking and also posing for pictures

Hike

Winnow

Winnow

Winnow

NLP

Language identification

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

bullDemo

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Tim Cook Apple Stevie Wonder Cupertino Angela Ahrendts Bruce Wayne Thomas Vintberg

Pharrell NYU

Whisk

Whisk

Whisk

Whisk

NLP

Language identification

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

bullDemo

Why should you use the NLP APIs

Homogeneous Text Processing

Homogeneous Text Processing

NLP APIs

Natural language text typed

recognized handwriting

transcribed speech

Consistent text processing

Consistent user experience

Privacy

Privacy

On-device machine learning

User data stays on-device

Performance

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Chinese tokenization is 30 faster on iOS

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Named Entity Recognition 80 faster on iOS

Performance

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

40000 tokenssec

65000 tokenssec

Named Entity Recognition

Language Support

Language Support

Language identification 29 scripts 52 languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Accuracy

Accuracy

0

20

40

60

80

100

Part of speech

Named entity recognition

English Spanish

Debugging Hints

Debugging Hints

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Explicitly set language if known

Summary

NLP APIsmdashNSLinguisticTagger bull Support for new units bull Faster bull Higher accuracy bull More languages

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

Natural Language Processing

Lemmatize text

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Natural Language Processing

Mr Tim Cook presided over the earnings report of Apple The stock was up 3 after hours

Lemmatize text

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Natural Language Processing

Mr Tim Cook presided over the earnings report of Apple The stock was up 3 after hoursVerb NounVerb

preside hourbe

Lemmatize text

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Natural Language Processing

Named entity recognition

Extract entities

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Mr Tim Cook presided over the earnings report of Apple Inc on Tuesday

Natural Language Processing

Mr Tim Cook presided over the earnings report of Apple Inc on TuesdayPER ORG

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Extract entities

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Confer intelligence

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Linguistics

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Confer intelligence

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Linguistics Machine learning

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Confer intelligence

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Linguistics Machine learning

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Confer intelligence

Natural language text typed

recognized handwriting

transcribed speech

NLP APIs

Enough Tell me how to use them

NLP APIs

NLP APIs

NSLinguisticTagger

NSLinguisticTagger

Class in foundation

Segment and tag text

Linguistic tasks tagSchemes

NSLinguisticTagger

Class in foundation

Segment and tag text

Linguistic tasks tagSchemes

NSLinguisticTaggerNEW

NSLinguisticTagger

Tagging units

NEW

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

Units and schemes

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

Units and schemes

NEW

class func availableTagSchemes (for unit NSLinguisticTaggerUnit language String) -gt [NSLinguisticTagScheme]

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

Units and schemes

NEW

class func availableTagSchemes (for unit NSLinguisticTaggerUnit language String) -gt [NSLinguisticTagScheme]

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTaggerNEW

NSLinguisticTagger

dominantLanguage

NEW

NSLinguisticTagger

dominantLanguage

Swift 4 named types for tags and tagSchemes

NEW

NSLinguisticTagger

dominantLanguage

Swift 4 named types for tags and tagSchemes

Improved performance

Higher accuracy

Additional language support

NEW

Winnow and Whisk

Winnow and Whisk

Winnow and Whisk

Winnow Tag photos with descriptions

Winnow Tag photos with descriptions

Winnow Tag photos with descriptions

We hiked to the top and then ran down Lizzie won

Kids partied with all the goodieshellip

Die Kleinen haben friedlich zusammen gespielt

July 4th 2016hellipsummer parties at the

Holdenrsquos begin

Winnow Search for pictures

Winnow Search for pictures

Hike

Winnow Search for pictures

Hike No results

Winnow Improve search experience using NLP

Winnow Improve search experience using NLP

Hike

Winnow Improve search experience using NLP

We hiked to the top and then ran down Lizzie won

Great hikes make great pics

The hiking boysHolden family loves hiking and also posing for pictures

Hike

Winnow

Winnow

Winnow

NLP

Language identification

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

bullDemo

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Tim Cook Apple Stevie Wonder Cupertino Angela Ahrendts Bruce Wayne Thomas Vintberg

Pharrell NYU

Whisk

Whisk

Whisk

Whisk

NLP

Language identification

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

bullDemo

Why should you use the NLP APIs

Homogeneous Text Processing

Homogeneous Text Processing

NLP APIs

Natural language text typed

recognized handwriting

transcribed speech

Consistent text processing

Consistent user experience

Privacy

Privacy

On-device machine learning

User data stays on-device

Performance

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Chinese tokenization is 30 faster on iOS

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Named Entity Recognition 80 faster on iOS

Performance

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

40000 tokenssec

65000 tokenssec

Named Entity Recognition

Language Support

Language Support

Language identification 29 scripts 52 languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Accuracy

Accuracy

0

20

40

60

80

100

Part of speech

Named entity recognition

English Spanish

Debugging Hints

Debugging Hints

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Explicitly set language if known

Summary

NLP APIsmdashNSLinguisticTagger bull Support for new units bull Faster bull Higher accuracy bull More languages

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

Natural Language Processing

Mr Tim Cook presided over the earnings report of Apple The stock was up 3 after hours

Lemmatize text

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Natural Language Processing

Mr Tim Cook presided over the earnings report of Apple The stock was up 3 after hoursVerb NounVerb

preside hourbe

Lemmatize text

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Natural Language Processing

Named entity recognition

Extract entities

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Mr Tim Cook presided over the earnings report of Apple Inc on Tuesday

Natural Language Processing

Mr Tim Cook presided over the earnings report of Apple Inc on TuesdayPER ORG

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Extract entities

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Confer intelligence

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Linguistics

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Confer intelligence

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Linguistics Machine learning

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Confer intelligence

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Linguistics Machine learning

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Confer intelligence

Natural language text typed

recognized handwriting

transcribed speech

NLP APIs

Enough Tell me how to use them

NLP APIs

NLP APIs

NSLinguisticTagger

NSLinguisticTagger

Class in foundation

Segment and tag text

Linguistic tasks tagSchemes

NSLinguisticTagger

Class in foundation

Segment and tag text

Linguistic tasks tagSchemes

NSLinguisticTaggerNEW

NSLinguisticTagger

Tagging units

NEW

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

Units and schemes

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

Units and schemes

NEW

class func availableTagSchemes (for unit NSLinguisticTaggerUnit language String) -gt [NSLinguisticTagScheme]

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

Units and schemes

NEW

class func availableTagSchemes (for unit NSLinguisticTaggerUnit language String) -gt [NSLinguisticTagScheme]

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTaggerNEW

NSLinguisticTagger

dominantLanguage

NEW

NSLinguisticTagger

dominantLanguage

Swift 4 named types for tags and tagSchemes

NEW

NSLinguisticTagger

dominantLanguage

Swift 4 named types for tags and tagSchemes

Improved performance

Higher accuracy

Additional language support

NEW

Winnow and Whisk

Winnow and Whisk

Winnow and Whisk

Winnow Tag photos with descriptions

Winnow Tag photos with descriptions

Winnow Tag photos with descriptions

We hiked to the top and then ran down Lizzie won

Kids partied with all the goodieshellip

Die Kleinen haben friedlich zusammen gespielt

July 4th 2016hellipsummer parties at the

Holdenrsquos begin

Winnow Search for pictures

Winnow Search for pictures

Hike

Winnow Search for pictures

Hike No results

Winnow Improve search experience using NLP

Winnow Improve search experience using NLP

Hike

Winnow Improve search experience using NLP

We hiked to the top and then ran down Lizzie won

Great hikes make great pics

The hiking boysHolden family loves hiking and also posing for pictures

Hike

Winnow

Winnow

Winnow

NLP

Language identification

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

bullDemo

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Tim Cook Apple Stevie Wonder Cupertino Angela Ahrendts Bruce Wayne Thomas Vintberg

Pharrell NYU

Whisk

Whisk

Whisk

Whisk

NLP

Language identification

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

bullDemo

Why should you use the NLP APIs

Homogeneous Text Processing

Homogeneous Text Processing

NLP APIs

Natural language text typed

recognized handwriting

transcribed speech

Consistent text processing

Consistent user experience

Privacy

Privacy

On-device machine learning

User data stays on-device

Performance

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Chinese tokenization is 30 faster on iOS

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Named Entity Recognition 80 faster on iOS

Performance

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

40000 tokenssec

65000 tokenssec

Named Entity Recognition

Language Support

Language Support

Language identification 29 scripts 52 languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Accuracy

Accuracy

0

20

40

60

80

100

Part of speech

Named entity recognition

English Spanish

Debugging Hints

Debugging Hints

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Explicitly set language if known

Summary

NLP APIsmdashNSLinguisticTagger bull Support for new units bull Faster bull Higher accuracy bull More languages

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

Natural Language Processing

Mr Tim Cook presided over the earnings report of Apple The stock was up 3 after hoursVerb NounVerb

preside hourbe

Lemmatize text

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Natural Language Processing

Named entity recognition

Extract entities

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Mr Tim Cook presided over the earnings report of Apple Inc on Tuesday

Natural Language Processing

Mr Tim Cook presided over the earnings report of Apple Inc on TuesdayPER ORG

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Extract entities

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Confer intelligence

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Linguistics

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Confer intelligence

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Linguistics Machine learning

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Confer intelligence

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Linguistics Machine learning

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Confer intelligence

Natural language text typed

recognized handwriting

transcribed speech

NLP APIs

Enough Tell me how to use them

NLP APIs

NLP APIs

NSLinguisticTagger

NSLinguisticTagger

Class in foundation

Segment and tag text

Linguistic tasks tagSchemes

NSLinguisticTagger

Class in foundation

Segment and tag text

Linguistic tasks tagSchemes

NSLinguisticTaggerNEW

NSLinguisticTagger

Tagging units

NEW

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

Units and schemes

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

Units and schemes

NEW

class func availableTagSchemes (for unit NSLinguisticTaggerUnit language String) -gt [NSLinguisticTagScheme]

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

Units and schemes

NEW

class func availableTagSchemes (for unit NSLinguisticTaggerUnit language String) -gt [NSLinguisticTagScheme]

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTaggerNEW

NSLinguisticTagger

dominantLanguage

NEW

NSLinguisticTagger

dominantLanguage

Swift 4 named types for tags and tagSchemes

NEW

NSLinguisticTagger

dominantLanguage

Swift 4 named types for tags and tagSchemes

Improved performance

Higher accuracy

Additional language support

NEW

Winnow and Whisk

Winnow and Whisk

Winnow and Whisk

Winnow Tag photos with descriptions

Winnow Tag photos with descriptions

Winnow Tag photos with descriptions

We hiked to the top and then ran down Lizzie won

Kids partied with all the goodieshellip

Die Kleinen haben friedlich zusammen gespielt

July 4th 2016hellipsummer parties at the

Holdenrsquos begin

Winnow Search for pictures

Winnow Search for pictures

Hike

Winnow Search for pictures

Hike No results

Winnow Improve search experience using NLP

Winnow Improve search experience using NLP

Hike

Winnow Improve search experience using NLP

We hiked to the top and then ran down Lizzie won

Great hikes make great pics

The hiking boysHolden family loves hiking and also posing for pictures

Hike

Winnow

Winnow

Winnow

NLP

Language identification

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

bullDemo

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Tim Cook Apple Stevie Wonder Cupertino Angela Ahrendts Bruce Wayne Thomas Vintberg

Pharrell NYU

Whisk

Whisk

Whisk

Whisk

NLP

Language identification

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

bullDemo

Why should you use the NLP APIs

Homogeneous Text Processing

Homogeneous Text Processing

NLP APIs

Natural language text typed

recognized handwriting

transcribed speech

Consistent text processing

Consistent user experience

Privacy

Privacy

On-device machine learning

User data stays on-device

Performance

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Chinese tokenization is 30 faster on iOS

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Named Entity Recognition 80 faster on iOS

Performance

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

40000 tokenssec

65000 tokenssec

Named Entity Recognition

Language Support

Language Support

Language identification 29 scripts 52 languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Accuracy

Accuracy

0

20

40

60

80

100

Part of speech

Named entity recognition

English Spanish

Debugging Hints

Debugging Hints

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Explicitly set language if known

Summary

NLP APIsmdashNSLinguisticTagger bull Support for new units bull Faster bull Higher accuracy bull More languages

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

Natural Language Processing

Named entity recognition

Extract entities

Natural language text typed

recognized handwriting

transcribed speech

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Mr Tim Cook presided over the earnings report of Apple Inc on Tuesday

Natural Language Processing

Mr Tim Cook presided over the earnings report of Apple Inc on TuesdayPER ORG

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Extract entities

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Confer intelligence

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Linguistics

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Confer intelligence

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Linguistics Machine learning

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Confer intelligence

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Linguistics Machine learning

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Confer intelligence

Natural language text typed

recognized handwriting

transcribed speech

NLP APIs

Enough Tell me how to use them

NLP APIs

NLP APIs

NSLinguisticTagger

NSLinguisticTagger

Class in foundation

Segment and tag text

Linguistic tasks tagSchemes

NSLinguisticTagger

Class in foundation

Segment and tag text

Linguistic tasks tagSchemes

NSLinguisticTaggerNEW

NSLinguisticTagger

Tagging units

NEW

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

Units and schemes

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

Units and schemes

NEW

class func availableTagSchemes (for unit NSLinguisticTaggerUnit language String) -gt [NSLinguisticTagScheme]

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

Units and schemes

NEW

class func availableTagSchemes (for unit NSLinguisticTaggerUnit language String) -gt [NSLinguisticTagScheme]

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTaggerNEW

NSLinguisticTagger

dominantLanguage

NEW

NSLinguisticTagger

dominantLanguage

Swift 4 named types for tags and tagSchemes

NEW

NSLinguisticTagger

dominantLanguage

Swift 4 named types for tags and tagSchemes

Improved performance

Higher accuracy

Additional language support

NEW

Winnow and Whisk

Winnow and Whisk

Winnow and Whisk

Winnow Tag photos with descriptions

Winnow Tag photos with descriptions

Winnow Tag photos with descriptions

We hiked to the top and then ran down Lizzie won

Kids partied with all the goodieshellip

Die Kleinen haben friedlich zusammen gespielt

July 4th 2016hellipsummer parties at the

Holdenrsquos begin

Winnow Search for pictures

Winnow Search for pictures

Hike

Winnow Search for pictures

Hike No results

Winnow Improve search experience using NLP

Winnow Improve search experience using NLP

Hike

Winnow Improve search experience using NLP

We hiked to the top and then ran down Lizzie won

Great hikes make great pics

The hiking boysHolden family loves hiking and also posing for pictures

Hike

Winnow

Winnow

Winnow

NLP

Language identification

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

bullDemo

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Tim Cook Apple Stevie Wonder Cupertino Angela Ahrendts Bruce Wayne Thomas Vintberg

Pharrell NYU

Whisk

Whisk

Whisk

Whisk

NLP

Language identification

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

bullDemo

Why should you use the NLP APIs

Homogeneous Text Processing

Homogeneous Text Processing

NLP APIs

Natural language text typed

recognized handwriting

transcribed speech

Consistent text processing

Consistent user experience

Privacy

Privacy

On-device machine learning

User data stays on-device

Performance

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Chinese tokenization is 30 faster on iOS

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Named Entity Recognition 80 faster on iOS

Performance

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

40000 tokenssec

65000 tokenssec

Named Entity Recognition

Language Support

Language Support

Language identification 29 scripts 52 languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Accuracy

Accuracy

0

20

40

60

80

100

Part of speech

Named entity recognition

English Spanish

Debugging Hints

Debugging Hints

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Explicitly set language if known

Summary

NLP APIsmdashNSLinguisticTagger bull Support for new units bull Faster bull Higher accuracy bull More languages

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

Natural Language Processing

Mr Tim Cook presided over the earnings report of Apple Inc on TuesdayPER ORG

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Extract entities

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Confer intelligence

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Linguistics

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Confer intelligence

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Linguistics Machine learning

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Confer intelligence

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Linguistics Machine learning

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Confer intelligence

Natural language text typed

recognized handwriting

transcribed speech

NLP APIs

Enough Tell me how to use them

NLP APIs

NLP APIs

NSLinguisticTagger

NSLinguisticTagger

Class in foundation

Segment and tag text

Linguistic tasks tagSchemes

NSLinguisticTagger

Class in foundation

Segment and tag text

Linguistic tasks tagSchemes

NSLinguisticTaggerNEW

NSLinguisticTagger

Tagging units

NEW

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

Units and schemes

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

Units and schemes

NEW

class func availableTagSchemes (for unit NSLinguisticTaggerUnit language String) -gt [NSLinguisticTagScheme]

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

Units and schemes

NEW

class func availableTagSchemes (for unit NSLinguisticTaggerUnit language String) -gt [NSLinguisticTagScheme]

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTaggerNEW

NSLinguisticTagger

dominantLanguage

NEW

NSLinguisticTagger

dominantLanguage

Swift 4 named types for tags and tagSchemes

NEW

NSLinguisticTagger

dominantLanguage

Swift 4 named types for tags and tagSchemes

Improved performance

Higher accuracy

Additional language support

NEW

Winnow and Whisk

Winnow and Whisk

Winnow and Whisk

Winnow Tag photos with descriptions

Winnow Tag photos with descriptions

Winnow Tag photos with descriptions

We hiked to the top and then ran down Lizzie won

Kids partied with all the goodieshellip

Die Kleinen haben friedlich zusammen gespielt

July 4th 2016hellipsummer parties at the

Holdenrsquos begin

Winnow Search for pictures

Winnow Search for pictures

Hike

Winnow Search for pictures

Hike No results

Winnow Improve search experience using NLP

Winnow Improve search experience using NLP

Hike

Winnow Improve search experience using NLP

We hiked to the top and then ran down Lizzie won

Great hikes make great pics

The hiking boysHolden family loves hiking and also posing for pictures

Hike

Winnow

Winnow

Winnow

NLP

Language identification

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

bullDemo

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Tim Cook Apple Stevie Wonder Cupertino Angela Ahrendts Bruce Wayne Thomas Vintberg

Pharrell NYU

Whisk

Whisk

Whisk

Whisk

NLP

Language identification

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

bullDemo

Why should you use the NLP APIs

Homogeneous Text Processing

Homogeneous Text Processing

NLP APIs

Natural language text typed

recognized handwriting

transcribed speech

Consistent text processing

Consistent user experience

Privacy

Privacy

On-device machine learning

User data stays on-device

Performance

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Chinese tokenization is 30 faster on iOS

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Named Entity Recognition 80 faster on iOS

Performance

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

40000 tokenssec

65000 tokenssec

Named Entity Recognition

Language Support

Language Support

Language identification 29 scripts 52 languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Accuracy

Accuracy

0

20

40

60

80

100

Part of speech

Named entity recognition

English Spanish

Debugging Hints

Debugging Hints

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Explicitly set language if known

Summary

NLP APIsmdashNSLinguisticTagger bull Support for new units bull Faster bull Higher accuracy bull More languages

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

Natural Language Processing

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Confer intelligence

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Linguistics

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Confer intelligence

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Linguistics Machine learning

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Confer intelligence

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Linguistics Machine learning

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Confer intelligence

Natural language text typed

recognized handwriting

transcribed speech

NLP APIs

Enough Tell me how to use them

NLP APIs

NLP APIs

NSLinguisticTagger

NSLinguisticTagger

Class in foundation

Segment and tag text

Linguistic tasks tagSchemes

NSLinguisticTagger

Class in foundation

Segment and tag text

Linguistic tasks tagSchemes

NSLinguisticTaggerNEW

NSLinguisticTagger

Tagging units

NEW

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

Units and schemes

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

Units and schemes

NEW

class func availableTagSchemes (for unit NSLinguisticTaggerUnit language String) -gt [NSLinguisticTagScheme]

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

Units and schemes

NEW

class func availableTagSchemes (for unit NSLinguisticTaggerUnit language String) -gt [NSLinguisticTagScheme]

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTaggerNEW

NSLinguisticTagger

dominantLanguage

NEW

NSLinguisticTagger

dominantLanguage

Swift 4 named types for tags and tagSchemes

NEW

NSLinguisticTagger

dominantLanguage

Swift 4 named types for tags and tagSchemes

Improved performance

Higher accuracy

Additional language support

NEW

Winnow and Whisk

Winnow and Whisk

Winnow and Whisk

Winnow Tag photos with descriptions

Winnow Tag photos with descriptions

Winnow Tag photos with descriptions

We hiked to the top and then ran down Lizzie won

Kids partied with all the goodieshellip

Die Kleinen haben friedlich zusammen gespielt

July 4th 2016hellipsummer parties at the

Holdenrsquos begin

Winnow Search for pictures

Winnow Search for pictures

Hike

Winnow Search for pictures

Hike No results

Winnow Improve search experience using NLP

Winnow Improve search experience using NLP

Hike

Winnow Improve search experience using NLP

We hiked to the top and then ran down Lizzie won

Great hikes make great pics

The hiking boysHolden family loves hiking and also posing for pictures

Hike

Winnow

Winnow

Winnow

NLP

Language identification

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

bullDemo

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Tim Cook Apple Stevie Wonder Cupertino Angela Ahrendts Bruce Wayne Thomas Vintberg

Pharrell NYU

Whisk

Whisk

Whisk

Whisk

NLP

Language identification

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

bullDemo

Why should you use the NLP APIs

Homogeneous Text Processing

Homogeneous Text Processing

NLP APIs

Natural language text typed

recognized handwriting

transcribed speech

Consistent text processing

Consistent user experience

Privacy

Privacy

On-device machine learning

User data stays on-device

Performance

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Chinese tokenization is 30 faster on iOS

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Named Entity Recognition 80 faster on iOS

Performance

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

40000 tokenssec

65000 tokenssec

Named Entity Recognition

Language Support

Language Support

Language identification 29 scripts 52 languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Accuracy

Accuracy

0

20

40

60

80

100

Part of speech

Named entity recognition

English Spanish

Debugging Hints

Debugging Hints

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Explicitly set language if known

Summary

NLP APIsmdashNSLinguisticTagger bull Support for new units bull Faster bull Higher accuracy bull More languages

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

Natural Language Processing

Linguistics

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Confer intelligence

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Linguistics Machine learning

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Confer intelligence

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Linguistics Machine learning

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Confer intelligence

Natural language text typed

recognized handwriting

transcribed speech

NLP APIs

Enough Tell me how to use them

NLP APIs

NLP APIs

NSLinguisticTagger

NSLinguisticTagger

Class in foundation

Segment and tag text

Linguistic tasks tagSchemes

NSLinguisticTagger

Class in foundation

Segment and tag text

Linguistic tasks tagSchemes

NSLinguisticTaggerNEW

NSLinguisticTagger

Tagging units

NEW

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

Units and schemes

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

Units and schemes

NEW

class func availableTagSchemes (for unit NSLinguisticTaggerUnit language String) -gt [NSLinguisticTagScheme]

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

Units and schemes

NEW

class func availableTagSchemes (for unit NSLinguisticTaggerUnit language String) -gt [NSLinguisticTagScheme]

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTaggerNEW

NSLinguisticTagger

dominantLanguage

NEW

NSLinguisticTagger

dominantLanguage

Swift 4 named types for tags and tagSchemes

NEW

NSLinguisticTagger

dominantLanguage

Swift 4 named types for tags and tagSchemes

Improved performance

Higher accuracy

Additional language support

NEW

Winnow and Whisk

Winnow and Whisk

Winnow and Whisk

Winnow Tag photos with descriptions

Winnow Tag photos with descriptions

Winnow Tag photos with descriptions

We hiked to the top and then ran down Lizzie won

Kids partied with all the goodieshellip

Die Kleinen haben friedlich zusammen gespielt

July 4th 2016hellipsummer parties at the

Holdenrsquos begin

Winnow Search for pictures

Winnow Search for pictures

Hike

Winnow Search for pictures

Hike No results

Winnow Improve search experience using NLP

Winnow Improve search experience using NLP

Hike

Winnow Improve search experience using NLP

We hiked to the top and then ran down Lizzie won

Great hikes make great pics

The hiking boysHolden family loves hiking and also posing for pictures

Hike

Winnow

Winnow

Winnow

NLP

Language identification

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

bullDemo

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Tim Cook Apple Stevie Wonder Cupertino Angela Ahrendts Bruce Wayne Thomas Vintberg

Pharrell NYU

Whisk

Whisk

Whisk

Whisk

NLP

Language identification

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

bullDemo

Why should you use the NLP APIs

Homogeneous Text Processing

Homogeneous Text Processing

NLP APIs

Natural language text typed

recognized handwriting

transcribed speech

Consistent text processing

Consistent user experience

Privacy

Privacy

On-device machine learning

User data stays on-device

Performance

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Chinese tokenization is 30 faster on iOS

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Named Entity Recognition 80 faster on iOS

Performance

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

40000 tokenssec

65000 tokenssec

Named Entity Recognition

Language Support

Language Support

Language identification 29 scripts 52 languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Accuracy

Accuracy

0

20

40

60

80

100

Part of speech

Named entity recognition

English Spanish

Debugging Hints

Debugging Hints

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Explicitly set language if known

Summary

NLP APIsmdashNSLinguisticTagger bull Support for new units bull Faster bull Higher accuracy bull More languages

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

Natural Language Processing

Linguistics Machine learning

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Confer intelligence

Natural language text typed

recognized handwriting

transcribed speech

Natural Language Processing

Linguistics Machine learning

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Confer intelligence

Natural language text typed

recognized handwriting

transcribed speech

NLP APIs

Enough Tell me how to use them

NLP APIs

NLP APIs

NSLinguisticTagger

NSLinguisticTagger

Class in foundation

Segment and tag text

Linguistic tasks tagSchemes

NSLinguisticTagger

Class in foundation

Segment and tag text

Linguistic tasks tagSchemes

NSLinguisticTaggerNEW

NSLinguisticTagger

Tagging units

NEW

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

Units and schemes

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

Units and schemes

NEW

class func availableTagSchemes (for unit NSLinguisticTaggerUnit language String) -gt [NSLinguisticTagScheme]

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

Units and schemes

NEW

class func availableTagSchemes (for unit NSLinguisticTaggerUnit language String) -gt [NSLinguisticTagScheme]

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTaggerNEW

NSLinguisticTagger

dominantLanguage

NEW

NSLinguisticTagger

dominantLanguage

Swift 4 named types for tags and tagSchemes

NEW

NSLinguisticTagger

dominantLanguage

Swift 4 named types for tags and tagSchemes

Improved performance

Higher accuracy

Additional language support

NEW

Winnow and Whisk

Winnow and Whisk

Winnow and Whisk

Winnow Tag photos with descriptions

Winnow Tag photos with descriptions

Winnow Tag photos with descriptions

We hiked to the top and then ran down Lizzie won

Kids partied with all the goodieshellip

Die Kleinen haben friedlich zusammen gespielt

July 4th 2016hellipsummer parties at the

Holdenrsquos begin

Winnow Search for pictures

Winnow Search for pictures

Hike

Winnow Search for pictures

Hike No results

Winnow Improve search experience using NLP

Winnow Improve search experience using NLP

Hike

Winnow Improve search experience using NLP

We hiked to the top and then ran down Lizzie won

Great hikes make great pics

The hiking boysHolden family loves hiking and also posing for pictures

Hike

Winnow

Winnow

Winnow

NLP

Language identification

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

bullDemo

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Tim Cook Apple Stevie Wonder Cupertino Angela Ahrendts Bruce Wayne Thomas Vintberg

Pharrell NYU

Whisk

Whisk

Whisk

Whisk

NLP

Language identification

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

bullDemo

Why should you use the NLP APIs

Homogeneous Text Processing

Homogeneous Text Processing

NLP APIs

Natural language text typed

recognized handwriting

transcribed speech

Consistent text processing

Consistent user experience

Privacy

Privacy

On-device machine learning

User data stays on-device

Performance

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Chinese tokenization is 30 faster on iOS

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Named Entity Recognition 80 faster on iOS

Performance

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

40000 tokenssec

65000 tokenssec

Named Entity Recognition

Language Support

Language Support

Language identification 29 scripts 52 languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Accuracy

Accuracy

0

20

40

60

80

100

Part of speech

Named entity recognition

English Spanish

Debugging Hints

Debugging Hints

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Explicitly set language if known

Summary

NLP APIsmdashNSLinguisticTagger bull Support for new units bull Faster bull Higher accuracy bull More languages

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

Natural Language Processing

Linguistics Machine learning

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Named entity recognition

Confer intelligence

Natural language text typed

recognized handwriting

transcribed speech

NLP APIs

Enough Tell me how to use them

NLP APIs

NLP APIs

NSLinguisticTagger

NSLinguisticTagger

Class in foundation

Segment and tag text

Linguistic tasks tagSchemes

NSLinguisticTagger

Class in foundation

Segment and tag text

Linguistic tasks tagSchemes

NSLinguisticTaggerNEW

NSLinguisticTagger

Tagging units

NEW

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

Units and schemes

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

Units and schemes

NEW

class func availableTagSchemes (for unit NSLinguisticTaggerUnit language String) -gt [NSLinguisticTagScheme]

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

Units and schemes

NEW

class func availableTagSchemes (for unit NSLinguisticTaggerUnit language String) -gt [NSLinguisticTagScheme]

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTaggerNEW

NSLinguisticTagger

dominantLanguage

NEW

NSLinguisticTagger

dominantLanguage

Swift 4 named types for tags and tagSchemes

NEW

NSLinguisticTagger

dominantLanguage

Swift 4 named types for tags and tagSchemes

Improved performance

Higher accuracy

Additional language support

NEW

Winnow and Whisk

Winnow and Whisk

Winnow and Whisk

Winnow Tag photos with descriptions

Winnow Tag photos with descriptions

Winnow Tag photos with descriptions

We hiked to the top and then ran down Lizzie won

Kids partied with all the goodieshellip

Die Kleinen haben friedlich zusammen gespielt

July 4th 2016hellipsummer parties at the

Holdenrsquos begin

Winnow Search for pictures

Winnow Search for pictures

Hike

Winnow Search for pictures

Hike No results

Winnow Improve search experience using NLP

Winnow Improve search experience using NLP

Hike

Winnow Improve search experience using NLP

We hiked to the top and then ran down Lizzie won

Great hikes make great pics

The hiking boysHolden family loves hiking and also posing for pictures

Hike

Winnow

Winnow

Winnow

NLP

Language identification

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

bullDemo

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Tim Cook Apple Stevie Wonder Cupertino Angela Ahrendts Bruce Wayne Thomas Vintberg

Pharrell NYU

Whisk

Whisk

Whisk

Whisk

NLP

Language identification

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

bullDemo

Why should you use the NLP APIs

Homogeneous Text Processing

Homogeneous Text Processing

NLP APIs

Natural language text typed

recognized handwriting

transcribed speech

Consistent text processing

Consistent user experience

Privacy

Privacy

On-device machine learning

User data stays on-device

Performance

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Chinese tokenization is 30 faster on iOS

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Named Entity Recognition 80 faster on iOS

Performance

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

40000 tokenssec

65000 tokenssec

Named Entity Recognition

Language Support

Language Support

Language identification 29 scripts 52 languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Accuracy

Accuracy

0

20

40

60

80

100

Part of speech

Named entity recognition

English Spanish

Debugging Hints

Debugging Hints

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Explicitly set language if known

Summary

NLP APIsmdashNSLinguisticTagger bull Support for new units bull Faster bull Higher accuracy bull More languages

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

Enough Tell me how to use them

NLP APIs

NLP APIs

NSLinguisticTagger

NSLinguisticTagger

Class in foundation

Segment and tag text

Linguistic tasks tagSchemes

NSLinguisticTagger

Class in foundation

Segment and tag text

Linguistic tasks tagSchemes

NSLinguisticTaggerNEW

NSLinguisticTagger

Tagging units

NEW

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

Units and schemes

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

Units and schemes

NEW

class func availableTagSchemes (for unit NSLinguisticTaggerUnit language String) -gt [NSLinguisticTagScheme]

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

Units and schemes

NEW

class func availableTagSchemes (for unit NSLinguisticTaggerUnit language String) -gt [NSLinguisticTagScheme]

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTaggerNEW

NSLinguisticTagger

dominantLanguage

NEW

NSLinguisticTagger

dominantLanguage

Swift 4 named types for tags and tagSchemes

NEW

NSLinguisticTagger

dominantLanguage

Swift 4 named types for tags and tagSchemes

Improved performance

Higher accuracy

Additional language support

NEW

Winnow and Whisk

Winnow and Whisk

Winnow and Whisk

Winnow Tag photos with descriptions

Winnow Tag photos with descriptions

Winnow Tag photos with descriptions

We hiked to the top and then ran down Lizzie won

Kids partied with all the goodieshellip

Die Kleinen haben friedlich zusammen gespielt

July 4th 2016hellipsummer parties at the

Holdenrsquos begin

Winnow Search for pictures

Winnow Search for pictures

Hike

Winnow Search for pictures

Hike No results

Winnow Improve search experience using NLP

Winnow Improve search experience using NLP

Hike

Winnow Improve search experience using NLP

We hiked to the top and then ran down Lizzie won

Great hikes make great pics

The hiking boysHolden family loves hiking and also posing for pictures

Hike

Winnow

Winnow

Winnow

NLP

Language identification

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

bullDemo

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Tim Cook Apple Stevie Wonder Cupertino Angela Ahrendts Bruce Wayne Thomas Vintberg

Pharrell NYU

Whisk

Whisk

Whisk

Whisk

NLP

Language identification

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

bullDemo

Why should you use the NLP APIs

Homogeneous Text Processing

Homogeneous Text Processing

NLP APIs

Natural language text typed

recognized handwriting

transcribed speech

Consistent text processing

Consistent user experience

Privacy

Privacy

On-device machine learning

User data stays on-device

Performance

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Chinese tokenization is 30 faster on iOS

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Named Entity Recognition 80 faster on iOS

Performance

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

40000 tokenssec

65000 tokenssec

Named Entity Recognition

Language Support

Language Support

Language identification 29 scripts 52 languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Accuracy

Accuracy

0

20

40

60

80

100

Part of speech

Named entity recognition

English Spanish

Debugging Hints

Debugging Hints

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Explicitly set language if known

Summary

NLP APIsmdashNSLinguisticTagger bull Support for new units bull Faster bull Higher accuracy bull More languages

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

NLP APIs

NLP APIs

NSLinguisticTagger

NSLinguisticTagger

Class in foundation

Segment and tag text

Linguistic tasks tagSchemes

NSLinguisticTagger

Class in foundation

Segment and tag text

Linguistic tasks tagSchemes

NSLinguisticTaggerNEW

NSLinguisticTagger

Tagging units

NEW

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

Units and schemes

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

Units and schemes

NEW

class func availableTagSchemes (for unit NSLinguisticTaggerUnit language String) -gt [NSLinguisticTagScheme]

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

Units and schemes

NEW

class func availableTagSchemes (for unit NSLinguisticTaggerUnit language String) -gt [NSLinguisticTagScheme]

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTaggerNEW

NSLinguisticTagger

dominantLanguage

NEW

NSLinguisticTagger

dominantLanguage

Swift 4 named types for tags and tagSchemes

NEW

NSLinguisticTagger

dominantLanguage

Swift 4 named types for tags and tagSchemes

Improved performance

Higher accuracy

Additional language support

NEW

Winnow and Whisk

Winnow and Whisk

Winnow and Whisk

Winnow Tag photos with descriptions

Winnow Tag photos with descriptions

Winnow Tag photos with descriptions

We hiked to the top and then ran down Lizzie won

Kids partied with all the goodieshellip

Die Kleinen haben friedlich zusammen gespielt

July 4th 2016hellipsummer parties at the

Holdenrsquos begin

Winnow Search for pictures

Winnow Search for pictures

Hike

Winnow Search for pictures

Hike No results

Winnow Improve search experience using NLP

Winnow Improve search experience using NLP

Hike

Winnow Improve search experience using NLP

We hiked to the top and then ran down Lizzie won

Great hikes make great pics

The hiking boysHolden family loves hiking and also posing for pictures

Hike

Winnow

Winnow

Winnow

NLP

Language identification

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

bullDemo

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Tim Cook Apple Stevie Wonder Cupertino Angela Ahrendts Bruce Wayne Thomas Vintberg

Pharrell NYU

Whisk

Whisk

Whisk

Whisk

NLP

Language identification

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

bullDemo

Why should you use the NLP APIs

Homogeneous Text Processing

Homogeneous Text Processing

NLP APIs

Natural language text typed

recognized handwriting

transcribed speech

Consistent text processing

Consistent user experience

Privacy

Privacy

On-device machine learning

User data stays on-device

Performance

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Chinese tokenization is 30 faster on iOS

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Named Entity Recognition 80 faster on iOS

Performance

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

40000 tokenssec

65000 tokenssec

Named Entity Recognition

Language Support

Language Support

Language identification 29 scripts 52 languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Accuracy

Accuracy

0

20

40

60

80

100

Part of speech

Named entity recognition

English Spanish

Debugging Hints

Debugging Hints

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Explicitly set language if known

Summary

NLP APIsmdashNSLinguisticTagger bull Support for new units bull Faster bull Higher accuracy bull More languages

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

NLP APIs

NSLinguisticTagger

NSLinguisticTagger

Class in foundation

Segment and tag text

Linguistic tasks tagSchemes

NSLinguisticTagger

Class in foundation

Segment and tag text

Linguistic tasks tagSchemes

NSLinguisticTaggerNEW

NSLinguisticTagger

Tagging units

NEW

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

Units and schemes

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

Units and schemes

NEW

class func availableTagSchemes (for unit NSLinguisticTaggerUnit language String) -gt [NSLinguisticTagScheme]

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

Units and schemes

NEW

class func availableTagSchemes (for unit NSLinguisticTaggerUnit language String) -gt [NSLinguisticTagScheme]

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTaggerNEW

NSLinguisticTagger

dominantLanguage

NEW

NSLinguisticTagger

dominantLanguage

Swift 4 named types for tags and tagSchemes

NEW

NSLinguisticTagger

dominantLanguage

Swift 4 named types for tags and tagSchemes

Improved performance

Higher accuracy

Additional language support

NEW

Winnow and Whisk

Winnow and Whisk

Winnow and Whisk

Winnow Tag photos with descriptions

Winnow Tag photos with descriptions

Winnow Tag photos with descriptions

We hiked to the top and then ran down Lizzie won

Kids partied with all the goodieshellip

Die Kleinen haben friedlich zusammen gespielt

July 4th 2016hellipsummer parties at the

Holdenrsquos begin

Winnow Search for pictures

Winnow Search for pictures

Hike

Winnow Search for pictures

Hike No results

Winnow Improve search experience using NLP

Winnow Improve search experience using NLP

Hike

Winnow Improve search experience using NLP

We hiked to the top and then ran down Lizzie won

Great hikes make great pics

The hiking boysHolden family loves hiking and also posing for pictures

Hike

Winnow

Winnow

Winnow

NLP

Language identification

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

bullDemo

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Tim Cook Apple Stevie Wonder Cupertino Angela Ahrendts Bruce Wayne Thomas Vintberg

Pharrell NYU

Whisk

Whisk

Whisk

Whisk

NLP

Language identification

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

bullDemo

Why should you use the NLP APIs

Homogeneous Text Processing

Homogeneous Text Processing

NLP APIs

Natural language text typed

recognized handwriting

transcribed speech

Consistent text processing

Consistent user experience

Privacy

Privacy

On-device machine learning

User data stays on-device

Performance

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Chinese tokenization is 30 faster on iOS

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Named Entity Recognition 80 faster on iOS

Performance

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

40000 tokenssec

65000 tokenssec

Named Entity Recognition

Language Support

Language Support

Language identification 29 scripts 52 languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Accuracy

Accuracy

0

20

40

60

80

100

Part of speech

Named entity recognition

English Spanish

Debugging Hints

Debugging Hints

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Explicitly set language if known

Summary

NLP APIsmdashNSLinguisticTagger bull Support for new units bull Faster bull Higher accuracy bull More languages

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

NSLinguisticTagger

Class in foundation

Segment and tag text

Linguistic tasks tagSchemes

NSLinguisticTagger

Class in foundation

Segment and tag text

Linguistic tasks tagSchemes

NSLinguisticTaggerNEW

NSLinguisticTagger

Tagging units

NEW

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

Units and schemes

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

Units and schemes

NEW

class func availableTagSchemes (for unit NSLinguisticTaggerUnit language String) -gt [NSLinguisticTagScheme]

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

Units and schemes

NEW

class func availableTagSchemes (for unit NSLinguisticTaggerUnit language String) -gt [NSLinguisticTagScheme]

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTaggerNEW

NSLinguisticTagger

dominantLanguage

NEW

NSLinguisticTagger

dominantLanguage

Swift 4 named types for tags and tagSchemes

NEW

NSLinguisticTagger

dominantLanguage

Swift 4 named types for tags and tagSchemes

Improved performance

Higher accuracy

Additional language support

NEW

Winnow and Whisk

Winnow and Whisk

Winnow and Whisk

Winnow Tag photos with descriptions

Winnow Tag photos with descriptions

Winnow Tag photos with descriptions

We hiked to the top and then ran down Lizzie won

Kids partied with all the goodieshellip

Die Kleinen haben friedlich zusammen gespielt

July 4th 2016hellipsummer parties at the

Holdenrsquos begin

Winnow Search for pictures

Winnow Search for pictures

Hike

Winnow Search for pictures

Hike No results

Winnow Improve search experience using NLP

Winnow Improve search experience using NLP

Hike

Winnow Improve search experience using NLP

We hiked to the top and then ran down Lizzie won

Great hikes make great pics

The hiking boysHolden family loves hiking and also posing for pictures

Hike

Winnow

Winnow

Winnow

NLP

Language identification

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

bullDemo

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Tim Cook Apple Stevie Wonder Cupertino Angela Ahrendts Bruce Wayne Thomas Vintberg

Pharrell NYU

Whisk

Whisk

Whisk

Whisk

NLP

Language identification

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

bullDemo

Why should you use the NLP APIs

Homogeneous Text Processing

Homogeneous Text Processing

NLP APIs

Natural language text typed

recognized handwriting

transcribed speech

Consistent text processing

Consistent user experience

Privacy

Privacy

On-device machine learning

User data stays on-device

Performance

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Chinese tokenization is 30 faster on iOS

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Named Entity Recognition 80 faster on iOS

Performance

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

40000 tokenssec

65000 tokenssec

Named Entity Recognition

Language Support

Language Support

Language identification 29 scripts 52 languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Accuracy

Accuracy

0

20

40

60

80

100

Part of speech

Named entity recognition

English Spanish

Debugging Hints

Debugging Hints

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Explicitly set language if known

Summary

NLP APIsmdashNSLinguisticTagger bull Support for new units bull Faster bull Higher accuracy bull More languages

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

NSLinguisticTagger

Class in foundation

Segment and tag text

Linguistic tasks tagSchemes

NSLinguisticTaggerNEW

NSLinguisticTagger

Tagging units

NEW

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

Units and schemes

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

Units and schemes

NEW

class func availableTagSchemes (for unit NSLinguisticTaggerUnit language String) -gt [NSLinguisticTagScheme]

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

Units and schemes

NEW

class func availableTagSchemes (for unit NSLinguisticTaggerUnit language String) -gt [NSLinguisticTagScheme]

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTaggerNEW

NSLinguisticTagger

dominantLanguage

NEW

NSLinguisticTagger

dominantLanguage

Swift 4 named types for tags and tagSchemes

NEW

NSLinguisticTagger

dominantLanguage

Swift 4 named types for tags and tagSchemes

Improved performance

Higher accuracy

Additional language support

NEW

Winnow and Whisk

Winnow and Whisk

Winnow and Whisk

Winnow Tag photos with descriptions

Winnow Tag photos with descriptions

Winnow Tag photos with descriptions

We hiked to the top and then ran down Lizzie won

Kids partied with all the goodieshellip

Die Kleinen haben friedlich zusammen gespielt

July 4th 2016hellipsummer parties at the

Holdenrsquos begin

Winnow Search for pictures

Winnow Search for pictures

Hike

Winnow Search for pictures

Hike No results

Winnow Improve search experience using NLP

Winnow Improve search experience using NLP

Hike

Winnow Improve search experience using NLP

We hiked to the top and then ran down Lizzie won

Great hikes make great pics

The hiking boysHolden family loves hiking and also posing for pictures

Hike

Winnow

Winnow

Winnow

NLP

Language identification

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

bullDemo

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Tim Cook Apple Stevie Wonder Cupertino Angela Ahrendts Bruce Wayne Thomas Vintberg

Pharrell NYU

Whisk

Whisk

Whisk

Whisk

NLP

Language identification

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

bullDemo

Why should you use the NLP APIs

Homogeneous Text Processing

Homogeneous Text Processing

NLP APIs

Natural language text typed

recognized handwriting

transcribed speech

Consistent text processing

Consistent user experience

Privacy

Privacy

On-device machine learning

User data stays on-device

Performance

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Chinese tokenization is 30 faster on iOS

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Named Entity Recognition 80 faster on iOS

Performance

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

40000 tokenssec

65000 tokenssec

Named Entity Recognition

Language Support

Language Support

Language identification 29 scripts 52 languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Accuracy

Accuracy

0

20

40

60

80

100

Part of speech

Named entity recognition

English Spanish

Debugging Hints

Debugging Hints

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Explicitly set language if known

Summary

NLP APIsmdashNSLinguisticTagger bull Support for new units bull Faster bull Higher accuracy bull More languages

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

NSLinguisticTaggerNEW

NSLinguisticTagger

Tagging units

NEW

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

Units and schemes

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

Units and schemes

NEW

class func availableTagSchemes (for unit NSLinguisticTaggerUnit language String) -gt [NSLinguisticTagScheme]

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

Units and schemes

NEW

class func availableTagSchemes (for unit NSLinguisticTaggerUnit language String) -gt [NSLinguisticTagScheme]

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTaggerNEW

NSLinguisticTagger

dominantLanguage

NEW

NSLinguisticTagger

dominantLanguage

Swift 4 named types for tags and tagSchemes

NEW

NSLinguisticTagger

dominantLanguage

Swift 4 named types for tags and tagSchemes

Improved performance

Higher accuracy

Additional language support

NEW

Winnow and Whisk

Winnow and Whisk

Winnow and Whisk

Winnow Tag photos with descriptions

Winnow Tag photos with descriptions

Winnow Tag photos with descriptions

We hiked to the top and then ran down Lizzie won

Kids partied with all the goodieshellip

Die Kleinen haben friedlich zusammen gespielt

July 4th 2016hellipsummer parties at the

Holdenrsquos begin

Winnow Search for pictures

Winnow Search for pictures

Hike

Winnow Search for pictures

Hike No results

Winnow Improve search experience using NLP

Winnow Improve search experience using NLP

Hike

Winnow Improve search experience using NLP

We hiked to the top and then ran down Lizzie won

Great hikes make great pics

The hiking boysHolden family loves hiking and also posing for pictures

Hike

Winnow

Winnow

Winnow

NLP

Language identification

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

bullDemo

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Tim Cook Apple Stevie Wonder Cupertino Angela Ahrendts Bruce Wayne Thomas Vintberg

Pharrell NYU

Whisk

Whisk

Whisk

Whisk

NLP

Language identification

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

bullDemo

Why should you use the NLP APIs

Homogeneous Text Processing

Homogeneous Text Processing

NLP APIs

Natural language text typed

recognized handwriting

transcribed speech

Consistent text processing

Consistent user experience

Privacy

Privacy

On-device machine learning

User data stays on-device

Performance

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Chinese tokenization is 30 faster on iOS

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Named Entity Recognition 80 faster on iOS

Performance

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

40000 tokenssec

65000 tokenssec

Named Entity Recognition

Language Support

Language Support

Language identification 29 scripts 52 languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Accuracy

Accuracy

0

20

40

60

80

100

Part of speech

Named entity recognition

English Spanish

Debugging Hints

Debugging Hints

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Explicitly set language if known

Summary

NLP APIsmdashNSLinguisticTagger bull Support for new units bull Faster bull Higher accuracy bull More languages

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

NSLinguisticTagger

Tagging units

NEW

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

Units and schemes

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

Units and schemes

NEW

class func availableTagSchemes (for unit NSLinguisticTaggerUnit language String) -gt [NSLinguisticTagScheme]

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

Units and schemes

NEW

class func availableTagSchemes (for unit NSLinguisticTaggerUnit language String) -gt [NSLinguisticTagScheme]

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTaggerNEW

NSLinguisticTagger

dominantLanguage

NEW

NSLinguisticTagger

dominantLanguage

Swift 4 named types for tags and tagSchemes

NEW

NSLinguisticTagger

dominantLanguage

Swift 4 named types for tags and tagSchemes

Improved performance

Higher accuracy

Additional language support

NEW

Winnow and Whisk

Winnow and Whisk

Winnow and Whisk

Winnow Tag photos with descriptions

Winnow Tag photos with descriptions

Winnow Tag photos with descriptions

We hiked to the top and then ran down Lizzie won

Kids partied with all the goodieshellip

Die Kleinen haben friedlich zusammen gespielt

July 4th 2016hellipsummer parties at the

Holdenrsquos begin

Winnow Search for pictures

Winnow Search for pictures

Hike

Winnow Search for pictures

Hike No results

Winnow Improve search experience using NLP

Winnow Improve search experience using NLP

Hike

Winnow Improve search experience using NLP

We hiked to the top and then ran down Lizzie won

Great hikes make great pics

The hiking boysHolden family loves hiking and also posing for pictures

Hike

Winnow

Winnow

Winnow

NLP

Language identification

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

bullDemo

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Tim Cook Apple Stevie Wonder Cupertino Angela Ahrendts Bruce Wayne Thomas Vintberg

Pharrell NYU

Whisk

Whisk

Whisk

Whisk

NLP

Language identification

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

bullDemo

Why should you use the NLP APIs

Homogeneous Text Processing

Homogeneous Text Processing

NLP APIs

Natural language text typed

recognized handwriting

transcribed speech

Consistent text processing

Consistent user experience

Privacy

Privacy

On-device machine learning

User data stays on-device

Performance

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Chinese tokenization is 30 faster on iOS

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Named Entity Recognition 80 faster on iOS

Performance

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

40000 tokenssec

65000 tokenssec

Named Entity Recognition

Language Support

Language Support

Language identification 29 scripts 52 languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Accuracy

Accuracy

0

20

40

60

80

100

Part of speech

Named entity recognition

English Spanish

Debugging Hints

Debugging Hints

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Explicitly set language if known

Summary

NLP APIsmdashNSLinguisticTagger bull Support for new units bull Faster bull Higher accuracy bull More languages

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

Units and schemes

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

Units and schemes

NEW

class func availableTagSchemes (for unit NSLinguisticTaggerUnit language String) -gt [NSLinguisticTagScheme]

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

Units and schemes

NEW

class func availableTagSchemes (for unit NSLinguisticTaggerUnit language String) -gt [NSLinguisticTagScheme]

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTaggerNEW

NSLinguisticTagger

dominantLanguage

NEW

NSLinguisticTagger

dominantLanguage

Swift 4 named types for tags and tagSchemes

NEW

NSLinguisticTagger

dominantLanguage

Swift 4 named types for tags and tagSchemes

Improved performance

Higher accuracy

Additional language support

NEW

Winnow and Whisk

Winnow and Whisk

Winnow and Whisk

Winnow Tag photos with descriptions

Winnow Tag photos with descriptions

Winnow Tag photos with descriptions

We hiked to the top and then ran down Lizzie won

Kids partied with all the goodieshellip

Die Kleinen haben friedlich zusammen gespielt

July 4th 2016hellipsummer parties at the

Holdenrsquos begin

Winnow Search for pictures

Winnow Search for pictures

Hike

Winnow Search for pictures

Hike No results

Winnow Improve search experience using NLP

Winnow Improve search experience using NLP

Hike

Winnow Improve search experience using NLP

We hiked to the top and then ran down Lizzie won

Great hikes make great pics

The hiking boysHolden family loves hiking and also posing for pictures

Hike

Winnow

Winnow

Winnow

NLP

Language identification

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

bullDemo

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Tim Cook Apple Stevie Wonder Cupertino Angela Ahrendts Bruce Wayne Thomas Vintberg

Pharrell NYU

Whisk

Whisk

Whisk

Whisk

NLP

Language identification

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

bullDemo

Why should you use the NLP APIs

Homogeneous Text Processing

Homogeneous Text Processing

NLP APIs

Natural language text typed

recognized handwriting

transcribed speech

Consistent text processing

Consistent user experience

Privacy

Privacy

On-device machine learning

User data stays on-device

Performance

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Chinese tokenization is 30 faster on iOS

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Named Entity Recognition 80 faster on iOS

Performance

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

40000 tokenssec

65000 tokenssec

Named Entity Recognition

Language Support

Language Support

Language identification 29 scripts 52 languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Accuracy

Accuracy

0

20

40

60

80

100

Part of speech

Named entity recognition

English Spanish

Debugging Hints

Debugging Hints

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Explicitly set language if known

Summary

NLP APIsmdashNSLinguisticTagger bull Support for new units bull Faster bull Higher accuracy bull More languages

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

Units and schemes

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

Units and schemes

NEW

class func availableTagSchemes (for unit NSLinguisticTaggerUnit language String) -gt [NSLinguisticTagScheme]

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

Units and schemes

NEW

class func availableTagSchemes (for unit NSLinguisticTaggerUnit language String) -gt [NSLinguisticTagScheme]

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTaggerNEW

NSLinguisticTagger

dominantLanguage

NEW

NSLinguisticTagger

dominantLanguage

Swift 4 named types for tags and tagSchemes

NEW

NSLinguisticTagger

dominantLanguage

Swift 4 named types for tags and tagSchemes

Improved performance

Higher accuracy

Additional language support

NEW

Winnow and Whisk

Winnow and Whisk

Winnow and Whisk

Winnow Tag photos with descriptions

Winnow Tag photos with descriptions

Winnow Tag photos with descriptions

We hiked to the top and then ran down Lizzie won

Kids partied with all the goodieshellip

Die Kleinen haben friedlich zusammen gespielt

July 4th 2016hellipsummer parties at the

Holdenrsquos begin

Winnow Search for pictures

Winnow Search for pictures

Hike

Winnow Search for pictures

Hike No results

Winnow Improve search experience using NLP

Winnow Improve search experience using NLP

Hike

Winnow Improve search experience using NLP

We hiked to the top and then ran down Lizzie won

Great hikes make great pics

The hiking boysHolden family loves hiking and also posing for pictures

Hike

Winnow

Winnow

Winnow

NLP

Language identification

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

bullDemo

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Tim Cook Apple Stevie Wonder Cupertino Angela Ahrendts Bruce Wayne Thomas Vintberg

Pharrell NYU

Whisk

Whisk

Whisk

Whisk

NLP

Language identification

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

bullDemo

Why should you use the NLP APIs

Homogeneous Text Processing

Homogeneous Text Processing

NLP APIs

Natural language text typed

recognized handwriting

transcribed speech

Consistent text processing

Consistent user experience

Privacy

Privacy

On-device machine learning

User data stays on-device

Performance

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Chinese tokenization is 30 faster on iOS

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Named Entity Recognition 80 faster on iOS

Performance

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

40000 tokenssec

65000 tokenssec

Named Entity Recognition

Language Support

Language Support

Language identification 29 scripts 52 languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Accuracy

Accuracy

0

20

40

60

80

100

Part of speech

Named entity recognition

English Spanish

Debugging Hints

Debugging Hints

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Explicitly set language if known

Summary

NLP APIsmdashNSLinguisticTagger bull Support for new units bull Faster bull Higher accuracy bull More languages

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

Units and schemes

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

Units and schemes

NEW

class func availableTagSchemes (for unit NSLinguisticTaggerUnit language String) -gt [NSLinguisticTagScheme]

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

Units and schemes

NEW

class func availableTagSchemes (for unit NSLinguisticTaggerUnit language String) -gt [NSLinguisticTagScheme]

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTaggerNEW

NSLinguisticTagger

dominantLanguage

NEW

NSLinguisticTagger

dominantLanguage

Swift 4 named types for tags and tagSchemes

NEW

NSLinguisticTagger

dominantLanguage

Swift 4 named types for tags and tagSchemes

Improved performance

Higher accuracy

Additional language support

NEW

Winnow and Whisk

Winnow and Whisk

Winnow and Whisk

Winnow Tag photos with descriptions

Winnow Tag photos with descriptions

Winnow Tag photos with descriptions

We hiked to the top and then ran down Lizzie won

Kids partied with all the goodieshellip

Die Kleinen haben friedlich zusammen gespielt

July 4th 2016hellipsummer parties at the

Holdenrsquos begin

Winnow Search for pictures

Winnow Search for pictures

Hike

Winnow Search for pictures

Hike No results

Winnow Improve search experience using NLP

Winnow Improve search experience using NLP

Hike

Winnow Improve search experience using NLP

We hiked to the top and then ran down Lizzie won

Great hikes make great pics

The hiking boysHolden family loves hiking and also posing for pictures

Hike

Winnow

Winnow

Winnow

NLP

Language identification

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

bullDemo

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Tim Cook Apple Stevie Wonder Cupertino Angela Ahrendts Bruce Wayne Thomas Vintberg

Pharrell NYU

Whisk

Whisk

Whisk

Whisk

NLP

Language identification

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

bullDemo

Why should you use the NLP APIs

Homogeneous Text Processing

Homogeneous Text Processing

NLP APIs

Natural language text typed

recognized handwriting

transcribed speech

Consistent text processing

Consistent user experience

Privacy

Privacy

On-device machine learning

User data stays on-device

Performance

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Chinese tokenization is 30 faster on iOS

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Named Entity Recognition 80 faster on iOS

Performance

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

40000 tokenssec

65000 tokenssec

Named Entity Recognition

Language Support

Language Support

Language identification 29 scripts 52 languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Accuracy

Accuracy

0

20

40

60

80

100

Part of speech

Named entity recognition

English Spanish

Debugging Hints

Debugging Hints

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Explicitly set language if known

Summary

NLP APIsmdashNSLinguisticTagger bull Support for new units bull Faster bull Higher accuracy bull More languages

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

Units and schemes

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

Units and schemes

NEW

class func availableTagSchemes (for unit NSLinguisticTaggerUnit language String) -gt [NSLinguisticTagScheme]

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

Units and schemes

NEW

class func availableTagSchemes (for unit NSLinguisticTaggerUnit language String) -gt [NSLinguisticTagScheme]

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTaggerNEW

NSLinguisticTagger

dominantLanguage

NEW

NSLinguisticTagger

dominantLanguage

Swift 4 named types for tags and tagSchemes

NEW

NSLinguisticTagger

dominantLanguage

Swift 4 named types for tags and tagSchemes

Improved performance

Higher accuracy

Additional language support

NEW

Winnow and Whisk

Winnow and Whisk

Winnow and Whisk

Winnow Tag photos with descriptions

Winnow Tag photos with descriptions

Winnow Tag photos with descriptions

We hiked to the top and then ran down Lizzie won

Kids partied with all the goodieshellip

Die Kleinen haben friedlich zusammen gespielt

July 4th 2016hellipsummer parties at the

Holdenrsquos begin

Winnow Search for pictures

Winnow Search for pictures

Hike

Winnow Search for pictures

Hike No results

Winnow Improve search experience using NLP

Winnow Improve search experience using NLP

Hike

Winnow Improve search experience using NLP

We hiked to the top and then ran down Lizzie won

Great hikes make great pics

The hiking boysHolden family loves hiking and also posing for pictures

Hike

Winnow

Winnow

Winnow

NLP

Language identification

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

bullDemo

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Tim Cook Apple Stevie Wonder Cupertino Angela Ahrendts Bruce Wayne Thomas Vintberg

Pharrell NYU

Whisk

Whisk

Whisk

Whisk

NLP

Language identification

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

bullDemo

Why should you use the NLP APIs

Homogeneous Text Processing

Homogeneous Text Processing

NLP APIs

Natural language text typed

recognized handwriting

transcribed speech

Consistent text processing

Consistent user experience

Privacy

Privacy

On-device machine learning

User data stays on-device

Performance

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Chinese tokenization is 30 faster on iOS

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Named Entity Recognition 80 faster on iOS

Performance

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

40000 tokenssec

65000 tokenssec

Named Entity Recognition

Language Support

Language Support

Language identification 29 scripts 52 languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Accuracy

Accuracy

0

20

40

60

80

100

Part of speech

Named entity recognition

English Spanish

Debugging Hints

Debugging Hints

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Explicitly set language if known

Summary

NLP APIsmdashNSLinguisticTagger bull Support for new units bull Faster bull Higher accuracy bull More languages

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

NSLinguisticTagger

Tagging units

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

Units and schemes

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

Units and schemes

NEW

class func availableTagSchemes (for unit NSLinguisticTaggerUnit language String) -gt [NSLinguisticTagScheme]

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

Units and schemes

NEW

class func availableTagSchemes (for unit NSLinguisticTaggerUnit language String) -gt [NSLinguisticTagScheme]

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTaggerNEW

NSLinguisticTagger

dominantLanguage

NEW

NSLinguisticTagger

dominantLanguage

Swift 4 named types for tags and tagSchemes

NEW

NSLinguisticTagger

dominantLanguage

Swift 4 named types for tags and tagSchemes

Improved performance

Higher accuracy

Additional language support

NEW

Winnow and Whisk

Winnow and Whisk

Winnow and Whisk

Winnow Tag photos with descriptions

Winnow Tag photos with descriptions

Winnow Tag photos with descriptions

We hiked to the top and then ran down Lizzie won

Kids partied with all the goodieshellip

Die Kleinen haben friedlich zusammen gespielt

July 4th 2016hellipsummer parties at the

Holdenrsquos begin

Winnow Search for pictures

Winnow Search for pictures

Hike

Winnow Search for pictures

Hike No results

Winnow Improve search experience using NLP

Winnow Improve search experience using NLP

Hike

Winnow Improve search experience using NLP

We hiked to the top and then ran down Lizzie won

Great hikes make great pics

The hiking boysHolden family loves hiking and also posing for pictures

Hike

Winnow

Winnow

Winnow

NLP

Language identification

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

bullDemo

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Tim Cook Apple Stevie Wonder Cupertino Angela Ahrendts Bruce Wayne Thomas Vintberg

Pharrell NYU

Whisk

Whisk

Whisk

Whisk

NLP

Language identification

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

bullDemo

Why should you use the NLP APIs

Homogeneous Text Processing

Homogeneous Text Processing

NLP APIs

Natural language text typed

recognized handwriting

transcribed speech

Consistent text processing

Consistent user experience

Privacy

Privacy

On-device machine learning

User data stays on-device

Performance

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Chinese tokenization is 30 faster on iOS

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Named Entity Recognition 80 faster on iOS

Performance

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

40000 tokenssec

65000 tokenssec

Named Entity Recognition

Language Support

Language Support

Language identification 29 scripts 52 languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Accuracy

Accuracy

0

20

40

60

80

100

Part of speech

Named entity recognition

English Spanish

Debugging Hints

Debugging Hints

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Explicitly set language if known

Summary

NLP APIsmdashNSLinguisticTagger bull Support for new units bull Faster bull Higher accuracy bull More languages

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

NSLinguisticTagger

Tagging units

Units and schemes

NEW

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

Units and schemes

NEW

class func availableTagSchemes (for unit NSLinguisticTaggerUnit language String) -gt [NSLinguisticTagScheme]

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

Units and schemes

NEW

class func availableTagSchemes (for unit NSLinguisticTaggerUnit language String) -gt [NSLinguisticTagScheme]

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTaggerNEW

NSLinguisticTagger

dominantLanguage

NEW

NSLinguisticTagger

dominantLanguage

Swift 4 named types for tags and tagSchemes

NEW

NSLinguisticTagger

dominantLanguage

Swift 4 named types for tags and tagSchemes

Improved performance

Higher accuracy

Additional language support

NEW

Winnow and Whisk

Winnow and Whisk

Winnow and Whisk

Winnow Tag photos with descriptions

Winnow Tag photos with descriptions

Winnow Tag photos with descriptions

We hiked to the top and then ran down Lizzie won

Kids partied with all the goodieshellip

Die Kleinen haben friedlich zusammen gespielt

July 4th 2016hellipsummer parties at the

Holdenrsquos begin

Winnow Search for pictures

Winnow Search for pictures

Hike

Winnow Search for pictures

Hike No results

Winnow Improve search experience using NLP

Winnow Improve search experience using NLP

Hike

Winnow Improve search experience using NLP

We hiked to the top and then ran down Lizzie won

Great hikes make great pics

The hiking boysHolden family loves hiking and also posing for pictures

Hike

Winnow

Winnow

Winnow

NLP

Language identification

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

bullDemo

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Tim Cook Apple Stevie Wonder Cupertino Angela Ahrendts Bruce Wayne Thomas Vintberg

Pharrell NYU

Whisk

Whisk

Whisk

Whisk

NLP

Language identification

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

bullDemo

Why should you use the NLP APIs

Homogeneous Text Processing

Homogeneous Text Processing

NLP APIs

Natural language text typed

recognized handwriting

transcribed speech

Consistent text processing

Consistent user experience

Privacy

Privacy

On-device machine learning

User data stays on-device

Performance

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Chinese tokenization is 30 faster on iOS

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Named Entity Recognition 80 faster on iOS

Performance

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

40000 tokenssec

65000 tokenssec

Named Entity Recognition

Language Support

Language Support

Language identification 29 scripts 52 languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Accuracy

Accuracy

0

20

40

60

80

100

Part of speech

Named entity recognition

English Spanish

Debugging Hints

Debugging Hints

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Explicitly set language if known

Summary

NLP APIsmdashNSLinguisticTagger bull Support for new units bull Faster bull Higher accuracy bull More languages

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

NSLinguisticTagger

Tagging units

Units and schemes

NEW

class func availableTagSchemes (for unit NSLinguisticTaggerUnit language String) -gt [NSLinguisticTagScheme]

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTagger

Tagging units

Units and schemes

NEW

class func availableTagSchemes (for unit NSLinguisticTaggerUnit language String) -gt [NSLinguisticTagScheme]

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTaggerNEW

NSLinguisticTagger

dominantLanguage

NEW

NSLinguisticTagger

dominantLanguage

Swift 4 named types for tags and tagSchemes

NEW

NSLinguisticTagger

dominantLanguage

Swift 4 named types for tags and tagSchemes

Improved performance

Higher accuracy

Additional language support

NEW

Winnow and Whisk

Winnow and Whisk

Winnow and Whisk

Winnow Tag photos with descriptions

Winnow Tag photos with descriptions

Winnow Tag photos with descriptions

We hiked to the top and then ran down Lizzie won

Kids partied with all the goodieshellip

Die Kleinen haben friedlich zusammen gespielt

July 4th 2016hellipsummer parties at the

Holdenrsquos begin

Winnow Search for pictures

Winnow Search for pictures

Hike

Winnow Search for pictures

Hike No results

Winnow Improve search experience using NLP

Winnow Improve search experience using NLP

Hike

Winnow Improve search experience using NLP

We hiked to the top and then ran down Lizzie won

Great hikes make great pics

The hiking boysHolden family loves hiking and also posing for pictures

Hike

Winnow

Winnow

Winnow

NLP

Language identification

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

bullDemo

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Tim Cook Apple Stevie Wonder Cupertino Angela Ahrendts Bruce Wayne Thomas Vintberg

Pharrell NYU

Whisk

Whisk

Whisk

Whisk

NLP

Language identification

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

bullDemo

Why should you use the NLP APIs

Homogeneous Text Processing

Homogeneous Text Processing

NLP APIs

Natural language text typed

recognized handwriting

transcribed speech

Consistent text processing

Consistent user experience

Privacy

Privacy

On-device machine learning

User data stays on-device

Performance

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Chinese tokenization is 30 faster on iOS

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Named Entity Recognition 80 faster on iOS

Performance

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

40000 tokenssec

65000 tokenssec

Named Entity Recognition

Language Support

Language Support

Language identification 29 scripts 52 languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Accuracy

Accuracy

0

20

40

60

80

100

Part of speech

Named entity recognition

English Spanish

Debugging Hints

Debugging Hints

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Explicitly set language if known

Summary

NLP APIsmdashNSLinguisticTagger bull Support for new units bull Faster bull Higher accuracy bull More languages

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

NSLinguisticTagger

Tagging units

Units and schemes

NEW

class func availableTagSchemes (for unit NSLinguisticTaggerUnit language String) -gt [NSLinguisticTagScheme]

public enum NSLinguisticTaggerUnit Int case word case sentence case paragraph case document

NSLinguisticTaggerNEW

NSLinguisticTagger

dominantLanguage

NEW

NSLinguisticTagger

dominantLanguage

Swift 4 named types for tags and tagSchemes

NEW

NSLinguisticTagger

dominantLanguage

Swift 4 named types for tags and tagSchemes

Improved performance

Higher accuracy

Additional language support

NEW

Winnow and Whisk

Winnow and Whisk

Winnow and Whisk

Winnow Tag photos with descriptions

Winnow Tag photos with descriptions

Winnow Tag photos with descriptions

We hiked to the top and then ran down Lizzie won

Kids partied with all the goodieshellip

Die Kleinen haben friedlich zusammen gespielt

July 4th 2016hellipsummer parties at the

Holdenrsquos begin

Winnow Search for pictures

Winnow Search for pictures

Hike

Winnow Search for pictures

Hike No results

Winnow Improve search experience using NLP

Winnow Improve search experience using NLP

Hike

Winnow Improve search experience using NLP

We hiked to the top and then ran down Lizzie won

Great hikes make great pics

The hiking boysHolden family loves hiking and also posing for pictures

Hike

Winnow

Winnow

Winnow

NLP

Language identification

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

bullDemo

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Tim Cook Apple Stevie Wonder Cupertino Angela Ahrendts Bruce Wayne Thomas Vintberg

Pharrell NYU

Whisk

Whisk

Whisk

Whisk

NLP

Language identification

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

bullDemo

Why should you use the NLP APIs

Homogeneous Text Processing

Homogeneous Text Processing

NLP APIs

Natural language text typed

recognized handwriting

transcribed speech

Consistent text processing

Consistent user experience

Privacy

Privacy

On-device machine learning

User data stays on-device

Performance

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Chinese tokenization is 30 faster on iOS

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Named Entity Recognition 80 faster on iOS

Performance

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

40000 tokenssec

65000 tokenssec

Named Entity Recognition

Language Support

Language Support

Language identification 29 scripts 52 languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Accuracy

Accuracy

0

20

40

60

80

100

Part of speech

Named entity recognition

English Spanish

Debugging Hints

Debugging Hints

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Explicitly set language if known

Summary

NLP APIsmdashNSLinguisticTagger bull Support for new units bull Faster bull Higher accuracy bull More languages

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

NSLinguisticTaggerNEW

NSLinguisticTagger

dominantLanguage

NEW

NSLinguisticTagger

dominantLanguage

Swift 4 named types for tags and tagSchemes

NEW

NSLinguisticTagger

dominantLanguage

Swift 4 named types for tags and tagSchemes

Improved performance

Higher accuracy

Additional language support

NEW

Winnow and Whisk

Winnow and Whisk

Winnow and Whisk

Winnow Tag photos with descriptions

Winnow Tag photos with descriptions

Winnow Tag photos with descriptions

We hiked to the top and then ran down Lizzie won

Kids partied with all the goodieshellip

Die Kleinen haben friedlich zusammen gespielt

July 4th 2016hellipsummer parties at the

Holdenrsquos begin

Winnow Search for pictures

Winnow Search for pictures

Hike

Winnow Search for pictures

Hike No results

Winnow Improve search experience using NLP

Winnow Improve search experience using NLP

Hike

Winnow Improve search experience using NLP

We hiked to the top and then ran down Lizzie won

Great hikes make great pics

The hiking boysHolden family loves hiking and also posing for pictures

Hike

Winnow

Winnow

Winnow

NLP

Language identification

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

bullDemo

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Tim Cook Apple Stevie Wonder Cupertino Angela Ahrendts Bruce Wayne Thomas Vintberg

Pharrell NYU

Whisk

Whisk

Whisk

Whisk

NLP

Language identification

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

bullDemo

Why should you use the NLP APIs

Homogeneous Text Processing

Homogeneous Text Processing

NLP APIs

Natural language text typed

recognized handwriting

transcribed speech

Consistent text processing

Consistent user experience

Privacy

Privacy

On-device machine learning

User data stays on-device

Performance

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Chinese tokenization is 30 faster on iOS

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Named Entity Recognition 80 faster on iOS

Performance

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

40000 tokenssec

65000 tokenssec

Named Entity Recognition

Language Support

Language Support

Language identification 29 scripts 52 languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Accuracy

Accuracy

0

20

40

60

80

100

Part of speech

Named entity recognition

English Spanish

Debugging Hints

Debugging Hints

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Explicitly set language if known

Summary

NLP APIsmdashNSLinguisticTagger bull Support for new units bull Faster bull Higher accuracy bull More languages

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

NSLinguisticTagger

dominantLanguage

NEW

NSLinguisticTagger

dominantLanguage

Swift 4 named types for tags and tagSchemes

NEW

NSLinguisticTagger

dominantLanguage

Swift 4 named types for tags and tagSchemes

Improved performance

Higher accuracy

Additional language support

NEW

Winnow and Whisk

Winnow and Whisk

Winnow and Whisk

Winnow Tag photos with descriptions

Winnow Tag photos with descriptions

Winnow Tag photos with descriptions

We hiked to the top and then ran down Lizzie won

Kids partied with all the goodieshellip

Die Kleinen haben friedlich zusammen gespielt

July 4th 2016hellipsummer parties at the

Holdenrsquos begin

Winnow Search for pictures

Winnow Search for pictures

Hike

Winnow Search for pictures

Hike No results

Winnow Improve search experience using NLP

Winnow Improve search experience using NLP

Hike

Winnow Improve search experience using NLP

We hiked to the top and then ran down Lizzie won

Great hikes make great pics

The hiking boysHolden family loves hiking and also posing for pictures

Hike

Winnow

Winnow

Winnow

NLP

Language identification

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

bullDemo

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Tim Cook Apple Stevie Wonder Cupertino Angela Ahrendts Bruce Wayne Thomas Vintberg

Pharrell NYU

Whisk

Whisk

Whisk

Whisk

NLP

Language identification

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

bullDemo

Why should you use the NLP APIs

Homogeneous Text Processing

Homogeneous Text Processing

NLP APIs

Natural language text typed

recognized handwriting

transcribed speech

Consistent text processing

Consistent user experience

Privacy

Privacy

On-device machine learning

User data stays on-device

Performance

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Chinese tokenization is 30 faster on iOS

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Named Entity Recognition 80 faster on iOS

Performance

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

40000 tokenssec

65000 tokenssec

Named Entity Recognition

Language Support

Language Support

Language identification 29 scripts 52 languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Accuracy

Accuracy

0

20

40

60

80

100

Part of speech

Named entity recognition

English Spanish

Debugging Hints

Debugging Hints

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Explicitly set language if known

Summary

NLP APIsmdashNSLinguisticTagger bull Support for new units bull Faster bull Higher accuracy bull More languages

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

NSLinguisticTagger

dominantLanguage

Swift 4 named types for tags and tagSchemes

NEW

NSLinguisticTagger

dominantLanguage

Swift 4 named types for tags and tagSchemes

Improved performance

Higher accuracy

Additional language support

NEW

Winnow and Whisk

Winnow and Whisk

Winnow and Whisk

Winnow Tag photos with descriptions

Winnow Tag photos with descriptions

Winnow Tag photos with descriptions

We hiked to the top and then ran down Lizzie won

Kids partied with all the goodieshellip

Die Kleinen haben friedlich zusammen gespielt

July 4th 2016hellipsummer parties at the

Holdenrsquos begin

Winnow Search for pictures

Winnow Search for pictures

Hike

Winnow Search for pictures

Hike No results

Winnow Improve search experience using NLP

Winnow Improve search experience using NLP

Hike

Winnow Improve search experience using NLP

We hiked to the top and then ran down Lizzie won

Great hikes make great pics

The hiking boysHolden family loves hiking and also posing for pictures

Hike

Winnow

Winnow

Winnow

NLP

Language identification

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

bullDemo

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Tim Cook Apple Stevie Wonder Cupertino Angela Ahrendts Bruce Wayne Thomas Vintberg

Pharrell NYU

Whisk

Whisk

Whisk

Whisk

NLP

Language identification

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

bullDemo

Why should you use the NLP APIs

Homogeneous Text Processing

Homogeneous Text Processing

NLP APIs

Natural language text typed

recognized handwriting

transcribed speech

Consistent text processing

Consistent user experience

Privacy

Privacy

On-device machine learning

User data stays on-device

Performance

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Chinese tokenization is 30 faster on iOS

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Named Entity Recognition 80 faster on iOS

Performance

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

40000 tokenssec

65000 tokenssec

Named Entity Recognition

Language Support

Language Support

Language identification 29 scripts 52 languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Accuracy

Accuracy

0

20

40

60

80

100

Part of speech

Named entity recognition

English Spanish

Debugging Hints

Debugging Hints

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Explicitly set language if known

Summary

NLP APIsmdashNSLinguisticTagger bull Support for new units bull Faster bull Higher accuracy bull More languages

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

NSLinguisticTagger

dominantLanguage

Swift 4 named types for tags and tagSchemes

Improved performance

Higher accuracy

Additional language support

NEW

Winnow and Whisk

Winnow and Whisk

Winnow and Whisk

Winnow Tag photos with descriptions

Winnow Tag photos with descriptions

Winnow Tag photos with descriptions

We hiked to the top and then ran down Lizzie won

Kids partied with all the goodieshellip

Die Kleinen haben friedlich zusammen gespielt

July 4th 2016hellipsummer parties at the

Holdenrsquos begin

Winnow Search for pictures

Winnow Search for pictures

Hike

Winnow Search for pictures

Hike No results

Winnow Improve search experience using NLP

Winnow Improve search experience using NLP

Hike

Winnow Improve search experience using NLP

We hiked to the top and then ran down Lizzie won

Great hikes make great pics

The hiking boysHolden family loves hiking and also posing for pictures

Hike

Winnow

Winnow

Winnow

NLP

Language identification

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

bullDemo

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Tim Cook Apple Stevie Wonder Cupertino Angela Ahrendts Bruce Wayne Thomas Vintberg

Pharrell NYU

Whisk

Whisk

Whisk

Whisk

NLP

Language identification

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

bullDemo

Why should you use the NLP APIs

Homogeneous Text Processing

Homogeneous Text Processing

NLP APIs

Natural language text typed

recognized handwriting

transcribed speech

Consistent text processing

Consistent user experience

Privacy

Privacy

On-device machine learning

User data stays on-device

Performance

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Chinese tokenization is 30 faster on iOS

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Named Entity Recognition 80 faster on iOS

Performance

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

40000 tokenssec

65000 tokenssec

Named Entity Recognition

Language Support

Language Support

Language identification 29 scripts 52 languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Accuracy

Accuracy

0

20

40

60

80

100

Part of speech

Named entity recognition

English Spanish

Debugging Hints

Debugging Hints

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Explicitly set language if known

Summary

NLP APIsmdashNSLinguisticTagger bull Support for new units bull Faster bull Higher accuracy bull More languages

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

Winnow and Whisk

Winnow and Whisk

Winnow and Whisk

Winnow Tag photos with descriptions

Winnow Tag photos with descriptions

Winnow Tag photos with descriptions

We hiked to the top and then ran down Lizzie won

Kids partied with all the goodieshellip

Die Kleinen haben friedlich zusammen gespielt

July 4th 2016hellipsummer parties at the

Holdenrsquos begin

Winnow Search for pictures

Winnow Search for pictures

Hike

Winnow Search for pictures

Hike No results

Winnow Improve search experience using NLP

Winnow Improve search experience using NLP

Hike

Winnow Improve search experience using NLP

We hiked to the top and then ran down Lizzie won

Great hikes make great pics

The hiking boysHolden family loves hiking and also posing for pictures

Hike

Winnow

Winnow

Winnow

NLP

Language identification

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

bullDemo

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Tim Cook Apple Stevie Wonder Cupertino Angela Ahrendts Bruce Wayne Thomas Vintberg

Pharrell NYU

Whisk

Whisk

Whisk

Whisk

NLP

Language identification

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

bullDemo

Why should you use the NLP APIs

Homogeneous Text Processing

Homogeneous Text Processing

NLP APIs

Natural language text typed

recognized handwriting

transcribed speech

Consistent text processing

Consistent user experience

Privacy

Privacy

On-device machine learning

User data stays on-device

Performance

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Chinese tokenization is 30 faster on iOS

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Named Entity Recognition 80 faster on iOS

Performance

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

40000 tokenssec

65000 tokenssec

Named Entity Recognition

Language Support

Language Support

Language identification 29 scripts 52 languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Accuracy

Accuracy

0

20

40

60

80

100

Part of speech

Named entity recognition

English Spanish

Debugging Hints

Debugging Hints

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Explicitly set language if known

Summary

NLP APIsmdashNSLinguisticTagger bull Support for new units bull Faster bull Higher accuracy bull More languages

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

Winnow and Whisk

Winnow and Whisk

Winnow Tag photos with descriptions

Winnow Tag photos with descriptions

Winnow Tag photos with descriptions

We hiked to the top and then ran down Lizzie won

Kids partied with all the goodieshellip

Die Kleinen haben friedlich zusammen gespielt

July 4th 2016hellipsummer parties at the

Holdenrsquos begin

Winnow Search for pictures

Winnow Search for pictures

Hike

Winnow Search for pictures

Hike No results

Winnow Improve search experience using NLP

Winnow Improve search experience using NLP

Hike

Winnow Improve search experience using NLP

We hiked to the top and then ran down Lizzie won

Great hikes make great pics

The hiking boysHolden family loves hiking and also posing for pictures

Hike

Winnow

Winnow

Winnow

NLP

Language identification

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

bullDemo

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Tim Cook Apple Stevie Wonder Cupertino Angela Ahrendts Bruce Wayne Thomas Vintberg

Pharrell NYU

Whisk

Whisk

Whisk

Whisk

NLP

Language identification

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

bullDemo

Why should you use the NLP APIs

Homogeneous Text Processing

Homogeneous Text Processing

NLP APIs

Natural language text typed

recognized handwriting

transcribed speech

Consistent text processing

Consistent user experience

Privacy

Privacy

On-device machine learning

User data stays on-device

Performance

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Chinese tokenization is 30 faster on iOS

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Named Entity Recognition 80 faster on iOS

Performance

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

40000 tokenssec

65000 tokenssec

Named Entity Recognition

Language Support

Language Support

Language identification 29 scripts 52 languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Accuracy

Accuracy

0

20

40

60

80

100

Part of speech

Named entity recognition

English Spanish

Debugging Hints

Debugging Hints

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Explicitly set language if known

Summary

NLP APIsmdashNSLinguisticTagger bull Support for new units bull Faster bull Higher accuracy bull More languages

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

Winnow and Whisk

Winnow Tag photos with descriptions

Winnow Tag photos with descriptions

Winnow Tag photos with descriptions

We hiked to the top and then ran down Lizzie won

Kids partied with all the goodieshellip

Die Kleinen haben friedlich zusammen gespielt

July 4th 2016hellipsummer parties at the

Holdenrsquos begin

Winnow Search for pictures

Winnow Search for pictures

Hike

Winnow Search for pictures

Hike No results

Winnow Improve search experience using NLP

Winnow Improve search experience using NLP

Hike

Winnow Improve search experience using NLP

We hiked to the top and then ran down Lizzie won

Great hikes make great pics

The hiking boysHolden family loves hiking and also posing for pictures

Hike

Winnow

Winnow

Winnow

NLP

Language identification

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

bullDemo

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Tim Cook Apple Stevie Wonder Cupertino Angela Ahrendts Bruce Wayne Thomas Vintberg

Pharrell NYU

Whisk

Whisk

Whisk

Whisk

NLP

Language identification

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

bullDemo

Why should you use the NLP APIs

Homogeneous Text Processing

Homogeneous Text Processing

NLP APIs

Natural language text typed

recognized handwriting

transcribed speech

Consistent text processing

Consistent user experience

Privacy

Privacy

On-device machine learning

User data stays on-device

Performance

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Chinese tokenization is 30 faster on iOS

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Named Entity Recognition 80 faster on iOS

Performance

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

40000 tokenssec

65000 tokenssec

Named Entity Recognition

Language Support

Language Support

Language identification 29 scripts 52 languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Accuracy

Accuracy

0

20

40

60

80

100

Part of speech

Named entity recognition

English Spanish

Debugging Hints

Debugging Hints

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Explicitly set language if known

Summary

NLP APIsmdashNSLinguisticTagger bull Support for new units bull Faster bull Higher accuracy bull More languages

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

Winnow Tag photos with descriptions

Winnow Tag photos with descriptions

Winnow Tag photos with descriptions

We hiked to the top and then ran down Lizzie won

Kids partied with all the goodieshellip

Die Kleinen haben friedlich zusammen gespielt

July 4th 2016hellipsummer parties at the

Holdenrsquos begin

Winnow Search for pictures

Winnow Search for pictures

Hike

Winnow Search for pictures

Hike No results

Winnow Improve search experience using NLP

Winnow Improve search experience using NLP

Hike

Winnow Improve search experience using NLP

We hiked to the top and then ran down Lizzie won

Great hikes make great pics

The hiking boysHolden family loves hiking and also posing for pictures

Hike

Winnow

Winnow

Winnow

NLP

Language identification

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

bullDemo

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Tim Cook Apple Stevie Wonder Cupertino Angela Ahrendts Bruce Wayne Thomas Vintberg

Pharrell NYU

Whisk

Whisk

Whisk

Whisk

NLP

Language identification

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

bullDemo

Why should you use the NLP APIs

Homogeneous Text Processing

Homogeneous Text Processing

NLP APIs

Natural language text typed

recognized handwriting

transcribed speech

Consistent text processing

Consistent user experience

Privacy

Privacy

On-device machine learning

User data stays on-device

Performance

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Chinese tokenization is 30 faster on iOS

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Named Entity Recognition 80 faster on iOS

Performance

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

40000 tokenssec

65000 tokenssec

Named Entity Recognition

Language Support

Language Support

Language identification 29 scripts 52 languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Accuracy

Accuracy

0

20

40

60

80

100

Part of speech

Named entity recognition

English Spanish

Debugging Hints

Debugging Hints

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Explicitly set language if known

Summary

NLP APIsmdashNSLinguisticTagger bull Support for new units bull Faster bull Higher accuracy bull More languages

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

Winnow Tag photos with descriptions

Winnow Tag photos with descriptions

We hiked to the top and then ran down Lizzie won

Kids partied with all the goodieshellip

Die Kleinen haben friedlich zusammen gespielt

July 4th 2016hellipsummer parties at the

Holdenrsquos begin

Winnow Search for pictures

Winnow Search for pictures

Hike

Winnow Search for pictures

Hike No results

Winnow Improve search experience using NLP

Winnow Improve search experience using NLP

Hike

Winnow Improve search experience using NLP

We hiked to the top and then ran down Lizzie won

Great hikes make great pics

The hiking boysHolden family loves hiking and also posing for pictures

Hike

Winnow

Winnow

Winnow

NLP

Language identification

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

bullDemo

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Tim Cook Apple Stevie Wonder Cupertino Angela Ahrendts Bruce Wayne Thomas Vintberg

Pharrell NYU

Whisk

Whisk

Whisk

Whisk

NLP

Language identification

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

bullDemo

Why should you use the NLP APIs

Homogeneous Text Processing

Homogeneous Text Processing

NLP APIs

Natural language text typed

recognized handwriting

transcribed speech

Consistent text processing

Consistent user experience

Privacy

Privacy

On-device machine learning

User data stays on-device

Performance

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Chinese tokenization is 30 faster on iOS

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Named Entity Recognition 80 faster on iOS

Performance

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

40000 tokenssec

65000 tokenssec

Named Entity Recognition

Language Support

Language Support

Language identification 29 scripts 52 languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Accuracy

Accuracy

0

20

40

60

80

100

Part of speech

Named entity recognition

English Spanish

Debugging Hints

Debugging Hints

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Explicitly set language if known

Summary

NLP APIsmdashNSLinguisticTagger bull Support for new units bull Faster bull Higher accuracy bull More languages

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

Winnow Tag photos with descriptions

We hiked to the top and then ran down Lizzie won

Kids partied with all the goodieshellip

Die Kleinen haben friedlich zusammen gespielt

July 4th 2016hellipsummer parties at the

Holdenrsquos begin

Winnow Search for pictures

Winnow Search for pictures

Hike

Winnow Search for pictures

Hike No results

Winnow Improve search experience using NLP

Winnow Improve search experience using NLP

Hike

Winnow Improve search experience using NLP

We hiked to the top and then ran down Lizzie won

Great hikes make great pics

The hiking boysHolden family loves hiking and also posing for pictures

Hike

Winnow

Winnow

Winnow

NLP

Language identification

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

bullDemo

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Tim Cook Apple Stevie Wonder Cupertino Angela Ahrendts Bruce Wayne Thomas Vintberg

Pharrell NYU

Whisk

Whisk

Whisk

Whisk

NLP

Language identification

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

bullDemo

Why should you use the NLP APIs

Homogeneous Text Processing

Homogeneous Text Processing

NLP APIs

Natural language text typed

recognized handwriting

transcribed speech

Consistent text processing

Consistent user experience

Privacy

Privacy

On-device machine learning

User data stays on-device

Performance

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Chinese tokenization is 30 faster on iOS

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Named Entity Recognition 80 faster on iOS

Performance

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

40000 tokenssec

65000 tokenssec

Named Entity Recognition

Language Support

Language Support

Language identification 29 scripts 52 languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Accuracy

Accuracy

0

20

40

60

80

100

Part of speech

Named entity recognition

English Spanish

Debugging Hints

Debugging Hints

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Explicitly set language if known

Summary

NLP APIsmdashNSLinguisticTagger bull Support for new units bull Faster bull Higher accuracy bull More languages

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

Winnow Search for pictures

Winnow Search for pictures

Hike

Winnow Search for pictures

Hike No results

Winnow Improve search experience using NLP

Winnow Improve search experience using NLP

Hike

Winnow Improve search experience using NLP

We hiked to the top and then ran down Lizzie won

Great hikes make great pics

The hiking boysHolden family loves hiking and also posing for pictures

Hike

Winnow

Winnow

Winnow

NLP

Language identification

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

bullDemo

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Tim Cook Apple Stevie Wonder Cupertino Angela Ahrendts Bruce Wayne Thomas Vintberg

Pharrell NYU

Whisk

Whisk

Whisk

Whisk

NLP

Language identification

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

bullDemo

Why should you use the NLP APIs

Homogeneous Text Processing

Homogeneous Text Processing

NLP APIs

Natural language text typed

recognized handwriting

transcribed speech

Consistent text processing

Consistent user experience

Privacy

Privacy

On-device machine learning

User data stays on-device

Performance

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Chinese tokenization is 30 faster on iOS

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Named Entity Recognition 80 faster on iOS

Performance

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

40000 tokenssec

65000 tokenssec

Named Entity Recognition

Language Support

Language Support

Language identification 29 scripts 52 languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Accuracy

Accuracy

0

20

40

60

80

100

Part of speech

Named entity recognition

English Spanish

Debugging Hints

Debugging Hints

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Explicitly set language if known

Summary

NLP APIsmdashNSLinguisticTagger bull Support for new units bull Faster bull Higher accuracy bull More languages

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

Winnow Search for pictures

Hike

Winnow Search for pictures

Hike No results

Winnow Improve search experience using NLP

Winnow Improve search experience using NLP

Hike

Winnow Improve search experience using NLP

We hiked to the top and then ran down Lizzie won

Great hikes make great pics

The hiking boysHolden family loves hiking and also posing for pictures

Hike

Winnow

Winnow

Winnow

NLP

Language identification

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

bullDemo

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Tim Cook Apple Stevie Wonder Cupertino Angela Ahrendts Bruce Wayne Thomas Vintberg

Pharrell NYU

Whisk

Whisk

Whisk

Whisk

NLP

Language identification

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

bullDemo

Why should you use the NLP APIs

Homogeneous Text Processing

Homogeneous Text Processing

NLP APIs

Natural language text typed

recognized handwriting

transcribed speech

Consistent text processing

Consistent user experience

Privacy

Privacy

On-device machine learning

User data stays on-device

Performance

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Chinese tokenization is 30 faster on iOS

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Named Entity Recognition 80 faster on iOS

Performance

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

40000 tokenssec

65000 tokenssec

Named Entity Recognition

Language Support

Language Support

Language identification 29 scripts 52 languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Accuracy

Accuracy

0

20

40

60

80

100

Part of speech

Named entity recognition

English Spanish

Debugging Hints

Debugging Hints

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Explicitly set language if known

Summary

NLP APIsmdashNSLinguisticTagger bull Support for new units bull Faster bull Higher accuracy bull More languages

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

Winnow Search for pictures

Hike No results

Winnow Improve search experience using NLP

Winnow Improve search experience using NLP

Hike

Winnow Improve search experience using NLP

We hiked to the top and then ran down Lizzie won

Great hikes make great pics

The hiking boysHolden family loves hiking and also posing for pictures

Hike

Winnow

Winnow

Winnow

NLP

Language identification

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

bullDemo

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Tim Cook Apple Stevie Wonder Cupertino Angela Ahrendts Bruce Wayne Thomas Vintberg

Pharrell NYU

Whisk

Whisk

Whisk

Whisk

NLP

Language identification

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

bullDemo

Why should you use the NLP APIs

Homogeneous Text Processing

Homogeneous Text Processing

NLP APIs

Natural language text typed

recognized handwriting

transcribed speech

Consistent text processing

Consistent user experience

Privacy

Privacy

On-device machine learning

User data stays on-device

Performance

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Chinese tokenization is 30 faster on iOS

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Named Entity Recognition 80 faster on iOS

Performance

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

40000 tokenssec

65000 tokenssec

Named Entity Recognition

Language Support

Language Support

Language identification 29 scripts 52 languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Accuracy

Accuracy

0

20

40

60

80

100

Part of speech

Named entity recognition

English Spanish

Debugging Hints

Debugging Hints

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Explicitly set language if known

Summary

NLP APIsmdashNSLinguisticTagger bull Support for new units bull Faster bull Higher accuracy bull More languages

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

Winnow Improve search experience using NLP

Winnow Improve search experience using NLP

Hike

Winnow Improve search experience using NLP

We hiked to the top and then ran down Lizzie won

Great hikes make great pics

The hiking boysHolden family loves hiking and also posing for pictures

Hike

Winnow

Winnow

Winnow

NLP

Language identification

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

bullDemo

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Tim Cook Apple Stevie Wonder Cupertino Angela Ahrendts Bruce Wayne Thomas Vintberg

Pharrell NYU

Whisk

Whisk

Whisk

Whisk

NLP

Language identification

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

bullDemo

Why should you use the NLP APIs

Homogeneous Text Processing

Homogeneous Text Processing

NLP APIs

Natural language text typed

recognized handwriting

transcribed speech

Consistent text processing

Consistent user experience

Privacy

Privacy

On-device machine learning

User data stays on-device

Performance

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Chinese tokenization is 30 faster on iOS

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Named Entity Recognition 80 faster on iOS

Performance

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

40000 tokenssec

65000 tokenssec

Named Entity Recognition

Language Support

Language Support

Language identification 29 scripts 52 languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Accuracy

Accuracy

0

20

40

60

80

100

Part of speech

Named entity recognition

English Spanish

Debugging Hints

Debugging Hints

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Explicitly set language if known

Summary

NLP APIsmdashNSLinguisticTagger bull Support for new units bull Faster bull Higher accuracy bull More languages

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

Winnow Improve search experience using NLP

Hike

Winnow Improve search experience using NLP

We hiked to the top and then ran down Lizzie won

Great hikes make great pics

The hiking boysHolden family loves hiking and also posing for pictures

Hike

Winnow

Winnow

Winnow

NLP

Language identification

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

bullDemo

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Tim Cook Apple Stevie Wonder Cupertino Angela Ahrendts Bruce Wayne Thomas Vintberg

Pharrell NYU

Whisk

Whisk

Whisk

Whisk

NLP

Language identification

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

bullDemo

Why should you use the NLP APIs

Homogeneous Text Processing

Homogeneous Text Processing

NLP APIs

Natural language text typed

recognized handwriting

transcribed speech

Consistent text processing

Consistent user experience

Privacy

Privacy

On-device machine learning

User data stays on-device

Performance

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Chinese tokenization is 30 faster on iOS

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Named Entity Recognition 80 faster on iOS

Performance

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

40000 tokenssec

65000 tokenssec

Named Entity Recognition

Language Support

Language Support

Language identification 29 scripts 52 languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Accuracy

Accuracy

0

20

40

60

80

100

Part of speech

Named entity recognition

English Spanish

Debugging Hints

Debugging Hints

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Explicitly set language if known

Summary

NLP APIsmdashNSLinguisticTagger bull Support for new units bull Faster bull Higher accuracy bull More languages

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

Winnow Improve search experience using NLP

We hiked to the top and then ran down Lizzie won

Great hikes make great pics

The hiking boysHolden family loves hiking and also posing for pictures

Hike

Winnow

Winnow

Winnow

NLP

Language identification

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

bullDemo

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Tim Cook Apple Stevie Wonder Cupertino Angela Ahrendts Bruce Wayne Thomas Vintberg

Pharrell NYU

Whisk

Whisk

Whisk

Whisk

NLP

Language identification

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

bullDemo

Why should you use the NLP APIs

Homogeneous Text Processing

Homogeneous Text Processing

NLP APIs

Natural language text typed

recognized handwriting

transcribed speech

Consistent text processing

Consistent user experience

Privacy

Privacy

On-device machine learning

User data stays on-device

Performance

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Chinese tokenization is 30 faster on iOS

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Named Entity Recognition 80 faster on iOS

Performance

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

40000 tokenssec

65000 tokenssec

Named Entity Recognition

Language Support

Language Support

Language identification 29 scripts 52 languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Accuracy

Accuracy

0

20

40

60

80

100

Part of speech

Named entity recognition

English Spanish

Debugging Hints

Debugging Hints

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Explicitly set language if known

Summary

NLP APIsmdashNSLinguisticTagger bull Support for new units bull Faster bull Higher accuracy bull More languages

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

Winnow

Winnow

Winnow

NLP

Language identification

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

bullDemo

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Tim Cook Apple Stevie Wonder Cupertino Angela Ahrendts Bruce Wayne Thomas Vintberg

Pharrell NYU

Whisk

Whisk

Whisk

Whisk

NLP

Language identification

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

bullDemo

Why should you use the NLP APIs

Homogeneous Text Processing

Homogeneous Text Processing

NLP APIs

Natural language text typed

recognized handwriting

transcribed speech

Consistent text processing

Consistent user experience

Privacy

Privacy

On-device machine learning

User data stays on-device

Performance

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Chinese tokenization is 30 faster on iOS

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Named Entity Recognition 80 faster on iOS

Performance

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

40000 tokenssec

65000 tokenssec

Named Entity Recognition

Language Support

Language Support

Language identification 29 scripts 52 languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Accuracy

Accuracy

0

20

40

60

80

100

Part of speech

Named entity recognition

English Spanish

Debugging Hints

Debugging Hints

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Explicitly set language if known

Summary

NLP APIsmdashNSLinguisticTagger bull Support for new units bull Faster bull Higher accuracy bull More languages

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

Winnow

Winnow

NLP

Language identification

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

bullDemo

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Tim Cook Apple Stevie Wonder Cupertino Angela Ahrendts Bruce Wayne Thomas Vintberg

Pharrell NYU

Whisk

Whisk

Whisk

Whisk

NLP

Language identification

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

bullDemo

Why should you use the NLP APIs

Homogeneous Text Processing

Homogeneous Text Processing

NLP APIs

Natural language text typed

recognized handwriting

transcribed speech

Consistent text processing

Consistent user experience

Privacy

Privacy

On-device machine learning

User data stays on-device

Performance

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Chinese tokenization is 30 faster on iOS

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Named Entity Recognition 80 faster on iOS

Performance

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

40000 tokenssec

65000 tokenssec

Named Entity Recognition

Language Support

Language Support

Language identification 29 scripts 52 languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Accuracy

Accuracy

0

20

40

60

80

100

Part of speech

Named entity recognition

English Spanish

Debugging Hints

Debugging Hints

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Explicitly set language if known

Summary

NLP APIsmdashNSLinguisticTagger bull Support for new units bull Faster bull Higher accuracy bull More languages

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

Winnow

NLP

Language identification

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

bullDemo

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Tim Cook Apple Stevie Wonder Cupertino Angela Ahrendts Bruce Wayne Thomas Vintberg

Pharrell NYU

Whisk

Whisk

Whisk

Whisk

NLP

Language identification

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

bullDemo

Why should you use the NLP APIs

Homogeneous Text Processing

Homogeneous Text Processing

NLP APIs

Natural language text typed

recognized handwriting

transcribed speech

Consistent text processing

Consistent user experience

Privacy

Privacy

On-device machine learning

User data stays on-device

Performance

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Chinese tokenization is 30 faster on iOS

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Named Entity Recognition 80 faster on iOS

Performance

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

40000 tokenssec

65000 tokenssec

Named Entity Recognition

Language Support

Language Support

Language identification 29 scripts 52 languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Accuracy

Accuracy

0

20

40

60

80

100

Part of speech

Named entity recognition

English Spanish

Debugging Hints

Debugging Hints

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Explicitly set language if known

Summary

NLP APIsmdashNSLinguisticTagger bull Support for new units bull Faster bull Higher accuracy bull More languages

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

Language identification

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

bullDemo

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Tim Cook Apple Stevie Wonder Cupertino Angela Ahrendts Bruce Wayne Thomas Vintberg

Pharrell NYU

Whisk

Whisk

Whisk

Whisk

NLP

Language identification

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

bullDemo

Why should you use the NLP APIs

Homogeneous Text Processing

Homogeneous Text Processing

NLP APIs

Natural language text typed

recognized handwriting

transcribed speech

Consistent text processing

Consistent user experience

Privacy

Privacy

On-device machine learning

User data stays on-device

Performance

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Chinese tokenization is 30 faster on iOS

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Named Entity Recognition 80 faster on iOS

Performance

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

40000 tokenssec

65000 tokenssec

Named Entity Recognition

Language Support

Language Support

Language identification 29 scripts 52 languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Accuracy

Accuracy

0

20

40

60

80

100

Part of speech

Named entity recognition

English Spanish

Debugging Hints

Debugging Hints

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Explicitly set language if known

Summary

NLP APIsmdashNSLinguisticTagger bull Support for new units bull Faster bull Higher accuracy bull More languages

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

Language identification

TokenizationWord Sentence Paragraph

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

bullDemo

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Tim Cook Apple Stevie Wonder Cupertino Angela Ahrendts Bruce Wayne Thomas Vintberg

Pharrell NYU

Whisk

Whisk

Whisk

Whisk

NLP

Language identification

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

bullDemo

Why should you use the NLP APIs

Homogeneous Text Processing

Homogeneous Text Processing

NLP APIs

Natural language text typed

recognized handwriting

transcribed speech

Consistent text processing

Consistent user experience

Privacy

Privacy

On-device machine learning

User data stays on-device

Performance

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Chinese tokenization is 30 faster on iOS

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Named Entity Recognition 80 faster on iOS

Performance

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

40000 tokenssec

65000 tokenssec

Named Entity Recognition

Language Support

Language Support

Language identification 29 scripts 52 languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Accuracy

Accuracy

0

20

40

60

80

100

Part of speech

Named entity recognition

English Spanish

Debugging Hints

Debugging Hints

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Explicitly set language if known

Summary

NLP APIsmdashNSLinguisticTagger bull Support for new units bull Faster bull Higher accuracy bull More languages

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

bullDemo

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Tim Cook Apple Stevie Wonder Cupertino Angela Ahrendts Bruce Wayne Thomas Vintberg

Pharrell NYU

Whisk

Whisk

Whisk

Whisk

NLP

Language identification

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

bullDemo

Why should you use the NLP APIs

Homogeneous Text Processing

Homogeneous Text Processing

NLP APIs

Natural language text typed

recognized handwriting

transcribed speech

Consistent text processing

Consistent user experience

Privacy

Privacy

On-device machine learning

User data stays on-device

Performance

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Chinese tokenization is 30 faster on iOS

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Named Entity Recognition 80 faster on iOS

Performance

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

40000 tokenssec

65000 tokenssec

Named Entity Recognition

Language Support

Language Support

Language identification 29 scripts 52 languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Accuracy

Accuracy

0

20

40

60

80

100

Part of speech

Named entity recognition

English Spanish

Debugging Hints

Debugging Hints

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Explicitly set language if known

Summary

NLP APIsmdashNSLinguisticTagger bull Support for new units bull Faster bull Higher accuracy bull More languages

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

bullDemo

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Tim Cook Apple Stevie Wonder Cupertino Angela Ahrendts Bruce Wayne Thomas Vintberg

Pharrell NYU

Whisk

Whisk

Whisk

Whisk

NLP

Language identification

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

bullDemo

Why should you use the NLP APIs

Homogeneous Text Processing

Homogeneous Text Processing

NLP APIs

Natural language text typed

recognized handwriting

transcribed speech

Consistent text processing

Consistent user experience

Privacy

Privacy

On-device machine learning

User data stays on-device

Performance

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Chinese tokenization is 30 faster on iOS

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Named Entity Recognition 80 faster on iOS

Performance

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

40000 tokenssec

65000 tokenssec

Named Entity Recognition

Language Support

Language Support

Language identification 29 scripts 52 languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Accuracy

Accuracy

0

20

40

60

80

100

Part of speech

Named entity recognition

English Spanish

Debugging Hints

Debugging Hints

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Explicitly set language if known

Summary

NLP APIsmdashNSLinguisticTagger bull Support for new units bull Faster bull Higher accuracy bull More languages

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

Language identification

TokenizationWord Sentence Paragraph

Part of speech

Lemmatization

Winnow

NLP

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

bullDemo

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Tim Cook Apple Stevie Wonder Cupertino Angela Ahrendts Bruce Wayne Thomas Vintberg

Pharrell NYU

Whisk

Whisk

Whisk

Whisk

NLP

Language identification

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

bullDemo

Why should you use the NLP APIs

Homogeneous Text Processing

Homogeneous Text Processing

NLP APIs

Natural language text typed

recognized handwriting

transcribed speech

Consistent text processing

Consistent user experience

Privacy

Privacy

On-device machine learning

User data stays on-device

Performance

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Chinese tokenization is 30 faster on iOS

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Named Entity Recognition 80 faster on iOS

Performance

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

40000 tokenssec

65000 tokenssec

Named Entity Recognition

Language Support

Language Support

Language identification 29 scripts 52 languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Accuracy

Accuracy

0

20

40

60

80

100

Part of speech

Named entity recognition

English Spanish

Debugging Hints

Debugging Hints

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Explicitly set language if known

Summary

NLP APIsmdashNSLinguisticTagger bull Support for new units bull Faster bull Higher accuracy bull More languages

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

bullDemo

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Tim Cook Apple Stevie Wonder Cupertino Angela Ahrendts Bruce Wayne Thomas Vintberg

Pharrell NYU

Whisk

Whisk

Whisk

Whisk

NLP

Language identification

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

bullDemo

Why should you use the NLP APIs

Homogeneous Text Processing

Homogeneous Text Processing

NLP APIs

Natural language text typed

recognized handwriting

transcribed speech

Consistent text processing

Consistent user experience

Privacy

Privacy

On-device machine learning

User data stays on-device

Performance

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Chinese tokenization is 30 faster on iOS

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Named Entity Recognition 80 faster on iOS

Performance

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

40000 tokenssec

65000 tokenssec

Named Entity Recognition

Language Support

Language Support

Language identification 29 scripts 52 languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Accuracy

Accuracy

0

20

40

60

80

100

Part of speech

Named entity recognition

English Spanish

Debugging Hints

Debugging Hints

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Explicitly set language if known

Summary

NLP APIsmdashNSLinguisticTagger bull Support for new units bull Faster bull Higher accuracy bull More languages

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

bullDemo

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Tim Cook Apple Stevie Wonder Cupertino Angela Ahrendts Bruce Wayne Thomas Vintberg

Pharrell NYU

Whisk

Whisk

Whisk

Whisk

NLP

Language identification

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

bullDemo

Why should you use the NLP APIs

Homogeneous Text Processing

Homogeneous Text Processing

NLP APIs

Natural language text typed

recognized handwriting

transcribed speech

Consistent text processing

Consistent user experience

Privacy

Privacy

On-device machine learning

User data stays on-device

Performance

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Chinese tokenization is 30 faster on iOS

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Named Entity Recognition 80 faster on iOS

Performance

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

40000 tokenssec

65000 tokenssec

Named Entity Recognition

Language Support

Language Support

Language identification 29 scripts 52 languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Accuracy

Accuracy

0

20

40

60

80

100

Part of speech

Named entity recognition

English Spanish

Debugging Hints

Debugging Hints

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Explicitly set language if known

Summary

NLP APIsmdashNSLinguisticTagger bull Support for new units bull Faster bull Higher accuracy bull More languages

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

bullDemo

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Tim Cook Apple Stevie Wonder Cupertino Angela Ahrendts Bruce Wayne Thomas Vintberg

Pharrell NYU

Whisk

Whisk

Whisk

Whisk

NLP

Language identification

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

bullDemo

Why should you use the NLP APIs

Homogeneous Text Processing

Homogeneous Text Processing

NLP APIs

Natural language text typed

recognized handwriting

transcribed speech

Consistent text processing

Consistent user experience

Privacy

Privacy

On-device machine learning

User data stays on-device

Performance

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Chinese tokenization is 30 faster on iOS

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Named Entity Recognition 80 faster on iOS

Performance

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

40000 tokenssec

65000 tokenssec

Named Entity Recognition

Language Support

Language Support

Language identification 29 scripts 52 languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Accuracy

Accuracy

0

20

40

60

80

100

Part of speech

Named entity recognition

English Spanish

Debugging Hints

Debugging Hints

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Explicitly set language if known

Summary

NLP APIsmdashNSLinguisticTagger bull Support for new units bull Faster bull Higher accuracy bull More languages

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

bullDemo

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Tim Cook Apple Stevie Wonder Cupertino Angela Ahrendts Bruce Wayne Thomas Vintberg

Pharrell NYU

Whisk

Whisk

Whisk

Whisk

NLP

Language identification

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

bullDemo

Why should you use the NLP APIs

Homogeneous Text Processing

Homogeneous Text Processing

NLP APIs

Natural language text typed

recognized handwriting

transcribed speech

Consistent text processing

Consistent user experience

Privacy

Privacy

On-device machine learning

User data stays on-device

Performance

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Chinese tokenization is 30 faster on iOS

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Named Entity Recognition 80 faster on iOS

Performance

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

40000 tokenssec

65000 tokenssec

Named Entity Recognition

Language Support

Language Support

Language identification 29 scripts 52 languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Accuracy

Accuracy

0

20

40

60

80

100

Part of speech

Named entity recognition

English Spanish

Debugging Hints

Debugging Hints

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Explicitly set language if known

Summary

NLP APIsmdashNSLinguisticTagger bull Support for new units bull Faster bull Higher accuracy bull More languages

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

Language Identification

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [language] options 0)

taggerstring = Die Kleinen haben friedlich zusammen gespielt

let language = taggerdominantLanguage

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

bullDemo

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Tim Cook Apple Stevie Wonder Cupertino Angela Ahrendts Bruce Wayne Thomas Vintberg

Pharrell NYU

Whisk

Whisk

Whisk

Whisk

NLP

Language identification

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

bullDemo

Why should you use the NLP APIs

Homogeneous Text Processing

Homogeneous Text Processing

NLP APIs

Natural language text typed

recognized handwriting

transcribed speech

Consistent text processing

Consistent user experience

Privacy

Privacy

On-device machine learning

User data stays on-device

Performance

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Chinese tokenization is 30 faster on iOS

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Named Entity Recognition 80 faster on iOS

Performance

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

40000 tokenssec

65000 tokenssec

Named Entity Recognition

Language Support

Language Support

Language identification 29 scripts 52 languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Accuracy

Accuracy

0

20

40

60

80

100

Part of speech

Named entity recognition

English Spanish

Debugging Hints

Debugging Hints

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Explicitly set language if known

Summary

NLP APIsmdashNSLinguisticTagger bull Support for new units bull Faster bull Higher accuracy bull More languages

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

bullDemo

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Tim Cook Apple Stevie Wonder Cupertino Angela Ahrendts Bruce Wayne Thomas Vintberg

Pharrell NYU

Whisk

Whisk

Whisk

Whisk

NLP

Language identification

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

bullDemo

Why should you use the NLP APIs

Homogeneous Text Processing

Homogeneous Text Processing

NLP APIs

Natural language text typed

recognized handwriting

transcribed speech

Consistent text processing

Consistent user experience

Privacy

Privacy

On-device machine learning

User data stays on-device

Performance

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Chinese tokenization is 30 faster on iOS

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Named Entity Recognition 80 faster on iOS

Performance

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

40000 tokenssec

65000 tokenssec

Named Entity Recognition

Language Support

Language Support

Language identification 29 scripts 52 languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Accuracy

Accuracy

0

20

40

60

80

100

Part of speech

Named entity recognition

English Spanish

Debugging Hints

Debugging Hints

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Explicitly set language if known

Summary

NLP APIsmdashNSLinguisticTagger bull Support for new units bull Faster bull Higher accuracy bull More languages

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

bullDemo

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Tim Cook Apple Stevie Wonder Cupertino Angela Ahrendts Bruce Wayne Thomas Vintberg

Pharrell NYU

Whisk

Whisk

Whisk

Whisk

NLP

Language identification

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

bullDemo

Why should you use the NLP APIs

Homogeneous Text Processing

Homogeneous Text Processing

NLP APIs

Natural language text typed

recognized handwriting

transcribed speech

Consistent text processing

Consistent user experience

Privacy

Privacy

On-device machine learning

User data stays on-device

Performance

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Chinese tokenization is 30 faster on iOS

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Named Entity Recognition 80 faster on iOS

Performance

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

40000 tokenssec

65000 tokenssec

Named Entity Recognition

Language Support

Language Support

Language identification 29 scripts 52 languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Accuracy

Accuracy

0

20

40

60

80

100

Part of speech

Named entity recognition

English Spanish

Debugging Hints

Debugging Hints

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Explicitly set language if known

Summary

NLP APIsmdashNSLinguisticTagger bull Support for new units bull Faster bull Higher accuracy bull More languages

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

bullDemo

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Tim Cook Apple Stevie Wonder Cupertino Angela Ahrendts Bruce Wayne Thomas Vintberg

Pharrell NYU

Whisk

Whisk

Whisk

Whisk

NLP

Language identification

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

bullDemo

Why should you use the NLP APIs

Homogeneous Text Processing

Homogeneous Text Processing

NLP APIs

Natural language text typed

recognized handwriting

transcribed speech

Consistent text processing

Consistent user experience

Privacy

Privacy

On-device machine learning

User data stays on-device

Performance

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Chinese tokenization is 30 faster on iOS

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Named Entity Recognition 80 faster on iOS

Performance

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

40000 tokenssec

65000 tokenssec

Named Entity Recognition

Language Support

Language Support

Language identification 29 scripts 52 languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Accuracy

Accuracy

0

20

40

60

80

100

Part of speech

Named entity recognition

English Spanish

Debugging Hints

Debugging Hints

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Explicitly set language if known

Summary

NLP APIsmdashNSLinguisticTagger bull Support for new units bull Faster bull Higher accuracy bull More languages

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

bullDemo

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Tim Cook Apple Stevie Wonder Cupertino Angela Ahrendts Bruce Wayne Thomas Vintberg

Pharrell NYU

Whisk

Whisk

Whisk

Whisk

NLP

Language identification

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

bullDemo

Why should you use the NLP APIs

Homogeneous Text Processing

Homogeneous Text Processing

NLP APIs

Natural language text typed

recognized handwriting

transcribed speech

Consistent text processing

Consistent user experience

Privacy

Privacy

On-device machine learning

User data stays on-device

Performance

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Chinese tokenization is 30 faster on iOS

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Named Entity Recognition 80 faster on iOS

Performance

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

40000 tokenssec

65000 tokenssec

Named Entity Recognition

Language Support

Language Support

Language identification 29 scripts 52 languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Accuracy

Accuracy

0

20

40

60

80

100

Part of speech

Named entity recognition

English Spanish

Debugging Hints

Debugging Hints

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Explicitly set language if known

Summary

NLP APIsmdashNSLinguisticTagger bull Support for new units bull Faster bull Higher accuracy bull More languages

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

bullDemo

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Tim Cook Apple Stevie Wonder Cupertino Angela Ahrendts Bruce Wayne Thomas Vintberg

Pharrell NYU

Whisk

Whisk

Whisk

Whisk

NLP

Language identification

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

bullDemo

Why should you use the NLP APIs

Homogeneous Text Processing

Homogeneous Text Processing

NLP APIs

Natural language text typed

recognized handwriting

transcribed speech

Consistent text processing

Consistent user experience

Privacy

Privacy

On-device machine learning

User data stays on-device

Performance

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Chinese tokenization is 30 faster on iOS

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Named Entity Recognition 80 faster on iOS

Performance

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

40000 tokenssec

65000 tokenssec

Named Entity Recognition

Language Support

Language Support

Language identification 29 scripts 52 languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Accuracy

Accuracy

0

20

40

60

80

100

Part of speech

Named entity recognition

English Spanish

Debugging Hints

Debugging Hints

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Explicitly set language if known

Summary

NLP APIsmdashNSLinguisticTagger bull Support for new units bull Faster bull Higher accuracy bull More languages

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

bullDemo

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Tim Cook Apple Stevie Wonder Cupertino Angela Ahrendts Bruce Wayne Thomas Vintberg

Pharrell NYU

Whisk

Whisk

Whisk

Whisk

NLP

Language identification

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

bullDemo

Why should you use the NLP APIs

Homogeneous Text Processing

Homogeneous Text Processing

NLP APIs

Natural language text typed

recognized handwriting

transcribed speech

Consistent text processing

Consistent user experience

Privacy

Privacy

On-device machine learning

User data stays on-device

Performance

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Chinese tokenization is 30 faster on iOS

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Named Entity Recognition 80 faster on iOS

Performance

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

40000 tokenssec

65000 tokenssec

Named Entity Recognition

Language Support

Language Support

Language identification 29 scripts 52 languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Accuracy

Accuracy

0

20

40

60

80

100

Part of speech

Named entity recognition

English Spanish

Debugging Hints

Debugging Hints

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Explicitly set language if known

Summary

NLP APIsmdashNSLinguisticTagger bull Support for new units bull Faster bull Higher accuracy bull More languages

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

Tokenization

import Foundation

let tagger = NSLinguisticTagger(tagSchemes [tokenType] options 0)

let text = NSLinguisticTagger provides text processing APIsn NSLinguisticTagger 是苹果的文字处理理平台

taggerstring = text let range = NSRange(location 0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme tokenType options options) tag tokenRange stop in let token = (text as NSString)substring(with tokenRange) Do something with each token

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

bullDemo

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Tim Cook Apple Stevie Wonder Cupertino Angela Ahrendts Bruce Wayne Thomas Vintberg

Pharrell NYU

Whisk

Whisk

Whisk

Whisk

NLP

Language identification

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

bullDemo

Why should you use the NLP APIs

Homogeneous Text Processing

Homogeneous Text Processing

NLP APIs

Natural language text typed

recognized handwriting

transcribed speech

Consistent text processing

Consistent user experience

Privacy

Privacy

On-device machine learning

User data stays on-device

Performance

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Chinese tokenization is 30 faster on iOS

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Named Entity Recognition 80 faster on iOS

Performance

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

40000 tokenssec

65000 tokenssec

Named Entity Recognition

Language Support

Language Support

Language identification 29 scripts 52 languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Accuracy

Accuracy

0

20

40

60

80

100

Part of speech

Named entity recognition

English Spanish

Debugging Hints

Debugging Hints

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Explicitly set language if known

Summary

NLP APIsmdashNSLinguisticTagger bull Support for new units bull Faster bull Higher accuracy bull More languages

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

bullDemo

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Tim Cook Apple Stevie Wonder Cupertino Angela Ahrendts Bruce Wayne Thomas Vintberg

Pharrell NYU

Whisk

Whisk

Whisk

Whisk

NLP

Language identification

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

bullDemo

Why should you use the NLP APIs

Homogeneous Text Processing

Homogeneous Text Processing

NLP APIs

Natural language text typed

recognized handwriting

transcribed speech

Consistent text processing

Consistent user experience

Privacy

Privacy

On-device machine learning

User data stays on-device

Performance

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Chinese tokenization is 30 faster on iOS

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Named Entity Recognition 80 faster on iOS

Performance

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

40000 tokenssec

65000 tokenssec

Named Entity Recognition

Language Support

Language Support

Language identification 29 scripts 52 languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Accuracy

Accuracy

0

20

40

60

80

100

Part of speech

Named entity recognition

English Spanish

Debugging Hints

Debugging Hints

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Explicitly set language if known

Summary

NLP APIsmdashNSLinguisticTagger bull Support for new units bull Faster bull Higher accuracy bull More languages

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

bullDemo

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Tim Cook Apple Stevie Wonder Cupertino Angela Ahrendts Bruce Wayne Thomas Vintberg

Pharrell NYU

Whisk

Whisk

Whisk

Whisk

NLP

Language identification

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

bullDemo

Why should you use the NLP APIs

Homogeneous Text Processing

Homogeneous Text Processing

NLP APIs

Natural language text typed

recognized handwriting

transcribed speech

Consistent text processing

Consistent user experience

Privacy

Privacy

On-device machine learning

User data stays on-device

Performance

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Chinese tokenization is 30 faster on iOS

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Named Entity Recognition 80 faster on iOS

Performance

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

40000 tokenssec

65000 tokenssec

Named Entity Recognition

Language Support

Language Support

Language identification 29 scripts 52 languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Accuracy

Accuracy

0

20

40

60

80

100

Part of speech

Named entity recognition

English Spanish

Debugging Hints

Debugging Hints

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Explicitly set language if known

Summary

NLP APIsmdashNSLinguisticTagger bull Support for new units bull Faster bull Higher accuracy bull More languages

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

bullDemo

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Tim Cook Apple Stevie Wonder Cupertino Angela Ahrendts Bruce Wayne Thomas Vintberg

Pharrell NYU

Whisk

Whisk

Whisk

Whisk

NLP

Language identification

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

bullDemo

Why should you use the NLP APIs

Homogeneous Text Processing

Homogeneous Text Processing

NLP APIs

Natural language text typed

recognized handwriting

transcribed speech

Consistent text processing

Consistent user experience

Privacy

Privacy

On-device machine learning

User data stays on-device

Performance

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Chinese tokenization is 30 faster on iOS

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Named Entity Recognition 80 faster on iOS

Performance

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

40000 tokenssec

65000 tokenssec

Named Entity Recognition

Language Support

Language Support

Language identification 29 scripts 52 languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Accuracy

Accuracy

0

20

40

60

80

100

Part of speech

Named entity recognition

English Spanish

Debugging Hints

Debugging Hints

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Explicitly set language if known

Summary

NLP APIsmdashNSLinguisticTagger bull Support for new units bull Faster bull Higher accuracy bull More languages

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

bullDemo

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Tim Cook Apple Stevie Wonder Cupertino Angela Ahrendts Bruce Wayne Thomas Vintberg

Pharrell NYU

Whisk

Whisk

Whisk

Whisk

NLP

Language identification

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

bullDemo

Why should you use the NLP APIs

Homogeneous Text Processing

Homogeneous Text Processing

NLP APIs

Natural language text typed

recognized handwriting

transcribed speech

Consistent text processing

Consistent user experience

Privacy

Privacy

On-device machine learning

User data stays on-device

Performance

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Chinese tokenization is 30 faster on iOS

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Named Entity Recognition 80 faster on iOS

Performance

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

40000 tokenssec

65000 tokenssec

Named Entity Recognition

Language Support

Language Support

Language identification 29 scripts 52 languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Accuracy

Accuracy

0

20

40

60

80

100

Part of speech

Named entity recognition

English Spanish

Debugging Hints

Debugging Hints

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Explicitly set language if known

Summary

NLP APIsmdashNSLinguisticTagger bull Support for new units bull Faster bull Higher accuracy bull More languages

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

bullDemo

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Tim Cook Apple Stevie Wonder Cupertino Angela Ahrendts Bruce Wayne Thomas Vintberg

Pharrell NYU

Whisk

Whisk

Whisk

Whisk

NLP

Language identification

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

bullDemo

Why should you use the NLP APIs

Homogeneous Text Processing

Homogeneous Text Processing

NLP APIs

Natural language text typed

recognized handwriting

transcribed speech

Consistent text processing

Consistent user experience

Privacy

Privacy

On-device machine learning

User data stays on-device

Performance

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Chinese tokenization is 30 faster on iOS

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Named Entity Recognition 80 faster on iOS

Performance

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

40000 tokenssec

65000 tokenssec

Named Entity Recognition

Language Support

Language Support

Language identification 29 scripts 52 languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Accuracy

Accuracy

0

20

40

60

80

100

Part of speech

Named entity recognition

English Spanish

Debugging Hints

Debugging Hints

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Explicitly set language if known

Summary

NLP APIsmdashNSLinguisticTagger bull Support for new units bull Faster bull Higher accuracy bull More languages

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

bullDemo

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Tim Cook Apple Stevie Wonder Cupertino Angela Ahrendts Bruce Wayne Thomas Vintberg

Pharrell NYU

Whisk

Whisk

Whisk

Whisk

NLP

Language identification

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

bullDemo

Why should you use the NLP APIs

Homogeneous Text Processing

Homogeneous Text Processing

NLP APIs

Natural language text typed

recognized handwriting

transcribed speech

Consistent text processing

Consistent user experience

Privacy

Privacy

On-device machine learning

User data stays on-device

Performance

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Chinese tokenization is 30 faster on iOS

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Named Entity Recognition 80 faster on iOS

Performance

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

40000 tokenssec

65000 tokenssec

Named Entity Recognition

Language Support

Language Support

Language identification 29 scripts 52 languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Accuracy

Accuracy

0

20

40

60

80

100

Part of speech

Named entity recognition

English Spanish

Debugging Hints

Debugging Hints

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Explicitly set language if known

Summary

NLP APIsmdashNSLinguisticTagger bull Support for new units bull Faster bull Higher accuracy bull More languages

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

bullDemo

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Tim Cook Apple Stevie Wonder Cupertino Angela Ahrendts Bruce Wayne Thomas Vintberg

Pharrell NYU

Whisk

Whisk

Whisk

Whisk

NLP

Language identification

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

bullDemo

Why should you use the NLP APIs

Homogeneous Text Processing

Homogeneous Text Processing

NLP APIs

Natural language text typed

recognized handwriting

transcribed speech

Consistent text processing

Consistent user experience

Privacy

Privacy

On-device machine learning

User data stays on-device

Performance

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Chinese tokenization is 30 faster on iOS

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Named Entity Recognition 80 faster on iOS

Performance

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

40000 tokenssec

65000 tokenssec

Named Entity Recognition

Language Support

Language Support

Language identification 29 scripts 52 languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Accuracy

Accuracy

0

20

40

60

80

100

Part of speech

Named entity recognition

English Spanish

Debugging Hints

Debugging Hints

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Explicitly set language if known

Summary

NLP APIsmdashNSLinguisticTagger bull Support for new units bull Faster bull Higher accuracy bull More languages

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

Lemmatization

import Foundation let tagger = NSLinguisticTagger(tagSchemes[lemma] options 0) let text = Great hikes make great pics Wonderful afternoon in Marin County

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace]

taggerenumerateTags(in range unit word scheme lemma options options) tag tokenRange stop in if let lemma = tagrawValue Do something with each lemma

bullDemo

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Tim Cook Apple Stevie Wonder Cupertino Angela Ahrendts Bruce Wayne Thomas Vintberg

Pharrell NYU

Whisk

Whisk

Whisk

Whisk

NLP

Language identification

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

bullDemo

Why should you use the NLP APIs

Homogeneous Text Processing

Homogeneous Text Processing

NLP APIs

Natural language text typed

recognized handwriting

transcribed speech

Consistent text processing

Consistent user experience

Privacy

Privacy

On-device machine learning

User data stays on-device

Performance

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Chinese tokenization is 30 faster on iOS

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Named Entity Recognition 80 faster on iOS

Performance

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

40000 tokenssec

65000 tokenssec

Named Entity Recognition

Language Support

Language Support

Language identification 29 scripts 52 languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Accuracy

Accuracy

0

20

40

60

80

100

Part of speech

Named entity recognition

English Spanish

Debugging Hints

Debugging Hints

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Explicitly set language if known

Summary

NLP APIsmdashNSLinguisticTagger bull Support for new units bull Faster bull Higher accuracy bull More languages

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

bullDemo

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Tim Cook Apple Stevie Wonder Cupertino Angela Ahrendts Bruce Wayne Thomas Vintberg

Pharrell NYU

Whisk

Whisk

Whisk

Whisk

NLP

Language identification

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

bullDemo

Why should you use the NLP APIs

Homogeneous Text Processing

Homogeneous Text Processing

NLP APIs

Natural language text typed

recognized handwriting

transcribed speech

Consistent text processing

Consistent user experience

Privacy

Privacy

On-device machine learning

User data stays on-device

Performance

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Chinese tokenization is 30 faster on iOS

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Named Entity Recognition 80 faster on iOS

Performance

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

40000 tokenssec

65000 tokenssec

Named Entity Recognition

Language Support

Language Support

Language identification 29 scripts 52 languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Accuracy

Accuracy

0

20

40

60

80

100

Part of speech

Named entity recognition

English Spanish

Debugging Hints

Debugging Hints

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Explicitly set language if known

Summary

NLP APIsmdashNSLinguisticTagger bull Support for new units bull Faster bull Higher accuracy bull More languages

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Tim Cook Apple Stevie Wonder Cupertino Angela Ahrendts Bruce Wayne Thomas Vintberg

Pharrell NYU

Whisk

Whisk

Whisk

Whisk

NLP

Language identification

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

bullDemo

Why should you use the NLP APIs

Homogeneous Text Processing

Homogeneous Text Processing

NLP APIs

Natural language text typed

recognized handwriting

transcribed speech

Consistent text processing

Consistent user experience

Privacy

Privacy

On-device machine learning

User data stays on-device

Performance

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Chinese tokenization is 30 faster on iOS

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Named Entity Recognition 80 faster on iOS

Performance

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

40000 tokenssec

65000 tokenssec

Named Entity Recognition

Language Support

Language Support

Language identification 29 scripts 52 languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Accuracy

Accuracy

0

20

40

60

80

100

Part of speech

Named entity recognition

English Spanish

Debugging Hints

Debugging Hints

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Explicitly set language if known

Summary

NLP APIsmdashNSLinguisticTagger bull Support for new units bull Faster bull Higher accuracy bull More languages

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

Whisk Collate social media feeds

Whisk Collate social media feeds

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Tim Cook Apple Stevie Wonder Cupertino Angela Ahrendts Bruce Wayne Thomas Vintberg

Pharrell NYU

Whisk

Whisk

Whisk

Whisk

NLP

Language identification

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

bullDemo

Why should you use the NLP APIs

Homogeneous Text Processing

Homogeneous Text Processing

NLP APIs

Natural language text typed

recognized handwriting

transcribed speech

Consistent text processing

Consistent user experience

Privacy

Privacy

On-device machine learning

User data stays on-device

Performance

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Chinese tokenization is 30 faster on iOS

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Named Entity Recognition 80 faster on iOS

Performance

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

40000 tokenssec

65000 tokenssec

Named Entity Recognition

Language Support

Language Support

Language identification 29 scripts 52 languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Accuracy

Accuracy

0

20

40

60

80

100

Part of speech

Named entity recognition

English Spanish

Debugging Hints

Debugging Hints

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Explicitly set language if known

Summary

NLP APIsmdashNSLinguisticTagger bull Support for new units bull Faster bull Higher accuracy bull More languages

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

Whisk Collate social media feeds

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Tim Cook Apple Stevie Wonder Cupertino Angela Ahrendts Bruce Wayne Thomas Vintberg

Pharrell NYU

Whisk

Whisk

Whisk

Whisk

NLP

Language identification

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

bullDemo

Why should you use the NLP APIs

Homogeneous Text Processing

Homogeneous Text Processing

NLP APIs

Natural language text typed

recognized handwriting

transcribed speech

Consistent text processing

Consistent user experience

Privacy

Privacy

On-device machine learning

User data stays on-device

Performance

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Chinese tokenization is 30 faster on iOS

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Named Entity Recognition 80 faster on iOS

Performance

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

40000 tokenssec

65000 tokenssec

Named Entity Recognition

Language Support

Language Support

Language identification 29 scripts 52 languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Accuracy

Accuracy

0

20

40

60

80

100

Part of speech

Named entity recognition

English Spanish

Debugging Hints

Debugging Hints

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Explicitly set language if known

Summary

NLP APIsmdashNSLinguisticTagger bull Support for new units bull Faster bull Higher accuracy bull More languages

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Tim Cook Apple Stevie Wonder Cupertino Angela Ahrendts Bruce Wayne Thomas Vintberg

Pharrell NYU

Whisk

Whisk

Whisk

Whisk

NLP

Language identification

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

bullDemo

Why should you use the NLP APIs

Homogeneous Text Processing

Homogeneous Text Processing

NLP APIs

Natural language text typed

recognized handwriting

transcribed speech

Consistent text processing

Consistent user experience

Privacy

Privacy

On-device machine learning

User data stays on-device

Performance

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Chinese tokenization is 30 faster on iOS

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Named Entity Recognition 80 faster on iOS

Performance

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

40000 tokenssec

65000 tokenssec

Named Entity Recognition

Language Support

Language Support

Language identification 29 scripts 52 languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Accuracy

Accuracy

0

20

40

60

80

100

Part of speech

Named entity recognition

English Spanish

Debugging Hints

Debugging Hints

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Explicitly set language if known

Summary

NLP APIsmdashNSLinguisticTagger bull Support for new units bull Faster bull Higher accuracy bull More languages

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

Whisk Organize feeds by People Organization and Location using NLP

Whisk Organize feeds by People Organization and Location using NLP

Tim Cook Apple Stevie Wonder Cupertino Angela Ahrendts Bruce Wayne Thomas Vintberg

Pharrell NYU

Whisk

Whisk

Whisk

Whisk

NLP

Language identification

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

bullDemo

Why should you use the NLP APIs

Homogeneous Text Processing

Homogeneous Text Processing

NLP APIs

Natural language text typed

recognized handwriting

transcribed speech

Consistent text processing

Consistent user experience

Privacy

Privacy

On-device machine learning

User data stays on-device

Performance

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Chinese tokenization is 30 faster on iOS

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Named Entity Recognition 80 faster on iOS

Performance

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

40000 tokenssec

65000 tokenssec

Named Entity Recognition

Language Support

Language Support

Language identification 29 scripts 52 languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Accuracy

Accuracy

0

20

40

60

80

100

Part of speech

Named entity recognition

English Spanish

Debugging Hints

Debugging Hints

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Explicitly set language if known

Summary

NLP APIsmdashNSLinguisticTagger bull Support for new units bull Faster bull Higher accuracy bull More languages

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

Whisk Organize feeds by People Organization and Location using NLP

Tim Cook Apple Stevie Wonder Cupertino Angela Ahrendts Bruce Wayne Thomas Vintberg

Pharrell NYU

Whisk

Whisk

Whisk

Whisk

NLP

Language identification

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

bullDemo

Why should you use the NLP APIs

Homogeneous Text Processing

Homogeneous Text Processing

NLP APIs

Natural language text typed

recognized handwriting

transcribed speech

Consistent text processing

Consistent user experience

Privacy

Privacy

On-device machine learning

User data stays on-device

Performance

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Chinese tokenization is 30 faster on iOS

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Named Entity Recognition 80 faster on iOS

Performance

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

40000 tokenssec

65000 tokenssec

Named Entity Recognition

Language Support

Language Support

Language identification 29 scripts 52 languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Accuracy

Accuracy

0

20

40

60

80

100

Part of speech

Named entity recognition

English Spanish

Debugging Hints

Debugging Hints

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Explicitly set language if known

Summary

NLP APIsmdashNSLinguisticTagger bull Support for new units bull Faster bull Higher accuracy bull More languages

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

Whisk

Whisk

Whisk

Whisk

NLP

Language identification

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

bullDemo

Why should you use the NLP APIs

Homogeneous Text Processing

Homogeneous Text Processing

NLP APIs

Natural language text typed

recognized handwriting

transcribed speech

Consistent text processing

Consistent user experience

Privacy

Privacy

On-device machine learning

User data stays on-device

Performance

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Chinese tokenization is 30 faster on iOS

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Named Entity Recognition 80 faster on iOS

Performance

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

40000 tokenssec

65000 tokenssec

Named Entity Recognition

Language Support

Language Support

Language identification 29 scripts 52 languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Accuracy

Accuracy

0

20

40

60

80

100

Part of speech

Named entity recognition

English Spanish

Debugging Hints

Debugging Hints

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Explicitly set language if known

Summary

NLP APIsmdashNSLinguisticTagger bull Support for new units bull Faster bull Higher accuracy bull More languages

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

Whisk

Whisk

Whisk

NLP

Language identification

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

bullDemo

Why should you use the NLP APIs

Homogeneous Text Processing

Homogeneous Text Processing

NLP APIs

Natural language text typed

recognized handwriting

transcribed speech

Consistent text processing

Consistent user experience

Privacy

Privacy

On-device machine learning

User data stays on-device

Performance

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Chinese tokenization is 30 faster on iOS

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Named Entity Recognition 80 faster on iOS

Performance

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

40000 tokenssec

65000 tokenssec

Named Entity Recognition

Language Support

Language Support

Language identification 29 scripts 52 languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Accuracy

Accuracy

0

20

40

60

80

100

Part of speech

Named entity recognition

English Spanish

Debugging Hints

Debugging Hints

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Explicitly set language if known

Summary

NLP APIsmdashNSLinguisticTagger bull Support for new units bull Faster bull Higher accuracy bull More languages

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

Whisk

Whisk

NLP

Language identification

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

bullDemo

Why should you use the NLP APIs

Homogeneous Text Processing

Homogeneous Text Processing

NLP APIs

Natural language text typed

recognized handwriting

transcribed speech

Consistent text processing

Consistent user experience

Privacy

Privacy

On-device machine learning

User data stays on-device

Performance

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Chinese tokenization is 30 faster on iOS

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Named Entity Recognition 80 faster on iOS

Performance

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

40000 tokenssec

65000 tokenssec

Named Entity Recognition

Language Support

Language Support

Language identification 29 scripts 52 languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Accuracy

Accuracy

0

20

40

60

80

100

Part of speech

Named entity recognition

English Spanish

Debugging Hints

Debugging Hints

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Explicitly set language if known

Summary

NLP APIsmdashNSLinguisticTagger bull Support for new units bull Faster bull Higher accuracy bull More languages

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

Whisk

NLP

Language identification

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

bullDemo

Why should you use the NLP APIs

Homogeneous Text Processing

Homogeneous Text Processing

NLP APIs

Natural language text typed

recognized handwriting

transcribed speech

Consistent text processing

Consistent user experience

Privacy

Privacy

On-device machine learning

User data stays on-device

Performance

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Chinese tokenization is 30 faster on iOS

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Named Entity Recognition 80 faster on iOS

Performance

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

40000 tokenssec

65000 tokenssec

Named Entity Recognition

Language Support

Language Support

Language identification 29 scripts 52 languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Accuracy

Accuracy

0

20

40

60

80

100

Part of speech

Named entity recognition

English Spanish

Debugging Hints

Debugging Hints

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Explicitly set language if known

Summary

NLP APIsmdashNSLinguisticTagger bull Support for new units bull Faster bull Higher accuracy bull More languages

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

Language identification

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

bullDemo

Why should you use the NLP APIs

Homogeneous Text Processing

Homogeneous Text Processing

NLP APIs

Natural language text typed

recognized handwriting

transcribed speech

Consistent text processing

Consistent user experience

Privacy

Privacy

On-device machine learning

User data stays on-device

Performance

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Chinese tokenization is 30 faster on iOS

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Named Entity Recognition 80 faster on iOS

Performance

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

40000 tokenssec

65000 tokenssec

Named Entity Recognition

Language Support

Language Support

Language identification 29 scripts 52 languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Accuracy

Accuracy

0

20

40

60

80

100

Part of speech

Named entity recognition

English Spanish

Debugging Hints

Debugging Hints

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Explicitly set language if known

Summary

NLP APIsmdashNSLinguisticTagger bull Support for new units bull Faster bull Higher accuracy bull More languages

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

Language identification

TokenizationWord Sentence Paragraph

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

bullDemo

Why should you use the NLP APIs

Homogeneous Text Processing

Homogeneous Text Processing

NLP APIs

Natural language text typed

recognized handwriting

transcribed speech

Consistent text processing

Consistent user experience

Privacy

Privacy

On-device machine learning

User data stays on-device

Performance

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Chinese tokenization is 30 faster on iOS

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Named Entity Recognition 80 faster on iOS

Performance

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

40000 tokenssec

65000 tokenssec

Named Entity Recognition

Language Support

Language Support

Language identification 29 scripts 52 languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Accuracy

Accuracy

0

20

40

60

80

100

Part of speech

Named entity recognition

English Spanish

Debugging Hints

Debugging Hints

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Explicitly set language if known

Summary

NLP APIsmdashNSLinguisticTagger bull Support for new units bull Faster bull Higher accuracy bull More languages

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

bullDemo

Why should you use the NLP APIs

Homogeneous Text Processing

Homogeneous Text Processing

NLP APIs

Natural language text typed

recognized handwriting

transcribed speech

Consistent text processing

Consistent user experience

Privacy

Privacy

On-device machine learning

User data stays on-device

Performance

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Chinese tokenization is 30 faster on iOS

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Named Entity Recognition 80 faster on iOS

Performance

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

40000 tokenssec

65000 tokenssec

Named Entity Recognition

Language Support

Language Support

Language identification 29 scripts 52 languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Accuracy

Accuracy

0

20

40

60

80

100

Part of speech

Named entity recognition

English Spanish

Debugging Hints

Debugging Hints

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Explicitly set language if known

Summary

NLP APIsmdashNSLinguisticTagger bull Support for new units bull Faster bull Higher accuracy bull More languages

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

Language identification

TokenizationWord Sentence Paragraph

Named entity recognition

Whisk

NLP

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

bullDemo

Why should you use the NLP APIs

Homogeneous Text Processing

Homogeneous Text Processing

NLP APIs

Natural language text typed

recognized handwriting

transcribed speech

Consistent text processing

Consistent user experience

Privacy

Privacy

On-device machine learning

User data stays on-device

Performance

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Chinese tokenization is 30 faster on iOS

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Named Entity Recognition 80 faster on iOS

Performance

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

40000 tokenssec

65000 tokenssec

Named Entity Recognition

Language Support

Language Support

Language identification 29 scripts 52 languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Accuracy

Accuracy

0

20

40

60

80

100

Part of speech

Named entity recognition

English Spanish

Debugging Hints

Debugging Hints

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Explicitly set language if known

Summary

NLP APIsmdashNSLinguisticTagger bull Support for new units bull Faster bull Higher accuracy bull More languages

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

bullDemo

Why should you use the NLP APIs

Homogeneous Text Processing

Homogeneous Text Processing

NLP APIs

Natural language text typed

recognized handwriting

transcribed speech

Consistent text processing

Consistent user experience

Privacy

Privacy

On-device machine learning

User data stays on-device

Performance

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Chinese tokenization is 30 faster on iOS

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Named Entity Recognition 80 faster on iOS

Performance

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

40000 tokenssec

65000 tokenssec

Named Entity Recognition

Language Support

Language Support

Language identification 29 scripts 52 languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Accuracy

Accuracy

0

20

40

60

80

100

Part of speech

Named entity recognition

English Spanish

Debugging Hints

Debugging Hints

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Explicitly set language if known

Summary

NLP APIsmdashNSLinguisticTagger bull Support for new units bull Faster bull Higher accuracy bull More languages

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

bullDemo

Why should you use the NLP APIs

Homogeneous Text Processing

Homogeneous Text Processing

NLP APIs

Natural language text typed

recognized handwriting

transcribed speech

Consistent text processing

Consistent user experience

Privacy

Privacy

On-device machine learning

User data stays on-device

Performance

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Chinese tokenization is 30 faster on iOS

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Named Entity Recognition 80 faster on iOS

Performance

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

40000 tokenssec

65000 tokenssec

Named Entity Recognition

Language Support

Language Support

Language identification 29 scripts 52 languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Accuracy

Accuracy

0

20

40

60

80

100

Part of speech

Named entity recognition

English Spanish

Debugging Hints

Debugging Hints

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Explicitly set language if known

Summary

NLP APIsmdashNSLinguisticTagger bull Support for new units bull Faster bull Higher accuracy bull More languages

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

bullDemo

Why should you use the NLP APIs

Homogeneous Text Processing

Homogeneous Text Processing

NLP APIs

Natural language text typed

recognized handwriting

transcribed speech

Consistent text processing

Consistent user experience

Privacy

Privacy

On-device machine learning

User data stays on-device

Performance

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Chinese tokenization is 30 faster on iOS

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Named Entity Recognition 80 faster on iOS

Performance

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

40000 tokenssec

65000 tokenssec

Named Entity Recognition

Language Support

Language Support

Language identification 29 scripts 52 languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Accuracy

Accuracy

0

20

40

60

80

100

Part of speech

Named entity recognition

English Spanish

Debugging Hints

Debugging Hints

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Explicitly set language if known

Summary

NLP APIsmdashNSLinguisticTagger bull Support for new units bull Faster bull Higher accuracy bull More languages

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

bullDemo

Why should you use the NLP APIs

Homogeneous Text Processing

Homogeneous Text Processing

NLP APIs

Natural language text typed

recognized handwriting

transcribed speech

Consistent text processing

Consistent user experience

Privacy

Privacy

On-device machine learning

User data stays on-device

Performance

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Chinese tokenization is 30 faster on iOS

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Named Entity Recognition 80 faster on iOS

Performance

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

40000 tokenssec

65000 tokenssec

Named Entity Recognition

Language Support

Language Support

Language identification 29 scripts 52 languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Accuracy

Accuracy

0

20

40

60

80

100

Part of speech

Named entity recognition

English Spanish

Debugging Hints

Debugging Hints

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Explicitly set language if known

Summary

NLP APIsmdashNSLinguisticTagger bull Support for new units bull Faster bull Higher accuracy bull More languages

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

bullDemo

Why should you use the NLP APIs

Homogeneous Text Processing

Homogeneous Text Processing

NLP APIs

Natural language text typed

recognized handwriting

transcribed speech

Consistent text processing

Consistent user experience

Privacy

Privacy

On-device machine learning

User data stays on-device

Performance

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Chinese tokenization is 30 faster on iOS

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Named Entity Recognition 80 faster on iOS

Performance

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

40000 tokenssec

65000 tokenssec

Named Entity Recognition

Language Support

Language Support

Language identification 29 scripts 52 languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Accuracy

Accuracy

0

20

40

60

80

100

Part of speech

Named entity recognition

English Spanish

Debugging Hints

Debugging Hints

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Explicitly set language if known

Summary

NLP APIsmdashNSLinguisticTagger bull Support for new units bull Faster bull Higher accuracy bull More languages

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

bullDemo

Why should you use the NLP APIs

Homogeneous Text Processing

Homogeneous Text Processing

NLP APIs

Natural language text typed

recognized handwriting

transcribed speech

Consistent text processing

Consistent user experience

Privacy

Privacy

On-device machine learning

User data stays on-device

Performance

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Chinese tokenization is 30 faster on iOS

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Named Entity Recognition 80 faster on iOS

Performance

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

40000 tokenssec

65000 tokenssec

Named Entity Recognition

Language Support

Language Support

Language identification 29 scripts 52 languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Accuracy

Accuracy

0

20

40

60

80

100

Part of speech

Named entity recognition

English Spanish

Debugging Hints

Debugging Hints

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Explicitly set language if known

Summary

NLP APIsmdashNSLinguisticTagger bull Support for new units bull Faster bull Higher accuracy bull More languages

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

bullDemo

Why should you use the NLP APIs

Homogeneous Text Processing

Homogeneous Text Processing

NLP APIs

Natural language text typed

recognized handwriting

transcribed speech

Consistent text processing

Consistent user experience

Privacy

Privacy

On-device machine learning

User data stays on-device

Performance

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Chinese tokenization is 30 faster on iOS

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Named Entity Recognition 80 faster on iOS

Performance

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

40000 tokenssec

65000 tokenssec

Named Entity Recognition

Language Support

Language Support

Language identification 29 scripts 52 languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Accuracy

Accuracy

0

20

40

60

80

100

Part of speech

Named entity recognition

English Spanish

Debugging Hints

Debugging Hints

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Explicitly set language if known

Summary

NLP APIsmdashNSLinguisticTagger bull Support for new units bull Faster bull Higher accuracy bull More languages

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

bullDemo

Why should you use the NLP APIs

Homogeneous Text Processing

Homogeneous Text Processing

NLP APIs

Natural language text typed

recognized handwriting

transcribed speech

Consistent text processing

Consistent user experience

Privacy

Privacy

On-device machine learning

User data stays on-device

Performance

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Chinese tokenization is 30 faster on iOS

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Named Entity Recognition 80 faster on iOS

Performance

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

40000 tokenssec

65000 tokenssec

Named Entity Recognition

Language Support

Language Support

Language identification 29 scripts 52 languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Accuracy

Accuracy

0

20

40

60

80

100

Part of speech

Named entity recognition

English Spanish

Debugging Hints

Debugging Hints

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Explicitly set language if known

Summary

NLP APIsmdashNSLinguisticTagger bull Support for new units bull Faster bull Higher accuracy bull More languages

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

Named Entity Recognition

import Foundation let tagger = NSLinguisticTagger(tagSchemes [nameType] options 0)

let text = Tim Cook is the CEO of Apple Inc which is located in Cupertino California

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range unit word scheme nameType options options) tag tokenRange stop in if let tag = tag tagscontains(tag) let name = (text as NSString)substring(with tokenRange)

bullDemo

Why should you use the NLP APIs

Homogeneous Text Processing

Homogeneous Text Processing

NLP APIs

Natural language text typed

recognized handwriting

transcribed speech

Consistent text processing

Consistent user experience

Privacy

Privacy

On-device machine learning

User data stays on-device

Performance

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Chinese tokenization is 30 faster on iOS

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Named Entity Recognition 80 faster on iOS

Performance

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

40000 tokenssec

65000 tokenssec

Named Entity Recognition

Language Support

Language Support

Language identification 29 scripts 52 languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Accuracy

Accuracy

0

20

40

60

80

100

Part of speech

Named entity recognition

English Spanish

Debugging Hints

Debugging Hints

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Explicitly set language if known

Summary

NLP APIsmdashNSLinguisticTagger bull Support for new units bull Faster bull Higher accuracy bull More languages

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

bullDemo

Why should you use the NLP APIs

Homogeneous Text Processing

Homogeneous Text Processing

NLP APIs

Natural language text typed

recognized handwriting

transcribed speech

Consistent text processing

Consistent user experience

Privacy

Privacy

On-device machine learning

User data stays on-device

Performance

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Chinese tokenization is 30 faster on iOS

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Named Entity Recognition 80 faster on iOS

Performance

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

40000 tokenssec

65000 tokenssec

Named Entity Recognition

Language Support

Language Support

Language identification 29 scripts 52 languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Accuracy

Accuracy

0

20

40

60

80

100

Part of speech

Named entity recognition

English Spanish

Debugging Hints

Debugging Hints

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Explicitly set language if known

Summary

NLP APIsmdashNSLinguisticTagger bull Support for new units bull Faster bull Higher accuracy bull More languages

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

Why should you use the NLP APIs

Homogeneous Text Processing

Homogeneous Text Processing

NLP APIs

Natural language text typed

recognized handwriting

transcribed speech

Consistent text processing

Consistent user experience

Privacy

Privacy

On-device machine learning

User data stays on-device

Performance

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Chinese tokenization is 30 faster on iOS

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Named Entity Recognition 80 faster on iOS

Performance

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

40000 tokenssec

65000 tokenssec

Named Entity Recognition

Language Support

Language Support

Language identification 29 scripts 52 languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Accuracy

Accuracy

0

20

40

60

80

100

Part of speech

Named entity recognition

English Spanish

Debugging Hints

Debugging Hints

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Explicitly set language if known

Summary

NLP APIsmdashNSLinguisticTagger bull Support for new units bull Faster bull Higher accuracy bull More languages

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

Homogeneous Text Processing

Homogeneous Text Processing

NLP APIs

Natural language text typed

recognized handwriting

transcribed speech

Consistent text processing

Consistent user experience

Privacy

Privacy

On-device machine learning

User data stays on-device

Performance

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Chinese tokenization is 30 faster on iOS

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Named Entity Recognition 80 faster on iOS

Performance

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

40000 tokenssec

65000 tokenssec

Named Entity Recognition

Language Support

Language Support

Language identification 29 scripts 52 languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Accuracy

Accuracy

0

20

40

60

80

100

Part of speech

Named entity recognition

English Spanish

Debugging Hints

Debugging Hints

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Explicitly set language if known

Summary

NLP APIsmdashNSLinguisticTagger bull Support for new units bull Faster bull Higher accuracy bull More languages

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

Homogeneous Text Processing

NLP APIs

Natural language text typed

recognized handwriting

transcribed speech

Consistent text processing

Consistent user experience

Privacy

Privacy

On-device machine learning

User data stays on-device

Performance

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Chinese tokenization is 30 faster on iOS

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Named Entity Recognition 80 faster on iOS

Performance

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

40000 tokenssec

65000 tokenssec

Named Entity Recognition

Language Support

Language Support

Language identification 29 scripts 52 languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Accuracy

Accuracy

0

20

40

60

80

100

Part of speech

Named entity recognition

English Spanish

Debugging Hints

Debugging Hints

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Explicitly set language if known

Summary

NLP APIsmdashNSLinguisticTagger bull Support for new units bull Faster bull Higher accuracy bull More languages

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

Privacy

Privacy

On-device machine learning

User data stays on-device

Performance

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Chinese tokenization is 30 faster on iOS

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Named Entity Recognition 80 faster on iOS

Performance

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

40000 tokenssec

65000 tokenssec

Named Entity Recognition

Language Support

Language Support

Language identification 29 scripts 52 languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Accuracy

Accuracy

0

20

40

60

80

100

Part of speech

Named entity recognition

English Spanish

Debugging Hints

Debugging Hints

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Explicitly set language if known

Summary

NLP APIsmdashNSLinguisticTagger bull Support for new units bull Faster bull Higher accuracy bull More languages

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

Privacy

On-device machine learning

User data stays on-device

Performance

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Chinese tokenization is 30 faster on iOS

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Named Entity Recognition 80 faster on iOS

Performance

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

40000 tokenssec

65000 tokenssec

Named Entity Recognition

Language Support

Language Support

Language identification 29 scripts 52 languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Accuracy

Accuracy

0

20

40

60

80

100

Part of speech

Named entity recognition

English Spanish

Debugging Hints

Debugging Hints

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Explicitly set language if known

Summary

NLP APIsmdashNSLinguisticTagger bull Support for new units bull Faster bull Higher accuracy bull More languages

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

Performance

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Chinese tokenization is 30 faster on iOS

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Named Entity Recognition 80 faster on iOS

Performance

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

40000 tokenssec

65000 tokenssec

Named Entity Recognition

Language Support

Language Support

Language identification 29 scripts 52 languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Accuracy

Accuracy

0

20

40

60

80

100

Part of speech

Named entity recognition

English Spanish

Debugging Hints

Debugging Hints

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Explicitly set language if known

Summary

NLP APIsmdashNSLinguisticTagger bull Support for new units bull Faster bull Higher accuracy bull More languages

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Chinese tokenization is 30 faster on iOS

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Named Entity Recognition 80 faster on iOS

Performance

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

40000 tokenssec

65000 tokenssec

Named Entity Recognition

Language Support

Language Support

Language identification 29 scripts 52 languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Accuracy

Accuracy

0

20

40

60

80

100

Part of speech

Named entity recognition

English Spanish

Debugging Hints

Debugging Hints

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Explicitly set language if known

Summary

NLP APIsmdashNSLinguisticTagger bull Support for new units bull Faster bull Higher accuracy bull More languages

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Chinese tokenization is 30 faster on iOS

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Named Entity Recognition 80 faster on iOS

Performance

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

40000 tokenssec

65000 tokenssec

Named Entity Recognition

Language Support

Language Support

Language identification 29 scripts 52 languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Accuracy

Accuracy

0

20

40

60

80

100

Part of speech

Named entity recognition

English Spanish

Debugging Hints

Debugging Hints

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Explicitly set language if known

Summary

NLP APIsmdashNSLinguisticTagger bull Support for new units bull Faster bull Higher accuracy bull More languages

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

Performance

Highly optimized on-device

Multi-threaded

Existing clientsmdashsignificant speedup

Named Entity Recognition 80 faster on iOS

Performance

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

40000 tokenssec

65000 tokenssec

Named Entity Recognition

Language Support

Language Support

Language identification 29 scripts 52 languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Accuracy

Accuracy

0

20

40

60

80

100

Part of speech

Named entity recognition

English Spanish

Debugging Hints

Debugging Hints

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Explicitly set language if known

Summary

NLP APIsmdashNSLinguisticTagger bull Support for new units bull Faster bull Higher accuracy bull More languages

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

Performance

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

40000 tokenssec

65000 tokenssec

Named Entity Recognition

Language Support

Language Support

Language identification 29 scripts 52 languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Accuracy

Accuracy

0

20

40

60

80

100

Part of speech

Named entity recognition

English Spanish

Debugging Hints

Debugging Hints

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Explicitly set language if known

Summary

NLP APIsmdashNSLinguisticTagger bull Support for new units bull Faster bull Higher accuracy bull More languages

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

40000 tokenssec

65000 tokenssec

Named Entity Recognition

Language Support

Language Support

Language identification 29 scripts 52 languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Accuracy

Accuracy

0

20

40

60

80

100

Part of speech

Named entity recognition

English Spanish

Debugging Hints

Debugging Hints

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Explicitly set language if known

Summary

NLP APIsmdashNSLinguisticTagger bull Support for new units bull Faster bull Higher accuracy bull More languages

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

Performance

50000 tokenssec

80000 tokenssec

Part of Speech Tagging

1 thread

40000 tokenssec

65000 tokenssec

Named Entity Recognition

Language Support

Language Support

Language identification 29 scripts 52 languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Accuracy

Accuracy

0

20

40

60

80

100

Part of speech

Named entity recognition

English Spanish

Debugging Hints

Debugging Hints

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Explicitly set language if known

Summary

NLP APIsmdashNSLinguisticTagger bull Support for new units bull Faster bull Higher accuracy bull More languages

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

Language Support

Language Support

Language identification 29 scripts 52 languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Accuracy

Accuracy

0

20

40

60

80

100

Part of speech

Named entity recognition

English Spanish

Debugging Hints

Debugging Hints

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Explicitly set language if known

Summary

NLP APIsmdashNSLinguisticTagger bull Support for new units bull Faster bull Higher accuracy bull More languages

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

Language Support

Language identification 29 scripts 52 languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Accuracy

Accuracy

0

20

40

60

80

100

Part of speech

Named entity recognition

English Spanish

Debugging Hints

Debugging Hints

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Explicitly set language if known

Summary

NLP APIsmdashNSLinguisticTagger bull Support for new units bull Faster bull Higher accuracy bull More languages

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Accuracy

Accuracy

0

20

40

60

80

100

Part of speech

Named entity recognition

English Spanish

Debugging Hints

Debugging Hints

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Explicitly set language if known

Summary

NLP APIsmdashNSLinguisticTagger bull Support for new units bull Faster bull Higher accuracy bull More languages

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Accuracy

Accuracy

0

20

40

60

80

100

Part of speech

Named entity recognition

English Spanish

Debugging Hints

Debugging Hints

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Explicitly set language if known

Summary

NLP APIsmdashNSLinguisticTagger bull Support for new units bull Faster bull Higher accuracy bull More languages

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Accuracy

Accuracy

0

20

40

60

80

100

Part of speech

Named entity recognition

English Spanish

Debugging Hints

Debugging Hints

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Explicitly set language if known

Summary

NLP APIsmdashNSLinguisticTagger bull Support for new units bull Faster bull Higher accuracy bull More languages

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Accuracy

Accuracy

0

20

40

60

80

100

Part of speech

Named entity recognition

English Spanish

Debugging Hints

Debugging Hints

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Explicitly set language if known

Summary

NLP APIsmdashNSLinguisticTagger bull Support for new units bull Faster bull Higher accuracy bull More languages

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

Language Support

Language identification 29 scripts 52 languages

Tokenization All iOSmacOS system languages

LemmatizationEnglish French Italian

German Spanish

Portuguese Russian Turkish

Part of speech

Named entity recognition

Accuracy

Accuracy

0

20

40

60

80

100

Part of speech

Named entity recognition

English Spanish

Debugging Hints

Debugging Hints

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Explicitly set language if known

Summary

NLP APIsmdashNSLinguisticTagger bull Support for new units bull Faster bull Higher accuracy bull More languages

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

Accuracy

Accuracy

0

20

40

60

80

100

Part of speech

Named entity recognition

English Spanish

Debugging Hints

Debugging Hints

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Explicitly set language if known

Summary

NLP APIsmdashNSLinguisticTagger bull Support for new units bull Faster bull Higher accuracy bull More languages

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

Accuracy

0

20

40

60

80

100

Part of speech

Named entity recognition

English Spanish

Debugging Hints

Debugging Hints

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Explicitly set language if known

Summary

NLP APIsmdashNSLinguisticTagger bull Support for new units bull Faster bull Higher accuracy bull More languages

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

Debugging Hints

Debugging Hints

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Explicitly set language if known

Summary

NLP APIsmdashNSLinguisticTagger bull Support for new units bull Faster bull Higher accuracy bull More languages

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

Debugging Hints

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Explicitly set language if known

Summary

NLP APIsmdashNSLinguisticTagger bull Support for new units bull Faster bull Higher accuracy bull More languages

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Explicitly set language if known

Summary

NLP APIsmdashNSLinguisticTagger bull Support for new units bull Faster bull Higher accuracy bull More languages

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

Debugging Hints

Downloaded over-the-air

Tags are NSLinguisticTagOtherWord bull Model not downloaded

Explicitly set language if known

Summary

NLP APIsmdashNSLinguisticTagger bull Support for new units bull Faster bull Higher accuracy bull More languages

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

Summary

NLP APIsmdashNSLinguisticTagger bull Support for new units bull Faster bull Higher accuracy bull More languages

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

More Informationhttpsdeveloperapplecomwwdc17208

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

Related Sessions

Whats New in Cocoa Touch WWDC 2017

Introducing Core ML WWDC 2017

Vision Framework Building on Core ML Hall 2 Wednesday 310PM

Core ML in Depth Hall 3 Thursday 900 AM

Accelerate and Sparse Solvers Grand Ballroom A Thursday 1000 AM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM

Labs

Core ML amp Natural Language Processing Lab Technology Lab D Thu 1100AM-330PM

Vision Lab Technology Lab A Fri 150PM-400PM

Core ML amp Natural Language Processing Lab Technology Lab D Fri 150PM-400PM

Cocoa Lab Technology Lab B Fri 150PM-320PM