SlideShare uma empresa Scribd logo
1 de 34
Baixar para ler offline
Exploring Natural Language
Processing in Ruby
Kevin Dias!
Tokyo Rubyist Meetup - April 9th, 2015
Rubyで自然言語処理の世界を探求してみよう
Developer at
Twitter: @diasks2!
GitHub: diasks2
Pragmatic Segmenter
Chat Correct
Word Count Analyzer
? ? ?
Pragmatic Segmenter
A rule-based sentence boundary
detection gem that works out-of-the-box
across many languages.
What is segmentation?
Segmentation is the process of splitting a text
into segments or sentences. In other words,
deciding where sentences begin and end.
Pragmatic Segmenter
text = ”Hello Tokyo Rubyists. Let’s try segmentation.”
segment #1: Hello Tokyo Rubyists.
segment #2: Let’s try segmentation.
Why care about segmentation?
Pragmatic Segmenter
Sentence segmentation is the foundation of many
common NLP tasks:!
• Translation!
• Machine translation!
• Bitext alignment!
• Summarization!
• Part-of-speech tagging!
• Grammar parsing
Errors in segmentation compound
into errors in these other NLP tasks
Why reinvent the wheel?
Pragmatic Segmenter
• Most segmentation libraries are built to
support only English (or English plus a few
other languages)!
• Current solutions do not handle ill-formatted
content well!
• Some libraries perform really well when
trained with a data in a specific language and
a specific domain, but what happens when
your data could come from any language
and/or domain
Sentence segmentation methods
Pragmatic Segmenter
• Machine learning !
• Rule-based!
• Tokenize-first group-later (e.g. Stanford CoreNLP)
How can we achieve the following
in Ruby1?
string = “Hello world. Let’s try segmentation.”
Desired output: [“Hello world.”, “Let’s try segmentation.”]
Pragmatic Segmenter1 Using the core or standard library (no gems)
Time to check your solutions
Pragmatic Segmenter
Some potential answers
• string.scan(/[^.]+[.]/).map(&:strip)!
• string.scan(/(?<=s|A)[^.]+[.]/)!
• string.split(/(?<=.)s*/)!
• string.split(/(?<=.)/).map(&:strip)!
• string.split('.').map { |segment| segment.strip.insert(-1, '.') }!
• … your answer
Pragmatic Segmenter
Let’s change the original string
string = “Hello from Mt. Fuji. Let’s try segmentation.”
Desired output: [“Hello from Mt. Fuji.”, “Let’s try segmentation.”]
Pragmatic Segmenter
Uh oh…
string = “Hello from Mt. Fuji. Let’s try segmentation.”
=> [“Hello from Mt.”, “Fuji.”, “Let’s try segmentation.”]
string.scan(/[^.]+[.]/).map(&:strip)
Pragmatic Segmenter
Let’s brainstorm other edge cases
that will make our first solution fail
• abbreviations!
• …!
• …!
• …!
• …!
• …
Pragmatic Segmenter
Golden Rules
Pragmatic Segmenter
Currently 52 English Golden Rules covering edge cases such as:!
• abbreviations!
• abbreviations at the end of a sentence!
• numbers!
• parentheticals!
• email addresses!
• web addresses!
• quotations!
• lists!
• geo coordinates!
• ellipses
Rubyists like to keep it DRY
Pragmatic Segmenter
Most researchers either use the WSJ corpus or Brown corpus from the Penn
Treebank to test their segmentation algorithm!
!
There are limits to using these corpora:!
1. The corpora may be too expensive for some people ($1,700)!
2. The majority of the sentences in the corpora are sentences that end
with a regular word followed by a period, thus testing the same thing
over and over again
In the Brown Corpus 92% of potential sentence boundaries come after a regular word.
The WSJ Corpus is richer with abbreviations and only 83% of sentences end with a
regular word followed by a period.!
!
Andrei Mikheev - Periods, Capitalized Words, etc.
A comparison of segmentation libraries
Pragmatic Segmenter
Name Language License
Golden Rule Score !
(English)
Golden Rule Score
(Other Languages)
Speed
Pragmatic Segmenter Ruby MIT 98.08% 100.00% 3.84 s
TactfulTokenizer Ruby GNU GPLv3 65.38% 48.57% 46.32 s
Open NLP Java APLv2 59.62% 45.71% 1.27 s
Stanford CoreNLP Java GNU GPLv3 59.62% 31.43% 0.92 s
Splitta Python APLv2 55.77% 37.14% N/A
Punkt Python APLv2 46.15% 48.57% 1.79 s
SRX English Ruby GNU GPLv3 30.77% 28.57% 6.19 s
Scapel Ruby GNU GPLv3 28.85% 20.00% 0.13 s
† The performance test takes the 50 English Golden Rules combined into one string and runs it 100 times through each library. The number is an average of 10 runs.
The Holy Grail
Pragmatic Segmenter
A.M. / P.M. as non sentence boundary and sentence boundary
At 5 a.m. Mr. Smith went to the bank. He left the bank at 6 P.M. Mr. Smith then went to the store.
Golden Rule #18
All tested segmentation libraries failed this spec
["At 5 a.m. Mr. Smith went to the bank.", "He left the bank at 6 P.M.", "Mr. Smith then went to the store."]
Chat Correct
A Ruby gem that shows the errors
and error types when a correct
English sentence is diffed with an
incorrect English sentence.
The problem
Chat Correct
I was giving a weekly Skype English lesson
and the student was focusing on writing
practice for the TOEFL test
I would correct the student’s sentence, but it
would often seem as if he was missing some
of my corrections - even if I read it with a
LOT OF STRESS!!
The idea
Chat Correct
A color coded way to
a student’s mistake(s)
PoInT OuT
The solution
Chat Correct
Word Count Analyzer
Analyzes a string for potential areas
of the text that might cause word
count discrepancies depending on
the tool used.
The problem
Word Count Analyzer
• Translation is typically billed on a per
word basis!
• Different tools often report different
word counts
I wanted to understand what was
causing these differences in word count
Word count gray areas
Word Count Analyzer
Common word count gray areas include:!
• Ellipses!
• Hyperlinks!
• Contractions!
• Hyphenated Words!
• Dates!
• Numbers!
• Numbered Lists!
• XML and HTML tags!
• Forward slashes and backslashes!
• Punctuation
Visualize the gray areas
Word Count Analyzer
? ? ?
A bitext alignment (aka parallel text
alignment) tool with a focus on high
accuracy
What’s it used for?
• Translation memory!
• Machine translation
? ? ?
Bitext alignment
Current commercial state-of-the-art!
• Gale-Church sentence-length information plus
dictionary if available (e.g. hunalign)!
? ? ?
Areas for improvement
? ? ?
•Early misalignment compounds into
errors throughout!
•Accuracy may suffer for non-Roman
languages unless the algorithm is
properly tuned!
•Does not handle cross alignments
nor uneven alignments
A method for higher accuracy
• Machine translate A - B and B - A!
• Relative sentence length!
• Order or position in the document
? ? ?
0 1 2 3 4 5
0
1 X
2 X
3
4 X
5 X
X
The trade-offs
Pros!
• better accuracy!
• can handle crossing alignments!
• can handle uneven segments matches !
(1 to 2, 2 to 1, 1 to 3, 3 to 1, 2 to 3, and 3 to 2)
? ? ?
Cons!
• slower!
• potential data privacy issues !
(depending on method to obtain machine translation)
Small framework for thinking about new
problems
Step 1!
Use your ignorance as a weapon to think about a problem
from first principles (you aren’t yet weighed down with any
bias).
Step 3!
Diff your conceptual framework and your research. Look
at where it diverges and try to understand why.!
!
Has tech changed/advanced? Were you missing something?
Step 2!
Do your research.
Ruby NLP Resources
https://github.com/diasks2/ruby-nlp

