Пример #1
0
class Postag2:
	def __init__(self,modelSegment,modelPos,sentence=None):
		self.modelPos = modelPos
		if sentence != None:
			self.segment = Segment(modelFile=modelSegment,sentence=sentence)
		else:
			self.segment = Segment(modelFile=modelSegment)

	def setSentence(self,sentence):
		self.segment.setSentence(sentence)

	def __preProcess(self,tagger):
		self.segmentSentence = self.segment.getSequence()
		print(self.segmentSentence)

		for tokens in self.segmentSentence.split():
			tagger.add(tokens + " " +tokens[len(tokens)-1])

	def getResult(self):
		tagger = CRFPP.Tagger("-m "+str(self.modelPos))
		tagger.clear()
		self.__preProcess(tagger)
		tagger.parse()

		result=""
		for i in range(tagger.size()):
			result += tagger.x(i,0)+tagger.y2(i)+"   "

		return result
Пример #2
0
	def __init__(self,modelSegment,modelPos,sentence=None):
		self.modelPos = modelPos
		if sentence != None:
			self.segment = Segment(modelFile=modelSegment,sentence=sentence)
		else:
			self.segment = Segment(modelFile=modelSegment)