University of Sheffield NLP Module 3: Introduction to JAPE © The University of Sheffield, 1995-2010 This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike.

Slides:



Advertisements
Similar presentations
1/(20) Introduction to ANNIE Diana Maynard University of Sheffield March 2004
Advertisements

An Introduction to GATE
University of Sheffield NLP Exercise I Objective: Implement a ML component based on SVM to identify the following concepts in company profiles: company.
University of Sheffield NLP Module 4: Machine Learning.
ANNIC ANNotations In Context GATE Training Course 27 – 28 April 2006 Niraj Aswani.
The Assembly Language Level
Tutorial 8: Developing an Excel Application
Lecture 2 Introduction to C Programming
Introduction to C Programming
Advanced JAPE Mark A. Greenwood. University of Sheffield NLP Recap Installed and run GATE Understand the idea of  LR – Language Resources  PR – Processing.
 2007 Pearson Education, Inc. All rights reserved Introduction to C Programming.
Introduction to a Programming Environment
Introduction to C Programming
 2008 Pearson Education, Inc. All rights reserved JavaScript: Control Statements II.
Introduction to C Topics Compilation Using the gcc Compiler
Chapter 3: Introduction to C Programming Language C development environment A simple program example Characters and tokens Structure of a C program –comment.
EASY TEAM MANAGER By Dave Abineri EASYWARE: PO Box 231, Milford, OHIO (Cincinnati) Phone: (513) Use UP arrow to move to the NEXT slide Use.
Computer Science 101 Introduction to Programming.
Apply Sub Procedures/Methods and User Defined Functions
CHAPTER 4: INTRODUCTION TO COMPUTER ORGANIZATION AND PROGRAMMING DESIGN Lec. Ghader Kurdi.
Created by NW 2012 – please note all copyright on images used is property of copyright holder. Note: some of the more complicated descriptions are taken.
XP New Perspectives on Microsoft Access 2002 Tutorial 51 Microsoft Access 2002 Tutorial 5 – Enhancing a Table’s Design, and Creating Advanced Queries and.
Fortran 1- Basics Chapters 1-2 in your Fortran book.
University of Sheffield NLP Module 3: Introduction to JAPE.
ANNIC ANNotations In Context GATE Training Course October 2006 Kalina Bontcheva (with help from Niraj Aswani)
IPC144 Introduction to Programming Using C Week 1 – Lesson 2
06/10/ Working with Data. 206/10/2015 Learning Objectives Explain the circumstances when the following might be useful: Disabling buttons and.
COMP Parsing 2 of 4 Lecture 22. How do we write programs to do this? The process of getting from the input string to the parse tree consists of.
Programming With C.
1 Conditions Logical Expressions Selection Control Structures Chapter 5.
1 Relational Expressions Relational expressions: –Expressions that compare operands –Sometimes called conditions –Evaluated to yield a result –Typically.
Copyrighted material John Tullis 10/17/2015 page 1 04/15/00 XML Part 3 John Tullis DePaul Instructor
University of Sheffield NLP Module 1: Introduction to GATE Developer © The University of Sheffield, This work is licenced under the Creative.
New Perspectives on XML, 2nd Edition
CPSC 388 – Compiler Design and Construction Scanners – JLex Scanner Generator.
CMSC 104, Version 9/011 Introduction to C Topics Compilation Using the gcc Compiler The Anatomy of a C Program 104 C Programming Standards and Indentation.
Forms and Server Side Includes. What are Forms? Forms are used to get user input We’ve all used them before. For example, ever had to sign up for courses.
Variables and ConstantstMyn1 Variables and Constants PHP stands for: ”PHP: Hypertext Preprocessor”, and it is a server-side programming language. Special.
Working with the VB IDE. Running a Program u Clicking the”start” tool begins the program u The “break” tool pauses a program in mid-execution u The “end”
Computer Programming I Hour 2 - Writing Your First C Program.
Introduction to GATE Developer Ian Roberts. University of Sheffield NLP Overview The GATE component model (CREOLE) Documents, annotations and corpora.
6 Chapter 61 Looping Programming Logic and Design, Second Edition, Comprehensive 6.
CPS120: Introduction to Computer Science Decision Making in Programs.
Introduction to programming in the Java programming language.
WDMD 170 – UW Stevens Point 1 WDMD 170 Internet Languages eLesson: Variables, Functions and Events (there is an audio component to this eLesson) © Dr.
Exceptions in Java. Exceptions An exception is an object describing an unusual or erroneous situation Exceptions are thrown by a program, and may be caught.
C++ Basics C++ is a high-level, general purpose, object-oriented programming language.
FIX Eye FIX Eye Getting started: The guide EPAM Systems B2BITS.
©2003 Paula Matuszek Taken primarily from a presentation by Lin Lin. CSC 9010: Text Mining Applications.
When you read a sentence, your mind breaks it into tokens—individual words and punctuation marks that convey meaning. Compilers also perform tokenization.
Tutorial 13 Validating Documents with Schemas
Introduction to sed. Sed : a “S tream ED itor ” What is Sed ?  A “non-interactive” text editor that is called from the unix command line.  Input text.
University of Sheffield, NLP Module 6: ANNIC Kalina Bontcheva © The University of Sheffield, This work is licensed under the Creative Commons.
Java Programming Fifth Edition Chapter 5 Making Decisions.
Chapter 5: Making Decisions. Objectives Plan decision-making logic Make decisions with the if and if…else structures Use multiple statements in if and.
Files Tutor: You will need ….
Introduction to Computer Programming - Project 2 Intro to Digital Technology.
The single most important skill for a computer programmer is problem solving Problem solving means the ability to formulate problems, think creatively.
©2012 Paula Matuszek GATE and ANNIE Information taken primarily from the GATE user manual, gate.ac.uk/sale/tao, and GATE training materials,
1 CSC160 Chapter 1: Introduction to JavaScript Chapter 2: Placing JavaScript in an HTML File.
University of Sheffield NLP Module 1: Introduction to JAPE © The University of Sheffield, This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike.
L071 Introduction to C Topics Compilation Using the gcc Compiler The Anatomy of a C Program Reading Sections
1 Agenda  Unit 7: Introduction to Programming Using JavaScript T. Jumana Abu Shmais – AOU - Riyadh.
Linux Administration Working with the BASH Shell.
FILES AND EXCEPTIONS Topics Introduction to File Input and Output Using Loops to Process Files Processing Records Exceptions.
Part 1 Learning Objectives To understand that variables are a temporary named location to store data and that programmers work with different data types.
Perform a complete mail merge Lesson 14 By the end of this lesson you will be able to complete the following: Use the Mail Merge Wizard to perform a basic.
Introduction to C Topics Compilation Using the gcc Compiler
Module 3: Introduction to JAPE
Stata Basic Course Lab 2.
Presentation transcript:

