SoFunction
Updated on 2024-10-29

Python Chinese participle tool of stuttering participle usage example summary [classic case

This article example tells the Python Chinese participle tool of stuttering participle usage. Shared for your reference, as follows:

Installation and basic usage of the Stuttering Segmentation Tool, the previous article, "ThePython stuttering Chinese participle tool used in the process of problems and solutionsIt has already been described in the book. What we are going to talk about here is closer to the actual application - reading Chinese information from the text and utilizing the Stuttering Segmentation Tool for segmentation and lexical annotation.

The sample code is as follows:

#coding=utf-8
import jieba
import  as pseg
import time
t1=()
f=open("t_with_splitter.txt","r") #Read the text
string=().decode("utf-8")
words = (string) # Make a split word
result="" # Variables to record final results
for w in words:
   result+= str()+"/"+str() # Add lexical notation
f=open("t_with_POS_tag.txt","w") # Save the results to another document
(result)
()
t2=()
print("Segmentation and lexical labeling complete, time consumed:"+str(t2-t1)+"Seconds.") # Feedback results

Where the t_with_splitter.txt file has the following contents:

I am a professional website building resource in the country、Scripting Programming Learning Sites,furnishasp、php、、javascript、jquery、vbscript、dosbatch file、web authoring、network programming、Programming materials such as website construction。

The Python 2.7.9 platform runs as shown belowfalse

A check of the relevant information shows that it needs to be added at the beginning:

import sys
reload(sys)
( "utf-8" )

final codeShould be:

#coding=utf-8
import jieba
import  as pseg
import time
import sys
reload(sys)
( "utf-8" )
t1=()
f=open("t_with_splitter.txt","r") #Read the text
string=().decode("utf-8")
words = (string) # Make a split word
result="" # Variables to record final results
for w in words:
   result+= str()+"/"+str() # Add lexical notation
f=open("t_with_POS_tag.txt","w") # Save the results to another document
(result)
()
t2=()
print("Segmentation and lexical labeling complete, time consumed:"+str(t2-t1)+"Seconds.") # Feedback results

The run was successful:

Editplus opens the t_with_POS_tag.txt file as shown below:

More about Python related content can be viewed on this site's topic: theSummary of Python dictionary manipulation techniques》、《Summary of Python string manipulation techniques》、《Summary of common Python traversal techniques》、《Python Data Structures and Algorithms Tutorial》、《Summary of Python function usage tipsand thePython introductory and advanced classic tutorials

I hope that what I have said in this article will help you in Python programming.