Example usage for com.google.common.collect Maps newHashMap

List of usage examples for com.google.common.collect Maps newHashMap

Introduction

In this page you can find the example usage for com.google.common.collect Maps newHashMap.

Prototype

public static <K, V> HashMap<K, V> newHashMap() 

Source Link

Document

Creates a mutable, empty HashMap instance.

Usage

From source file:org.carrot2.examples.clustering.ClusteringNonEnglishContent.java

@SuppressWarnings("unchecked")
public static void main(String[] args) {
    // [[[start:clustering-non-english-content]]]
    /*/*from   www.  j  av  a 2s.c  o m*/
     * We use a Controller that reuse instances of Carrot2 processing components 
     * and caches results produced by document sources.
     */
    final Controller controller = ControllerFactory.createCachingPooling(IDocumentSource.class);

    /*
     * In the first call, we'll cluster a document list, setting the language for each
     * document separately.
     */
    final List<Document> documents = Lists.newArrayList();
    for (Document document : SampleDocumentData.DOCUMENTS_DATA_MINING) {
        documents.add(new Document(document.getTitle(), document.getSummary(), document.getContentUrl(),
                LanguageCode.ENGLISH));
    }

    final Map<String, Object> attributes = Maps.newHashMap();
    CommonAttributesDescriptor.attributeBuilder(attributes).documents(documents);
    final ProcessingResult englishResult = controller.process(attributes, LingoClusteringAlgorithm.class);
    ConsoleFormatter.displayResults(englishResult);

    /*
     * In the second call, we will fetch results for a Chinese query from Bing,
     * setting explicitly the Bing's specific language attribute. Based on that
     * attribute, the document source will set the appropriate language for each
     * document.
     */
    attributes.clear();

    CommonAttributesDescriptor.attributeBuilder(attributes).query("?" /* clustering? */).results(100);

    Bing3WebDocumentSourceDescriptor.attributeBuilder(attributes).market(MarketOption.CHINESE_CHINA);
    Bing3WebDocumentSourceDescriptor.attributeBuilder(attributes).appid(BingKeyAccess.getKey()); // use your own ID here!

    final ProcessingResult chineseResult = controller.process(attributes, Bing3WebDocumentSource.class,
            LingoClusteringAlgorithm.class);
    ConsoleFormatter.displayResults(chineseResult);

    /*
     * In the third call, we will fetch results for the same Chinese query from
     * Google. As Google document source does not have its specific attribute for
     * setting the language, it will not set the documents' language for us. To make
     * sure the right lexical resources are used, we will need to set the
     * MultilingualClustering.defaultLanguage attribute to Chinese on our own.
     */
    attributes.clear();

    CommonAttributesDescriptor.attributeBuilder(attributes).query("?" /* clustering? */).results(100);

    MultilingualClusteringDescriptor.attributeBuilder(attributes)
            .defaultLanguage(LanguageCode.CHINESE_SIMPLIFIED);

    final ProcessingResult chineseResult2 = controller.process(attributes, GoogleDocumentSource.class,
            LingoClusteringAlgorithm.class);
    ConsoleFormatter.displayResults(chineseResult2);
    // [[[end:clustering-non-english-content]]]
}

From source file:com.pansky.integration.generate.Generate.java

public static void main(String[] args) throws Exception {

    // ==========  ?? ====================

    // ??????/*www  .j av a 2 s .  c o m*/
    // ?{packageName}/{moduleName}/{dao,entity,service,web}/{subModuleName}/{className}

    // packageName ????applicationContext.xmlsrping-mvc.xml?base-package?packagesToScan?4?
    String packageName = "com.pansky.integration.modules";

    String moduleName = "test"; // ???sys
    String subModuleName = "test1"; // ????? 
    String className = "test1"; // ??user
    String classAuthor = "renmh"; // ThinkGem
    String functionName = ""; // ??

    // ???
    //      Boolean isEnable = false;
    Boolean isEnable = true;

    // ==========  ?? ====================

    if (!isEnable) {
        logger.error("????isEnable = true");
        return;
    }

    if (StringUtils.isBlank(moduleName) || StringUtils.isBlank(moduleName) || StringUtils.isBlank(className)
            || StringUtils.isBlank(functionName)) {
        logger.error("??????????????");
        return;
    }

    // ?
    String separator = File.separator;

    // ?
    File projectPath = new DefaultResourceLoader().getResource("").getFile();
    while (!new File(projectPath.getPath() + separator + "src" + separator + "main").exists()) {
        projectPath = projectPath.getParentFile();
    }
    logger.info("Project Path: {}", projectPath);

    // ?
    String tplPath = StringUtils
            .replace(projectPath + "/src/main/java/com/pansky/integration/generate/template", "/", separator);
    logger.info("Template Path: {}", tplPath);

    // Java
    String javaPath = StringUtils.replaceEach(
            projectPath + "/src/main/java/" + StringUtils.lowerCase(packageName), new String[] { "/", "." },
            new String[] { separator, separator });
    String javaTestPath = StringUtils.replaceEach(
            projectPath + "/src/test/java/" + StringUtils.lowerCase(packageName), new String[] { "/", "." },
            new String[] { separator, separator });
    logger.info("Java Path: {}", javaPath);

    // 
    String viewPath = StringUtils.replace(projectPath + "/src/main/webapp/WEB-INF/views", "/", separator);
    logger.info("View Path: {}", viewPath);

    // ???
    Configuration cfg = new Configuration();
    cfg.setDefaultEncoding("UTF-8");
    cfg.setDirectoryForTemplateLoading(new File(tplPath));

    // ???
    Map<String, String> model = Maps.newHashMap();
    model.put("packageName", StringUtils.lowerCase(packageName));
    model.put("moduleName", StringUtils.lowerCase(moduleName));
    model.put("subModuleName",
            StringUtils.isNotBlank(subModuleName) ? "." + StringUtils.lowerCase(subModuleName) : "");
    model.put("className", StringUtils.uncapitalize(className));
    model.put("ClassName", StringUtils.capitalize(className));
    model.put("classAuthor", StringUtils.isNotBlank(classAuthor) ? classAuthor : "Generate Tools");
    model.put("classVersion", DateUtils.getDate());
    model.put("functionName", functionName);
    model.put("tableName",
            model.get("moduleName")
                    + (StringUtils.isNotBlank(subModuleName) ? "_" + StringUtils.lowerCase(subModuleName) : "")
                    + "_" + model.get("className"));
    model.put("urlPrefix",
            model.get("moduleName")
                    + (StringUtils.isNotBlank(subModuleName) ? "/" + StringUtils.lowerCase(subModuleName) : "")
                    + "/" + model.get("className"));
    model.put("viewPrefix", //StringUtils.substringAfterLast(model.get("packageName"),".")+"/"+
            model.get("urlPrefix"));
    model.put("permissionPrefix",
            model.get("moduleName")
                    + (StringUtils.isNotBlank(subModuleName) ? ":" + StringUtils.lowerCase(subModuleName) : "")
                    + ":" + model.get("className"));

    // ? Entity
    Template template = cfg.getTemplate("entity.ftl");
    String content = FreeMarkers.renderTemplate(template, model);
    String filePath = javaPath + separator + model.get("moduleName") + separator + "entity" + separator
            + StringUtils.lowerCase(subModuleName) + separator + model.get("ClassName") + ".java";
    writeFile(content, filePath);
    logger.info("Entity: {}", filePath);

    // ? Dao
    template = cfg.getTemplate("dao.ftl");
    content = FreeMarkers.renderTemplate(template, model);
    filePath = javaPath + separator + model.get("moduleName") + separator + "dao" + separator
            + StringUtils.lowerCase(subModuleName) + separator + model.get("ClassName") + "Dao.java";
    writeFile(content, filePath);
    logger.info("Dao: {}", filePath);

    // ? Service
    template = cfg.getTemplate("service.ftl");
    content = FreeMarkers.renderTemplate(template, model);
    filePath = javaPath + separator + model.get("moduleName") + separator + "service" + separator
            + StringUtils.lowerCase(subModuleName) + separator + model.get("ClassName") + "Service.java";
    writeFile(content, filePath);
    logger.info("Service: {}", filePath);

    // ? Controller
    template = cfg.getTemplate("controller.ftl");
    content = FreeMarkers.renderTemplate(template, model);
    filePath = javaPath + separator + model.get("moduleName") + separator + "web" + separator
            + StringUtils.lowerCase(subModuleName) + separator + model.get("ClassName") + "Controller.java";
    writeFile(content, filePath);
    logger.info("Controller: {}", filePath);

    // ? ViewForm
    template = cfg.getTemplate("viewForm.ftl");
    content = FreeMarkers.renderTemplate(template, model);
    filePath = viewPath + separator + StringUtils.substringAfterLast(model.get("packageName"), ".") + separator
            + model.get("moduleName") + separator + StringUtils.lowerCase(subModuleName) + separator
            + model.get("className") + "Form.jsp";
    writeFile(content, filePath);
    logger.info("ViewForm: {}", filePath);

    // ? ViewList
    template = cfg.getTemplate("viewList.ftl");
    content = FreeMarkers.renderTemplate(template, model);
    filePath = viewPath + separator + StringUtils.substringAfterLast(model.get("packageName"), ".") + separator
            + model.get("moduleName") + separator + StringUtils.lowerCase(subModuleName) + separator
            + model.get("className") + "List.jsp";
    writeFile(content, filePath);
    logger.info("ViewList: {}", filePath);
    //?TestCase
    template = cfg.getTemplate("serviceTest.ftl");
    content = FreeMarkers.renderTemplate(template, model);
    filePath = javaTestPath + separator + model.get("moduleName") + separator + "service" + separator
            + StringUtils.lowerCase(subModuleName) + separator + model.get("ClassName") + "ServiceTest.java";
    writeFile(content, filePath);
    logger.info("Service: {}", filePath);
    logger.info("Generate Success.");
}

From source file:com.sishuok.es.generate.Generate.java