University of Sheffield NLP Module 3: Introduction to JAPE © The University of Sheffield, This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike Licence

University of Sheffield NLP About this tutorial As in previous modules, this tutorial will be a hands on session with some explanation as you go Things for you to try yourself are in red Example JAPE code is in blue Your hands-on materials are in module-3-jape/jape- hands-on There you'll find a corpus directory containing documents, and a grammar directory containing JAPE grammar files 2

University of Sheffield NLP Pre-requisites Basic knowledge of GATE GUI (modules 1 and 2) You should be able to: Load documents and corpora Create new instances of PRs Create applications and add PRs to them Run applications on corpora View and interpret the results We'll assume you can do these without explicit instruction But please ask - or look back at the previous modules - if you get stuck 3

University of Sheffield NLP Topics covered in this module What is JAPE? Parts of the rule: LHS and RHS How to write simple patterns How to create new annotations and features Different operators Different matching styles Macros 4

University of Sheffield NLP What is JAPE and what is it good for? 5

University of Sheffield NLP What is JAPE? a Jolly And Pleasant Experience :-) Specially developed pattern matching language for GATE Each JAPE rule consists of – LHS which contains patterns to match – RHS which details the annotations to be created JAPE rules combine to create a phase Rule priority based on pattern length, rule status and rule ordering Phases combine to create a grammar 6

University of Sheffield NLP Limitations of gazetteers Gazetteer lists are designed for annotating simple, regular features Some flexibility is provided, but this is not enough for most tasks recognising addresses using just a gazetteer would be impossible but combined with other linguistic pre-processing results, we have lots of annotations and features POS tags, capitalisation, punctuation, lookup features, etc can all be combined to form patterns suggesting more complex information This is where JAPE comes in. 7

University of Sheffield NLP JAPE example A typical JAPE rule might match all university names in the UK, e.g. “University of Sheffield” The gazetteer might contain the word “Sheffield” in the list of cities The rule looks for specific words such as “University of” followed by the name of a city. This wouldn't be enough to match all university names, but it's a start. Later, we'll see how we can extend this kind of rule to cover other variations. 8

