A gentle introduction to programming for students and researchers interested in conducting computer-based analysis in linguistics, this book is an ideal starting point for linguists approaching programming for the first time. Assuming no background knowledge of programming, the author introduces basic notions and techniques needed for linguistics programming and helps readers to develop their understanding of electronic texts. The book includes many examples based on diverse topics in linguistics in order to demonstrate the applicability of the concepts at the heart of programming. Practical examples are designed to help the reader to: *Identify basic issues in handling language data, including Unicode processing *Conduct simple analyses in morphology/morphosyntax, and phonotactics *Understanding techniques for matching linguistic patterns *Learn to convert data into formats and data structures suitable for linguistic analysis *Create frequency lists from corpus materials to gather basic descriptive statistics on texts *Understand, obtain and 'clean up' web-based data *Design graphical user interfaces for writing more efficient and easy-to-use analysis tools.
Two different types of exercise help readers to either learn to interpret and understand illustrative sample code, or to develop algorithmic thinking and solution strategies through turning a series of instructions into sample programs. Readers will be equipped with the necessary tools for designing their own extended projects. Key Features: *Ideal introduction for students of linguistics attempting to process corpus materials or literary texts for dissertations, theses or advanced research work *Linguistic examples throughout the text clearly demonstrate the application of programming theory and techniques *Coverage ranging from basic to more complex topics and methodologies enables the reader to progress at their own pace *Two chapters on the advantages of modularity and associated issues provide a basis for more advanced projects *A final main chapter introduces graphical user interfaces, providing a basis for user-friendly programs and multi-lingual analysis.
Martin Weisser is Associate Professor in English Language and Linguistics at the City University of Hong Kong
1 Introduction; 1.1 Why Use Perl?; 1.2 The Command Prompt/Console; 1.3 How to Navigate a File System; 1.3.1 Understanding File System Hierarchies; 1.3.2 Navigating Through File Systems; 1.4 Plain Text Editors; 1.5 Installing Perl and Perl/Tk on Your Computer; 1.5.1 Installing Perl; 1.5.2 Installing the Perl/Tk Toolkit; 2 Basic Programming Concepts - 1; 2.1 How to Issue Instructions (Statements); 2.2 How to Store Data in Memory (Variables); 2.3 What to Store & How (Basic Data Types); 2.3.1 Scalars; 2.3.2 Arrays; 2.3.3 Hashes; 2.4 Understanding About Defaults (Special Variables); 2.5 Making Your Code More Intelligible (Comments); 3 Basic Programming Concepts - 2; 3.1 Making Decisions (Flow Control); 3.2 Doing Repetitive Tasks Automatically (Basic for Loops); 3.2.1 The for Loop; 3.2.2 Iterating over Array Elements; 3.2.3 The foreach Loop; 3.3 More Repetitiveness (Further Loops); 3.3.1 The while loop; 3.3.2 The until Loop; 3.3.3 Controlling Loops Further; 4 Working with Text (Basic String Handling); 4.1 Chomping & Chopping; 4.2 Extracting a Substring from a Longer String; 4.3 'Adding' Strings Together; 4.4 Establishing the Length of a String; 4.5 Handling Case; 5 Working with Stored Data (Basic File Handling); 5.1 Opening a Filehandle; 5.2 Tweaking Your Input and/or Output Options; 5.3 Reading from a Filehandle; 5.3.1 File Processing in List Context; 5.3.2 File Processing in Line Context; 5.3.3 Slurping in Scalar Context; 5.4 Default Filehandles; 5.5 Writing to a Filehandle; 5.6 Working with Directories; 6 Identifying Textual Patterns (Basic & Extended Regular Expressions); 6.1 Matching; 6.2 Character Classes; 6.3 Quantification; 6.4 Grouping, Alternation & Anchoring; 6.5 Memorising; 6.6 Modifiers; 6.7 Extended Regular Expressions;7 Modifying Textual Patterns (Substitution & Transliteration); 7.1 Substitution; 7.2 Greediness; 7.3 A Very Brief Introduction to Markup Languages (SGML, HTML & XML); 7.4 Transliteration; 8 Getting Things Into the Right Order (Basic Sorting); 8.1 Keys & Sort Order; 8.2 'Vocabulary Handling' (Creating Simple Word Lists); 9 Elementary Texts Stats (Creating Basic Frequency Lists); 9.1 Complex Sorting; 9.2 Word Frequency Lists; 9.3 Implementing a List; 9.4 Sorting & Printing the List; 10 More Repetitiveness or How to Tie Things Together (Introducing Modularity); 10.1 Functions & Subroutines; 10.1.1 Creating Your Own Subroutines; 10.1.2 Calling a Subroutine; 10.1.3 Localising Variables & Being Strict With Yourself; 10.2 References & Modules; 10.2.1 Basic Named References; 10.2.2 Anonymous References; 10.2.3 What Do Modules Look Like?; 10.2.4 Importing & Using Modules; 10.2.5 Writing a Simplistic HTML Page Downloader and Parser; 11 Objects; 11.1 OO Concepts; 11.2 Creating an Object in Perl; 11.3 Creating a Regular Verb Object; 11.4 Instantiating the Verb Object; 11.5 Creating Appropriate Accessor Methods; 12 Getting Graphical (Simple User Interfaces); 12.1 Elements of a GUI; 12.2 Basic Steps in Creating Tk Programs; 12.3 Adding Widgets; 12.4 The GUI Concordancer - An Advanced Example; 12.4.1 Adding a Menu Bar & the Remaining GUI Elements; 12.4.2 Programming the Functionality; 12.4.3 Handling the Text Widget; 13 Conclusion; Appendix A - Sample Solutions; Appendix B - How to Get Further Help on Perl; References