load all the words in the specified lexicon file into the dictionary

@param   config
@param   dic
@param   file
@param   buffer
@throws  IOException
@throws  FileNotFoundException
@throws  NumberFormatException
197062
public static void loadWords( 
            JcsegTaskConfig config, ADictionary dic, File file, List<String[]> buffer ) 
            throws NumberFormatException, FileNotFoundException, IOException 
    {
        loadWords(config, dic, new FileInputStream(file), buffer);
    }
905380
def load_config(filename=None):
    
    try:
        with _config_stream(filename) as handle:
            filename = handle.name
            return deserialize_config(handle.read())
    except (OSError, toml.TomlDecodeError, UnicodeDecodeError) as exc:
        raise ConfigError(
            'Error loading configuration from {}'.format(filename)) from exc
903114
@Override
  public void parseDirectory(File configurationDirectory) throws Exception {
    this.configurationDirectory = configurationDirectory;
    if(configurationDirectory != null && configurationDirectory.isDirectory() && configurationDirectory.canRead()) {
      Collection<File> configFiles = FileUtils.listFiles(configurationDirectory, new String[] {"yml", "yaml"}, true);
      List<File> files = new ArrayList<File>(configFiles);
      Collections.sort(files, NameFileComparator.NAME_INSENSITIVE_COMPARATOR);
      Map<String, Map<String, ?>> configurationMap = new HashMap<String, Map<String, ?>>();
      Yaml yamlParser = new Yaml(getClassTags());
      for(File configFile : files) {
        FileReader reader = null;
        try {
          reader = new FileReader(configFile);
          for(Object parsed : yamlParser.loadAll(reader)){
            mergeConfigs(configurationMap, parsed);
          }
        } finally {
          IOUtils.closeQuietly(reader);
        }
      }
      this.configuration = configurationMap;
    } else if(configurationDirectory != null && configurationDirectory.isDirectory()){
      logger.warn("Directory {} cannot be read.", configurationDirectory);
    } else if(configurationDirectory != null){
      logger.warn("Directory {} is not a directory or does not exist.", configurationDirectory);
    } else {
      throw new IllegalArgumentException("The configurationDirectory must be specified.");
    }
  }
1321911
public void loadConfig(String config)
        throws IOException
    {
        Properties properties = new Properties();
        Resource resource=Resource.newResource(config);
        properties.load(resource.getInputStream());
        
        _jdbcDriver = properties.getProperty("jdbcdriver");
        _url = properties.getProperty("url");
        _userName = properties.getProperty("username");
        _password = properties.getProperty("password");
        _userTable = properties.getProperty("usertable");
        _userTableKey = properties.getProperty("usertablekey");
        _userTableUserField = properties.getProperty("usertableuserfield");
        _userTablePasswordField = properties.getProperty("usertablepasswordfield");
        _roleTable = properties.getProperty("roletable");
        _roleTableKey = properties.getProperty("roletablekey");
        _roleTableRoleField = properties.getProperty("roletablerolefield");
        _userRoleTable = properties.getProperty("userroletable");
        _userRoleTableUserKey = properties.getProperty("userroletableuserkey");
        _userRoleTableRoleKey = properties.getProperty("userroletablerolekey");
        _cacheTime = new Integer(properties.getProperty("cachetime")).intValue();
        
        if (_jdbcDriver == null || _jdbcDriver.equals("")
            || _url == null || _url.equals("")
            || _userName == null || _userName.equals("")
            || _password == null
            || _cacheTime < 0)
        {
            if(log.isDebugEnabled())log.debug("UserRealm " + getName()
                        + " has not been properly configured");
        }
        _cacheTime *= 1000;
        _lastHashPurge = 0;
        _userSql = "select " + _userTableKey + ","
            + _userTablePasswordField + " from "
            + _userTable + " where "
            + _userTableUserField + " = ?";
        _roleSql = "select r." + _roleTableRoleField
            + " from " + _roleTable + " r, "
            + _userRoleTable + " u where u."
            + _userRoleTableUserKey + " = ?"
            + " and r." + _roleTableKey + " = u."
            + _userRoleTableRoleKey;
    }
