LING/C SC/PSYC 438/538 Lecture 8 Sandiway Fong.

Slides:



Advertisements
Similar presentations
LING/C SC/PSYC 438/538 Lecture 11 Sandiway Fong. Administrivia Homework 3 graded.
Advertisements

 Use the Left and Right arrow keys or the Page Up and Page Down keys to move between the pages. You can also click on the pages to move forward.  To.
LING/C SC/PSYC 438/538 Lecture 4 9/1 Sandiway Fong.
LING/C SC/PSYC 438/538 Computational Linguistics Sandiway Fong Lecture 3: 8/28.
LING/C SC/PSYC 438/538 Computational Linguistics Sandiway Fong Lecture 2: 8/23.
LING 388: Language and Computers Sandiway Fong Lecture 2: 8/23.
LING 388: Language and Computers Sandiway Fong Lecture 3: 8/28.
Introduction to Perl Software Tools. Slide 2 Introduction to Perl l Perl is a scripting language that makes manipulation of text, files, and processes.
1.10 Strings academy.zariba.com 1. Lecture Content 1.What is a string? 2.Creating and Using strings 3.Manipulating Strings 4.Other String Operations 5.Building.
LING/C SC/PSYC 438/538 Lecture 5 9/8 Sandiway Fong.
Recitation 1 Programming for Engineers in Python.
Computer Programming for Biologists Class 2 Oct 31 st, 2014 Karsten Hokamp
LING/C SC/PSYC 438/538 Lecture 5 Sandiway Fong. Today’s Topics File input/output – open, References Perl modules Homework 2: due next Monday by midnight.
1 CA201 Word Application Increasing Efficiency Week # 13 By Tariq Ibn Aziz Dammam Community college.
LING/C SC/PSYC 438/538 Computational Linguistics Sandiway Fong Lecture 4: 8/30.
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.
LING/C SC/PSYC 438/538 Lecture 8 Sandiway Fong. Adminstrivia Homework 4 not yet graded …
Random Bits of Perl None of this stuff is worthy of it’s own lecture, but it’s all a bunch of things you should learn to use Perl well.
Perl Variables: Array Web Programming1. Review: Perl Variables Scalar ► e.g. $var1 = “Mary”; $var2= 1; ► holds number, character, string Array ► e.g.
Lab00-Getting Started with VC Launch VS 2005 Launch Visual Studio 2005 – Start > All Programs > Microsoft Visual Studio 2005 > Microsoft Visual.
LING/C SC/PSYC 438/538 Lecture 6 Sandiway Fong. Homework 4 Submit one PDF file Your submission should include code and sample runs Due date Monday 21.
LING/C SC/PSYC 438/538 Lecture 10 Sandiway Fong. Today's Topics A note on the UIUC POS Tagger Fun with POS Tagging Perl regex wrap-up.
LING/C SC/PSYC 438/538 Online Lecture 7 Sandiway Fong.
CSE 303 Concepts and Tools for Software Development Richard C. Davis UW CSE – 10/9/2006 Lecture 6 – String Processing.
Regular Expressions Copyright Doug Maxwell (
LING/C SC/PSYC 438/538 Lecture 5 Sandiway Fong.
CSE 374 Programming Concepts & Tools
Looking for Patterns - Finding them with Regular Expressions
Miscellaneous Items Loop control, block labels, unless/until, backwards syntax for “if” statements, split, join, substring, length, logical operators,
LING/C SC/PSYC 438/538 Lecture 11 Sandiway Fong.
LING/C SC/PSYC 438/538 Lecture 10 Sandiway Fong.
LING/C SC/PSYC 438/538 Lecture 4 Sandiway Fong.
LING/C SC/PSYC 438/538 Lecture 2 Sandiway Fong.
LING/C SC/PSYC 438/538 Lecture 8 Sandiway Fong.
LING/C SC/PSYC 438/538 Lecture 7 Sandiway Fong.
LING/C SC/PSYC 438/538 Lecture 5 Sandiway Fong.
LING/C SC/PSYC 438/538 Lecture 7 Sandiway Fong.
LING 388: Computers and Language
LING 388: Computers and Language
IPC144 Introduction to Programming Using C Week 1 – Lesson 2
Instructor: Raul Cruz-Cano
LING 388: Computers and Language
LING/C SC/PSYC 438/538 Lecture 4 Sandiway Fong.
LING/C SC/PSYC 438/538 Lecture 3 Sandiway Fong.
LING 388: Computers and Language
LING/C SC/PSYC 438/538 Lecture 6 Sandiway Fong.
LING/C SC/PSYC 438/538 Lecture 10 Sandiway Fong.
InControl R2 Overview Running Reports.
LING/C SC/PSYC 438/538 Lecture 12 Sandiway Fong.
InControl R2 Contact Center Reports Overview
LING/C SC/PSYC 438/538 Lecture 19 Sandiway Fong.
Hello World! Syntax.
LING/C SC/PSYC 438/538 Lecture 21 Sandiway Fong.
LING 408/508: Computational Techniques for Linguists
LING 408/508: Computational Techniques for Linguists
LING/C SC/PSYC 438/538 Lecture 15 Sandiway Fong.
LING/C SC/PSYC 438/538 Lecture 18 Sandiway Fong.
LING/C SC/PSYC 438/538 Lecture 13 Sandiway Fong.
LING/C SC/PSYC 438/538 Lecture 11 Sandiway Fong.
LING/C SC/PSYC 438/538 Lecture 17 Sandiway Fong.
String Processing 1 MIS 3406 Department of MIS Fox School of Business
Introduction to Computer Science
Lab 3: File Permissions.
Microsoft Excel 2007 – Level 2
LING 388: Computers and Language
LING/C SC/PSYC 438/538 Lecture 7 Sandiway Fong.
How To Password Protect A PDF Free With or Without Acrobat.
LING/C SC/PSYC 438/538 Lecture 4 Sandiway Fong.
LING/C SC/PSYC 438/538 Lecture 3 Sandiway Fong.
LING/C SC/PSYC 438/538 Lecture 12 Sandiway Fong.
Presentation transcript:

LING/C SC/PSYC 438/538 Lecture 8 Sandiway Fong

Today's Topics A note on UTF-8 and PowerShell in Windows 10 Review Homework 6 Homework 7

Unicode and PowerShell Windows 10: Default console is not UTF-8 and uses ancient codepage technology (437 = US)! Set it to UTF-8. Note codepage change. Unfortunately, it now understands UTF-8, but fails to print the character!

Unicode and PowerShell Right-click menu bar Properties > Font Consult https://docs.micro soft.com/en- us/typography/fon t-list/ for the codepages that each font supports

Unicode and PowerShell Default console font is actually called Consolas Even the Lucida Console font family is limited.

Unicode and PowerShell Pick a known Japanese font licensed by Microsoft from Ricoh (Japan). MS Mincho

Unicode and PowerShell Et voilà!

Homework 6 Review Question 1: what's the difference between a) and b)? my @a = 4 x 4; my @a = (4) x 4; perl -le '@a = 4 x 4; print $#a; print "@a"' 4444 perl -le '@a = (4) x 4; print $#a; print "@a"' 3 4 4 4 4

Homework 6 Review read https://perldoc.perl.org/functions/split.html Question 2: what does split do here for a) vs. b)? my @a = split " ", 'this is a sentence.'; my @a = split //, 'this is a sentence.'; perl -le "@a = split \" \", 'this is a sentence.'; print \$#a; print \"@a\"" 3 this is a sentence. perl -le "@a = split //, 'this is a sentence.'; print \$#a; print \"@a\"" 18 t h i s   i s   a   s e n t e n c e .

Homework 7 Read https://en.wikipedia.org/wiki/Disemvoweling Q1: Write a Perl program to remove vowels a, e, i, o, u from words typed into the command line. (Don't worry about y.) Hint: use split from HW 6 Question 2 Example:

Homework 7 A possible template for your code exists $vowel{$char}

Homework 7 Q2: Suppose we modified the program to print underscores instead of deleting vowels. Which quote below do you find easier to read? Translate the quote back into regular English orthography. All h_m_n b__ngs _r_ b_rn fr__ _nd _q__l _n d_gn_ty _nd r_ghts. Th_y _r_ _nd_w_d w_th r__s_n _nd c_nsc__nc_ _nd sh__ld _ct t_w_rds _n_ _n_th_r _n _ sp_r_t _f br_th_rh__d.  All hmn bngs r brn fr nd ql n dgnty nd rghts. Thy r ndwd wth rsn nd cnscnc nd shld ct twrds n nthr n  sprt f brthrhd. Due date: Monday night. One PDF file. Submit your code and example runs.

Python list ranges Perl has a range operator: .. less powerful in some ways, more powerful in others https://perldoc.perl.org/perlop.html#Range-Operators

Perl list ranges Python equivalent: for i in range(1,1000001): # code iterates setting $. (default variable) from 1, 2, .., 1000000

Perl: useful string functions chomp (useful with file I/O) vs. chop Note: multiple spaces ok with " " variant

Python: .split() string (sentence) splitting is an important part of text processing. Oftentimes we split strings by a regular expression: import re re.split(regex,s)

Perl: useful string functions Transliterate: tr/matchingcharacters/replacementcharacters/modifiers modifiers are optional:

Perl: useful string functions Perl doesn't have a built-in trim-whitespace-from-both-ends-of-a- string function. Can be mimicked using regex (more later) Python:

Python: strings Many methods that work on lists also work on strings

Python: strings List comprehension: sentence = ['A', 'big', 'cat', 'in', 'Tucson'] [x.lower() for x in sentence] Suppose we want to use .endswith() in a list comprehension: Reference: https://docs.python.org/3.7/library/stdtypes.html#text-sequence-type-str

Python: strings conditional list comprehensions