Mais conteúdo relacionado

Mais procurados

Ruby Introduction
Ruby IntroductionRuby Introduction
Ruby IntroductionPrabu D
 
Stemming And Lemmatization Tutorial | Natural Language Processing (NLP) With ...
Stemming And Lemmatization Tutorial | Natural Language Processing (NLP) With ...Stemming And Lemmatization Tutorial | Natural Language Processing (NLP) With ...
Stemming And Lemmatization Tutorial | Natural Language Processing (NLP) With ...Edureka!
 
Tools for the Toolmakers
Tools for the ToolmakersTools for the Toolmakers
Tools for the ToolmakersCaleb Callaway
 
Natural Language Processing (NLP) & Text Mining Tutorial Using NLTK | NLP Tra...
Natural Language Processing (NLP) & Text Mining Tutorial Using NLTK | NLP Tra...Natural Language Processing (NLP) & Text Mining Tutorial Using NLTK | NLP Tra...
Natural Language Processing (NLP) & Text Mining Tutorial Using NLTK | NLP Tra...Edureka!
 
Ruby monsters
Ruby monstersRuby monsters
Ruby monsters1337807
 
Semana Interop: Trabalhando com IronPython e com Ironruby
Semana Interop: Trabalhando com IronPython e com IronrubySemana Interop: Trabalhando com IronPython e com Ironruby
Semana Interop: Trabalhando com IronPython e com IronrubyAlessandro Binhara
 