University of Sheffield NLP Simple JAPE Rule Rule: University1 ( {Token.string == "University"} {Token.string == "of"} {Lookup.minorType == city} ):orgName --> :orgName.Organisation = {kind = "university", rule = "University1"} 9

University of Sheffield NLP Parts of the rule Rule: University1 ( {Token.string == "University"} {Token.string == "of"} {Lookup.minorType == city} ):orgName --> :orgName.Organisation = {kind = "university", rule = "University1"} Rule Name LHS RHS 10

University of Sheffield NLP LHS of the rule Rule: University1 ( {Token.string == "University"} {Token.string == "of"} {Lookup.minorType == city} ):orgName --> LHS is everything before the arrow It describes the pattern to be matched, in terms of annotations and (optionally) their features Each annotation is enclosed in a curly brace 11

University of Sheffield NLP Matching a text string Everything to be matched must be specified in terms of annotations To match a string of text, use the “Token” annotation and the “string” feature {Token.string == "University"} Note that case is important in the value of the string You can combine sequences of annotations in a pattern {Token.string == "University"} {Token.string == "of"} {Lookup.minorType == city} 12

University of Sheffield NLP Labels on the LHS For every combination of patterns that you want to create an annotation for, you need a label The pattern combination that you want to label is enclosed in round brackets, followed by a colon and the label The label name can be any legal name you want: it's only used within the rule itself ( {Token.string == "University"} {Token.string == "of"} {Lookup.minorType == city} ) :orgName 13

University of Sheffield NLP Operators on the LHS Traditional Kleene and other operators can be used | OR * zero or more occurrences ? zero or one occurrence + one or more occurrences ({Lookup.minorType == city}| {Lookup.minorType == country}) 14

University of Sheffield NLP Delimiting operator range Use round brackets to delimit the range of the operators ({Lookup.minorType == city}| {Lookup.minorType == country} )+ is not the same as ({Lookup.minorType == city}| ({Lookup.minorType == country})+ ) One or more cities or countries in any order and combination One city OR one or more countries 15

University of Sheffield NLP Exercise: using operators Start GATE. Load ANNIE with defaults, then remove the NE transducer and orthomatcher completely from GATE Load the JAPE transducer location1.jape, add it to the end of your application, and run on the text locations.txt Now open the grammar location1.jape in your favourite text editor and change the kind of operator or its coverage Just ignore the rest of the rule and don't change it, we'll come to that later Save the file, then reinitialise the grammar in GATE and run the application again. View the difference. WARNING: be very careful with typos, brackets etc. when editing the grammar. Your syntax HAS TO BE CORRECT! 16

University of Sheffield NLP JAPE RHS Rule: University1 ( {Token.string == "University"} {Token.string == "of"} {Lookup.minorType == city} ):orgName --> :orgName.Organisation = {kind = "university", rule = "University1"} 17

University of Sheffield NLP Breaking down the RHS (…) :orgName --> :orgName. Organisation = {kind = "university"} label annotation type feature + value 18

University of Sheffield NLP Labels The label on the RHS must match a label on the LHS ( {Token.string == "University"} {Token.string == "of"} {Lookup.minorType == city} ) :orgName --> :orgName.Organization = {kind = organization} This is so we know which part of the pattern to attach the new annotation to 19

University of Sheffield NLP Go label crazy... You can have as many patterns and actions as you want Patterns can be consecutive, nested, or both! Patterns cannot overlap ( ({Token.string == "University"}):uniKey {Token.string == "of"} ({Lookup.minorType == city}):cityName ) :orgName --> 20

University of Sheffield NLP Multiple patterns and labels We can have several actions on the RHS corresponding to different labels. Separate the actions with a comma ( ({Token.string == "University"}) {Token.string == "of"} ({Lookup.minorType == city}) : cityName ) :orgName --> :cityName. Location = {kind = city}, :orgName.Organization = {kind = university} 21

University of Sheffield NLP Patterns and actions A pattern does not have to have a corresponding action If there's no action, you don't need to label it Patterns specified will normally be consumed (more on this later) Here, we want to add a special annotation for university towns ( {Token.string == "University"} {Token.string == "of"} ) ({Lookup.minorType == city}): cityName --> :cityName. Location = {kind = university_town} 22

