Saturday, July 16, 2011

SRILM note: the use of MACHINE_TYPE for customized compilation

SRILM supports compilation for different architectures by the MACHINE_TYPE variable. By default, MACHINE_TYPE is defined automatically. However, for special purposes, such as 64 bit support, MACHINE_TYPE can be manually specified. For a particular machine type x (i.e. i686, i686-m64, i686-gcc4), the corresponding compiler options are defined in common/Makefile.machine.x. When running 'make MACHINE_TYPE=x', a separate folder x will be created under bin, lib, lm/obj, dstruct/obj and other folders. The fact can be taken advantage of when making a specific compilation of the code. For example, suppose that we want to compile a position independent version of srilm for sharing. We can do this by copying one machine specific makefile, such as Makefile.machine.i686, to Makefile.machine.foo. Then we can modify the compiler flag of foo, adding what we need. For this particular case, it is -fPIC. Then we compile srilm by 'make MACHINE_TYPE=foo'. The resulting objects, such as liboolm.a, will be placed at lib/foo. This is handy since it does not clash with existing libraries and binaries.

Friday, July 08, 2011

OpenOffice Note: selecting all footnotes

The current version of OpenOffice writer does not directly support the extracting of all footnotes, but there are ways to get around this. First, footnotes can be selected by Edit | Find & Replace ..., and then choosing More Options, and ticking Search for Styles below. Choose Footnote as the style in the drop down list above, then press the button Find All. All foot notes will be highlighted, and then can be copied into clipboard. Second, when trying to paste the selected footnotes into a target file, it turns out that all new lines after footnotes are gone. This can be solved by the following trick.

(1) In the original document from which footnotes are extracted, select all footnotes in the aforementioned way.

(2) (Assuming that each footnote ends with a period) remove trailing space characters (if any) by using Find and Replace, ticking Current Selection Only and Regular Expression in More Options. Find all patterns: [ ]+$ (note the space between [ and ]) and replacing them with an empty string (by emptying textbox).

(3) Again select all footnotes in that document, and then use the same method is the previous step to replace pattern \.$ with .ENDOFPARAGRAPH. The special word ENDOFPARAGRAPH is used as a placeholder for newline.

(4) Use the method mentioned before to select all footnotes again now, and copy them and paste them into a new document.

(5) from the new document, use Find and Replace to replace all ENDOFPARAGRAH with \n, ticking Find Regular Expression under MoreOptions.

That will do the extraction. Use an Undo step to undo the insertion of placeholder words in the original document. Or simply replace them again with ''.