Tuesday, March 30, 2010

HTK bug of HHEd

Description:
When I run HHEd -T 1 -H lib/am/MMF44 -M classes regtree.hed MMF44.mlist
The output is as follows:
HHEd
65561/18300 Models Loaded [5 states max, 8 mixes max]

LS lib/am/stats.MMF44.S1.en
Loading state occupation stats
Stats loaded for 18300 models
Mean Occupation Count = 6833.864217

RC 32 rtree
Building regression tree with 32 terminals
Creating regression class tree with ident rtree.tree and baseclass rtree.base

^
Error { expected
ERROR [+7230] EdError: item list parse error
FATAL ERROR - Terminating program HHEd


Bug:
I had checked for a long time to locate the problem.
Finally, I found that the last line of the regtree.hed file do not have a "\n" at the end of the line. If I added the "\n", everything is fine.
Thus, I think the HHEd of HTK can't read file without a terminator of the file, such as "\n".

Sunday, March 28, 2010

How to use screen command in Linux

$ screen //创建一个跑着shell的单一窗口
//在这个窗口中,你可以正常跑任何程序
//然后Ctrl+a d退出刚创建的窗口
//screen窗口都不会关闭,会在后台正常运行
//重复这样的步骤,可以建立多个独立的shell窗口

$ screen -ls //可以看所有的screen sessions' id

// screen session不再使用的时候
$ screen -r sessionid //输入exit就可以退出,关掉这个screen session

Thursday, March 11, 2010

How to change the NetBeans default JDK

change /etc/netbeans.conf file:

# Default location of JDK, can be overridden by using –jdkhome:
netbeans_jdkhome=”C:\Program Files\Java\jdk1.6.0_05″

How to change NetBeans Interface language

Adding "--locale en_US" to the *netbeans_default_options* value in file:
/etc/netbeans.conf

Thursday, March 4, 2010

How to read Excel file in Java

1. you need to download org.apache.poi from:
http://poi.apache.org/download.html

2. then you can use the package just downloaded in Java, and of course you need to put the package in your own project

3. The following code showing you the simple procedure to read an Excel file:

//http://poi.apache.org/index.html
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.poifs.filesystem.POIFSFileSystem;

class sample
{
void readExcelFile(String excelFileName)
{
try
{
POIFSFileSystem fs = new POIFSFileSystem(new FileInputStream(excelFileName));
HSSFWorkbook wb = new HSSFWorkbook(fs);
HSSFSheet sheet = wb.getSheetAt(0);
HSSFRow row = null;
HSSFCell cell = null;

int count_rows; // NO of rows
count_rows = sheet.getPhysicalNumberOfRows();

int count_columns = 0; // NO of columns
int current_columns = 0;

// This trick ensures that we get the data properly even if it
// doesn't start from first few rows
for (int r = 0; r<10 && r < count_rows; r++)
{
row = sheet.getRow(r);
if (row != null)
{
current_columns = row.getPhysicalNumberOfCells();
if (current_columns > count_columns)
count_columns = current_columns;
}
}

for (int r = 0; r < count_rows; r++)
{
row = sheet.getRow(r);
if (row != null)
{// process one row
for (int c = 0; c < count_columns; c++)
{
cell = row.getCell(c);
if (cell != null)
{// main part of processing cells

System.out.print(cell.getStringCellValue()+" ");
}
}
System.out.println();
}
}
}
catch (Exception ioe)
{
ioe.printStackTrace();
}
}
}