Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chinese word can't be supported #73

Open
bestchenwu opened this issue Nov 20, 2018 · 2 comments
Open

chinese word can't be supported #73

bestchenwu opened this issue Nov 20, 2018 · 2 comments

Comments

@bestchenwu
Copy link

I want to make a chinese word cloud,and the code is

public class ChineseAnalyzeTask {

public static void main(String[] args) throws IOException{
	final FrequencyAnalyzer frequencyAnalyzer = new FrequencyAnalyzer();
	frequencyAnalyzer.setWordFrequenciesToReturn(600);
	frequencyAnalyzer.setMinWordLength(2);
	frequencyAnalyzer.setWordTokenizer(new ChineseWordTokenizer());

	final List<WordFrequency> wordFrequencies = frequencyAnalyzer.load("D:\\test.txt");
	final Dimension dimension = new Dimension(600, 600);
	final WordCloud wordCloud = new WordCloud(dimension, CollisionMode.PIXEL_PERFECT);
	wordCloud.setPadding(2);
	wordCloud.setBackgroundColor(new Color(0x000000FF, true));
	wordCloud.setBackground(new CircleBackground(300));
	wordCloud.setColorPalette(new ColorPalette(new Color(0xD5CFFA), new Color(0xBBB1FA), new Color(0x9A8CF5), new Color(0x806EF5)));
	wordCloud.setFontScalar(new SqrtFontScalar(12, 45));
	wordCloud.build(wordFrequencies);
	//Font font = new java.awt.Font("STSong-Light", 2, 20);
	//wordCloud.setKumoFont(new KumoFont(font));
	wordCloud.setKumoFont(new KumoFont("simsun",FontWeight.PLAIN));
	wordCloud.writeToFile("D:\\kumo\\output\\chinese_language_circle.png");
}

}

When I run the program,The result is the underlying picture--chinese_language_circle.png

And I am sure,I have moved simsun.ttf to /jre/lib/fonts directory,like this:

@kennycason
Copy link
Owner

@bestchenwu could you upload the font file?

@csmake
Copy link

csmake commented Sep 8, 2019

       final FrequencyAnalyzer frequencyAnalyzer = new FrequencyAnalyzer();
        frequencyAnalyzer.setWordFrequenciesToReturn(600);
        frequencyAnalyzer.setMinWordLength(2);
        frequencyAnalyzer.setWordTokenizer(new ChineseWordTokenizer());

        final List<WordFrequency> wordFrequencies = frequencyAnalyzer.load("词频汇总.txt");
        final Dimension dimension = new Dimension(600, 600);
        final WordCloud wordCloud = new WordCloud(dimension, CollisionMode.PIXEL_PERFECT);
        wordCloud.setPadding(2);
            KumoFont kumoFont = new KumoFont("simsun",FontWeight.PLAIN);
            wordCloud.setKumoFont(kumoFont);
        wordCloud.setBackground(new CircleBackground(300));
        wordCloud.setColorPalette(new ColorPalette(new Color(0xD5CFFA), new Color(0xBBB1FA), new Color(0x9A8CF5), new Color(0x806EF5)));
        wordCloud.setFontScalar(new SqrtFontScalar(12, 45));
        wordCloud.build(wordFrequencies);
        wordCloud.writeToFile("chinese_language_circle.png");

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants