# coding: utf8

from __future__ import unicode_literals
from nltk.tag import stanford


class POSTagger(stanford.POSTagger):
	def __init__(self, *args, **kwargs):
		kwargs['encoding'] = 'utf8'
		if 'path_to_model' not in kwargs:
			kwargs['path_to_model'] = 'resources/persian.tagger'
		if 'path_to_jar' not in kwargs:
			kwargs['path_to_jar'] = 'resources/stanford-postagger.jar'

		self._SEPARATOR = '/'
		super(stanford.POSTagger, self).__init__(*args, **kwargs)

	def tag_sents(self, sentences):
		"""
		>>> tagger.tag(['من', 'به', 'مدرسه', 'رفته بودم', '.'])
		[('من', 'PR'), ('به', 'PREP'), ('مدرسه', 'N'), ('رفته بودم', 'V'), ('.', 'PUNC')]
		"""

		replace_spaces = lambda sentence: [word.replace(' ', '_') for word in sentence]
		return super(stanford.POSTagger, self).tag_sents(map(replace_spaces, sentences))

@@ -656,31 +656,28 @@
 %09%09re
-place_spaces = 
+fined = map(
 lambda s
 ente
@@ -676,22 +676,12 @@
 da s
-entence
 : %5Bw
-ord
 .rep
@@ -704,14 +704,15 @@
 or w
-ord
  in
+ s%5D,
  sen
@@ -720,18 +720,21 @@
 ence
-%5D%0A%09%09return
+s)%0A%09%09tagged =
  sup
@@ -776,36 +776,92 @@
 nts(
-map(replace_spaces, sentences
+refined)%0A%09%09return list(map(lambda s: %5B(w.replace('_', ' '), t) for w, t in s%5D, tagged
 ))%0A

fix tagger issue