Natural Language Processing

Similar documents
Basic Text Processing

Information Retrieval

More about Posting Lists

Information Retrieval

More on indexing and text operations CE-324: Modern Information Retrieval Sharif University of Technology

Recap of the previous lecture. Recall the basic indexing pipeline. Plan for this lecture. Parsing a document. Introduction to Information Retrieval

More on indexing and text operations CE-324: Modern Information Retrieval Sharif University of Technology

Information Retrieval

CS276 Information Retrieval and Web Search. Lecture 2: Dictionary and Postings

Boolean retrieval & basics of indexing CE-324: Modern Information Retrieval Sharif University of Technology

Part 3: The term vocabulary, postings lists and tolerant retrieval Francesco Ricci

DD2476: Search Engines and Information Retrieval Systems

Regular Expressions. using REs to find patterns. implementing REs using finite state automata. Sunday, 4 December 11

Information Retrieval and Web Search

CS6322: Information Retrieval Sanda Harabagiu. Lecture 2: The term vocabulary and postings lists

Informa(on Retrieval

Information Retrieval and Organisation

Web Information Retrieval. Lecture 2 Tokenization, Normalization, Speedup, Phrase Queries

Lecture 2: Encoding models for text. Many thanks to Prabhakar Raghavan for sharing most content from the following slides

n Tuesday office hours changed: n 2-3pm n Homework 1 due Tuesday n Assignment 1 n Due next Friday n Can work with a partner

CSE528 Natural Language Processing Venue:ADB-405 Topic: Regular Expressions & Automata. www. l ea rn ersd esk.weeb l y. com

Text Pre-processing and Faster Query Processing

applied regex implementing REs using finite state automata using REs to find patterns Informatics 1 School of Informatics, University of Edinburgh 1

Information Retrieval CS-E credits

INFO 4300 / CS4300 Information Retrieval. slides adapted from Hinrich Schütze s, linked from

Chapter 4. Processing Text

Regular Expressions. Computer Science and Engineering College of Engineering The Ohio State University. Lecture 9

Information Retrieval and Text Mining

Digital Libraries: Language Technologies

Tuesday, September 30, 14.

Describing Languages with Regular Expressions

Speech and Language Processing. Lecture 3 Chapter 3 of SLP

Introduction to Lexical Analysis

Regular Expressions. Steve Renals (based on original notes by Ewan Klein) ICL 12 October Outline Overview of REs REs in Python

Non-deterministic Finite Automata (NFA)

Applied Natural Language Processing

INFO 4300 / CS4300 Information Retrieval. slides adapted from Hinrich Schütze s, linked from

Introduction to: Computers & Programming: Strings and Other Sequences

Lexical Analysis. Lecture 3. January 10, 2018


INF FALL NATURAL LANGUAGE PROCESSING. Jan Tore Lønning, Lecture 4, 10.9

Compiler Design. 2. Regular Expressions & Finite State Automata (FSA) Kanat Bolazar January 21, 2010

This example uses the or-operator ' '. Strings which are enclosed in angle brackets (like <N>, <sg>, and <pl> in the example) are multi-character symb

WEB AND SOCIAL INFORMATION EXTRACTION

Dr. Sarah Abraham University of Texas at Austin Computer Science Department. Regular Expressions. Elements of Graphics CS324e Spring 2017

Challenge. Case Study. The fabric of space and time has collapsed. What s the big deal? Miami University of Ohio

Lexical Analysis. Finite Automata

Introduction to Lexical Analysis

Lexical Analysis. Finite Automata

Course introduction. Marco Kuhlmann Department of Computer and Information Science. TDDE17 Introduction to Language Technology (2017)

Tokenization and Sentence Segmentation. Yan Shao Department of Linguistics and Philology, Uppsala University 29 March 2017

Influence of Word Normalization on Text Classification

Expressions, Text Normalization, Edit Distance

Lecture 3 Regular Expressions and Automata

CSE 7/5337: Information Retrieval and Web Search The term vocabulary and postings lists (IIR 2)

Syntactic Analysis. CS345H: Programming Languages. Lecture 3: Lexical Analysis. Outline. Lexical Analysis. What is a Token? Tokens

Lexical Analysis (ASU Ch 3, Fig 3.1)

Lexical Analysis. Lecture 3-4

Regular expressions. LING78100: Methods in Computational Linguistics I

Information Retrieval. Lecture 2 - Building an index

Lexical Analysis. Chapter 2

Cunning Plan. Informal Sketch of Lexical Analysis. Issues in Lexical Analysis. Specifying Lexers

Introduction to Information Retrieval

Concepts Introduced in Chapter 3. Lexical Analysis. Lexical Analysis Terms. Attributes for Tokens

Language Support, Linguistics, and Text Analytics in Solr

CSC401/2511 ONE OF THE FIRST TUTORIALS EVER, EVERYBODY SAYS SO. Frank Rudzicz

Introduction to: Computers & Programming: Strings and Other Sequences

Bioinformatics Programming. EE, NCKU Tien-Hao Chang (Darby Chang)

CS6200 Information Retrieval. David Smith College of Computer and Information Science Northeastern University

Lexical Analysis. Lecture 2-4

Regular Expressions. Michael Wrzaczek Dept of Biosciences, Plant Biology Viikki Plant Science Centre (ViPS) University of Helsinki, Finland

WFST: Weighted Finite State Transducer. September 12, 2017 Prof. Marie Meteer

Practical Natural Language Processing with Senior Architect West Monroe Partners

Regular Expressions & Automata

Part 5 Program Analysis Principles and Techniques

CS Unix Tools & Scripting

Compiler Construction D7011E

Stemming Techniques for Tamil Language

The Web Enabling Company

jprocessing Documentation

Regular Expressions.

More on indexing CE-324: Modern Information Retrieval Sharif University of Technology

Parsing and Pattern Recognition

Regular Expressions. Regular Expression Syntax in Python. Achtung!

Structure of Programming Languages Lecture 3

Regular Expressions. Regular expressions are a powerful search-and-replace technique that is widely used in other environments (such as Unix and Perl)

Compiler Construction LECTURE # 3

CMSC 132: Object-Oriented Programming II

Automatic Lemmatizer Construction with Focus on OOV Words Lemmatization

CS 124/LINGUIST 180 From Languages to Information. Unix for Poets Dan Jurafsky

UVa ID: NAME (print): CS 4501 LDI Midterm 1

Lexical Analysis. Dragon Book Chapter 3 Formal Languages Regular Expressions Finite Automata Theory Lexical Analysis using Automata

Formal Languages. Formal Languages

CSCE 314 Programming Languages

Understanding Regular Expressions, Special Characters, and Patterns

Lexical Analysis. Lexical analysis is the first phase of compilation: The file is converted from ASCII to tokens. It must be fast!

Introduction to regular expressions

Finite-State and the Noisy Channel Intro to NLP - J. Eisner 1

terms September 21, 2017 adapted from Schütze, Center for Information and Language Processing, University of Munich

Compilers. Nai-Wei Lin Department of Computer Science and Information Engineering National Chung Cheng University

Transcription:

Natural Language Processing Basic Text Processing! Thanks to Dan Jurafsky and Chris Manning for reuse of (some) slides!

Basic text processing Before we can start processing a piece of text: Segment text into tokens (words, punctuation marks, and other symbols) Regularize tokens in various ways (spelling, capitalization, inflection) Chunk tokens into sentences (often the largest meaningful units in NLP) Finite state technology Transduction = mapping an input sequence to an output sequence Performed efficiently using finite state automata (FSA, FST) Specified using regular expressions (RE) 2

Regular Expressions A formal language for specifying text strings How can we search for any of these? woodchuck woodchucks Woodchuck Woodchucks 3

Regular Expressions: Literals Most characters represent themselves Pattern Matches woodchuck woodchuck 123! 123 Some characters have to be escaped Pattern Matches 4 \.. This is a sentence. \$ $ $100,000

Regular Expressions: Disjunctions Letters inside square brackets []! Pattern! [ww]oodchuck Ranges [A-Z]! 5 Pattern Matches [1234567890]! Any digit Matches Woodchuck, woodchuck [A-Z] An upper case letter Drenched Blossoms [a-z] A lower case letter my beans were impatient [0-9] A single digit Chapter 1: Down the Rabbit Hole

Regular Expressions: Character Classes Ranges work well for English, but what about é, ç, Å, ß, œ? Often better to use (LOCALE dependent) character classes In Python: Pattern Matches ASCII equivalent \w Alphanumeric [0-9A- Za- z_] \d Digit [0-9] \s Whitespace [ \t\n\r\f\v] 6

Regular Expressions: Negation in Disjunction Negations [^Ss]! Caret means negation only when first in [] Pattern Matches [^A-Z] Not an upper case letter Oyfn pripetchik [^Ss]! Neither S nor s I have no exquisite reason [^e^] Neither e nor ^ Look here a^b The pattern a caret b Look up a^b now 7

Regular Expressions: More Disjunction Woodchucks is another name for groundhog! The pipe for disjunction Pattern groundhog woodchuck yours mine a b c = [abc] [gg]roundhog [Ww]oodchuck 8 Photo D. Fletcher

Regular Expressions:? * +. Pattern Matches colou?r Optional previous char color colour oo*h! 0 or more of previous char oh! ooh! oooh! ooooh! o+h! 1 or more of previous char oh! ooh! oooh! ooooh! baa+ baa baaa baaaa baaaaa Stephen C Kleene beg.n begin begun begun beg3n Kleene *, Kleene + 9

Regular Expressions: Anchors ^ $ Pattern Matches ^[A-Z] Palo Alto ^[^A-Za-z] 1 Hello \.$ The end..$ The end? The end!! 10

Example Find me all instances of the word the in a text. the Misses capitalized examples [tt]he!!! Incorrectly returns other or theology [^\w][tt]he[^\w]! Good enough? 11

Errors The process we just went through was based on fixing two kinds of errors Matching strings that we should not have matched (there, then, other) False positives (Type I) Not matching things that we should have matched (The) False negatives (Type II) 12

Errors In NLP we are always dealing with these kinds of errors Reducing the error rate for an application often involves two antagonistic efforts: Increasing accuracy or precision (minimizing false positives) Increasing coverage or recall (minimizing false negatives) 13

Summary Regular expressions play a surprisingly large role Sophisticated sequences of regular expressions are often the first model for any text processing text For many hard tasks, we use machine learning classifiers But regular expressions are used as features in the classifiers Can be very useful in capturing generalizations 14

Tokenization Segment text into tokens words (cat, part- of- speech, IBM) numerical expressions (3.14, 10,000) punctuation marks (?,!, ) other symbols (%, #, &) Main sources of information in alphabetic writing character classes (letters, numbers, etc.) whitespace (space, newline, etc.) 15

Issues in Tokenization Finland s capital Finland Finlands Finland s? what re, I m, isn t What are, I am, is not! Hewlett-Packard Hewlett Packard?! state-of-the-art state of the art? Lowercase!! lower-case lowercase lower case? San Francisco! one token or two? m.p.h., PhD.?? NB: Different applications may require different tokenisations 16

French Tokenization: language issues L'ensemble one token or two? L? L? Le? Want l ensemble to match with un ensemble! German noun compounds are not segmented 17 Lebensversicherungsgesellschaftsangestellter life insurance company employee German information retrieval needs compound splitter

Tokenization: language issues Chinese and Japanese no spaces between words: 莎拉波娃现在居住在美国东南部的佛罗里达 莎拉波娃现在居住在美国东南部的佛罗里达 Sharapova now lives in US southeastern Florida Further complicated in Japanese, with multiple alphabets intermingled Dates/amounts in multiple formats フォーチュン 500 社は情報不足のため時間あた $500K( 約 6,000 万円 ) 18 Katakana Hiragana Kanji Romaji

Word Tokenization in Chinese Also called Word Segmentation Chinese words are composed of characters Characters are generally 1 syllable and 1 morpheme. Average word is 2.4 characters long. Standard baseline segmentation algorithm: Maximum Matching (also called Greedy) 19

Maximum Matching Given a wordlist of Chinese, and a string: 1) Start a pointer at the beginning of the string 2) Find the longest word in dictionary that matches the string starting at pointer 3) Move the pointer over the word in string 4) Go to 2 20

