LING 408/508: Computational Techniques for Linguists

Slides:



Advertisements
Similar presentations
UNIX Chapter 10 Advanced File Processing Mr. Mohammad Smirat.
Advertisements

Learning Ruby Regular Expressions Get at practice page by logging on to csilm.usu.edu and selecting PROGRAMMING LANGUAGES|Regular Expressions.
Strings and regular expressions Day 10 LING Computational Linguistics Harry Howard Tulane University.
ISBN Regular expressions Mastering Regular Expressions by Jeffrey E. F. Friedl –(on reserve.
LING 581: Advanced Computational Linguistics Lecture Notes February 2nd.
LING/C SC/PSYC 438/538 Lecture 4 9/1 Sandiway Fong.
More Regular Expressions. List/Scalar Context for m// Last week, we said that m// returns ‘true’ or ‘false’ in scalar context. (really, 1 or 0). In list.
LING/C SC/PSYC 438/538 Lecture 5 9/8 Sandiway Fong.
Regular Expressions in ColdFusion Applications Dave Fauth DOMAIN technologies Knowledge Engineering : Systems Integration : Web.
05/09/2015SJF L31 F21SF Software Engineering Foundations Formatting Converting numbers to Strings and vice versa Monica Farrow EM G30
Line Continuation, Output Formatting, and Decision Structures CS303E: Elements of Computers and Programming.
Computer Programming for Biologists Class 5 Nov 20 st, 2014 Karsten Hokamp
Unix Talk #2 (sed). 2 You have learned…  Regular expressions, grep, & egrep  grep & egrep are tools used to search for text in a file  AWK -- powerful.
LING/C SC/PSYC 438/538 Computational Linguistics Sandiway Fong Lecture 4: 8/30.
Review Please turn in your homework and practicals sed.
CIS 218 Advanced UNIX1 CIS 218 – Advanced UNIX (g)awk.
LING/C SC/PSYC 438/538 Lecture 2 Sandiway Fong. Today’s Topics Did you read Chapter 1 of JM? – Short Homework 2 (submit by midnight Friday) Today is Perl.
Perl and Regular Expressions Regular Expressions are available as part of the programming languages Java, JScript, Visual Basic and VBScript, JavaScript,
VB Games: Preparing for Memory Brainstorm controls & events Parallel structures (again), Visibility, LoadPicture, User-defined procedures, Do While/Loop,busy.
Section 6.2 Multiplying & Dividing Rational Expressions  Multiplying Rational Expressions  Finding Powers of Rational Expressions  Dividing Rational.
P51UST: Unix and Software Tools Unix and Software Tools (P51UST) Exam Revision Ruibin Bai (Room AB326) Division of Computer Science The University of Nottingham.
Post-Module JavaScript BTM 395: Internet Programming.
Clearly Visual Basic: Programming with Visual Basic 2008 Chapter 24 The String Section.
Time to talk about your class projects!. Shell Scripting Awk (lecture 2)
Visual Basic Games: Week 4 Recap Parallel structures Initialization Prepare for Memory Scoring Shuffling Homework: when ready, move on to next game/chapter.
LING/C SC/PSYC 438/538 Lecture 8 Sandiway Fong. Adminstrivia Homework 4 not yet graded …
LING 408/508: Programming for Linguists Lecture 8 September 23 rd.
1 Lecture 9 Shell Programming – Command substitution Regular expressions and grep Use of exit, for loop and expr commands COP 3353 Introduction to UNIX.
LING 408/508: Programming for Linguists Lecture 14 October 19 th.
Department of Electrical and Computer Engineering Introduction to Perl By Hector M Lugo-Cordero August 26, 2008.
Operators and Expressions. 2 String Concatenation  The plus operator (+) is also used for arithmetic addition  The function that the + operator performs.
1 Introduction to Python LING 5200 Computational Corpus Linguistics Martha Palmer.
Unit 11 –Reglar Expressions Instructor: Brent Presley.
Prof. Alfred J Bird, Ph.D., NBCT Door Code for IT441 Students.
P51UST: Unix and Software Tools Unix and Software Tools (P51UST) Awk Programming (3) Ruibin Bai (Room AB326) Division of Computer Science The University.
1 Lecture 10 Introduction to AWK COP 3344 Introduction to UNIX.
LING 408/508: Programming for Linguists Online Lecture 7 September 16 th.
LING/C SC/PSYC 438/538 Online Lecture 7 Sandiway Fong.
-Joseph Beberman *Some slides are inspired by a PowerPoint presentation used by professor Seikyung Jung, which was derived from Charlie Wiseman.
CSE 311 Foundations of Computing I Lecture 18 Recursive Definitions: Context-Free Grammars and Languages Autumn 2011 CSE 3111.
Regular Expressions In Javascript cosc What Do They Do? Does pattern matching on text We use the term “string” to indicate the text that the regular.
Moving away from alert() Using innerHTML Using an empty div section
Regular Expressions 'RegEx'.
Perl Regular Expression in SAS
Looking for Patterns - Finding them with Regular Expressions
CSC 131: Introduction to Computer Science
Regular Expressions in Perl
Algorithms Problem: Write pseudocode for a program that keeps asking the user to input integers until the user enters zero, and then determines and outputs.
Lecture 9 Shell Programming – Command substitution
LING/C SC/PSYC 438/538 Lecture 8 Sandiway Fong.
LING 388: Computers and Language
Topics in Linguistics ENG 331
LING 388: Computers and Language
LING 388: Computers and Language
LING 408/508: Computational Techniques for Linguists
LING 408/508: Computational Techniques for Linguists
LING/C SC/PSYC 438/538 Lecture 10 Sandiway Fong.
Unix Talk #2 grep/egrep/fgrep (maybe add more to this one….)
CSCI 431 Programming Languages Fall 2003
Unix Talk #2 (sed).
LING 408/508: Computational Techniques for Linguists
LING 408/508: Computational Techniques for Linguists
LING 408/508: Computational Techniques for Linguists
LING 388: Computers and Language
LING/C SC/PSYC 438/538 Lecture 13 Sandiway Fong.
Regular Expressions and Grep
EECE.2160 ECE Application Programming
Lab 8: Regular Expressions
Topic A Grade 1.
LING 388: Computers and Language
Presentation transcript:

LING 408/508: Computational Techniques for Linguists Lecture 12

Today's Topics Continuing with gawk regexs: Homework 5 https://www.gnu.org/software/gawk/manual/html_node/Regexp.html Homework 5

awk: regex

awk: gensub https://www.gnu.org/software/gawk/manual/html_node/String-Functions.html gensub(regexp, replacement, how [, target])  Search the target string target for matches of the regular expression regexp. If how is a string beginning with ‘g’ or ‘G’ (short for “global”), then replace all matches of regexp with replacement. Otherwise, how is treated as a number indicating which match of regexp to replace. If no target is supplied, use $0. It returns the modified string as the result of the function and the original target string is not changed. gensub() provides an additional feature that is not available in sub() or gsub(): the ability to specify components of a regexp in the replacement text. This is done by using parentheses in the regexp to mark the components and then specifying ‘\N’ in the replacement text, where Nis a digit from 1 to 9. 

awk: gensub If only a BEGIN section, no need to provide file (to read). gawk 'BEGIN {print "hello"}' hello -v (sets variable): gawk -v n="hello" 'BEGIN {print n, "\n"}' hello  gensub(regex, replacement,how, target) regex = /(.+) (.+)/ replacement = "\\2 \\1" how = "g" target = (variable) n gawk -v n="hello goodbye" 'BEGIN {print gensub(/(.+) (.+)/, "\\2 \\1", "g", n), "\n"}' What happens?

Homework 5 Reference: https://www.gnu.org/software/gawk/manual/html_node/Regexp.html Answer questions 1,2 and 4 using file hw5data.txt Extra credit! supply your own hw5q5data.txt hw5a6data.txt test files

Homework 5 File: hw5data.txt there's one line per question line 3 is left intentionally blank

Homework 5 Question 1: fix this code! Line 1 of hw5.data:

Homework 5 Show your awk command line Due next Monday by midnight Subject: 408/508 Homework 5 Your Name One PDF file please!