public static void main(String[] args) throws Exception {

    // ==========  ?? ====================

    // ??????//  w w  w .ja  v a2  s.  c  om
    // ?{packageName}/{moduleName}/{dao,entity,service,web}/{subModuleName}/{className}

    // packageName ????applicationContext.xmlsrping-mvc.xml?base-package?packagesToScan?4?
    String packageName = "com.sishuok.es";

    String sysName = "sys"; // ??sys?showcase?maintain?personal?shop
    String moduleName = "xxs"; // ???? 
    String tableName = "sys_xxs_attribute"; // user
    String className = "XxsAttribute"; // ??User
    String permissionName = "sys:xxsAttribute";//??????????
    String folderName = "xxs";//??
    String classAuthor = "xxs"; // ThinkGem
    String functionName = "??????"; // ??

    // ???
    //Boolean isEnable = false;
    Boolean isEnable = true;

    // ==========  ?? ====================

    if (!isEnable) {
        logger.error("????isEnable = true");
        return;
    }

    if (StringUtils.isBlank(moduleName) || StringUtils.isBlank(moduleName) || StringUtils.isBlank(className)
            || StringUtils.isBlank(functionName)) {
        logger.error("??????????????");
        return;
    }

    // ?
    String separator = File.separator;

    // ?
    File projectPath = new DefaultResourceLoader().getResource("").getFile();
    while (!new File(projectPath.getPath() + separator + "src" + separator + "main").exists()) {
        projectPath = projectPath.getParentFile();
    }
    logger.info("Project Path: {}", projectPath);

    // ?
    String tplPath = StringUtils.replace(projectPath + "/src/main/java/com/sishuok/es/generate/template", "/",
            separator);
    logger.info("Template Path: {}", tplPath);

    // Java
    String javaPath = StringUtils.replaceEach(
            projectPath + "/src/main/java/" + StringUtils.lowerCase(packageName), new String[] { "/", "." },
            new String[] { separator, separator });
    logger.info("Java Path: {}", javaPath);

    // 
    String viewPath = StringUtils.replace(projectPath + "/src/main/webapp/WEB-INF/jsp/admin", "/", separator);
    logger.info("View Path: {}", viewPath);

    // ???
    Configuration cfg = new Configuration();
    cfg.setDefaultEncoding("UTF-8");
    cfg.setDirectoryForTemplateLoading(new File(tplPath));

    // ???
    Map<String, String> model = Maps.newHashMap();
    model.put("packageName", StringUtils.lowerCase(packageName)); //
    model.put("sysName", StringUtils.lowerCase(sysName)); //???
    model.put("moduleName", StringUtils.lowerCase(moduleName)); //???
    model.put("tableName", StringUtils.lowerCase(tableName)); //
    model.put("className", StringUtils.uncapitalize(className)); //???
    model.put("permissionName", permissionName); //????
    model.put("ClassName", StringUtils.capitalize(className)); //??
    model.put("classAuthor", StringUtils.isNotBlank(classAuthor) ? classAuthor : "Generate Tools"); //
    model.put("classVersion", DateUtils.getDate()); //
    model.put("functionName", functionName); //???
    model.put("folderName", folderName); //??
    model.put("urlPrefix", model.get("moduleName") + "_" + model.get("className")); //jsp??
    model.put("viewPrefix", //StringUtils.substringAfterLast(model.get("packageName"),".")+"/"+
            model.get("urlPrefix"));
    model.put("permissionPrefix", model.get("sysName") + ":" + model.get("moduleName")); //??

    // ? Entity
    Template template = cfg.getTemplate("entity.ftl");
    String content = FreeMarkers.renderTemplate(template, model);
    String filePath = javaPath + separator + model.get("sysName") + separator + model.get("moduleName")
            + separator + "entity" + separator + model.get("ClassName") + ".java";
    System.out.println("Entity   filePath" + filePath);
    writeFile(content, filePath);
    logger.info("Entity: {}", filePath);

    // ? Repository
    template = cfg.getTemplate("repository.ftl");
    content = FreeMarkers.renderTemplate(template, model);
    filePath = javaPath + separator + model.get("sysName") + separator + model.get("moduleName") + separator
            + "repository" + separator + separator + model.get("ClassName") + "Repository.java";
    System.out.println("repository   filePath" + filePath);
    writeFile(content, filePath);
    logger.info("Dao: {}", filePath);

    // ? Service
    template = cfg.getTemplate("service.ftl");
    content = FreeMarkers.renderTemplate(template, model);
    filePath = javaPath + separator + model.get("sysName") + separator + model.get("moduleName") + separator
            + "service" + separator + separator + model.get("ClassName") + "Service.java";
    System.out.println("Service   filePath" + filePath);
    writeFile(content, filePath);
    logger.info("Service: {}", filePath);

    // ? ??Controller
    template = cfg.getTemplate("frontController.ftl");
    content = FreeMarkers.renderTemplate(template, model);
    filePath = javaPath + separator + model.get("sysName") + separator + model.get("moduleName") + separator
            + "web" + separator + "controller" + separator + "front" + separator + model.get("ClassName")
            + "Controller.java";
    System.out.println("Controller   filePath" + filePath);
    writeFile(content, filePath);
    logger.info("Controller: {}", filePath);

    // ? ??Controller
    template = cfg.getTemplate("adminController.ftl");
    content = FreeMarkers.renderTemplate(template, model);
    filePath = javaPath + separator + model.get("sysName") + separator + model.get("moduleName") + separator
            + "web" + separator + "controller" + separator + "admin" + separator + model.get("ClassName")
            + "Controller.java";
    System.out.println("Controller   filePath" + filePath);
    writeFile(content, filePath);
    logger.info("Controller: {}", filePath);

    // ? editForm
    template = cfg.getTemplate("editForm.ftl");
    content = FreeMarkers.renderTemplate(template, model);
    filePath = viewPath + separator + model.get("sysName") + separator + model.get("folderName") + separator
            + "editForm.jsp";
    System.out.println("---------------------------------------------------");
    System.out.println("ViewForm   filePath" + filePath);
    writeFile(content, filePath);
    logger.info("ViewForm: {}", filePath);

    // ? list
    template = cfg.getTemplate("list.ftl");
    content = FreeMarkers.renderTemplate(template, model);
    filePath = viewPath + separator + model.get("sysName") + separator + model.get("folderName") + separator
            + "list.jsp";
    writeFile(content, filePath);
    System.out.println("ViewListfilePath" + filePath);
    logger.info("ViewList: {}", filePath);

    // ? searcheForm
    template = cfg.getTemplate("searchForm.ftl");
    content = FreeMarkers.renderTemplate(template, model);
    filePath = viewPath + separator + model.get("sysName") + separator + model.get("folderName") + separator
            + "searchForm.jsp";
    writeFile(content, filePath);
    System.out.println("searcheForm filePath" + filePath);
    logger.info("ViewList: {}", filePath);

    // ? listTable
    template = cfg.getTemplate("listTable.ftl");
    content = FreeMarkers.renderTemplate(template, model);
    filePath = viewPath + separator + model.get("sysName") + separator + model.get("folderName") + separator
            + "listTable.jsp";
    writeFile(content, filePath);
    System.out.println("listTable filePath" + filePath);
    logger.info("ViewList: {}", filePath);

    logger.info("Generate Success.");
}

From source file:cluster.ClusterComput.java

@SuppressWarnings("unchecked")
public static void main(String[] args) {
    List<OnlineText> onlineTexts = PMHibernateImpl.getInstance().retrieveOnlineText();
    // [[[start:clustering-non-english-content]]]
    /*/*from   www.  j a  v a2 s .c om*/
     * We use a Controller that reuse instances of Carrot2 processing
     * components and caches results produced by document sources.
     */
    final Controller controller = ControllerFactory.createCachingPooling(IDocumentSource.class);

    /*
     * In the first call, we'll cluster a document list, setting the
     * language for each document separately.
     */
    final List<Document> documents = Lists.newArrayList();
    // for (Document document : SampleDocumentData.DOCUMENTS_DATA_MINING)
    // {
    // documents.add(new Document(document.getTitle(),
    // document.getSummary(),
    // document.getContentUrl(), LanguageCode.ENGLISH));
    // }

    for (OnlineText onlineText : onlineTexts) {
        documents.add(new Document(onlineText.getTitle(), onlineText.getContext(), "",
                LanguageCode.CHINESE_SIMPLIFIED));
    }
    final Map<String, Object> attributes = Maps.newHashMap();
    CommonAttributesDescriptor.attributeBuilder(attributes).documents(documents);
    final ProcessingResult englishResult = controller.process(attributes, LingoClusteringAlgorithm.class);
    ConsoleFormatter.displayResults(englishResult);
    final List<Cluster> clustersByTopic = englishResult.getClusters();
    for (Cluster cluster : clustersByTopic) {
        // System.out.println(clustersByTopic.indexOf(cluster) +
        // "? "
        // + cluster.getLabel());
        System.out.println(cluster.getScore());
        List<Document> cDocLst = cluster.getAllDocuments();
        for (Document doc : cDocLst) {
            // System.out.println(documents.indexOf(doc) + "--------"
            // + doc.getTitle());
            int index = documents.indexOf(doc);
            String file_title = documents.get(index).getTitle();
            String url = onlineTexts.get(index).getOnlinetext_id();
            ClusterRelation clusterRelation = new ClusterRelation();
            clusterRelation.setMetaFile(url);
            clusterRelation.setScore(cluster.getScore());
            clusterRelation.setName(cluster.getLabel());
            clusterRelation.setTitle(file_title);
            PMHibernateImpl.getInstance().save(clusterRelation);
        }
    }

    /*
     * In the second call, we will fetch results for a Chinese query from
     * Bing, setting explicitly the Bing's specific language attribute.
     * Based on that attribute, the document source will set the appropriate
     * language for each document.
     */
    attributes.clear();

    CommonAttributesDescriptor.attributeBuilder(attributes).query("?" /* clustering? */).results(100);

    Bing3WebDocumentSourceDescriptor.attributeBuilder(attributes).market(MarketOption.CHINESE_CHINA);
    Bing3WebDocumentSourceDescriptor.attributeBuilder(attributes).appid(BingKeyAccess.getKey()); // use your own ID here!

    final ProcessingResult chineseResult = controller.process(attributes, Bing3WebDocumentSource.class,
            LingoClusteringAlgorithm.class);
    ConsoleFormatter.displayResults(chineseResult);

    /*
     * In the third call, we will fetch results for the same Chinese query
     * from Google. As Google document source does not have its specific
     * attribute for setting the language, it will not set the documents'
     * language for us. To make sure the right lexical resources are used,
     * we will need to set the MultilingualClustering.defaultLanguage
     * attribute to Chinese on our own.
     */
    attributes.clear();

    CommonAttributesDescriptor.attributeBuilder(attributes).query("?" /* clustering? */).results(100);

    MultilingualClusteringDescriptor.attributeBuilder(attributes)
            .defaultLanguage(LanguageCode.CHINESE_SIMPLIFIED);

    final ProcessingResult chineseResult2 = controller.process(attributes, GoogleDocumentSource.class,
            LingoClusteringAlgorithm.class);
    ConsoleFormatter.displayResults(chineseResult2);

    // [[[end:clustering-non-english-content]]]
}

From source file:org.guess.generate.Generate.java

public static void main(String[] args) {

    // ==========  ?? ====================

    // ??????/*w  w w. j a va2  s . c  o  m*/
    // ?{packageName}/{moduleName}/{dao,entity,service,web}/{subModuleName}/{className}

    // packageName
    // ????applicationContext.xmlsrping-mvc.xml?base-package?packagesToScan?4?
    String packageName = "net.iharding.modulesmeta";

    String moduleName = "meta"; // ???sys
    String className = "project"; // ??user
    String classAuthor = "Joe.zhang"; // 
    String functionName = "??"; // ??

    List<Field> fields = new ArrayList<Field>();
    fields.add(new Field("projectCode", "?", "String"));
    fields.add(new Field("projectName", "??", "String"));
    fields.add(new Field("remark", "", "String"));
    fields.add(new Field("createDate", "", "Date"));
    fields.add(new Field("updateDate", "", "Date"));
    fields.add(new Field("createId", "", "createId"));
    fields.add(new Field("updateId", "", "updateId"));

    // ???
    Boolean isEnable = true;

    // ==========  ?? ====================

    if (!isEnable) {
        logger.error("????isEnable = true");
        return;
    }

    if (StringUtils.isBlank(moduleName) || StringUtils.isBlank(moduleName) || StringUtils.isBlank(className)
            || StringUtils.isBlank(functionName)) {
        logger.error("??????????????");
        return;
    }

    // ?
    String separator = File.separator;

    // ?
    File projectPath = null;
    try {
        projectPath = new DefaultResourceLoader().getResource("").getFile();
        //         File projectPath = new File("D:/template");
        while (!new File(projectPath.getPath() + separator + "src" + separator + "main").exists()) {
            projectPath = projectPath.getParentFile();
        }
        logger.info("Project Path: {}", projectPath);

        // ?
        String tplPath = StringUtils.replace(
                projectPath.getAbsolutePath() + "/src/test/java/org/guess/generate/temp", "/", separator);
        logger.info("Template Path: {}", tplPath);

        // Java
        String javaPath = StringUtils.replaceEach(
                projectPath.getAbsolutePath() + "/src/main/java/" + StringUtils.lowerCase(packageName),
                new String[] { "/", "." }, new String[] { separator, separator });
        //         String javaPath = "D:/template";
        logger.info("Java Path: {}", javaPath);

        String viewPath = StringUtils.replace(
                projectPath + "/src/main/webapp/WEB-INF/content/" + moduleName + "/" + className, "/",
                separator);
        //         String viewPath = "D:/template";

        // ???
        Configuration cfg = new Configuration();
        FileUtils.isFolderExitAndCreate(tplPath);
        cfg.setDirectoryForTemplateLoading(new File(tplPath));

        // ???
        Map<String, Object> model = Maps.newHashMap();
        model.put("packageName", StringUtils.lowerCase(packageName));
        model.put("moduleName", StringUtils.lowerCase(moduleName));
        model.put("className", StringUtils.uncapitalize(className));
        model.put("ClassName", StringUtils.capitalize(className));
        model.put("classAuthor", StringUtils.isNotBlank(classAuthor) ? classAuthor : "Generate Tools");
        model.put("classVersion", DateUtil.getCurrenDate());
        model.put("functionName", functionName);
        model.put("tableName", model.get("moduleName") + "_" + model.get("className"));

        model.put("fields", fields);

        // ? Entity
        Template template = cfg.getTemplate("entity.ftl");
        String content = FreeMarkers.renderTemplate(template, model);
        String filePath = javaPath + separator + model.get("moduleName") + separator + "model" + separator
                + model.get("ClassName") + ".java";
        //         writeFile(content, filePath);
        logger.info("Entity: {}", filePath);

        // ? Dao
        template = cfg.getTemplate("dao.ftl");
        content = FreeMarkers.renderTemplate(template, model);
        filePath = javaPath + separator + model.get("moduleName") + separator + "dao" + separator
                + model.get("ClassName") + "Dao.java";
        writeFile(content, filePath);
        logger.info("Dao: {}", filePath);

        // ? DaoImpl
        template = cfg.getTemplate("daoImpl.ftl");
        content = FreeMarkers.renderTemplate(template, model);
        filePath = javaPath + separator + model.get("moduleName") + separator + "dao" + separator + "impl"
                + separator + model.get("ClassName") + "DaoImpl.java";
        writeFile(content, filePath);
        logger.info("Dao: {}", filePath);

        // ? Service
        template = cfg.getTemplate("service.ftl");
        content = FreeMarkers.renderTemplate(template, model);
        filePath = javaPath + separator + model.get("moduleName") + separator + "service" + separator
                + model.get("ClassName") + "Service.java";
        writeFile(content, filePath);
        logger.info("Service: {}", filePath);

        // ? Service
        template = cfg.getTemplate("serviceImpl.ftl");
        content = FreeMarkers.renderTemplate(template, model);
        filePath = javaPath + separator + model.get("moduleName") + separator + "service" + separator + "impl"
                + separator + model.get("ClassName") + "ServiceImpl.java";
        writeFile(content, filePath);
        logger.info("Service: {}", filePath);

        // ? Controller
        template = cfg.getTemplate("controller.ftl");
        content = FreeMarkers.renderTemplate(template, model);
        filePath = javaPath + separator + model.get("moduleName") + separator + "controller" + separator
                + model.get("ClassName") + "Controller.java";
        writeFile(content, filePath);
        logger.info("Controller: {}", filePath);

        /*   // ? list.jsp
           template = cfg.getTemplate("list.ftl");
           content = FreeMarkers.renderTemplate(template, model);
           filePath = viewPath + separator + "list.jsp";
           writeFile(content, filePath);
           logger.info("Controller: {}", filePath);
                   
           // ? edit.jsp
           template = cfg.getTemplate("edit.ftl");
           content = FreeMarkers.renderTemplate(template, model);
           filePath = viewPath + separator + "edit.jsp";
           writeFile(content, filePath);
           logger.info("Controller: {}", filePath);*/

        logger.info("Generate Success.");
    } catch (IOException e) {
        e.printStackTrace();
    }

}

