JAVA Faux MS Word Count

Source: Internet
Author: User

TODO Caihao 2016-11-06 Word Count tool class
/**
* Count words, refer to MS Office Word 2007 rules
* @param Context text content
* @return Words
*/
public int Getmswordscount (String context) {
int words_count = 0;
Chinese words
String cn_words = Context.replaceall ("[^] (\\u4e00-\\u9fa5,. 《》? ;’‘:“”【】、)(...... ¥!)] "," ");
int cn_words_count = Cn_words.length ();
Non-Chinese words
String non_cn_words = Context.replaceall ("[^ (a-za-z0-9 ' \\-=\ ';.,/[email protected]#$%^&* () _+|} {\ ": ><?\\[\\])]", "" ");
int non_cn_words_count = 0;
string[] ss = Non_cn_words.split ("");
for (String s:ss) {
if (S.trim (). Length ()!=0) non_cn_words_count++;
}
Total Chinese and non-Chinese words
Words_count = Cn_words_count + non_cn_words_count;
return words_count;
}

public static void Main (string[] args) {

String context=
  "Shangan the tone, obediently nodded, clutching his generous hand, closed his eyes." Half a ring, she opened her eyes, bitter face, "I can't sleep." "Su Jingchen did not answer, she brewing a bit," said again, "you accompany me to chat for a while." ” “......” "How have we been together?" "For this, Shangan seems to be in high spirits. "Did you forget to mention anything else?" "His eyes shining to her eyes, Shangan clearly caught his flashing taking middle, is it because of her?" She bites the lip of the innocent bite, "Su Jingchen, if I really love you, I will remember." "Because the saddest thing in the world is to forget the one that I love the most." Su Jingchen Silent half rang, in the end is nothing said, and patted her back, "very late, sleep it." "Shangan is really tired, the outside of the Thunder seems to whisper a lot, or is beside him in, let her ease down, and soon to sleep up." Shangan woke up, Chumucho is no longer in the room, the outside also sunny days, and last night scary appearance diametrically opposite. Stay at home for a few days, every day to hold the computer in the Internet search messages, Shangan also probably keep up with the current network technology and 21st century people's thinking. These days, she has been able to contact all the people have been contacted, are envious of the said, thanks to her years of stalker, only to catch up with Su Jingchen this fine husband. And she was unaware of her amnesia. Mount Kachi "The entrance door heard, Shangan detective Neck of the look, thought is Su Jingchen back," back? "Oh, do you think it's Jing back?" "The gate, into a strange woman, dressed in a purple cheongsam, the white shawl covered her shoulders, dressed in the delicate face of the slightest look at the traces of the years, a long hair was set up." Followed by a young woman, Shangan don't know two people, "who are you?" Why is there a key to my house? "Presumptuous!" "The woman face Dew dangerous, for her inquiry extremely dissatisfied," I am Jing's mother, why can't be here? "Shangan by her low drink frightened a jump, back a few steps, accidentally hit the edge of the sofa, fell on the sofa." Wu Junmei Cold Hum a sound, also followed sat down, "seems really like Jing said, amnesia." "You ..." Shangan swallowed, "What do you want?" Now he is not at home, looking for his words ... " "No, I just came to see you." "Find me?" Shangan again to hide, a pair of afraid of Wu Junmei appearance. Her little act fell into the eyes of Wu Junmei, and she was distracted, "cringe-shrinking, can hold what scene." "Shangan mou color a dark, sip lip not language." "Come today, I have only one thing." "Wu Junmei elegant look at their own description of the delicate nails, a smile," give you 1 million, with my son divorce, anyway you do not remember anything, gave you money hurriedly take money to leave my son. For your kind of humble origins.Micro woman, stalker to follow my son, can not know what your mind? "I ..." Shangan opened his mouth and was about to say something to refute, Wu Junmei interrupted her again. "You have nothing to say!" "Wu Junmei Crisp out a cheque, the above has been filled with numbers," before, is to see you have and Jing married, now, you also do not remember anything, nature does not need to continue in our Sue home free white live it. "The Wu Junmei's sarcastic voice to her ear, let her angry liver all stirred together and grabbed the pain." "This lady!" She stood up, the slender hand posseses the cheque, glanced at it, tore it to pieces and scattered it, "you said you are Su Jingchen's mother, I respect you, but, please respect me, I am amnesia, but I am not retarded!" "You ..." Wu Junmei did not expect Shangan will suddenly refute her, gas stare big eyes, slender fingers pointing at her, shaking the flower branch, it seems that the gas is not light. "I am my my, what am I?" "Shangan directly to her turned a look, knocked off the finger in her hand," first This is my home, even if you are an elder, please do not come up on the judge, I and Su Jingchen in the end how do not need your finger-pointing, and ... " "Mom, you have to stop, you do these things if you let your brother know that will be unhappy." A girl who had been silent interrupted her words and pulled Wu Junmei's hand to persuade him. Mount Kachi "Entrance door heard, attracted everyone's eyebrows, saw Su Jingchen holding briefcase is in the porch change shoes, looked up, see Shangan a face of rage, Wu Junmei is also so." "Shangan, what's the matter?" He wrinkled his brow. Shangan cold hum a sound, directly turned on the floor, heavy door fell, issued ' bang ' a loud bang, shaking the room for a long time are still maneuver. "What have you done?" Su Jingchen casually put the jacket on the edge of the sofa, face gloomy, the tone as usual, but let people back hair cool. Wu Junmei was shocked by his frightening gaze, "What do you do?" I am your mother, you this is what attitude, also, I this also for Hello, you also blame me? "Jing Yan brother, you also do not get angry, this thing is mother did overboard, but ..." Su Jingchen looked at the direction of the upstairs, just Shangan the appearance like engraved in his heart. The icy sight swept away and let her shut her mouth at once. "Yiu Qing, you don't have to meddle, I just know, what did she do to her?" "The woman who was called Yiu Qing the forehead sweating, looked at him, and looked at the Wu Junmei, this only to the confession," mother took ... Took 1 million to let ... Shangan divorced you. At the end of the day, Yiu Qing's voice grew smaller, until at last almost completely inaudible. Su Jingchen Corner of the mouth of a mocking laugh, "My business, when you need to intervene?" "I'm your mother!" "Wu Junmei the foot of the air," snapped the word. "Miss Wu, please.In today's matter, if there is another next time, do not blame me for not mercy face! "He directly ignored her words in the ' mother ' two words, directly under the zhukeling, words with profound meaning, let a person feared." "
;

Test () test = new Test ();

int words_count = Test.getmswordscount (context);

System.out.println ("Word count =" +words_count);

}

JAVA Faux MS Word Count

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.