Programming languages vienna
Programming languages viennaProgramming languages vienna
Programming languages viennagreg_s
 

Mais procurados (14)

BDD with F# at DDD9
BDD with F# at DDD9BDD with F# at DDD9
BDD with F# at DDD9
 
Ruby programming
Ruby programmingRuby programming
Ruby programming
 
NLP new words
NLP new wordsNLP new words
NLP new words
 
Ruby Introduction
Ruby IntroductionRuby Introduction
Ruby Introduction
 
Week2
Week2Week2
Week2
 
Stemming And Lemmatization Tutorial | Natural Language Processing (NLP) With ...
Stemming And Lemmatization Tutorial | Natural Language Processing (NLP) With ...Stemming And Lemmatization Tutorial | Natural Language Processing (NLP) With ...
Stemming And Lemmatization Tutorial | Natural Language Processing (NLP) With ...
 
Tools for the Toolmakers
Tools for the ToolmakersTools for the Toolmakers
Tools for the Toolmakers
 
Natural Language Processing (NLP) & Text Mining Tutorial Using NLTK | NLP Tra...
Natural Language Processing (NLP) & Text Mining Tutorial Using NLTK | NLP Tra...Natural Language Processing (NLP) & Text Mining Tutorial Using NLTK | NLP Tra...
Natural Language Processing (NLP) & Text Mining Tutorial Using NLTK | NLP Tra...
 
Ruby monsters
Ruby monstersRuby monsters
Ruby monsters
 
ANTLR4 in depth
ANTLR4 in depthANTLR4 in depth
ANTLR4 in depth
 
Intro to NLP. Lecture 2
Intro to NLP.  Lecture 2Intro to NLP.  Lecture 2
Intro to NLP. Lecture 2
 
Semana Interop: Trabalhando com IronPython e com Ironruby
Semana Interop: Trabalhando com IronPython e com IronrubySemana Interop: Trabalhando com IronPython e com Ironruby
Semana Interop: Trabalhando com IronPython e com Ironruby
 
Programming languages vienna
Programming languages viennaProgramming languages vienna
Programming languages vienna
 
Ruby
RubyRuby
Ruby
 

Semelhante a Exploring Natural Language Processing in Ruby

This talk lasts 三十分钟
This talk lasts 三十分钟This talk lasts 三十分钟
This talk lasts 三十分钟thepilif
 
Ruby, the language of devops
Ruby, the language of devopsRuby, the language of devops
Ruby, the language of devopsRob Kinyon
 
Meta Programming in Ruby - Code Camp 2010
Meta Programming in Ruby - Code Camp 2010Meta Programming in Ruby - Code Camp 2010
Meta Programming in Ruby - Code Camp 2010ssoroka
 
Rails development environment talk
Rails development environment talkRails development environment talk
Rails development environment talkReuven Lerner
 
Programming Languages #devcon2013
Programming Languages #devcon2013Programming Languages #devcon2013
Programming Languages #devcon2013Iván Montes
 
Go language presentation
Go language presentationGo language presentation
Go language presentationparamisoft
 
From Programming to Modeling And Back Again
From Programming to Modeling And Back AgainFrom Programming to Modeling And Back Again
From Programming to Modeling And Back AgainMarkus Voelter
 
A Static Type Analyzer of Untyped Ruby Code for Ruby 3
A Static Type Analyzer of Untyped Ruby Code for Ruby 3A Static Type Analyzer of Untyped Ruby Code for Ruby 3
A Static Type Analyzer of Untyped Ruby Code for Ruby 3mametter
 
Mind your lang (for role=drinks at CSUN 2017)
Mind your lang (for role=drinks at CSUN 2017)Mind your lang (for role=drinks at CSUN 2017)
Mind your lang (for role=drinks at CSUN 2017)Adrian Roselli
 
Intro to nlp
Intro to nlpIntro to nlp
Intro to nlpankit_ppt
 
introtonlp-190218095523 (1).pdf
introtonlp-190218095523 (1).pdfintrotonlp-190218095523 (1).pdf
introtonlp-190218095523 (1).pdfAdityaMishra178868
 