21 Max- Match Segmentation Illustration Thecatinthehat Thetabledownthere! Doesn t generally work in English!! But works astonishingly well in Chinese the cat in the hat the table down there theta bled own there 莎拉波娃现在居住在美国东南部的佛罗里达 莎拉波娃现在居住在美国东南部的佛罗里达

Normalization After tokenization, sometimes need to normalize terms Information Retrieval: indexed text & query terms must have same form. We want to match U.S.A. and USA We implicitly define equivalence classes of terms For examples, deleting periods in a term Alternative: asymmetric expansion: 22 Enter: window Search: window, windows Enter: windows Search: Windows, windows, window Enter: Windows Search: Windows

Case folding Applications like IR: reduce all letters to lower case Since users tend to use lower case Possible exception: upper case in mid- sentence? e.g., General Motors Fed vs. fed SAIL vs. sail For sentiment analysis, MT, information extraction 23

Morphology Morphemes: The building blocks of words Stems: The core meaning- bearing units (car, compute) Affixes: Bits and pieces that adhere to stems Derivational new words (computer, computational) Inflectional forms of a word (cars, computed) 24

Lemmatization and Stemming Lemmatization: Reduce inflected forms to base form (lemma) am, are, is be car, cars, car's, cars' car Stemming: Strip off (inflectional or derivational) suffixes car, cars, car's, cars' car computes, computed, computing, computer comput 25

Morphologically Rich Languages Some languages requires complex morpheme segmentation Turkish uygarlastiramadiklarimizdanmissinizcasina `(behaving) as if you are among those whom we could not civilize Analysis: uygar `civilized + las `become + tir `cause + ama `not able + dik `past + lar plural + imiz p1pl + dan abl + mis past + siniz 2pl + casina as if 26

Finite State Morphology Morphological analysis can be performed by a special kind of finite state automata called transducers 27

Sentence Segmentation!,? are relatively unambiguous Period. is quite ambiguous Sentence boundary Abbreviations like Inc. or Dr. Numbers like.02% or 4.3 Build a binary classifier Decides EndOfSentence/NotEndOfSentence Classifiers: hand- written rules, regular expressions, or machine learning 28

29 Decision Tree for Sentence Segmentation

Implementing Decision Trees A decision tree is just an if- then- else statement The interesting research is choosing the features Setting up the structure is often too hard to do by hand Hand- building only possible for very simple features, domains Structure usually learned by machine learning from a training corpus 30