Highlighting Text With Lucene Highlighter

I have a chance to use Lucene (3.6.0) to implement a full-text search in one of my recent projects. One of the requirements is to highlight the matched text in the result. The highlighted text should be displayed in the whole paragraph (not just a small text fragment). Here is my snippet to achieve this: private String getHighlightedField(Query query, Analyzer analyzer, String fieldName, String fieldValue) throws IOException, InvalidTokenOffsetsException { Formatter formatter = new SimpleHTMLFormatter("<span class=\"MatchedText\">", "</span>"); QueryScorer queryScorer = new QueryScorer(query); Highlighter highlighter = new Highlighter(formatter, queryScorer); highlighter.

How to import Git Projects from Bitbucket into Eclipse

This how-to is served as my memo to import a Bitbucket project into Eclipse. First things first, make sure you have an up-and-running Eclipse with EGit (in this how-to I am using Eclipse Indigo 3.7.2 with EGit 1.3.0) Create a folder to hold the workspace for your new project (You can skip this step if you want to use an existing workspace), I will use one of my project on Bitbucket in this how-to.

Compiling JNotify on Ubuntu 64bit

In my recent project, I have a need to monitor a directory for changes such as a new file created, modified or deleted. Surprisingly, JDK (up to JDK 6) does not have APIs to do that! JDK 7 does support it out of the box but I am stuck with the version 6. After looking around for an existing solution, I finally found that jNotify seems to fit the need. It supports all the three major platforms (Windows, Linux, and MacOS).

How to Install Gradle Templates Plugin Globally

I’ve been exposing to Gradle for a couple of weeks and really like it. As a Maven user, I found that Gradle is a refreshing methodology on how a build tool should be. But one thing I miss from the Maven land: the ability to generate the initial structure for a project (I mean the ‘archetype’ plugin of Maven). Luckily, due to the plugin architecture of Gradle, a Gradle user has developed a plugin just for that purpose.

Ibus Unikey is now in the AUR

I’ve uploaded a PKGBUILD for ibus-unikey to the ArchLinux AUR. You can install it with yaourt like this: yaourt -S ibus-unikey If you don’t want to build from the source, you have to install all the dependencies first: pacman -Sy gcc gconf gtk2 And then download and install the binary package Then add the following to your .bash_profile export XMODIFIERS=@im=ibus export GTK_IM_MODULE=ibus export QT_IM_MODULE=ibus PS: Ok, there is no spyware/malware/rootkit in this binary package!