Nontextual Cues
To ascertain nontextual cues, BibPort accesses a sequential container called "Words" located within a Document object, which corresponds to an open document within Word. In Figure 7, the Words container holds each individual parsed word of the document separately, as well as flags indicating whether specific formatting is activated (such as underlining, italics, or boldface). BibPort accesses the attribute flags within the Word object to obtain the visual cues used to assist in disambiguating a reference.
Using the WOM solves the difficulty of requiring understanding of file formats, but introduces a second problem: Because Word defines the manner in which words and characters are tokenized in documents, there will be several categories of tokens that are not split into the form needed by BibPort's parsers. One particular instance of this is the distribution of punctuation among tokens. The Words array was designed to be used with English words as its logical unit instead of more discrete units with punctuation being independent. Hence, WOM tends to group punctuation marks with words instead of representing them as separate tokens.
Listing One is a sample of the BibPort parsing code. This particular code listing is invoked to determine whether the current word is the beginning of the title for a book. There are several features in this snippet worth noting. First, because BibPort is programmed as a Word AddIn, the various WOM entities are inserted directly into a namespace called ThisAddIn. There is a single Document reference that is available within the Application object that indicates the current working document in Word.
Word.Document doc = Globals.ThisAddIn.Application.ActiveDocument; while (doc.Words[index].Underline == word.WdUnderline.wdUnderlineSingle) { if (doc.Words[index].Text.Trim() == "." && doc.Words[index + 1].Underline != Word.WdUnderline.wdUnderlineSingle) break; title += doc.Words[index++].Text; } if (title == "") return false;
A second observation concerns the code's manner of inspection of the token. In the APA style, the only means of detecting a book title is whether it's underlined. If it's not, the reference certainly is not a book, so BibPort stops parsing. As you can see, this is directly tested by a comparison of a particular attribute of a word against another value within the WOM that represents a single underlining.