private void generateProfileFromText() {
        if (arglist.size() != 1) {
            System.err.println("Need to specify text file path");
            return;
        }
        File file = new File(arglist.get(0));
        if (!file.exists()) {
            System.err.println("Need to specify existing text file path");
            return;
        }

        String lang = get("lang");
        if (lang == null) {
            System.err.println("Need to specify langage code(-l)");
            return;
        }

        FileOutputStream os = null;
        try {
            LangProfile profile = GenProfile.loadFromText(lang, file);
            profile.omitLessFreq();

            File profile_path = new File(lang);
            os = new FileOutputStream(profile_path);
            JSON.encode(profile, os);
        } catch (JSONException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } catch (LangDetectException e) {
            e.printStackTrace();
        } finally {
            try {
                if (os!=null) os.close();
            } catch (IOException e) {}
        }
    }