Tag Archives: java

Techie Toolbox Part 1

My PhD research requires a bit of a split personality. My field, knowledge representation and ontologies, is mainly theoretical: I deal with description logics and reasoning algorithms, graph structures, set theory, but also aspects of cognitive complexity. On the other hand, my tool, however, to do all this is still a computer (or, as currently on my desk, 1 mac, 1 desktop PC running Ubuntu, and 3 screens… you can never have too many machines, right?).

I often stumble across minor things that make my work a bit tricky sometimes, but I also find that, in the wonderful age of the internet, most of my problems have already been solved by at least one other person – and I would like to share the solutions with you. In my first ‘Techie Toolbox’ post, I will share some pointers to the ACM Computing Classification System, a great way to handle CSV files, and a quick fix for an illegible command shell.

How to read and write CSV files in Java

Most of the data output I get from experiments (see posts below) are dumped into CSV files at first – a convenient way of storing your data for processing in Excel etc. Of course, the most straightforward way to read and write CSV files in Java is to simply treat it as a text file and read/add the commas (or other separators) manually. This works fine, but it requires a lot of checking and can get messy once you have full text that uses the separating character in a sentence. Luckily, I came across Java CSV, a very lightweight and very convenient open source Java implementation for CSV input/output. Check it out: http://csvreader.com/java_csv.php

How to use the ACM Computing Classification System

You’re writing a research paper. The conference has kindly supplied a LaTeX template for the submission. But, what’s that? A section called ‘Categories and Subject Descriptors‘ containing codes and keywords? What are you supposed to put in there?

Don’t worry, it’s just the codes from the ACM Computing Classification System, which has been used since 1964 to tag publications with the appropriate subsection of computer science. The current version is from 1998 and can be found here: ACM Computing Classification System as browsable HTML – simply click through the hierarchy and find the area that’s closest to the topic of your publication.

If you’re using a LaTeX template for your paper, such as the ACM Sig Proceedings template, you can input categories like this:

category{H.3.5}{On-Line Information Services}{Web-Based Services}

How to change the colour of your command shell (bash)

The Ubuntu machine I’ve mentioned above is mainly used to run Java programs that I can’t or don’t want to run on my mac, for example to process large numbers of OWL files. While I’ve got the PC connected to a monitor right in front of me, I usually just use ssh to connect to it. Until this morning I was literally tormented by the outrageous colour choice for the shell: in addition to the usual neon green, files and directories were displayed in dark blue and dark red – on black background! I had been putting up for it too long, so I decided to overcome my laziness and change the colours. A quick google took me to the nixCraft blog, which has some straightforward advice on how to change your shell settings:

Your current shell settings are stored in an environment variable PS1. In order to display this variable in your shell, type:

echo $PS1

The output will be something like this:

h:W u$

The h stands for host name, the W for the current working directory name (a lowercase w would list the full directory path), and the u is your username. My prompt, which gives me the above output, looks like this:

mymacbook:MyDirectory samantha$

If I want my prompt to look a little fancier, for example samantha@mymacbook:MyDirectory, I simply change the environment variable PS1 using ‘export’:

export PS1=”u@h:W”

You should see the prompt changing straight away. In order to change the colour scheme, you add e[x;ym to the beginning of the PS1 variable to start the colour scheme, and e[m to end the colour scheme, where x;y is the colour code (see the ArchLinux wiki for a huge list of colour codes). In my case, in order to change everything to neon green, I simply used:

export PS1=”e[1;32u@h:We[m”

The changes to PS1 will be gone though as soon as you close the shell – in order to make the changes permanent, you will have to save the variable to a .bash_profile file. In your home directory, create a new file using

nano .bash_profile

which will start the nano text editor (or use a text editor of your choice…vi anyone?). Copy or type the whole ‘export…’ statement into the file, save and close it. That way, your shell prompt will have the same eye-friendly look every time you login.