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

148
#WWDC17 © 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 Natural Language Processing and your Apps Session 208 App Frameworks

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

Page 1: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. 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

Page 2: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal

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

Page 3: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. 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

Page 4: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. 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

Page 5: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal

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

Page 6: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal

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

Page 7: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal

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

Page 8: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal

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

Page 9: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal

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

Page 10: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal

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

Page 11: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal

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

Page 12: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal

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

Page 13: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal

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

Page 14: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal

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

Page 15: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal

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

Page 16: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal

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

Page 17: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal

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

Page 18: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal

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

Page 19: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal

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

Page 20: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal

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

Page 21: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal

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

Page 22: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal

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

Page 23: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal

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

Page 24: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal

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

Page 25: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal

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

Page 26: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal

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

Page 27: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal

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

Page 28: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal

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

Page 29: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal

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

Page 30: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal

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

Page 31: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal

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

Page 32: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal

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

Page 33: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal

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

Page 34: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal

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

Page 35: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal

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

Page 36: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal

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

Page 37: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal

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

Page 38: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal

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

Page 39: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal

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

Page 40: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal

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

Page 41: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal

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

Page 42: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal

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

Page 43: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal

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

Page 44: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal

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

Page 45: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal

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

Page 46: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal

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

Page 47: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal

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

Page 48: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal

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

Page 49: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal

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

Page 50: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal

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

Page 51: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal

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

Page 52: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal

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

Page 53: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal

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

Page 54: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal

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

Page 55: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal

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

Page 56: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal

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

Page 57: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal

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

Page 58: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal

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

Page 59: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal

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

Page 60: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal

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

Page 61: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal

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

Page 62: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal

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

Page 63: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal

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

Page 64: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal

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

Page 65: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal

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

Page 66: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal

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

Page 67: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal

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

Page 68: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal

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

Page 69: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal

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

Page 70: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal

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

Page 71: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal

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

Page 72: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal

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

Page 73: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal

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

Page 74: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal

Language Identification

import Foundation

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

taggerstring = Die Kleinen haben friedlich zusammen gespielt

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

Page 75: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal

Language Identification

import Foundation

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

taggerstring = Die Kleinen haben friedlich zusammen gespielt

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

Page 76: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal

Language Identification

import Foundation

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

taggerstring = Die Kleinen haben friedlich zusammen gespielt

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

Page 77: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal

Language Identification

import Foundation

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

taggerstring = Die Kleinen haben friedlich zusammen gespielt

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

Page 78: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal

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

Page 79: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal

Tokenization

import Foundation

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

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

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

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

Tokenization

import Foundation

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

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

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

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

Tokenization

import Foundation

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

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

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

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

Tokenization

import Foundation

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

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

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

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

Tokenization

import Foundation

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

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

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

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

Tokenization

import Foundation

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

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

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

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

Tokenization

import Foundation

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

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

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