From source file:com.sccl.attech.generate.Generate.java

/**
 * The main method./*from   www . j a v  a2 s. co  m*/
 * 
 * @param args the arguments
 * @throws Exception the exception
 */
public static void main(String[] args) throws Exception {

    // ==========  ?? ====================1412914

    // ??????
    // ?{packageName}/{moduleName}/{dao,entity,service,web}/{subModuleName}/{className}

    // packageName ????applicationContext.xmlsrping-mvc.xml?base-package?packagesToScan?4?
    String packageName = "com.sccl.attech.modules";

    String moduleName = "mobil"; // ???sys
    String subModuleName = ""; // ????? 
    String className = "updateApp"; // ??user
    List<GenerateField> fields = Lists.newArrayList();
    fields.add(new GenerateField("name", "??"));
    fields.add(new GenerateField("type", ""));
    fields.add(new GenerateField("version", ""));
    fields.add(new GenerateField("path", ""));

    String classAuthor = "zzz"; // zhaozz
    String functionName = "App?"; // ??

    // ???
    //Boolean isEnable = false;
    Boolean isEnable = true;

    // ==========  ?? ====================

    if (!isEnable) {
        logger.error("????isEnable = true");
        return;
    }

    if (StringUtils.isBlank(moduleName) || StringUtils.isBlank(moduleName) || StringUtils.isBlank(className)
            || StringUtils.isBlank(functionName)) {
        logger.error("??????????????");
        return;
    }

    // ?
    String separator = File.separator;

    // ?
    File projectPath = new DefaultResourceLoader().getResource("").getFile();
    while (!new File(projectPath.getPath() + separator + "src" + separator + "main").exists()) {
        projectPath = projectPath.getParentFile();
    }
    logger.info("Project Path: {}", projectPath);

    // ?
    String tplPath = StringUtils.replace(projectPath + "/src/main/java/com/sccl/attech/generate/template", "/",
            separator);
    logger.info("Template Path: {}", tplPath);

    // Java
    String javaPath = StringUtils.replaceEach(
            projectPath + "/src/main/java/" + StringUtils.lowerCase(packageName), new String[] { "/", "." },
            new String[] { separator, separator });
    logger.info("Java Path: {}", javaPath);

    // 
    String viewPath = StringUtils.replace(projectPath + "/WebRoot/pages", "/", separator);
    logger.info("View Path: {}", viewPath);
    String resPath = StringUtils.replace(projectPath + "/WebRoot/assets/js", "/", separator);
    logger.info("Res Path: {}", resPath);

    // ???
    Configuration cfg = new Configuration();
    cfg.setDefaultEncoding("UTF-8");
    cfg.setDirectoryForTemplateLoading(new File(tplPath));

    // ???
    Map<String, Object> model = Maps.newHashMap();
    model.put("packageName", StringUtils.lowerCase(packageName));
    model.put("moduleName", StringUtils.lowerCase(moduleName));
    model.put("fields", fields);
    model.put("subModuleName",
            StringUtils.isNotBlank(subModuleName) ? "." + StringUtils.lowerCase(subModuleName) : "");
    model.put("className", StringUtils.uncapitalize(className));
    model.put("ClassName", StringUtils.capitalize(className));
    model.put("classAuthor", StringUtils.isNotBlank(classAuthor) ? classAuthor : "Generate Tools");
    model.put("classVersion", DateUtils.getDate());
    model.put("functionName", functionName);
    model.put("tableName",
            model.get("moduleName")
                    + (StringUtils.isNotBlank(subModuleName) ? "_" + StringUtils.lowerCase(subModuleName) : "")
                    + "_" + model.get("className"));
    model.put("urlPrefix",
            model.get("moduleName")
                    + (StringUtils.isNotBlank(subModuleName) ? "/" + StringUtils.lowerCase(subModuleName) : "")
                    + "/" + model.get("className"));
    model.put("viewPrefix", //StringUtils.substringAfterLast(model.get("packageName"),".")+"/"+
            model.get("urlPrefix"));
    model.put("permissionPrefix",
            model.get("moduleName")
                    + (StringUtils.isNotBlank(subModuleName) ? ":" + StringUtils.lowerCase(subModuleName) : "")
                    + ":" + model.get("className"));

    // ? Entity
    Template template = cfg.getTemplate("entity.ftl");
    String content = FreeMarkers.renderTemplate(template, model);
    String filePath = javaPath + separator + model.get("moduleName") + separator + "entity" + separator
            + StringUtils.lowerCase(subModuleName) + separator + model.get("ClassName") + ".java";
    writeFile(content, filePath);
    logger.info("Entity: {}", filePath);

    // ? Dao
    template = cfg.getTemplate("dao.ftl");
    content = FreeMarkers.renderTemplate(template, model);
    filePath = javaPath + separator + model.get("moduleName") + separator + "dao" + separator
            + StringUtils.lowerCase(subModuleName) + separator + model.get("ClassName") + "Dao.java";
    writeFile(content, filePath);
    logger.info("Dao: {}", filePath);

    // ? Service
    template = cfg.getTemplate("service.ftl");
    content = FreeMarkers.renderTemplate(template, model);
    filePath = javaPath + separator + model.get("moduleName") + separator + "service" + separator
            + StringUtils.lowerCase(subModuleName) + separator + model.get("ClassName") + "Service.java";
    writeFile(content, filePath);
    logger.info("Service: {}", filePath);

    // ? Controller
    createJavaFile(subModuleName, separator, javaPath, cfg, model);

    // ? ViewForm
    template = cfg.getTemplate("viewForm.ftl");
    content = FreeMarkers.renderTemplate(template, model);
    filePath = viewPath//+separator+StringUtils.substringAfterLast(model.get("packageName"),".")
            + separator + model.get("moduleName") + separator + StringUtils.lowerCase(subModuleName) + separator
            + model.get("className") + "Form.html";
    writeFile(content, filePath);
    logger.info("ViewForm: {}", filePath);

    // ? ViewFormJs
    template = cfg.getTemplate("viewFormJs.ftl");
    content = FreeMarkers.renderTemplate(template, model);
    filePath = resPath//+separator+StringUtils.substringAfterLast(model.get("packageName"),".")
            + separator + model.get("moduleName") + separator + StringUtils.lowerCase(subModuleName) + separator
            + model.get("className") + "FormCtrl.js";
    writeFile(content, filePath);
    logger.info("ViewFormJs: {}", filePath);

    // ? ViewList
    template = cfg.getTemplate("viewList.ftl");
    content = FreeMarkers.renderTemplate(template, model);
    filePath = viewPath//+separator+StringUtils.substringAfterLast(model.get("packageName"),".")
            + separator + model.get("moduleName") + separator + StringUtils.lowerCase(subModuleName) + separator
            + model.get("className") + "List.html";
    writeFile(content, filePath);
    logger.info("ViewList: {}", filePath);

    // ? ViewListJs
    template = cfg.getTemplate("viewListJs.ftl");
    content = FreeMarkers.renderTemplate(template, model);
    filePath = resPath//+separator+StringUtils.substringAfterLast(model.get("packageName"),".")
            + separator + model.get("moduleName") + separator + StringUtils.lowerCase(subModuleName) + separator
            + model.get("className") + "ListCtrl.js";
    writeFile(content, filePath);
    logger.info("ViewList: {}", filePath);

    // ? ??sql
    template = cfg.getTemplate("sql.ftl");
    model.put("uid", IdGen.uuid());
    model.put("uid1", IdGen.uuid());
    content = FreeMarkers.renderTemplate(template, model);
    filePath = viewPath//+separator+StringUtils.substringAfterLast(model.get("packageName"),".")
            + separator + model.get("moduleName") + separator + StringUtils.lowerCase(subModuleName) + separator
            + model.get("className") + ".sql";
    writeFile(content, filePath);
    logger.info("ViewList: {}", filePath);

    logger.info("Generate Success.");
}

From source file:com.serendio.lingo3g.ClusteringDataFromLucene.java

public static void main(String[] args) throws IOException {
    /*/*from   w  ww  .  j  ava 2s  . c  o  m*/
     * We will use the CachingController for this example. Running
     * LuceneDocumentSource within the CachingController will let us open the index
     * once per component initialization and not once per query, which would be the
     * case with SimpleController. We will also use this opportunity to show how
     * component-specific attribute values can be passed during CachingComponent
     * initialization.
     */

    /*
     * Create a caching controller that will reuse processing component instances, but
     * will not perform any caching of results produced by components. We will leave
     * caching of documents from Lucene index to Lucene and the operating system
     * caches.
     */
    final Controller controller = ControllerFactory.createPooling();

    /*
     * Prepare a map with component-specific attributes. Here, this map will contain
     * the index location and names of fields to be used to fetch document title and
     * summary.
     */
    final Map<String, Object> luceneGlobalAttributes = new HashMap<String, Object>();

    //String indexPath = "/home/serendio/amc_dev/data/index";
    String serviceUrlBase = "Your solr source Url";
    //        if (args.length == 1)
    //        {
    //           serviceUrlBase = args[0];
    //        }
    SolrDocumentSourceDescriptor.attributeBuilder(luceneGlobalAttributes).serviceUrlBase(serviceUrlBase);
    //LuceneDocumentSourceDescriptor
    //.attributeBuilder(luceneGlobalAttributes)
    //.directory(FSDirectory.open(Paths.get(indexPath)));
    //.directory(FSDirectory.open(new File(indexPath)));

    /*
     * Specify fields providing data inside your Lucene index.
     */

    SolrDocumentSourceDescriptor.attributeBuilder(luceneGlobalAttributes).solrIdFieldName("id")
            .solrTitleFieldName("title").solrSummaryFieldName("sentence").solrUrlFieldName("url")
            .readClusters(true).useHighlighterOutput(true).copyFields(true).start(0).results(5000);

    //        SimpleFieldMapperDescriptor
    //            .attributeBuilder(luceneGlobalAttributes)
    //            .titleField("id")
    //            .contentField("sentence")
    //            .titleField("title")            
    //            .urlField("url")
    //            .searchFields(Arrays.asList(new String [] {"id","title", "sentence","url"}));
    //.contentField("title")
    //.urlField("url")            
    //.contentField("content");            
    //           .searchFields(Arrays.asList(new String [] {"sentence","sentence"}));

    /*
     * Initialize the controller passing the above attributes as component-specific
     * for Lucene. The global attributes map will be empty. Note that we've provided
     * an identifier for our specially-configured Lucene component, we'll need to use
     * this identifier when performing processing.
     */
    controller.init(new HashMap<String, Object>(),
            new ProcessingComponentConfiguration(SolrDocumentSource.class, "lucene", luceneGlobalAttributes));

    /*
     * Perform processing.
     */
    Scanner scanner = new Scanner(System.in);
    String input = scanner.next();
    String query = "case_id:" + input;
    final Map<String, Object> processingAttributes = Maps.newHashMap();
    CommonAttributesDescriptor.attributeBuilder(processingAttributes).query(query);

    /*
     * We need to refer to the Lucene component by its identifier we set during
     * initialization. As we've not assigned any identifier to the
     * LingoClusteringAlgorithm we want to use, we can its fully qualified class name.
     */
    //ProcessingResult process = controller.process(processingAttributes, "lucene",
    //  LingoClusteringAlgorithm.class.getName());
    //       ProcessingResult result = controller.process(processingAttributes,"lucene", Lingo3GClusteringAlgorithm.class);
    //        //ProcessingResult result = controller.process(processingAttributes,"lucene",Lingo3GClusteringAlgorithm.class.getName());
    //        
    //        ConsoleFormatter.displayResults(result);
    ProcessingResult result = controller.process(processingAttributes, "lucene",
            Lingo3GClusteringAlgorithm.class.getName());
    //System.out.println(luceneGlobalAttributes);
    //System.out.println(processingAttributes);        

    //ConsoleFormatter.displayResults(process);

    Writer writer = new FileWriter("/home/ram/Desktop/Lingo" + input + ".json");
    result.serializeJson(writer);

}

