李鈺昇 Who am I and why Im here Outline Introduction U nderstanding sentences Compressing sentences Word similarity I Spelling checkers Word similarity II Arithmetics with words Introduction ID: 815903
Download The PPT/PDF document "計算思維與解題 Computational thin..." is the property of its rightful owner. Permission is granted to download and print the materials on this web site for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.
Slide1
計算思維與解題Computational thinking
李鈺昇
Slide2Who am I (and why I’m here)
Slide3Outline
Introduction
U
nderstanding sentences
Compressing sentences
Word similarity I: Spelling checkers
Word similarity II: Arithmetics with words
Slide4Introduction
Understanding sentences
Compressing sentences
Word similarity I: Spelling checkers
Word similarity II: Arithmetics with words
Outline
Slide5Computational thinking is about ...
The thinking process of abstraction (or generalization)
Formalizing abstract ideas, i.e. turning thoughts into algorithms
Is a problem solvable? If so, is it easy or complex? How fast can it be solved?
Transforming or reducing complex problems into easier ones
Slide6Computational thinking is NOT about ...
Computer programming, like learning Python or C++
(even IOI is not about this)
Understanding how computers work
Slide7The intersection of linguistics and computational thinking
Linguists call it computational linguistics, while computer scientists call it natural language processing.
Slide8The intersection of linguistics and computational thinking
Slide9The intersection of linguistics and computational thinking
Slide10Outline
Introduction
Understanding sentences
Compressing sentences
Word similarity I: Spelling checkers
Word similarity II: Arithmetics with words
Slide11How do we understand (English) sentences?
Usually we just process them in our brain unconsciously.
As we grow up, we automatically learn how to form “natural” or “legal” sentences without thinking too much. And we know this is called grammar.
To make things easier, we often consider context-free grammar (CFG) in Chomsky normal form (CNF):
Starting variable S and other variables A, B, C, …
Terminals a, b, c, ...
Rules of the following types:
A -> BC
A -> a (and S ->
𝟄
)
http://mdaines.github.io/grammophone/
https://web.stanford.edu/class/archive/cs/cs103/cs103.1156/tools/cfg/
Slide12How can sentences be automatically parsed?
Parsing with shift-reduce parser.
http://nacloweb.org/resources/problems/2018/N2018-R.pdf
https://www.csie.ntu.edu.tw/~r07922087/shift-reduce-parser/
All Americans need to buy a house
is a large amount of money.
Melanie is pretty
busy.
Fat people eat
accumulates in their bodies.
Slide13Outline
Introduction
Understanding sentences
Compressing sentences
Word similarity I: Spelling checkers
Word similarity II: Arithmetics with words
Slide14How to compress sentences?
Suppose you want to tell someone some string, like:
eeeeeeeeee
civic
bookkeeper
grammar
shukaihsieh
Slide15If we assign same-length codes to each letter...
For example,
e -> 00000
s -> 00001
r -> 00010, … and so on
Then given an length-n string, the encoded string has length 5n.
Can we do it better, if we “know” the string?
Slide16Huffman coding
Main idea: Frequent letters should be assigned shorter codes, and vice versa.
Notice that the coding should be prefix-free to avoid ambiguity.
http://ben-tanen.com/adaptive-huffman/
http://nacloweb.org/resources/problems/2013/N2013-C.pdf
Slide17Outline
Introduction
Understanding sentences
Compressing sentences
Word similarity I: Spelling checkers
Word similarity II: Arithmetics with words
Slide18How do spelling checkers work?
Which pairs of the following words look similar?
gray,
great, grey, ray
, greet
sigh, sight, light, sign, flight
How do you measure similarity? What makes words look “different?”
Slide19Levenshtein distance (a.k.a. edit distance)
http://nacloweb.org/resources/problems/2009/N2009-B.pdf
https://phiresky.github.io/levenshtein-demo/
Slide20A simple algorithm for spelling checker
Input: w
Let v_min be something like fdlngskjfdnduvhadnlkjanf
For each word v in dictionary
Compute edit distance between v and w, say e
If e < edit distance between v_min and w
Then let v_min be v
Output: v_min
Slide21Outline
Introduction
Understanding sentences
Compressing sentences
Word similarity I: Spelling checkers
Word similarity II: Arithmetics with words
Slide22How to measure similarities among words?
You shall know a word by the company it keeps.
- John Rupert Firth
Slide23Can words have some kind of arithmetics?
https://projector.tensorflow.org/
https://ronxin.github.io/wevi/
http://nacloweb.org/resources/problems/2016/N2016-K.pdf
Slide24Thanks for your attention!