Skip to content

Traditional Chinese words always displayed in Simplified Chinese version in word cloud frequencies and image #112

@peyser81

Description

@peyser81

Hi, I have traditional Chinese words as input and the generated word frequencies and image always show the simplified version of the words. This is my sample code and the image

            final FrequencyAnalyzer frequencyAnalyzer = new FrequencyAnalyzer();
            frequencyAnalyzer.setWordFrequenciesToReturn(100);
            frequencyAnalyzer.setMinWordLength(2);
            frequencyAnalyzer.setStopWords(loadStopWords());
            frequencyAnalyzer.setWordTokenizer(new ChineseWordTokenizer());

            List<String> texts = new ArrayList<>();
            texts.add("畫畫"); //Traditional Chinese, 画画 is the simplified version
            texts.add("笨蛋");
            texts.add("purpose");
            final List<WordFrequency> wordFrequencies = frequencyAnalyzer.load(texts);
            final List<WordFrequency> wordFrequenciesNeg = frequencyAnalyzer.load(new ArrayList<>());
            freq = wordFrequencies;
            freqNeg = wordFrequenciesNeg;
            long t = System.currentTimeMillis();

            // Layered Word Cloud from two images/two word sets
            Dimension dimension = new Dimension(600, 386);
            LayeredWordCloud layeredWordCloud = new LayeredWordCloud(2, dimension, CollisionMode.PIXEL_PERFECT);
            layeredWordCloud.setAngleGenerator(0, new AngleGenerator(0));
            layeredWordCloud.setAngleGenerator(1, new AngleGenerator(0));

            layeredWordCloud.setPadding(0, 2);
            layeredWordCloud.setPadding(1, 2);

            layeredWordCloud.setKumoFont(0, new KumoFont("Noto Sans TC", FontWeight.PLAIN));
            layeredWordCloud.setKumoFont(1, new KumoFont("Noto Sans TC", FontWeight.PLAIN));

            String backgroundPath = context.getRealPath("/res/wordcloud/backgrounds/");
            layeredWordCloud.setBackground(0, new PixelBoundryBackground(backgroundPath + "cloud_bg.bmp"));
            layeredWordCloud.setBackground(1, new PixelBoundryBackground(backgroundPath + "cloud_fg.bmp"));

            layeredWordCloud.setBackgroundColor(Color.WHITE);

            layeredWordCloud.setColorPalette(0,
                    new ColorPalette(new Color(0xAF1B14), new Color(0xE0251C), new Color(0xF2473F),
                            new Color(0xFB7771), new Color(0xF9ADA9), new Color(0xF9ADA9), new Color(0xF9ADA9),
                            new Color(0xF9ADA9), new Color(0xF9ADA9), new Color(0xF9ADA9)));
            layeredWordCloud.setColorPalette(1,
                    new ColorPalette(new Color(0x336708), new Color(0x428609), new Color(0x58AE0F),
                            new Color(0x72D51F), new Color(0xA0CE7A), new Color(0xA0CE7A), new Color(0xA0CE7A),
                            new Color(0xA0CE7A), new Color(0xA0CE7A), new Color(0xA0CE7A)));

            layeredWordCloud.setFontScalar(0, new LinearFontScalar(12, 60));
            layeredWordCloud.setFontScalar(1, new LinearFontScalar(14, 80));

1677815320785

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions