<commit_before>/**
 * Copyright (c) 2014 Baidu, Inc. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *         http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.baidu.rigel.biplatform.ac.util;

import java.io.FileInputStream;
import java.io.IOException;
import java.util.Properties;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * 服务器配置信息，暂时只有Tesseract服务器地址配置
 * 
 * @author xiaoming.chen
 *
 */
public class ConfigInfoUtils {

    /**
     * LOG
     */
    private static Logger LOG = LoggerFactory.getLogger(ConfigInfoUtils.class);

    private static final String DEFAULT_SERVER_ADDRESS = "http://127.0.0.1:8080";

    private static Properties properties;
    /**
     * serverAddress
     */
    private static String SERVERADDRESS = null;

    static {
        FileInputStream inStream = null;
        try {
             String answerCoreConfFile = System
                    .getProperty("ac.config.location");
            properties = new Properties();
            inStream = new FileInputStream(answerCoreConfFile);
            properties.load(inStream);
            // Properties properties =
            // PropertiesLoaderUtils.loadAllProperties(answerCoreConfFile);
            SERVERADDRESS = properties.getProperty("server.tesseract.address",
                    DEFAULT_SERVER_ADDRESS);
            LOG.info("load serveraddress from properties:{}", SERVERADDRESS);
        } catch (IOException e) {
            LOG.error(e.getMessage(), e);
            throw new IllegalStateException("不能获取ac配置文件");
        } finally {<commit_msg>修改ac文件读取方式<commit_after>/**
 * Copyright (c) 2014 Baidu, Inc. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *         http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.baidu.rigel.biplatform.ac.util;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Properties;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.util.StringUtils;

/**
 * 服务器配置信息，暂时只有Tesseract服务器地址配置
 * 
 * @author xiaoming.chen
 *
 */
public class ConfigInfoUtils {

    /**
     * LOG
     */
    private static Logger LOG = LoggerFactory.getLogger(ConfigInfoUtils.class);

    private static final String DEFAULT_SERVER_ADDRESS = "http://127.0.0.1:8080";
    
    private static final String DEFAULT_AC_CONFIG_FILENAME="ac.properties";

    private static Properties properties;
    /**
     * serverAddress
     */
    private static String SERVERADDRESS = null;

    static {
        FileInputStream inStream = null;
        try {
             String answerCoreConfFile = System.getProperty("ac.config.location");
             if (StringUtils.isEmpty (answerCoreConfFile)) {
                 answerCoreConfFile = System.getProperty("user.dir") + File.separator + DEFAULT_AC_CONFIG_FILENAME;
             }
            properties = new Properties();
            inStream = new FileInputStream(answerCoreConfFile);
            properties.load(inStream);
            SERVERADDRESS = properties.getProperty("server.tesseract.address", DEFAULT_SERVER_ADDRESS);
            LOG.info("load serveraddress from properties:{}", SERVERADDRESS);
        } catch (IOException e) {
            LOG.error(e.getMessage(), e);
            throw new IllegalStateException("不能获取ac配置文件");
        } finally {
{'fraction_non_alphanumeric': 0.09292035398230089, 'fraction_numerical': 0.009315323707498836, 'mean_word_length': 2.933150183150183, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '421054', 'n_tokens_mistral': 1177, 'n_tokens_neox': 1159, 'n_words': 338}