University of Sheffield NLP Annotations and Features The annotation type and features created can be anything you want (as long as they are legal names) They don't need to currently exist anywhere Features and values are optional, and you can have as many as you like All the following are valid: :orgName.Organization = {} :orgName.Organization = {kind=university} :orgName.Organization = {kind=university, rule=University1} :fishLabel.InterestingFishAnnotation = {scales=yes} 23

University of Sheffield NLP Exercise: annotation types and features Remove any existing grammars and documents that you have loaded in GATE Load the grammar university1.jape, add it to your application, and run on the text university1.txt View the results Now open the grammar university1.jape in your favourite text editor and change the name of the annotation type created Save the file, then reinitialise the grammar in GATE and run the application again. View your new annotation.. Try changing the name of the features, removing features, and adding new ones, and adding multiple labels Don't forget to reinitialise the grammar before re-running! 24

University of Sheffield NLP Copying Feature Values to the RHS JAPE provides simple support for copying feature values from the LHS to the RHS ( {Lookup.majorType == location} ):loc --> :loc.Location = { type = :loc.Lookup.minorType} This copies the value of the Lookup minorType feature from the LHS to the new Location annotation Note that if more than one Lookup annotation is covered by the label, then one of them is chosen at random to copy the feature value from It's best not to use this facility unless you know there is only one matching annotation 25

University of Sheffield NLP Exercise: copying Lookup features Open university1.jape in your text editor and create a new annotation called “UniversityTown” that matches just the city name. Also copy the value of the majorType of the city to a new feature of this annotation, called “kind” Hint: the RHS for the previous example looked like this: :loc.Location = { type = :loc.Lookup.minorType} Run this on the university1.txt document and check the results You should see “Sheffield” annotated like this: 26

University of Sheffield NLP More complex RHS So far we've just shown RHS syntax involving JAPE You can also use any Java on the RHS instead, or as well This is useful for doing more complex things, such as Iterating through a list of annotations of unknown number Checking a word has a certain suffix before creating an annotation Getting information about one annotation from inside another annotation Complex Java on the RHS is taught in Track 2 (Programming in GATE) 27

University of Sheffield NLP JAPE Headers Each JAPE file must contain a set of headers at the top Phase: University Input: Token Lookup Options: control = appelt These headers apply to all rules within that grammar phase They contain Phase name, set of Input annotations and other Options 28

University of Sheffield NLP JAPE Phases A typical JAPE grammar will contain lots of different rules, divided into phases The set of phases is run sequentially over the document You might have some pre-processing, then some main annotation phases, then some cleanup phases Each phase needs a name, e.g Phase: University The phase name makes up part of the Java class name for the compiled RHS actions, so it must contain alphanumeric characters and underscores only, and cannot start with a number 29

University of Sheffield NLP JAPE Phases (II) Rules in the same phase compete for input Rules in separate phases run independently One phase can use annotations created by previous phases Instead of loading each JAPE grammar as a separate transducer in GATE, you can combine them in a multiphase transducer A multiphase transducer chains a set of JAPE grammars sequentially 30

University of Sheffield NLP Multiphase transducer The multiphase transducer lists the other grammars to be loaded: all you need to load is this file In ANNIE this is called main.jape - by default we usually label multiphase transducers with “main” in the filename MultiPhase:TestTheGrammars Phases: first name date final name of the multiphase list the phases in order of processing 31

University of Sheffield NLP Input Annotations The Input Annotations list contains a list of all the annotation types you want to use for matching on the LHS of rules in that grammar phase, e.g. Input: Token Lookup If an annotation type is used in a rule but not mentioned in the list, a warning will be generated when the grammar is compiled in GATE If an annotation is listed in Input but not used in the rules, it can block the matching (e.g Split) If no input is included, then all annotations are used 32

University of Sheffield NLP Input Annotations {Organization} {Location} 33 No Input Input: Organization Location

University of Sheffield NLP Exercise: input annotations Try altering the Input annotations in university1.jape Remove the Lookup annotation from the list. What happens when you run the grammar? Why? Add “SpaceToken” to the list. What happens when you run the grammar? What happens if you then add SpaceToken annotations into the rule? Check the Messages tab each time to see if GATE generates any warnings. 34

University of Sheffield NLP Matching styles Options: control = appelt “Rules in the same phase compete for input” What happens when 2 rules can match the same input? What happens when the same rule can match different lengths of input (e.g. +,* operators)? The matching style controls – Which rule gets applied – How much document content is ‘consumed’ – Which location to attempt matching next 35

University of Sheffield NLP Matching styles 5 different control styles possible: appelt (longest match, plus explicit priorities) first (shortest match fires) once (shortest match fires, and all matching stops) brill (fire every match that applies) (this is the default) all (all possible matches, starting from each offset in turn) 36

University of Sheffield NLP Matching styles Tim Berners Lee Appelt Once Brill First All {Name}+ longest match exit after first match first match every combination from start of match every combination 37

University of Sheffield NLP Appelt style In the appelt style, which rule to apply is selected in the following order: longest match explicit priority rule defined first Each rule has an optional priority parameter, whose value is an integer Higher numbers have greater priority If no explicit priority parameter, default value is -1 Once a match has fired, matching continues from the next offset following the end of the match Rule: Location1 Priority: 25 38

University of Sheffield NLP Exercise: priorities in appelt style Remove any NE transducers and any documents and corpora you have loaded in GATE Load the document china-sea1.txt Load grammar china-sea1.jape and add it to the ANNIE application Run the application on the corpus View the Location annotations “South China sea” is matched by rule 3, because it is the longest match “China sea” is matched by rule 1, because match length is the same for all 3 rules, and rule 1 has highest priority 39

University of Sheffield NLP Exercise: annotation stack view For these exercises, you might wish to use the annotation stack view. This shows the annotations in “stack” form rather than tabular form In the document viewer, select “Annotation Sets” and “Annotation Stack” Select Location from the annotation set view A viewer will show the Location annotations Use the “previous boundary” and “next boundary” to move between the different Location annotations Double click “Location” in the stack viewer to add features you wish to view (e.g. “rule”) 40

University of Sheffield NLP Viewing the annotation stack 41

University of Sheffield NLP Difference between first and once With both styles, the first match is fired This means they're inappropriate for rules ending in the operators + ? or * The difference between the two styles is what happens after a match has been found With the once style, the whole grammar phase is exited and no more matches are attempted With the first style, matching continues from the offset following the end of the existing match 42

University of Sheffield NLP What does “first match” mean? Some people think of the “first match” as the shortest, but it's not quite the same. Phase: MatchingStyles Input: Lookup Options: control = first Rule: Test1 ( {Lookup.majorType == location} ({Lookup.majorType == loc_key})? ):match --> :match.Location = {rule=Test1} What do you think this grammar will do on your document? Will it annotate “China” or “China sea”? 43

University of Sheffield NLP First match Remove the previous grammar, and load china-sea2.jape Add it to your application and run it on the china-sea document “China” is annotated rather than “China sea” because it is a shorter match (the optional Lookup at the end is ignored) 44

University of Sheffield NLP Shortest match? Phase: MatchingStyles Input: Lookup Options: control = first Rule: Test1 ( ({Lookup.majorType == location})? {Lookup.majorType == loc_key} ):match --> :match.Location = {rule=Test1} What about this grammar rule? Will it annotate “sea” or “China sea”? 45

University of Sheffield NLP First match (2) Remove the previous grammar and load china-sea3.jape Add it to your application and run it on the china-sea document Were you expecting just “sea” to be annotated? The first Lookup is optional, BUT there is a possible match starting from the beginning of “China” before moving on to the next offsets. So this match is the one that is chosen. 46

University of Sheffield NLP Difference between brill and all Both Brill and all match every possible combination from a given starting position When a match has been found, brill starts looking for the next match from the offset at the end of the longest match All starts looking for the next match by advancing one offset from the beginning of the previous match 47

University of Sheffield NLP Exercise: offset advancing (brill and all) Remove the previous grammar and load china-sea4.jape Add it to the application, and run on your china-sea document Use the annotation stack viewer to see the results You should get 4 Location annotations in total. Now change the matching style from brill to all in the grammar (using your text editor), reinitialise the grammar in GATE and run again See the difference using the annotation stack viewer You should now get 6 Location annotations 48

University of Sheffield NLP South China Sea Results ({Lookup.minorType == pre})? {Lookup.majorType == location} ({Lookup.majorType == loc_key})? Matching StyleAnnotated text brill South China sea South China allSouth China sea China sea China South China 49

University of Sheffield NLP LHS Macros Macros provide an easy way to reuse long or complex patterns The macro is specified once at the beginning of the grammar, and can then be reused by simply referring to its name, in all future rules Macros hold for ALL subsequent grammar files If a new macro is given later with the same name, it will override the previous one for that grammar Macro names are by convention written in capitals, and can only contain alphanumeric characters and underscores A macro looks like the LHS of a rule but without a label 50

