Presentation is loading. Please wait.

Presentation is loading. Please wait.

LING 408/508: Computational Techniques for Linguists

Similar presentations


Presentation on theme: "LING 408/508: Computational Techniques for Linguists"— Presentation transcript:

1 LING 408/508: Computational Techniques for Linguists
Lecture 18

2 Adminstrivia Reminder: no class next Tuesday (out of meeting)

3 Today's Topics Homework 6 graded Part 2: Homework 6 review Last time:

4 Homework 6 Review Javascript functions: Term project idea:
shuffle() solved() Term project idea: animate solution 16!/2 = 10,461,394,944,000 valid configurations i.e. write a function solve() ss.com/2008/01/27/puzzles- groups-and-groupoids/ Stage 1: put 1 and 2 into position, get 3 and 4 into the corner Stage 2: repeat for 5-8 Stage 3: put 9 and 13 into position Stage 4: solve rest of the pieces

5 Javascript regular expressions
Let's write our own browser-based tester to help you learn regular expressions: form See:

6 Javascript regular expressions
<input name=str> <input name=g> <input name=re>

7 Javascript regular expressions
optional What Javascript provides: RegEx object var re = new RegEx(string, flags) var re = /[A-Z]([a-z])*/gi (g= global; i=ignore case) Methods: var a = string.match(re) returns an array [entire match, ...submatches…] var a = regex.exec(string) returns an array different behaviors (under global flag)

8 Javascript Regexp Tester
Let's try the code: Mr. ([A-Z][a-z]*) Mr\. ([A-Z][a-z]*)

9 Javascript Regexp Tester
Useful property regex.lastIndex

10 Regular expression syntax

11 Regular expression syntax

12 Regular expression syntax

13 Regular expression syntax

14 Regular expression syntax

15 Regex Replace We'll also need the method replace():
var regex = new RegExp(re_s,flag_s); modified_string = string.replace(regex,replacement) replacement string can contain $n (NOT \n) (n = group number) developer.mozilla.org

16 Regex Replace Let's try it out:


Download ppt "LING 408/508: Computational Techniques for Linguists"

Similar presentations


Ads by Google