Package org.mcavallo.opencloud

Examples of org.mcavallo.opencloud.Cloud


    if (parameters == null)
      parameters = new TagCloudConfiguration();

    try {
      Cloud cloud = new Cloud()// create cloud
      if (parameters.getCloudCase().equals("Case.LOWER"))
        cloud.setTagCase(Case.LOWER);
      else if (parameters.getCloudCase().equals("Case.UPPER"))
        cloud.setTagCase(Case.UPPER);
      else if (parameters.getCloudCase().equals("Case.CAPITALIZATION"))
        cloud.setTagCase(Case.CAPITALIZATION);
      else if (parameters.getCloudCase().equals("Case.PRESERVE_CASE"))
        cloud.setTagCase(Case.PRESERVE_CASE);
      else if (parameters.getCloudCase().equals("Case.CASE_SENSITIVE"))
        cloud.setTagCase(Case.CASE_SENSITIVE);
      cloud.setMaxWeight(Double.parseDouble(parameters.getFontTo()));   // max font size
      cloud.setMinWeight(Double.parseDouble(parameters.getFontFrom()));
      if (parameters.getTotalTags()==-1)
        cloud.setMaxTagsToDisplay(1000000);
      else
        cloud.setMaxTagsToDisplay(parameters.getTotalTags());
     
      for (String subject : data.keySet()){
        if (data.get(subject).intValue() > Integer.parseInt(parameters.getCuttingLevel())){
          for (int i=0; i<data.get(subject).intValue(); i++){
            Tag tag2 = new Tag(subject, ((HttpServletRequest) pageContext.getRequest()).getContextPath()+(scope!=null?scope:"")+(type.equals("0")?("/simple-search?filterquery="+URLEncoder.encode(subject,"UTF-8")+"&filtername="+index+"&filtertype=equals"):("/browse?type="+index+"&value="+subject)));
            cloud.addTag(tag2);
          }
        }
      }

      out.println("<div class=\"tagcloud\">");
      int counter = 0;

      List<Tag> tagList = cloud.tags(new Tag.NameComparatorAsc());
      if (parameters.getOrdering().equals("Tag.NameComparatorAsc"))
        tagList = cloud.tags(new Tag.NameComparatorAsc());
      else if (parameters.getOrdering().equals("Tag.NameComparatorDesc"))
        tagList = cloud.tags(new Tag.NameComparatorDesc());
      else if (parameters.getOrdering().equals("Tag.ScoreComparatorAsc"))
        tagList = cloud.tags(new Tag.ScoreComparatorAsc());
      else if (parameters.getOrdering().equals("Tag.ScoreComparatorDesc"))
        tagList = cloud.tags(new Tag.ScoreComparatorDesc());

      for (Tag tag : tagList) {

        String tagClass = "";
       
View Full Code Here


            IntWritable k = new IntWritable();
            WeightedVectorWritable wvw = new WeightedVectorWritable();
            pointsReader = new SequenceFileDirectoryReader(clusteredPointsPath);
            while (pointsReader.next(k, wvw)) {
                int clusterId = k.get();
                Cloud c = cloudMap.get(clusterId);
                if (c == null) {
                    c = new Cloud(template);
                }
                Iterator<Element> viter = wvw.getVector().iterateNonZero();
                while (viter.hasNext()) {
                    Element e = viter.next();
                    String feature = invertedFeatureIndex.get(e.index());
                    c.addTag(new Tag(feature, e.get()));
                }
               
                cloudMap.put(clusterId, c);
            }
        } catch (IOException e) {
View Full Code Here

        if (args.length != 4) {
            System.out.println("Usage: WordCloud <clusterPoints> <feature-index> <tagsToDisplay> <htmlOutputPath>");
        }
        WordCloud wc = new WordCloud(new Path(args[0]), new Path(args[1]));
       
        Cloud template = new Cloud();
        template.setMaxTagsToDisplay(Integer.parseInt(args[2]));
        template.setTagCase(Case.LOWER);
        template.setMinWeight(10.0);
        template.setMaxWeight(96.0);
       
        Map<Integer,Cloud> cloudMap = wc.getClouds(template);
        wc.writeCloudsHTML(cloudMap, args[3]);
    }
View Full Code Here

TOP

Related Classes of org.mcavallo.opencloud.Cloud

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.