From source file:ca.dealsaccess.scout.driver.ScoutDriver.java

public static void main(String[] args) throws Throwable {

    ProgramDriver programDriver = new ProgramDriver();

    Properties mainClasses = loadProperties("driver.classes.props");
    if (mainClasses == null) {
        mainClasses = loadProperties("driver.classes.default.props");
    }//from w w  w.  j ava2 s.  c  o  m
    if (mainClasses == null) {
        throw new IOException("Can't load any properties file?");
    }

    boolean foundShortName = false;
    for (Object key : mainClasses.keySet()) {
        String keyString = (String) key;
        if (args.length > 0 && shortName(mainClasses.getProperty(keyString)).equals(args[0])) {
            foundShortName = true;
        }
        if (args.length > 0 && keyString.equalsIgnoreCase(args[0]) && isDeprecated(mainClasses, keyString)) {
            log.error(desc(mainClasses.getProperty(keyString)));
            return;
        }
        if (isDeprecated(mainClasses, keyString)) {
            continue;
        }
        addClass(programDriver, keyString, mainClasses.getProperty(keyString));
    }

    if (args.length < 1 || args[0] == null || "-h".equals(args[0]) || "--help".equals(args[0])) {
        programDriver.driver(args);
    }

    String progName = args[0];
    if (!foundShortName) {
        addClass(programDriver, progName, progName);
    }
    shift(args);

    Properties mainProps = loadProperties(progName + ".props");
    if (mainProps == null) {
        log.warn("No {}.props found on classpath, will use command-line arguments only", progName);
        mainProps = new Properties();
    }

    Map<String, String[]> argMap = Maps.newHashMap();
    int i = 0;
    while (i < args.length && args[i] != null) {
        List<String> argValues = Lists.newArrayList();
        String arg = args[i];
        i++;
        if (arg.startsWith("-D")) { // '-Dkey=value' or '-Dkey=value1,value2,etc' case
            String[] argSplit = arg.split("=");
            arg = argSplit[0];
            if (argSplit.length == 2) {
                argValues.add(argSplit[1]);
            }
        } else { // '-key [values]' or '--key [values]' case.
            while (i < args.length && args[i] != null) {
                if (args[i].startsWith("-")) {
                    break;
                }
                argValues.add(args[i]);
                i++;
            }
        }
        argMap.put(arg, argValues.toArray(new String[argValues.size()]));
    }

    // Add properties from the .props file that are not overridden on the command line
    for (String key : mainProps.stringPropertyNames()) {
        String[] argNamePair = key.split("\\|");
        String shortArg = '-' + argNamePair[0].trim();
        String longArg = argNamePair.length < 2 ? null : "--" + argNamePair[1].trim();
        if (!argMap.containsKey(shortArg) && (longArg == null || !argMap.containsKey(longArg))) {
            argMap.put(longArg, new String[] { mainProps.getProperty(key) });
        }
    }

    // Now add command-line args
    List<String> argsList = Lists.newArrayList();
    argsList.add(progName);
    for (Map.Entry<String, String[]> entry : argMap.entrySet()) {
        String arg = entry.getKey();
        if (arg.startsWith("-D")) { // arg is -Dkey - if value for this !isEmpty(), then arg -> -Dkey + "=" + value
            String[] argValues = entry.getValue();
            if (argValues.length > 0 && !argValues[0].trim().isEmpty()) {
                arg += '=' + argValues[0].trim();
            }
            argsList.add(1, arg);
        } else {
            argsList.add(arg);
            for (String argValue : Arrays.asList(argMap.get(arg))) {
                if (!argValue.isEmpty()) {
                    argsList.add(argValue);
                }
            }
        }
    }

    long start = System.currentTimeMillis();

    programDriver.driver(argsList.toArray(new String[argsList.size()]));

    if (log.isInfoEnabled()) {
        log.info("Program took {} ms (Minutes: {})", System.currentTimeMillis() - start,
                (System.currentTimeMillis() - start) / 60000.0);
    }
}

From source file:org.apache.mahout.driver.MahoutDriver.java

