Spire.Doc is a professional Word .NET library specifically designed for developers to create, read, write, convert and print Word document files. Get free and professional technical support for Spire.Doc for .NET, Java, Android, C++, Python.

Thu Sep 24, 2020 9:20 am

How to get paragraph word count when language is Japanese ?

majie123456
 
Posts: 6
Joined: Fri Jun 19, 2020 8:18 am

Thu Sep 24, 2020 10:15 am

Hello,

Thanks for your inquiry.
You can refer to the following code to get the count of characters in a paragraph. If there is any question, please provide your input file for our further analysis. You can send it to us (support@e-iceblue.com) via email.
Code: Select all
    Document document = new Document();
    document.LoadFromFile("test.docx");
    Paragraph para = document.Sections[0].Paragraphs[0];
    int characterCount = para.Text.Length;


Sincerely,
Rachel
E-iceblue support team
User avatar

rachel.lei
 
Posts: 1571
Joined: Tue Jul 09, 2019 2:22 am

Thu Sep 24, 2020 10:39 am

Sorry, I want to get the word count, not the character count.
Could you give me some sample code?

majie123456
 
Posts: 6
Joined: Fri Jun 19, 2020 8:18 am

Thu Sep 24, 2020 11:05 am

Hello,

Thanks for your prompt response.
Did you get a wrong result using the code I provided? Could you please provide us with your test file? Also, please tell us what the correct word count should be. Thanks in advance for your assistance.

Sincerely,
Rachel
E-iceblue support team
User avatar

rachel.lei
 
Posts: 1571
Joined: Tue Jul 09, 2019 2:22 am

Thu Sep 24, 2020 11:18 am

Thanks for your reply!
I'm using the spire to get the count of word in a paragraph with different language, and the "paragraph.getWordCount()" seem only useful to English.
I want to know how to set the language when loading file.

majie123456
 
Posts: 6
Joined: Fri Jun 19, 2020 8:18 am

Fri Sep 25, 2020 6:26 am

Hello,

Thank you for your further clarification.
I did notice that using "paragraph.getWordCount()" doesn't get the correct word count when the text in the paragraph is in Japanese. This issue has been logged in our bug tracking system with the ticket SPIREDOC-5001. If there is any update, we will let you know. Also, to ensure that the fix of the issue can work perfectly for your file in the future, please share your file with us if possible.
Moreover, for Japanese, a character is a word, so if the text in a paragraph is all in Japanese, you can refer to the code I provided earlier to get the word count.

Sincerely,
Rachel
E-iceblue support team
User avatar

rachel.lei
 
Posts: 1571
Joined: Tue Jul 09, 2019 2:22 am

Return to Spire.Doc