328487
public void loadDirectory( String lexDir ) throws IOException
    {
        File path = new File(lexDir);
        if ( ! path.exists() ) {
            throw new IOException("Lexicon directory ["+lexDir+"] does'n exists.");
        }
        
        /*
         * load all the lexicon file under the lexicon path 
         *     that start with "lex-" and end with ".lex".
         */
        File[] files = path.listFiles(new FilenameFilter(){
            @Override
            public boolean accept(File dir, String name) {
                return (name.startsWith("lex-") && name.endsWith(".lex"));
            }
        });
        
        for ( File file : files ) {
            load(file);
        }
    }
371135
private function loadFullDictionary(): void
    {
        $file = __DIR__ . '/../Dictionary/' . $this->language;
        if (!file_exists($file)) {
            $file = __DIR__ . '/../Dictionary/en_US';
        }

        self::$dictionary = array_filter(explode(PHP_EOL, file_get_contents($file)));
    }
557858
public void load( InputStream is ) throws IOException
    {
        Properties lexPro = new Properties();
        lexPro.load(new BufferedInputStream(is));
        
        //about the lexicon, the lexicon path
        String lexDirs = lexPro.getProperty("lexicon.path");
        if ( lexDirs == null ) {
            throw new IOException("Missing lexicon.path property in jcseg.properties file!!!");
        }
        
        if ( ! "null".equalsIgnoreCase(lexDirs) ) {
            if ( lexDirs.indexOf("{jar.dir}") > -1 ) {
                lexDirs = lexDirs.replace("{jar.dir}", Util.getJarHome(this));
            }
            
            //Multiple path for lexicon.path.
            lexPath = lexDirs.split(";");
            File f  = null;
            for ( int i = 0; i < lexPath.length; i++ ) {
                lexPath[i] = java.net.URLDecoder.decode(lexPath[i], "UTF-8");
                f = new File(lexPath[i]);
                if ( ! f.exists() ) {
                    throw new IOException("Invalid sub lexicon path " + lexPath[i] 
                            + " for lexicon.path in jcseg.properties");
                }
                f = null;    //Let gc do its work
            }
        }
        
        //reset all the options
        if ( lexPro.getProperty("jcseg.maxlen") != null )
            MAX_LENGTH = Integer.parseInt(lexPro.getProperty("jcseg.maxlen"));
        if ( lexPro.getProperty("jcseg.icnname") != null
                && lexPro.getProperty("jcseg.icnname").equals("1"))
            I_CN_NAME = true;
        if ( lexPro.getProperty("jcseg.cnmaxlnadron") != null )
            MAX_CN_LNADRON = Integer.parseInt(lexPro.getProperty("jcseg.cnmaxlnadron"));
        if ( lexPro.getProperty("jcseg.nsthreshold") != null )
            NAME_SINGLE_THRESHOLD = Integer.parseInt(lexPro.getProperty("jcseg.nsthreshold"));
        if ( lexPro.getProperty("jcseg.pptmaxlen") != null ) 
            PPT_MAX_LENGTH = Integer.parseInt(lexPro.getProperty("jcseg.pptmaxlen"));
        if ( lexPro.getProperty("jcseg.loadpinyin") != null
                && lexPro.getProperty("jcseg.loadpinyin").equals("1")) 
            LOAD_CJK_PINYIN = true;
        if ( lexPro.getProperty("jcseg.loadsyn") != null
                && lexPro.getProperty("jcseg.loadsyn").equals("1") )
            LOAD_CJK_SYN = true;
        if ( lexPro.getProperty("jcseg.loadpos") != null
                && lexPro.getProperty("jcseg.loadpos").equals("1")) 
            LOAD_CJK_POS = true;
        if ( lexPro.getProperty("jcseg.loadentity") != null
                && lexPro.getProperty("jcseg.loadentity").equals("0")) 
            LOAD_CJK_ENTITY = false;
        if ( lexPro.getProperty("jcseg.loadparameter") != null
                && lexPro.getProperty("jcseg.loadparameter").equals("0")) 
            LOAD_PARAMETER = false;
        if ( lexPro.getProperty("jcseg.clearstopword") != null
                && lexPro.getProperty("jcseg.clearstopword").equals("1"))
            CLEAR_STOPWORD = true;
        if ( lexPro.getProperty("jcseg.cnnumtoarabic") != null
                && lexPro.getProperty("jcseg.cnnumtoarabic").equals("0"))
            CNNUM_TO_ARABIC = false;
        if ( lexPro.getProperty("jcseg.cnfratoarabic") != null
                && lexPro.getProperty("jcseg.cnfratoarabic").equals("0"))
            CNFRA_TO_ARABIC = false;
        if ( lexPro.getProperty("jcseg.keepunregword") != null
                && lexPro.getProperty("jcseg.keepunregword").equals("1"))
            KEEP_UNREG_WORDS = true;
        if ( lexPro.getProperty("lexicon.autoload") != null
                && lexPro.getProperty("lexicon.autoload").equals("1"))
            lexAutoload = true;
        if ( lexPro.getProperty("lexicon.polltime") != null )
            polltime = Integer.parseInt(lexPro.getProperty("lexicon.polltime"));
        
        //secondary split
        if ( lexPro.getProperty("jcseg.ensencondseg") != null
                && lexPro.getProperty("jcseg.ensencondseg").equals("0"))
            EN_SECOND_SEG = false;
        if ( lexPro.getProperty("jcseg.stokenminlen") != null )
            STOKEN_MIN_LEN = Integer.parseInt(lexPro.getProperty("jcseg.stokenminlen"));
        
        //load the keep punctuation
        if ( lexPro.getProperty("jcseg.keeppunctuations") != null )
            KEEP_PUNCTUATIONS = lexPro.getProperty("jcseg.keeppunctuations");
    }
