Used to use C + + to Chinese word segmentation, also used python "stuttering" participle, recently used a Java ANSJ Chinese participle, feel good.
Here is a simple example of using ANSJ to Chinese word segmentation, hoping to be useful to everyone.
1. Download the relevant jar package for ANSJ
To use ANSJ for Chinese word segmentation, you must first download the ANSJ jar package, you can refer to:https://github.com/NLPchina/ansj_seg
2. Program Code
The simple code for Chinese word segmentation with ANSJ is as follows:
Import Org.ansj.splitword.analysis.toanalysis;public class Splitwordsbyansj {public static void main (string[] args) { String words = "China is one of the four ancient civilizations of the world, has a long history, about 5,000 years ago, the central Plains as the center began to appear in the settlement organization and then into the country and dynasties, after many years of evolution and Dynasty change, long duration of the dynasty has Xia, Shang, Zhou, Han, Jin, Tang, song, Yuan, Ming , Qing and so on. In the history of the Zhongyuan dynasty, the nomadic peoples of the North continued to engage and conquer, and many nationalities became Chinese. After the Xinhai Revolution in the early 20th century, China's monarchy withdrew from the historical stage and replaced it with a Republican polity. After the founding of the People's Republic of China in 1949, the Government of the NPC was established. China has a colorful folk culture, traditional art forms have poetry, drama, calligraphy and traditional Chinese painting, such as Spring Festival, Yuanxiao, Qingming, Dragon Boat Festival, mid-Autumn Festival, Chongyang, etc. are important traditional festivals in China. "; System.out.println (Toanalysis.parse (words));}}
3. Participle results
In the example, the result of the Chinese word segmentation is as follows:
[China, is, world, four, big, civilized, ancient, country, one,,, has, long, historical,,, distance, present, about, 5000, years ago,,, to, central Plains, region, for, center, start, appearance, settlement, organization, then, into, country, and, Dynasties,,, after, after, many times, evolution, and, dynasties, Change,,, duration, time, more, long,, dynasties, there, summer,,, Shang,,, Zhou,,, Han,,, Jin,,, Tang,,, Song,,, Yuan,,, Ming,, , Central Plains, Dynasty, history, on, continuous, and, north, nomadic, ethnic, communication,,, War,,, numerous, ethnic, fusion, become, the Chinese nation,. , 20, Century, beginning, Xinhai Revolution, Post,,, China, Monarch, polity, withdrawal, history, stage,,, replaced,,,,,,, Republican, polity. , 1949, People's Republic of China, founded, after,,, in, China, mainland, established,, people, Congress, System,, polity,. , China, has, many, colorful,, folklore, culture,, tradition, art, form, have, poetry,,, drama,,, calligraphy, and, Chinese painting, etc.,,, Spring Festival,,, Lantern Festival,,, Qingming Festival,, Country, importance, tradition, festival,. ]
This example is very simple and I hope to help you.
The use of "Java" Java Chinese word breaker ANSJ