// BUG: this is duplicating code in JoshuaConfiguration, needs unifying
public static void read_config_file(String config_file)
throws IOException {
LineReader configReader = new LineReader(config_file);
try { for (String line : configReader) {
//line = line.trim().toLowerCase();
line = line.trim();
if (Regex.commentOrEmptyLine.matches(line)) continue;
if (line.indexOf("=") != -1) { //parameters
String[] fds = Regex.equalsWithSpaces.split(line);
if (fds.length != 2) {
throw new IllegalArgumentException("Wrong config line: " + line);
}
if ("lm_file".equals(fds[0])) {
lm_file = fds[1].trim();
if (logger.isLoggable(Level.FINE))
logger.fine(String.format("lm file: %s", lm_file));
} else if ("use_srilm".equals(fds[0])) {
use_srilm = Boolean.valueOf(fds[1]);
if (logger.isLoggable(Level.FINE))
logger.fine(String.format("use_srilm: %s", use_srilm));
} else if ("lm_ceiling_cost".equals(fds[0])) {
lm_ceiling_cost = Double.parseDouble(fds[1]);
if (logger.isLoggable(Level.FINE))
logger.fine(String.format("lm_ceiling_cost: %s", lm_ceiling_cost));
} else if ("use_left_euqivalent_state".equals(fds[0])) {
use_left_euqivalent_state = Boolean.valueOf(fds[1]);
if (logger.isLoggable(Level.FINE))
logger.fine(String.format("use_left_euqivalent_state: %s", use_left_euqivalent_state));
} else if ("use_right_euqivalent_state".equals(fds[0])) {
use_right_euqivalent_state = Boolean.valueOf(fds[1]);
if (logger.isLoggable(Level.FINE))
logger.fine(String.format("use_right_euqivalent_state: %s", use_right_euqivalent_state));
} else if ("order".equals(fds[0])) {
g_lm_order = Integer.parseInt(fds[1]);
if (logger.isLoggable(Level.FINE))
logger.fine(String.format("g_lm_order: %s", g_lm_order));
} else if ("remote_lm_server_port".equals(fds[0])) {
port = Integer.parseInt(fds[1]);
if (logger.isLoggable(Level.FINE))
logger.fine(String.format("remote_lm_server_port: %s", port));
} else if ("remote_symbol_tbl".equals(fds[0])) {
remote_symbol_tbl = fds[1];
if (logger.isLoggable(Level.FINE))
logger.fine(String.format("remote_symbol_tbl: %s", remote_symbol_tbl));
} else if ("hostname".equals(fds[0])) {
g_host_name = fds[1].trim();
if (logger.isLoggable(Level.FINE))
logger.fine(String.format("host name is: %s", g_host_name));
} else if ("interpolation_weight".equals(fds[0])) {
interpolation_weight = Double.parseDouble(fds[1]);
if (logger.isLoggable(Level.FINE))
logger.fine(String.format("interpolation_weightt: %s", interpolation_weight));
} else {
logger.warning("LMServer doesn't use config line: " + line);
//System.exit(1);
}
}
} } finally { configReader.close(); }
}