1031802
public boolean loadDictionary(String corpus, int termIndex, int countIndex) {
    File file = new File(corpus);
    if (!file.exists()) {
      return false;
    }

    BufferedReader br = null;
    try {
      br = Files.newBufferedReader(Paths.get(corpus), StandardCharsets.UTF_8);
    } catch (IOException ex) {
      System.out.println(ex.getMessage());
    }
    if (br == null) {
      return false;
    }
    return loadDictionary(br, termIndex, countIndex);
  }
1226266
def load_conf(yml_file, conf={}):
    
    with open(yml_file) as f:
        data = yaml.load(f)
        if conf:
            data.update(conf)
        return dictdot(data)
18069
public static void writeConfigFile(File configFile, File searchDir, boolean sortClasses)
			throws SQLException, IOException {
		List<Class<?>> classList = new ArrayList<Class<?>>();
		findAnnotatedClasses(classList, searchDir, 0);
		writeConfigFile(configFile, classList.toArray(new Class[classList.size()]), sortClasses);
	}
39955
static Config loadOvercastConfigFromFile(String file) {

        if (file == null) {
            return ConfigFactory.empty();
        }

        File f = new File(file);
        if (!f.exists()) {
            logger.warn("File {} not found.", f.getAbsolutePath());
            return ConfigFactory.empty();
        }

        logger.info("Loading from file {}", f.getAbsolutePath());
        return ConfigFactory.parseFile(f);
    }
176423
public static void writeConfigFile(OutputStream outputStream, File searchDir) throws SQLException, IOException {
		writeConfigFile(outputStream, searchDir, false);
	}
