Download A framework for processing and presenting parallel text corpora
Transcript
46 Chapter 3 · The software architecture of LanguageExplorer and LanguageAnalyzer language itself as well as the format of all the textual data types is fully based on the UNICODE [U30] standard. This solves a lot of problems of older programming languages like C or C++ which usually use an 8-bit character set for the builtin, textual data types and which therefore always have to use special libraries if they want to process textual data stored in the UNICODE format. As already discussed in section 1.1.2, the UNICODE standard not only defines a character encoding for a wide range of modern and ancient languages, it also defines methods for how to handle collation, directionality, searching and other important language aspects for texts stored in that encoding. Figure 3.3 gives an overview of the different text related classes in the standard Java libraries. As can be seen in the figure, they are split around several packages. Among others, the package java.text contains the class Bidi for determining the writing direction of a text, collator classes for doing locale-sensitive string comparisons and the class BreakIterator which can be used to find for example word and sentence boundaries in a text. Most of the tasks performed by these classes seem to be trivial. However, for other languages than English they can be quit complicated. There are for example languages like Hebrew which have different writing directions for text (right to left) and numbers or foreign words (left to right) which can be arbitrary nested. Other languages like for example Thai need special, dictionary based word iterators because there exist no word separators in the text. Collation is also not straightforward, because every language has its own collation rules for accented and other special characters. And finally, as a consequence of the UNICODE standard, letters can have several representations (single character code entries, composition of several character code entries, part of a character code entry representing a ligature). Therefore even finding single letters in a character stream may be a nontrivial task. Together with the character class java.lang.Character the classes of the java.text package serve as a base library for all other classes dealing with text in Java. With java.util.regex a powerful new regular expression package has been added in Java 1.4. It allows for Perl style regular expressions [Friedl] but also supports the full syntax of UNICODE regular expressions [UnReEx]. See section 5.4.6 for the usage of regular expressions in LanguageExplorer. JTextComponent Model Controller Document EditorKit TextUI View View Figure 3.2: The high level view of a Swing text component. Finally, the package javax.swing.text and its sub-packages contain all the classes which are responsible for the visual representation of textual data on the screen and the interaction of the user with this data. Many parts of LanguageAnalyzer and LanguageExplorer have been derived from these classes. The high level text components like for example JTextPane for styled text which are all located in the javax.swing package and are all derived from JTextComponent, are in fact just container classes for the different model, view and controller related classes located in the javax.swing.text package. The model consists of one or more tree like structures of eleDissertation der Fak. f. Informations- u. Kognitionswissenschaften, Univ. Tübingen - 2004