package com.sabirjan.DrawUyghurWord;

import java.sql.Struct;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Vector;


public class MyStringTokenizer{
	

	   private String uyghurchars = "\u0627\ufe8d\ufe8e\u06D5\u0628\u067E\u062A\u062C\u0686\u062E\u062F\u0631\u0632\u0698\u0633\u0634\u063A\u0641\u0642\u0643\u06AF\u06AD\u0644\u0645\u0646\u06BE\u0648\u06C7\u06C6\u06C8\u06CB\u06D0\u0649\u064A\u0626";
	 private boolean isUyghurWord(char word)
	 {

			if(uyghurchars.indexOf(word)>0)
			{
				return true;
			}
		return false;
	}
	 public String[] GetSplitWord2(String sword)
     {
	
		 StringBuffer sb = new StringBuffer();
         StringBuffer sbtmp = new StringBuffer();
         char[] c = sword.toCharArray();
         for (int i = 0; i <c.length; i++)
         {
             if (c[i]==' ')
             {
                 sbtmp.append(" ");
                 continue;
             }
             if(c[i]=='،')
             {
            	  sbtmp.append(" , ");
                  continue;
             }
             if(c[i]=='ـ')
             {
            	 sbtmp.append("-");
                 continue;
             }
             if(c[i]=='؟')
             {
            	  sbtmp.append(" ? ");
                  continue;
             }
             
             if (c[i]=='ا')
             {
                 sbtmp.append(c[i]);
                     continue;
             }

             if (isUyghurWord(c[i]))
             {
                 sbtmp.append(c[i]);
                 continue;
             }
             else
             {
                 sb.append(sbtmp.toString()+" ");
                 sbtmp = new StringBuffer();
                 for (int j = i; j < c.length; j++)
                 {
                	 
                	 
                     i = j;
                     if (!isUyghurWord(c[i]))
                     {
                    	 if(c[i]=='ـ')
                         {
                        	 sbtmp.append("-");
                             continue;
                         }
                    	 if(c[i]=='،')
                         {
                        	  sbtmp.append(" , ");
                              continue;
                         }
                    	 if(c[i]=='؟')
                         {
                        	  sbtmp.append(" ? ");
                              continue;
                         }
                         sbtmp.append(c[i]);
                     }
                     else
                     {
                    	
                         sb.append(sbtmp.toString()+" ");
                         sbtmp = new StringBuffer();
                         i = j - 1;
                         break;
                     }
                     
                 }
                
                
             }//End if else
             if(sbtmp.length()>0)
             {
            	 sb.append(sbtmp.toString());
            	 sbtmp = new StringBuffer();
             }
         }//End  for
         if(sbtmp.length()>0)
         {
        	 sb.append(sbtmp.toString());
         } 
         return sb.toString().split(" ");
     }

	
}
