Customizable word base--yaha (dumb) participle

Source: Internet
Author: User

Customizable word base--yaha (dumb) participle
Online test Address: http://yaha.v-find.com/deployed in Gae yahademo.appspot.com
Yaha participle is the main feature of the word segmentation process is divided into 4 stages, each stage can allow users to join their own some customization, in order to face different user needs.

This is one of the simplest examples of true white:
#-*-Coding=utf-8-*-
Import SYS, RE
From Yaha import Cuttor, regexcutting, SurnameCutting2, suffixcutting

str = ' Tangcheng really tang Cheng Niu Longevity Township is a 1998love Tang Cheng Nowitzki '
Cuttor = Cuttor ()

# Get 3 Shortest paths for choise_best
#cuttor. SET_TOPK (3)

# Use Stage 1 to cut 中文版 and number
Cuttor.set_stage1_regex (Re.compile (' (\d+) | ( [a-za-z]+) ', Re. I|re. U))

# Or use Stage 2 to cut 中文版 and number
#cuttor. Add_stage (regexcutting (re.compile (' \d+ '), re. I|re. U)))
#cuttor. Add_stage (regexcutting (Re.compile (' [a-za-z]+ ', Re. I|re. U)))

# Use Stage 3 to cut Chinese name
#surname = surnamecutting ()
#cuttor. Add_stage (surname)

# Or use stage 4 to cut Chinese name
#surname = SurnameCutting2 ()
#cuttor. Add_stage (surname)

# Use Stage 4 to cut Chinese address or 中文版 name
#suffix = suffixcutting ()
#cuttor. Add_stage (suffix)

Seglist = Cuttor.cut (str)
print ', '. Join (list (seglist))

#seglist = CUTTOR.CUT_TOPK (str, 3)
#for seg in Seglist:
# print ', '. Join (SEG)
Stage explanation
Stage 1 is implemented in the clause, through regular can be directly divided into separate words of numbers or English words, generated independent of these words no longer participate in the next word.
Stage 2 is implemented before creating a direction-free graph, pre-scanning clauses, adding some possible words, and giving a certain probability.
Stage 3 is implemented during the creation of a forward loop-free graph, the probability of getting a word from a dictionary, or the possibility of getting a word by some matching pattern, giving a certain probability.
Stage 4 after the maximum probability of the direction-free graph (the shortest path in the program implementation), some words can not be the word to continue processing;
Or get the shortest number of paths, based on the user's interest to get a final path. If the user is interested, can be in this step to achieve the analysis of the part of speech.

Customizable word base--yaha (dumb) participle

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.