How to Make Your Strings Translator Friendly
How to Make Your Strings Translator FriendlyHow to Make Your Strings Translator Friendly
How to Make Your Strings Translator FriendlyNaoko Takano
 
Metaprogramming Go
Metaprogramming GoMetaprogramming Go
Metaprogramming GoWeng Wei
 
Converging Textual and Graphical Editors
Converging Textual  and Graphical EditorsConverging Textual  and Graphical Editors
Converging Textual and Graphical Editorsmeysholdt
 

Semelhante a Exploring Natural Language Processing in Ruby (20)

This talk lasts 三十分钟
This talk lasts 三十分钟This talk lasts 三十分钟
This talk lasts 三十分钟
 
Lexing and parsing
Lexing and parsingLexing and parsing
Lexing and parsing
 
JRuby: The Hard Parts
JRuby: The Hard PartsJRuby: The Hard Parts
JRuby: The Hard Parts
 
Ruby, the language of devops
Ruby, the language of devopsRuby, the language of devops
Ruby, the language of devops
 
Tips and tricks for PE
Tips and tricks for PETips and tricks for PE
Tips and tricks for PE
 
Build your own ASR engine
Build your own ASR engineBuild your own ASR engine
Build your own ASR engine
 
Meta Programming in Ruby - Code Camp 2010
Meta Programming in Ruby - Code Camp 2010Meta Programming in Ruby - Code Camp 2010
Meta Programming in Ruby - Code Camp 2010
 
Rails development environment talk
Rails development environment talkRails development environment talk
Rails development environment talk
 
Programming Languages #devcon2013
Programming Languages #devcon2013Programming Languages #devcon2013
Programming Languages #devcon2013
 
Go language presentation
Go language presentationGo language presentation
Go language presentation
 
From Programming to Modeling And Back Again
From Programming to Modeling And Back AgainFrom Programming to Modeling And Back Again
From Programming to Modeling And Back Again
 
A Static Type Analyzer of Untyped Ruby Code for Ruby 3
A Static Type Analyzer of Untyped Ruby Code for Ruby 3A Static Type Analyzer of Untyped Ruby Code for Ruby 3
A Static Type Analyzer of Untyped Ruby Code for Ruby 3
 
Mind your lang (for role=drinks at CSUN 2017)
Mind your lang (for role=drinks at CSUN 2017)Mind your lang (for role=drinks at CSUN 2017)
Mind your lang (for role=drinks at CSUN 2017)
 
Intro to nlp
Intro to nlpIntro to nlp
Intro to nlp
 
introtonlp-190218095523 (1).pdf
introtonlp-190218095523 (1).pdfintrotonlp-190218095523 (1).pdf
introtonlp-190218095523 (1).pdf
 
How to Make Your Strings Translator Friendly
How to Make Your Strings Translator FriendlyHow to Make Your Strings Translator Friendly
How to Make Your Strings Translator Friendly
 
Metaprogramming Go
Metaprogramming GoMetaprogramming Go
Metaprogramming Go
 
Apex for humans
Apex for humansApex for humans
Apex for humans
 
Ruby
RubyRuby
Ruby
 
Converging Textual and Graphical Editors
Converging Textual  and Graphical EditorsConverging Textual  and Graphical Editors
Converging Textual and Graphical Editors
 

Mais de Kevin Dias

TM-Town - Getting the Most out of Your Translation Memories
TM-Town - Getting the Most out of Your Translation MemoriesTM-Town - Getting the Most out of Your Translation Memories
TM-Town - Getting the Most out of Your Translation MemoriesKevin Dias
 
