title: using regex to substitute the half space in two Persian strings in a list?
body: <p>The data I am working on is as follows:
  (AJ_SIM فتنه برانگیز) ) ) ) ) (MV (ADJ (AJ_SIM روشن) ) (V (V_PRES_POS_3 می گردد) ) ) ) ) ) ) ) 
  There are some Persian words which were separated by space and when I split the contents of each file, they are considered as separate strings. I have to find each two Persian strings which are after the previous one like "  برانگیز"، "فنته" and replace that space with a half-space. But they must be in the same list with their tags. I mean the only change I have to do is to find these kinds of strings and join them with half space and save them with the previous strings in a list with the same order. 
  Here is my code:</p>
  
  <pre><code>import os
  import codecs
  import re
  
  
  
  ###opening the files from a folder in a directory
  matches=[]
  for root, dirs, files in os.walk("C:\\Test2"):
      for file in files:
          if file.endswith(".pts"):
              matches.append(os.path.join(root, file))
  print(matches)
  print(len(matches))
  
  ###reading files 
  for i, f in enumerate(matches):
      with codecs.open(f, "r", "utf-8") as fp:
          text=fp.read().split()
          #print(text)
          #print (len(text))
          print(type(text))
  
   ###substituting space with half-space       
          original_pattern= r'\b(\w)\s(\w)'
          new_pattern= '\\1\u200c\\2'
          list_words=[]
          for a in text:
              words= re.sub(original_pattern, new_pattern, a)
              list_words.append(words)
              #print(type(a))
              print(list_words)
  </code></pre>
  
  <p>Here is a sample of splitted text of each file:
  ['(ROOT', '(S', '(VP', '(VPS', '(NP', '(NP', '(N_EZ', '(N_PL_COM_EZ_LOC', 'کشورهای)', ')', '(ADJ', '(AJ_SIM', 'درحال', 'توسعه)', ')', ')', '(Punc', '(PUNC', '،)', ')', ')', '(VP', '(NP', '(N_YA', '(N_YA_SING_COM', 'زمانی)', ')', '(nid', '1)', ')', '(VP', '(PP', '(PREP', '(P', 'به)', ')', '(N', '(N_SING_COM', 'استقلال)', ')', ')', '(MV', '(N', '(N_SING_COM', 'دست)', ')', '(V', '(V_SIM_POS_PA_6', 'یافتند)', ')', ')', ')', ')', ')', '(CL_1', '(Conj', '(CONJ', 'که)', ')', '(VPSD', '(VP', '(ADV', '(ADV_SIM_GENR', 'مآلاً)', ')', '(VP', '(PP', '(PP', '(PREP', '(P', 'از)', ')', '(NP', '(N_EZ', '(N_SING_COM_EZ', 'سنت)', ')', '(NP', '(NP_C', '(N', '(N_PL_COM', 'علوم)', ')', '(N_C', '(Conj', '(CONJ', 'و)', ')', '(N_YA', '(N_YA_SING_COM', 'تکنولوژی', 'ای)', ')', ')', ')', '(CL', '(Conj', '(CONJ', 'که)', ')', '(VPSD', '(VP', '(AUX', '(V_NIN_POS_AUX', 'بتوان)', ')', '(VP', '(NP', '(PRON', '(PRO_DEMO_SING', 'آن)', ')', '(PostP', '(POSTP', 'را)', ')', ')', '(VP', '(ADJ', '(AJ_SIM', 'مدرن)', ')', '(MV', '(N', '(N_SING_COM', 'تلقی)', ')', '(V', '(V_SIM_POS_PA_3', 'نمود)', ')', ')', ')', ')', ')', ')', ')', ')', ')', ')', '(Punc', '(PUNC', '،)', ')', ')', '(VP', '(ADJ', '(AJ_SIM', 'برخوردار)', ')', '(V', '(V_COP_NEG_PA_6', 'نبودند)', ')', ')', ')', ')', ')', ')', ')', '(Punc', '(PUNC', '.)', ')', ')', ')']</p>
  
  <p>The only change I expect is that the strings which are like 'درحال', 'توسعه)' after each other to be joined together with a half space. </p>