439971
private static void loadConf(InputStream in) {
        try(BufferedReader reader = new BufferedReader(new InputStreamReader(in, "utf-8"))){
            String line;
            while((line = reader.readLine()) != null){
                line = line.trim();                
                if("".equals(line) || line.startsWith("#")){
                    continue;
                }
                int index = line.indexOf("=");
                if(index==-1){
                    LOGGER.error("错误的配置："+line);
                    continue;
                }
                //有K V
                if(index>0 && line.length()>index+1) {
                    String key = line.substring(0, index).trim();
                    String value = line.substring(index + 1, line.length()).trim();
                    conf.put(key, value);
                }
                //有K无V
                else if(index>0 && line.length()==index+1) {
                    String key = line.substring(0, index).trim();
                    conf.put(key, "");
                }else{
                    LOGGER.error("错误的配置："+line);
                }
            }
        } catch (IOException ex) {
            System.err.println("配置文件加载失败:"+ex.getMessage());
            throw new RuntimeException(ex);
        }
    }
290522
public Map<String, Object> parse(JBakeConfiguration config, File file) {
        this.configuration = config;
        List<String> fileContents;
        try (InputStream is = new FileInputStream(file)) {

            fileContents = IOUtils.readLines(is, config.getRenderEncoding());
        } catch (IOException e) {
            LOGGER.error("Error while opening file {}", file, e);

            return null;
        }

        boolean hasHeader = hasHeader(fileContents);
        ParserContext context = new ParserContext(
                file,
                fileContents,
                config,
                hasHeader
        );

        if (hasHeader) {
            // read header from file
            processDefaultHeader(context);
        }
        // then read engine specific headers
        processHeader(context);

        setModelDefaultsIfNotSetInHeader(context);
        sanitizeTags(context);

        if (context.getType().isEmpty() || context.getStatus().isEmpty()) {
            // output error
            LOGGER.warn("Parsing skipped (missing type or status value in header meta data) for file {}!", file);
            return null;
        }

        // generate default body
        processDefaultBody(context);

        // eventually process body using specific engine
        if (validate(context)) {
            processBody(context);
        } else {
            LOGGER.error("Incomplete source file ({}) for markup engine: {}", file, getClass().getSimpleName());
            return null;
        }
        // TODO: post parsing plugins to hook in here?

        return context.getDocumentModel();
    }
1199293
private void readConfigFromFile(URL file) throws IOException {
        FOKLogger.info(Config.class.getName(), "Reading config from local file...");
        InputStream inputStream = file.openStream();
        offlineProps.load(inputStream);
        inputStream.close();
    }
65254
void parse(File file) throws ParseException {
        if (file == null) {
            Log.warn("parsing NULL file, so fallback on default configuration!");
            return;
        }
        if (!file.exists()) {
            Log.warn(String.format("parsing not existing file %s, so fallback on default configuration!", file.getAbsolutePath()));
            return;
        }
        try {
            FileReader reader = new FileReader(file);
            parse(reader);
        } catch (FileNotFoundException fex) {
            Log.warn(String.format("parsing not existing file %s, so fallback on default configuration!", file.getAbsolutePath()), fex);
            return;
        }
    }
1363301
public static void loadDictionary(BufferedReader br, TreeMap<String, CoreDictionary.Attribute> storage, boolean isCSV, Nature defaultNature) throws IOException
    {
        String splitter = "\\s";
        if (isCSV)
        {
            splitter = ",";
        }
        String line;
        boolean firstLine = true;
        while ((line = br.readLine()) != null)
        {
            if (firstLine)
            {
                line = IOUtil.removeUTF8BOM(line);
                firstLine = false;
            }
            String param[] = line.split(splitter);

            int natureCount = (param.length - 1) / 2;
            CoreDictionary.Attribute attribute;
            if (natureCount == 0)
            {
                attribute = new CoreDictionary.Attribute(defaultNature);
            }
            else
            {
                attribute = new CoreDictionary.Attribute(natureCount);
                for (int i = 0; i < natureCount; ++i)
                {
                    attribute.nature[i] = LexiconUtility.convertStringToNature(param[1 + 2 * i]);
                    attribute.frequency[i] = Integer.parseInt(param[2 + 2 * i]);
                    attribute.totalFrequency += attribute.frequency[i];
                }
            }
            storage.put(param[0], attribute);
        }
        br.close();
    }