public static void main(String[] args) throws Throwable {

    Properties mainClasses = loadProperties("driver.classes.props");
    if (mainClasses == null) {
        mainClasses = loadProperties("driver.classes.default.props");
    }//from ww  w .  ja  v a2 s.c o  m
    if (mainClasses == null) {
        throw new IOException("Can't load any properties file?");
    }

    boolean foundShortName = false;
    ProgramDriver programDriver = new ProgramDriver();
    for (Object key : mainClasses.keySet()) {
        String keyString = (String) key;
        if (args.length > 0 && shortName(mainClasses.getProperty(keyString)).equals(args[0])) {
            foundShortName = true;
        }
        if (args.length > 0 && keyString.equalsIgnoreCase(args[0]) && isDeprecated(mainClasses, keyString)) {
            log.error(desc(mainClasses.getProperty(keyString)));
            return;
        }
        if (isDeprecated(mainClasses, keyString)) {
            continue;
        }
        addClass(programDriver, keyString, mainClasses.getProperty(keyString));
    }

    if (args.length < 1 || args[0] == null || "-h".equals(args[0]) || "--help".equals(args[0])) {
        programDriver.driver(args);
        return;
    }

    String progName = args[0];
    if (!foundShortName) {
        addClass(programDriver, progName, progName);
    }
    shift(args);

    Properties mainProps = loadProperties(progName + ".props");
    if (mainProps == null) {
        log.warn("No {}.props found on classpath, will use command-line arguments only", progName);
        mainProps = new Properties();
    }

    Map<String, String[]> argMap = Maps.newHashMap();
    int i = 0;
    while (i < args.length && args[i] != null) {
        List<String> argValues = Lists.newArrayList();
        String arg = args[i];
        i++;
        if (arg.startsWith("-D")) { // '-Dkey=value' or '-Dkey=value1,value2,etc' case
            String[] argSplit = arg.split("=");
            arg = argSplit[0];
            if (argSplit.length == 2) {
                argValues.add(argSplit[1]);
            }
        } else { // '-key [values]' or '--key [values]' case.
            while (i < args.length && args[i] != null) {
                if (args[i].startsWith("-")) {
                    break;
                }
                argValues.add(args[i]);
                i++;
            }
        }
        argMap.put(arg, argValues.toArray(new String[argValues.size()]));
    }

    // Add properties from the .props file that are not overridden on the command line
    for (String key : mainProps.stringPropertyNames()) {
        String[] argNamePair = key.split("\\|");
        String shortArg = '-' + argNamePair[0].trim();
        String longArg = argNamePair.length < 2 ? null : "--" + argNamePair[1].trim();
        if (!argMap.containsKey(shortArg) && (longArg == null || !argMap.containsKey(longArg))) {
            argMap.put(longArg, new String[] { mainProps.getProperty(key) });
        }
    }

    // Now add command-line args
    List<String> argsList = Lists.newArrayList();
    argsList.add(progName);
    for (Map.Entry<String, String[]> entry : argMap.entrySet()) {
        String arg = entry.getKey();
        if (arg.startsWith("-D")) { // arg is -Dkey - if value for this !isEmpty(), then arg -> -Dkey + "=" + value
            String[] argValues = entry.getValue();
            if (argValues.length > 0 && !argValues[0].trim().isEmpty()) {
                arg += '=' + argValues[0].trim();
            }
            argsList.add(1, arg);
        } else {
            argsList.add(arg);
            for (String argValue : Arrays.asList(argMap.get(arg))) {
                if (!argValue.isEmpty()) {
                    argsList.add(argValue);
                }
            }
        }
    }

    long start = System.currentTimeMillis();

    programDriver.driver(argsList.toArray(new String[argsList.size()]));

    if (log.isInfoEnabled()) {
        log.info("Program took {} ms (Minutes: {})", System.currentTimeMillis() - start,
                (System.currentTimeMillis() - start) / 60000.0);
    }
}

From source file:org.carrot2.examples.clustering.ClusteringDataFromLuceneWithCustomFields.java

/**
 * Entry point. /*from   w  ww  .  ja  v  a2s  .c om*/
 */
public static void main(String[] args) throws IOException {
    /*
     * We will use the CachingController for this example. Running
     * LuceneDocumentSource within the CachingController will let us open the index
     * once per component initialization and not once per query, which would be the
     * case with SimpleController. We will also use this opportunity to show how
     * component-specific attribute values can be passed during CachingComponent
     * initialization.
     */

    /*
     * Create a caching controller that will reuse processing component instances, but
     * will not perform any caching of results produced by components. We will leave
     * caching of documents from Lucene index to Lucene and the operating system
     * caches.
     */
    final Controller controller = ControllerFactory.createPooling();

    /*
     * Prepare a map with component-specific attributes. Here, this map will contain
     * the index location and names of fields to be used to fetch document title and
     * summary.
     */
    final Map<String, Object> luceneGlobalAttributes = new HashMap<String, Object>();

    String indexPath = "put your index path here or pass as the first argument";
    if (args.length == 1) {
        indexPath = args[0];
    }

    // Sanity check.
    if (!new File(indexPath).isDirectory()) {
        System.err.println("Index directory does not exist: " + indexPath);
        return;
    }

    LuceneDocumentSourceDescriptor.attributeBuilder(luceneGlobalAttributes)
            .directory(FSDirectory.open(new File(indexPath)));

    /*
     * In ClusteringDataFromLucene we used a simple configuration of
     * LuceneDocumentSource whereby we only provided the names of Lucene fields to be
     * used for titles and summaries. If more advanced mapping of Lucene documents is
     * required, you can implement your own version of IFieldMapper as below.
     * 
     * Note that we could also provide here an instance of the mapper rather than
     * its class. The differences are summarized below:
     * 
     * > Class: Class has to have a no-parameter constructor. Instances of the
     *   class will not be shared between processing threads, which means the
     *   implementation does not have to be thread-safe. Recommended in most 
     *   situations unless the instances are expensive to create.
     *   
     * > Instance: The provided instance will be shared across processing threads,
     *   which means the implementation MUST be thread-safe.
     */
    LuceneDocumentSourceDescriptor.attributeBuilder(luceneGlobalAttributes)
            .fieldMapper(new CustomFieldMapper());

    /*
     * The Analyzer used by Lucene while searching can also be provided via factory
     * because it does not have a parameterless constructor.
     */
    LuceneDocumentSourceDescriptor.attributeBuilder(luceneGlobalAttributes)
            .analyzer(StandardAnalyzerFactory.class);

    /*
     * Initialize the controller passing the above attributes as component-specific
     * for Lucene. The global attributes map will be empty. Note that we've provided
     * an identifier for our specially-configured Lucene component, we'll need to use
     * this identifier when performing processing.
     */
    controller.init(new HashMap<String, Object>(),
            new ProcessingComponentConfiguration(LuceneDocumentSource.class, "lucene", luceneGlobalAttributes));

    /*
     * Perform processing.
     */
    final String query = "mining";
    final Map<String, Object> processingAttributes = Maps.newHashMap();
    CommonAttributesDescriptor.attributeBuilder(processingAttributes).query(query);

    /*
     * We need to refer to the Lucene component by its identifier we set during
     * initialization. As we've not assigned any identifier to the
     * LingoClusteringAlgorithm we want to use, we can its fully qualified class name.
     */
    ProcessingResult process = controller.process(processingAttributes, "lucene",
            LingoClusteringAlgorithm.class.getName());

    ConsoleFormatter.displayResults(process);
}