taggerenumerateTags(in 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

Page 80: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal

Tokenization

import Foundation

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

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

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

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

Tokenization

import Foundation

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

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

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

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

Tokenization

import Foundation

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

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

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

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

Tokenization

import Foundation

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

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

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

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

Tokenization

import Foundation

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

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

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

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

Tokenization

import Foundation

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

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

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

taggerenumerateTags(in 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

Page 81: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal

Tokenization

import Foundation

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

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

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

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

Tokenization

import Foundation

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

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

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

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

Tokenization

import Foundation

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

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

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

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

Tokenization

import Foundation

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

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

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

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

Tokenization

import Foundation

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

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

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

taggerenumerateTags(in 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

Page 82: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal

Tokenization

import Foundation

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

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

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

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

Tokenization

import Foundation

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

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

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

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

Tokenization

import Foundation

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

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

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

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

Tokenization

import Foundation

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

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

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

taggerenumerateTags(in 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

Page 83: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal

Tokenization

import Foundation

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

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

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

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

Tokenization

import Foundation

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

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

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

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

Tokenization

import Foundation

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

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

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

taggerenumerateTags(in 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

Page 84: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal

Tokenization

import Foundation

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

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

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

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

Tokenization

import Foundation

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

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

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

taggerenumerateTags(in 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

Page 85: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal

Tokenization

import Foundation

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

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

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

taggerenumerateTags(in 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

Page 86: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal

Lemmatization

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

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

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

Lemmatization

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

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

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

Lemmatization

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

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

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

Lemmatization

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

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

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

Lemmatization

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

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

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

Lemmatization

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

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

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

Lemmatization

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

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

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

Lemmatization

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

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [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

Page 87: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal

Lemmatization

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

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

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

Lemmatization

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

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

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

Lemmatization

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

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

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

Lemmatization

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

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

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

Lemmatization

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

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

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

Lemmatization

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

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

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

Lemmatization

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

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [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

Page 88: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal

Lemmatization

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

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

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

Lemmatization

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

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

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

Lemmatization

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

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

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

Lemmatization

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

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

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

Lemmatization

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

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

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

Lemmatization

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

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [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

Page 89: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal

Lemmatization

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

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

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

Lemmatization

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

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

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

Lemmatization

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

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

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

Lemmatization

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

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

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

Lemmatization

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

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [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

Page 90: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal

Lemmatization

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

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

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

Lemmatization

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

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

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

Lemmatization

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

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

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

Lemmatization

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

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [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

Page 91: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal

Lemmatization

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

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

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

Lemmatization

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

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

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

Lemmatization

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

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [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

Page 92: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal

Lemmatization

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

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

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

Lemmatization

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

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [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

Page 93: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal

Lemmatization

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

taggerstring = text let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [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

Page 94: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal

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

Page 95: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal

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

Page 96: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal

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

Page 97: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal

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

Page 98: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal

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

Page 99: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal

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

Page 100: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal

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

Page 101: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal

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

Page 102: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal

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

Page 103: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal

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

Page 104: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal

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

Page 105: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal

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

Page 106: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal

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

Page 107: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal

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

Page 108: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal

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

Page 109: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal

Named Entity Recognition

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

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

taggerstring = text

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

Named Entity Recognition

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

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

taggerstring = text

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

Named Entity Recognition

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

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

taggerstring = text

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

Named Entity Recognition

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

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

taggerstring = text

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

Named Entity Recognition

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

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

taggerstring = text

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

Named Entity Recognition

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

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

taggerstring = text

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

Named Entity Recognition

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

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

taggerstring = text

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

Named Entity Recognition

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

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

taggerstring = text

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

Named Entity Recognition

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

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

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range 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

Page 110: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal

Named Entity Recognition

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

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

taggerstring = text

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

Named Entity Recognition

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

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

taggerstring = text

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

Named Entity Recognition

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

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

taggerstring = text

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

Named Entity Recognition

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

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

taggerstring = text

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

Named Entity Recognition

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

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

taggerstring = text

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

Named Entity Recognition

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

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

taggerstring = text

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

Named Entity Recognition

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

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

taggerstring = text

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

Named Entity Recognition

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

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

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range 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

Page 111: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal

Named Entity Recognition

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

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

taggerstring = text

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

Named Entity Recognition

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

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

taggerstring = text

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

Named Entity Recognition

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

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

taggerstring = text

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

Named Entity Recognition

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

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

taggerstring = text

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

Named Entity Recognition

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

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

taggerstring = text

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

Named Entity Recognition

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

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

taggerstring = text

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

Named Entity Recognition

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

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

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range 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

Page 112: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal

Named Entity Recognition

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

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

taggerstring = text

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

Named Entity Recognition

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

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

taggerstring = text

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

Named Entity Recognition

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

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

taggerstring = text

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

Named Entity Recognition

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

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

taggerstring = text

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

Named Entity Recognition

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

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

taggerstring = text

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

Named Entity Recognition

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

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

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range 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

Page 113: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal

Named Entity Recognition

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

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

taggerstring = text

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

Named Entity Recognition

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

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

taggerstring = text

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

Named Entity Recognition

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

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

taggerstring = text

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

Named Entity Recognition

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

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

taggerstring = text

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

Named Entity Recognition

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

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

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range 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

Page 114: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal

Named Entity Recognition

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

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

taggerstring = text

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

Named Entity Recognition

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

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

taggerstring = text

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

Named Entity Recognition

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

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

taggerstring = text

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

Named Entity Recognition

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

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

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range 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

Page 115: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal

Named Entity Recognition

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

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

taggerstring = text

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

Named Entity Recognition

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

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

taggerstring = text

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

Named Entity Recognition

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

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

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range 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

Page 116: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal

Named Entity Recognition

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

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

taggerstring = text

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

Named Entity Recognition

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

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

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range 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

Page 117: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal

Named Entity Recognition

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

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

taggerstring = text

let range = NSRange(location0 length textutf16count) let options NSLinguisticTaggerOptions = [omitPunctuation omitWhitespace joinNames] let tags [NSLinguisticTag] = [personalName placeName organizationName] taggerenumerateTags(in range 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

Page 118: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal

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

Page 119: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal

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

Page 120: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal

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

Page 121: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal

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

Page 122: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal

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

Page 123: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal

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

Page 124: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal

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

Page 125: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal

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

Page 126: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal

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

Page 127: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal

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

Page 128: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal

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

Page 129: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal

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

Page 130: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal

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

Page 131: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal

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

Page 132: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal

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

Page 133: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal

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

Page 134: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal

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

Page 135: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal

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

Page 136: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal

Language Support

Language 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

Page 137: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal

Language Support

Language 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

Page 138: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal

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

Page 139: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal

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

Page 140: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal

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

Page 141: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal

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

Page 142: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal

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

Page 143: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal

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

Page 144: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal

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

Page 145: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal

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

Page 146: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal

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

Page 147: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal

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

Page 148: 208 NaturalLanguageProcessingandyourApps 04 D · 2017. 6. 8. · App Frameworks. Goal. Goal. Goal Natural language input typed text recognized handwriting transcribed speech. Goal