public static void main(String[] args) {

        // -create he sample_he.txt utf-8

        String usage = "Usage: NGramProfile " + "[-create profilename filename encoding] " +
                "[-similarity file1 file2] " + "[-score profile-name filename encoding]";
        int command = 0;

        final int CREATE = 1;
        final int SIMILARITY = 2;
        final int SCORE = 3;

        String profilename = "";
        String filename = "";
        String filename2 = "";
        String encoding = "";

        if (args.length == 0) {
            System.err.println(usage);
            System.exit(-1);
        }

        for (int i = 0; i < args.length; i++) { // parse command line
            if (args[i].equals("-create")) { // found -create option
                command = CREATE;
                profilename = args[++i];
                filename = args[++i];
                encoding = args[++i];
            }

            if (args[i].equals("-similarity")) { // found -similarity option
                command = SIMILARITY;
                filename = args[++i];
                filename2 = args[++i];
                encoding = args[++i];
            }

            if (args[i].equals("-score")) { // found -Score option
                command = SCORE;
                profilename = args[++i];
                filename = args[++i];
                encoding = args[++i];
            }
        }

        try {

            switch (command) {

                case CREATE:

                    File f = new File(filename);
                    FileInputStream fis = new FileInputStream(f);
                    LanguageProfilerBuilder newProfile =
                            LanguageProfilerBuilder.create(profilename, fis, encoding);
                    fis.close();
                    f = new File(profilename + "." + FILE_EXTENSION);
                    FileOutputStream fos = new FileOutputStream(f);
                    newProfile.save(fos);
                    System.out.println(
                            "new profile " + profilename + "." + FILE_EXTENSION + " was created.");
                    break;

                case SIMILARITY:

                    f = new File(filename);
                    fis = new FileInputStream(f);
                    newProfile = LanguageProfilerBuilder.create(filename, fis, encoding);
                    newProfile.normalize();

                    f = new File(filename2);
                    fis = new FileInputStream(f);
                    LanguageProfilerBuilder newProfile2 =
                            LanguageProfilerBuilder.create(filename2, fis, encoding);
                    newProfile2.normalize();
                    System.out.println("Similarity is " + newProfile.getSimilarity(newProfile2));
                    break;

                case SCORE:
                    f = new File(filename);
                    fis = new FileInputStream(f);
                    newProfile = LanguageProfilerBuilder.create(filename, fis, encoding);

                    f = new File(profilename + "." + FILE_EXTENSION);
                    fis = new FileInputStream(f);
                    LanguageProfilerBuilder compare =
                            new LanguageProfilerBuilder(profilename, DEFAULT_MIN_NGRAM_LENGTH,
                                    DEFAULT_MAX_NGRAM_LENGTH);
                    compare.load(fis);
                    System.out.println("Score is " + compare.getSimilarity(newProfile));
                    break;

            }

        } catch (Exception e) {
            LOG.error("Some error: {}", e.getMessage(), e);
        }
    }
main method used for testing only

@param args
tika-langdetect/tika-langdetect-tika/src/main/java/org/apache/tika/langdetect/tika/LanguageProfilerBuilder.java