University of Sheffield NLP Using a macro in a rule Macro: NUMBER_FULL ({Token.kind == number} (({Token.string == ","}| {Token.string == "."}) {Token.kind == number} )* ) Rule: MoneyCurrencyUnit ( (NUMBER_FULL)? ({Lookup.majorType == currency_unit}) ) :number --> :number.Money = {kind = “number”, rule = "MoneyCurrencyUnit"} 51

University of Sheffield NLP Multi-constraint statements You can have more than one constraint on a pattern Just separate the constraints with a comma Make sure that all constraints are enclosed within a single curly brace {Lookup.majorType == loc_key, Lookup.minorType == post} Is not the same as {Lookup.majorType == loc_key} {Lookup.minorType == post} 52

University of Sheffield NLP Negative constraints on annotations (!) You can use the ! operator to indicate negation Negative constraints are generally used in combination with positive ones to constrain the locations at which the positive constraint can match. Rule: PossibleName ( {Token.orth == upperInitial, !Lookup} ):name --> :name.PossibleName = {} Matches any uppercase-initial Token, where there is no Lookup annotation starting at the same location 53

University of Sheffield NLP Negative constraints on features (!=) The previous example showed a negative constraint on an annotation {!Lookup} You can also constrain the features of an annotation {Lookup.majorType != stop} would match any Lookup except those with majorType “stop” (stopwords) Be careful about the difference between this and {!Lookup.majorType == stop} This matches ANY annotation except a Lookup whose majorType is “stop”, rather than any Lookup where the majorType is not “stop” 54

University of Sheffield NLP Comparison operators So far, we have compared features with the equality operators == and != We can also use the comparison operators >, >=. < and <= {Token.length > 3} matches a Token annotation whose length is an integer greater than 3 55

University of Sheffield NLP Kleene operator for ranges You can specify ranges when you don't know the exact number of occurrences of something ({Token})[2,5] will find between 2 and 5 consecutive Tokens In most cases you do NOT want to use unbounded Kleene operators (*, +) 56

University of Sheffield NLP Regular expression operators You can also use =~ and ==~ to match regular expressions {Token.string ==~ "[Dd]ogs"} matches a Token whose string feature value is (exactly) either “dogs” or “Dogs” {Token.string =~ "[Dd]ogs"} is the same but matches a Token whose string feature contains either “dogs” or “Dogs” within it Similarly, you can use !=~ and !~ In the first example, it would match a Token whose string feature is NOT either “dogs” or “Dogs” In the second example, it would match a Token whose string feature does NOT contain either “dogs” or “Dogs” within it 57

University of Sheffield NLP Contextual operators The contextual operators “contains” and “within” match annotations within the context of other annotations {Organization contains Person} matches if an Organization annotation completely contains a Person annotation. {Person within Organization} matches if a Person annotation lies completely within an Organization annotation The difference between the two is that the first annotation specified is the one matched In the first example, Organization is matched In the second example, Person is matched 58

University of Sheffield NLP Combining operators You can combine operators of different types, e.g. {Person within {Lookup.majorType == organization}} {!Person within {Lookup.majorType == organization}} {Person within {Lookup.majorType != organization}} {Person contains {!Lookup}, Person within {Organization}} But be sure you know what you're doing, as it can get quite complicated! 59

University of Sheffield NLP Summary This module has looked at some basic operations within JAPE. The best way to learn is to keep practising. Try things out and see what happens. It's usually best to build up JAPE rules in simple steps. Trying to do too much in a single rule will get you confused. Pay close attention to syntax and to things like making sure case is respected and that you have no typos in your rules. Remember you can use in your JAPE rules any annotations that you have previously used in your pipeline. You can also use any Java you want in your rules. Come back next time for the programming track to learn more about that! 60

University of Sheffield NLP Hands-on example Load the documents from the mmse-corpus directory into GATE Take a look at the Key annotation set It contains “gold standard” {MMSE} annotations, marking MMSE scores Write an application to annotate {MMSE}s into some other set, using the corpus QA tool to compare your results with those in the Key set Use ANNIE as a baseline system Add the Numbers In Words PR from the Numbers plugin Write some gazetteers Write JAPE to find {MMSE}, making use of your gazetteer Lookups, and the annotations created by ANNIE

University of Sheffield NLP More hands-on example Build on the MMSE application from the previous hands-on Add the MMSE numerator and denominator as features of your annotation Write JAPE to find the dates of your MMSEs Add the date as a feature of the annotation