Getting the Most out of Your Translation Memories (TM-Town ProZ Webinar April...
Getting the Most out of Your Translation Memories (TM-Town ProZ Webinar April...Getting the Most out of Your Translation Memories (TM-Town ProZ Webinar April...
Getting the Most out of Your Translation Memories (TM-Town ProZ Webinar April...Kevin Dias
 
TM-Town TAUS Translation Technology Webinar (April 2015)
TM-Town TAUS Translation Technology Webinar (April 2015)TM-Town TAUS Translation Technology Webinar (April 2015)
TM-Town TAUS Translation Technology Webinar (April 2015)Kevin Dias
 
Putter King Education Program - Physics Level 2 (Teacher's Guide English)
Putter King Education Program - Physics Level 2 (Teacher's Guide English)Putter King Education Program - Physics Level 2 (Teacher's Guide English)
Putter King Education Program - Physics Level 2 (Teacher's Guide English)Kevin Dias
 
Putter King Education Program - Physics Level 2 (English)
Putter King Education Program - Physics Level 2 (English)Putter King Education Program - Physics Level 2 (English)
Putter King Education Program - Physics Level 2 (English)Kevin Dias
 
Putter King Education Program - Physics Level 1 (Teacher's Guide Japanese)
Putter King Education Program - Physics Level 1 (Teacher's Guide Japanese)Putter King Education Program - Physics Level 1 (Teacher's Guide Japanese)
Putter King Education Program - Physics Level 1 (Teacher's Guide Japanese)Kevin Dias
 
Putter King Education Program - Physics Level 1 (Teacher's Guide English)
Putter King Education Program - Physics Level 1 (Teacher's Guide English)Putter King Education Program - Physics Level 1 (Teacher's Guide English)
Putter King Education Program - Physics Level 1 (Teacher's Guide English)Kevin Dias
 
Putter King Education Program - Physics Level 1 (Japanese)
Putter King Education Program - Physics Level 1 (Japanese)Putter King Education Program - Physics Level 1 (Japanese)
Putter King Education Program - Physics Level 1 (Japanese)Kevin Dias
 
Putter King Education Program - Physics Level 1 (English)
Putter King Education Program - Physics Level 1 (English)Putter King Education Program - Physics Level 1 (English)
Putter King Education Program - Physics Level 1 (English)Kevin Dias
 
Putter King Education Program - Math Level 3 (Teacher's Guide English)
Putter King Education Program - Math Level 3 (Teacher's Guide English)Putter King Education Program - Math Level 3 (Teacher's Guide English)
Putter King Education Program - Math Level 3 (Teacher's Guide English)Kevin Dias
 
Putter King Education Program - Math Level 3 (English)
Putter King Education Program - Math Level 3 (English)Putter King Education Program - Math Level 3 (English)
Putter King Education Program - Math Level 3 (English)Kevin Dias
 
Putter King Education Program - Math Level 2 (Teacher's Guide Japanese)
Putter King Education Program - Math Level 2 (Teacher's Guide Japanese)Putter King Education Program - Math Level 2 (Teacher's Guide Japanese)
Putter King Education Program - Math Level 2 (Teacher's Guide Japanese)Kevin Dias
 
Putter King Education Program - Math Level 2 (Teacher's Guide English)
Putter King Education Program - Math Level 2 (Teacher's Guide English)Putter King Education Program - Math Level 2 (Teacher's Guide English)
Putter King Education Program - Math Level 2 (Teacher's Guide English)Kevin Dias
 
Putter King Education Program - Math Level 2 (Japanese)
Putter King Education Program - Math Level 2 (Japanese)Putter King Education Program - Math Level 2 (Japanese)
Putter King Education Program - Math Level 2 (Japanese)Kevin Dias
 
Putter King Education Program - Math Level 2 (English)
Putter King Education Program - Math Level 2 (English)Putter King Education Program - Math Level 2 (English)
Putter King Education Program - Math Level 2 (English)Kevin Dias
 
Putter King Education Program - Math Level 1 (Teacher's Guide Japanese)
Putter King Education Program - Math Level 1 (Teacher's Guide Japanese)Putter King Education Program - Math Level 1 (Teacher's Guide Japanese)
Putter King Education Program - Math Level 1 (Teacher's Guide Japanese)Kevin Dias
 
Putter King Education Program - Math Level 1 (Japanese)
Putter King Education Program - Math Level 1 (Japanese)Putter King Education Program - Math Level 1 (Japanese)
Putter King Education Program - Math Level 1 (Japanese)Kevin Dias
 
Putter King Education Program - Math Level 1 (English)
Putter King Education Program - Math Level 1 (English)Putter King Education Program - Math Level 1 (English)
Putter King Education Program - Math Level 1 (English)Kevin Dias
 
Putter King Business Plan
Putter King Business PlanPutter King Business Plan
Putter King Business PlanKevin Dias
 
Student Database Presentation 1.14.10
Student Database Presentation 1.14.10Student Database Presentation 1.14.10
Student Database Presentation 1.14.10Kevin Dias
 

Mais de Kevin Dias (20)

TM-Town - Getting the Most out of Your Translation Memories
TM-Town - Getting the Most out of Your Translation MemoriesTM-Town - Getting the Most out of Your Translation Memories
TM-Town - Getting the Most out of Your Translation Memories
 
Getting the Most out of Your Translation Memories (TM-Town ProZ Webinar April...
Getting the Most out of Your Translation Memories (TM-Town ProZ Webinar April...Getting the Most out of Your Translation Memories (TM-Town ProZ Webinar April...
Getting the Most out of Your Translation Memories (TM-Town ProZ Webinar April...
 
TM-Town TAUS Translation Technology Webinar (April 2015)
TM-Town TAUS Translation Technology Webinar (April 2015)TM-Town TAUS Translation Technology Webinar (April 2015)
TM-Town TAUS Translation Technology Webinar (April 2015)
 
Putter King Education Program - Physics Level 2 (Teacher's Guide English)
Putter King Education Program - Physics Level 2 (Teacher's Guide English)Putter King Education Program - Physics Level 2 (Teacher's Guide English)
Putter King Education Program - Physics Level 2 (Teacher's Guide English)
 
Putter King Education Program - Physics Level 2 (English)
Putter King Education Program - Physics Level 2 (English)Putter King Education Program - Physics Level 2 (English)
Putter King Education Program - Physics Level 2 (English)
 
Putter King Education Program - Physics Level 1 (Teacher's Guide Japanese)
Putter King Education Program - Physics Level 1 (Teacher's Guide Japanese)Putter King Education Program - Physics Level 1 (Teacher's Guide Japanese)
Putter King Education Program - Physics Level 1 (Teacher's Guide Japanese)
 
Putter King Education Program - Physics Level 1 (Teacher's Guide English)
Putter King Education Program - Physics Level 1 (Teacher's Guide English)Putter King Education Program - Physics Level 1 (Teacher's Guide English)
Putter King Education Program - Physics Level 1 (Teacher's Guide English)
 
Putter King Education Program - Physics Level 1 (Japanese)
Putter King Education Program - Physics Level 1 (Japanese)Putter King Education Program - Physics Level 1 (Japanese)
Putter King Education Program - Physics Level 1 (Japanese)
 
Putter King Education Program - Physics Level 1 (English)
Putter King Education Program - Physics Level 1 (English)Putter King Education Program - Physics Level 1 (English)
Putter King Education Program - Physics Level 1 (English)
 
Putter King Education Program - Math Level 3 (Teacher's Guide English)
Putter King Education Program - Math Level 3 (Teacher's Guide English)Putter King Education Program - Math Level 3 (Teacher's Guide English)
Putter King Education Program - Math Level 3 (Teacher's Guide English)
 
Putter King Education Program - Math Level 3 (English)
Putter King Education Program - Math Level 3 (English)Putter King Education Program - Math Level 3 (English)
Putter King Education Program - Math Level 3 (English)
 
Putter King Education Program - Math Level 2 (Teacher's Guide Japanese)
Putter King Education Program - Math Level 2 (Teacher's Guide Japanese)Putter King Education Program - Math Level 2 (Teacher's Guide Japanese)
Putter King Education Program - Math Level 2 (Teacher's Guide Japanese)
 
Putter King Education Program - Math Level 2 (Teacher's Guide English)
Putter King Education Program - Math Level 2 (Teacher's Guide English)Putter King Education Program - Math Level 2 (Teacher's Guide English)
Putter King Education Program - Math Level 2 (Teacher's Guide English)
 
Putter King Education Program - Math Level 2 (Japanese)
Putter King Education Program - Math Level 2 (Japanese)Putter King Education Program - Math Level 2 (Japanese)
Putter King Education Program - Math Level 2 (Japanese)
 
Putter King Education Program - Math Level 2 (English)
Putter King Education Program - Math Level 2 (English)Putter King Education Program - Math Level 2 (English)
Putter King Education Program - Math Level 2 (English)
 
Putter King Education Program - Math Level 1 (Teacher's Guide Japanese)
Putter King Education Program - Math Level 1 (Teacher's Guide Japanese)Putter King Education Program - Math Level 1 (Teacher's Guide Japanese)
Putter King Education Program - Math Level 1 (Teacher's Guide Japanese)
 
Putter King Education Program - Math Level 1 (Japanese)
Putter King Education Program - Math Level 1 (Japanese)Putter King Education Program - Math Level 1 (Japanese)
Putter King Education Program - Math Level 1 (Japanese)
 
Putter King Education Program - Math Level 1 (English)
Putter King Education Program - Math Level 1 (English)Putter King Education Program - Math Level 1 (English)
Putter King Education Program - Math Level 1 (English)
 
Putter King Business Plan
Putter King Business PlanPutter King Business Plan
Putter King Business Plan
 
Student Database Presentation 1.14.10
Student Database Presentation 1.14.10Student Database Presentation 1.14.10
Student Database Presentation 1.14.10
 

Último

Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...SelfMade bd
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrainmasabamasaba
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Steffen Staab
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...Shane Coughlan
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...kalichargn70th171
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionOnePlan Solutions
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfonteinmasabamasaba
 
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdfAzure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdfryanfarris8
 
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...Nitya salvi
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfonteinmasabamasaba
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesVictorSzoltysek
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park masabamasaba
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnAmarnathKambale
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfVishalKumarJha10
 
LEVEL 5 - SESSION 1 2023 (1).pptx - PDF 123456
LEVEL 5   - SESSION 1 2023 (1).pptx - PDF 123456LEVEL 5   - SESSION 1 2023 (1).pptx - PDF 123456
LEVEL 5 - SESSION 1 2023 (1).pptx - PDF 123456KiaraTiradoMicha
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdfPearlKirahMaeRagusta1
 

Último (20)

Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdfAzure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
 
LEVEL 5 - SESSION 1 2023 (1).pptx - PDF 123456
LEVEL 5   - SESSION 1 2023 (1).pptx - PDF 123456LEVEL 5   - SESSION 1 2023 (1).pptx - PDF 123456
LEVEL 5 - SESSION 1 2023 (1).pptx - PDF 123456
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdf
 

Exploring Natural Language Processing in Ruby

  • 1. Exploring Natural Language Processing in Ruby Kevin Dias! Tokyo Rubyist Meetup - April 9th, 2015 Rubyで自然言語処理の世界を探求してみよう
  • 4. Pragmatic Segmenter A rule-based sentence boundary detection gem that works out-of-the-box across many languages.
  • 5. What is segmentation? Segmentation is the process of splitting a text into segments or sentences. In other words, deciding where sentences begin and end. Pragmatic Segmenter text = ”Hello Tokyo Rubyists. Let’s try segmentation.” segment #1: Hello Tokyo Rubyists. segment #2: Let’s try segmentation.
  • 6. Why care about segmentation? Pragmatic Segmenter Sentence segmentation is the foundation of many common NLP tasks:! • Translation! • Machine translation! • Bitext alignment! • Summarization! • Part-of-speech tagging! • Grammar parsing Errors in segmentation compound into errors in these other NLP tasks
  • 7. Why reinvent the wheel? Pragmatic Segmenter • Most segmentation libraries are built to support only English (or English plus a few other languages)! • Current solutions do not handle ill-formatted content well! • Some libraries perform really well when trained with a data in a specific language and a specific domain, but what happens when your data could come from any language and/or domain
  • 8. Sentence segmentation methods Pragmatic Segmenter • Machine learning ! • Rule-based! • Tokenize-first group-later (e.g. Stanford CoreNLP)
  • 9. How can we achieve the following in Ruby1? string = “Hello world. Let’s try segmentation.” Desired output: [“Hello world.”, “Let’s try segmentation.”] Pragmatic Segmenter1 Using the core or standard library (no gems)
  • 10. Time to check your solutions Pragmatic Segmenter
  • 11. Some potential answers • string.scan(/[^.]+[.]/).map(&:strip)! • string.scan(/(?<=s|A)[^.]+[.]/)! • string.split(/(?<=.)s*/)! • string.split(/(?<=.)/).map(&:strip)! • string.split('.').map { |segment| segment.strip.insert(-1, '.') }! • … your answer Pragmatic Segmenter
  • 12. Let’s change the original string string = “Hello from Mt. Fuji. Let’s try segmentation.” Desired output: [“Hello from Mt. Fuji.”, “Let’s try segmentation.”] Pragmatic Segmenter
  • 13. Uh oh… string = “Hello from Mt. Fuji. Let’s try segmentation.” => [“Hello from Mt.”, “Fuji.”, “Let’s try segmentation.”] string.scan(/[^.]+[.]/).map(&:strip) Pragmatic Segmenter
  • 14. Let’s brainstorm other edge cases that will make our first solution fail • abbreviations! • …! • …! • …! • …! • … Pragmatic Segmenter
  • 15. Golden Rules Pragmatic Segmenter Currently 52 English Golden Rules covering edge cases such as:! • abbreviations! • abbreviations at the end of a sentence! • numbers! • parentheticals! • email addresses! • web addresses! • quotations! • lists! • geo coordinates! • ellipses
  • 16. Rubyists like to keep it DRY Pragmatic Segmenter Most researchers either use the WSJ corpus or Brown corpus from the Penn Treebank to test their segmentation algorithm! ! There are limits to using these corpora:! 1. The corpora may be too expensive for some people ($1,700)! 2. The majority of the sentences in the corpora are sentences that end with a regular word followed by a period, thus testing the same thing over and over again In the Brown Corpus 92% of potential sentence boundaries come after a regular word. The WSJ Corpus is richer with abbreviations and only 83% of sentences end with a regular word followed by a period.! ! Andrei Mikheev - Periods, Capitalized Words, etc.
  • 17. A comparison of segmentation libraries Pragmatic Segmenter Name Language License Golden Rule Score ! (English) Golden Rule Score (Other Languages) Speed Pragmatic Segmenter Ruby MIT 98.08% 100.00% 3.84 s TactfulTokenizer Ruby GNU GPLv3 65.38% 48.57% 46.32 s Open NLP Java APLv2 59.62% 45.71% 1.27 s Stanford CoreNLP Java GNU GPLv3 59.62% 31.43% 0.92 s Splitta Python APLv2 55.77% 37.14% N/A Punkt Python APLv2 46.15% 48.57% 1.79 s SRX English Ruby GNU GPLv3 30.77% 28.57% 6.19 s Scapel Ruby GNU GPLv3 28.85% 20.00% 0.13 s † The performance test takes the 50 English Golden Rules combined into one string and runs it 100 times through each library. The number is an average of 10 runs.
  • 18. The Holy Grail Pragmatic Segmenter A.M. / P.M. as non sentence boundary and sentence boundary At 5 a.m. Mr. Smith went to the bank. He left the bank at 6 P.M. Mr. Smith then went to the store. Golden Rule #18 All tested segmentation libraries failed this spec ["At 5 a.m. Mr. Smith went to the bank.", "He left the bank at 6 P.M.", "Mr. Smith then went to the store."]
  • 19. Chat Correct A Ruby gem that shows the errors and error types when a correct English sentence is diffed with an incorrect English sentence.
  • 20. The problem Chat Correct I was giving a weekly Skype English lesson and the student was focusing on writing practice for the TOEFL test I would correct the student’s sentence, but it would often seem as if he was missing some of my corrections - even if I read it with a LOT OF STRESS!!
  • 21. The idea Chat Correct A color coded way to a student’s mistake(s) PoInT OuT
  • 23. Word Count Analyzer Analyzes a string for potential areas of the text that might cause word count discrepancies depending on the tool used.
  • 24. The problem Word Count Analyzer • Translation is typically billed on a per word basis! • Different tools often report different word counts I wanted to understand what was causing these differences in word count
  • 25. Word count gray areas Word Count Analyzer Common word count gray areas include:! • Ellipses! • Hyperlinks! • Contractions! • Hyphenated Words! • Dates! • Numbers! • Numbered Lists! • XML and HTML tags! • Forward slashes and backslashes! • Punctuation
  • 26. Visualize the gray areas Word Count Analyzer
  • 27. ? ? ? A bitext alignment (aka parallel text alignment) tool with a focus on high accuracy
  • 28. What’s it used for? • Translation memory! • Machine translation ? ? ?
  • 29. Bitext alignment Current commercial state-of-the-art! • Gale-Church sentence-length information plus dictionary if available (e.g. hunalign)! ? ? ?
  • 30. Areas for improvement ? ? ? •Early misalignment compounds into errors throughout! •Accuracy may suffer for non-Roman languages unless the algorithm is properly tuned! •Does not handle cross alignments nor uneven alignments
  • 31. A method for higher accuracy • Machine translate A - B and B - A! • Relative sentence length! • Order or position in the document ? ? ? 0 1 2 3 4 5 0 1 X 2 X 3 4 X 5 X X
  • 32. The trade-offs Pros! • better accuracy! • can handle crossing alignments! • can handle uneven segments matches ! (1 to 2, 2 to 1, 1 to 3, 3 to 1, 2 to 3, and 3 to 2) ? ? ? Cons! • slower! • potential data privacy issues ! (depending on method to obtain machine translation)
  • 33. Small framework for thinking about new problems Step 1! Use your ignorance as a weapon to think about a problem from first principles (you aren’t yet weighed down with any bias). Step 3! Diff your conceptual framework and your research. Look at where it diverges and try to understand why.! ! Has tech changed/advanced? Were you missing something? Step 2! Do your research.