Tajiks Worldwide Community: Tajik to Persian catalysis - Tajiks Worldwide Community

Jump to content

Toggle shoutbox Shoutbox

parwana Icon : (30 April 2014 - 05:21 PM) Posted Image
Parsistani Icon : (22 July 2013 - 04:02 AM) good morning :)
Gul agha Icon : (03 May 2013 - 04:29 PM) Sohrab, Tajikam doesn't only consist of a forum. We have two major sections in this website. One is in Persian which is updated frequently and the other is in Persian (Cyrillic). Additionally, the English page is still running and has a vast amount of information on Tajiks and Persians.
Gul agha Icon : (03 May 2013 - 04:27 PM) http://www.facebook.com/Tajikamsite
Sohrab Icon : (01 May 2013 - 06:31 AM) Tajikam on facebook?
SHA DOKHT Icon : (01 May 2013 - 12:12 AM) Like our page on Facebook: https://www.facebook...541604162529143
Sohrab Icon : (29 March 2013 - 08:31 AM) H again, I thought the site would be closed, but it's still running.
Gabaro_glt Icon : (26 March 2013 - 10:17 AM) Tajikistan was inhabited by the races of Cyrus the great (Sultan skindar Zulqarnain). The achmaniend dynasty ruled the entire region for several thousnd years.Cyrus the great's son cymbasis(Combchia)with forces migrated to Balkh ancient Bactaria or Bakhtar. Sultan Sumus the desecndant of Cyrus the great faught war against Alaxander of Macdonia in Bakhtar current tajikistan.
this ruling class was inhabited in the areas, like Balkh,fargana,alai,Tajikistan,badakhshan,Kabul,Takhar,Tashkorogan,Khutan,kashkar,Swat,Kashmir,Peshawar, hashtnager,Dir, Bajour,Gilgit,for serveral thaousand years.
Gabaro_glt Icon : (26 March 2013 - 10:16 AM) hellow
Gabaro_glt Icon : (26 March 2013 - 10:00 AM) Tajikistan was inhabited by the races of Cyrus the great (Sultan skindar Zulqarnain). The achmaniend dynasty ruled the entire region for several thousnd years.Cyrus the great's son cymbasis(Combchia)with forces migrated to Balkh ancient Bactaria or Bakhtar. Sultan Sumus the desecndant of Cyrus the great faught war against Alaxander of Macdonia in Bakhtar current tajikistan.
this ruling class was inhabited in the areas, like Balkh,fargana,alai,Tajikistan,badakhshan,Kabul,Takhar,Tashkorogan,Khutan,kashkar,Swat,Kashmir,Peshawar, hashtnager,Dir, Bajour,Gilgit,for serveral thaousand years.
Gabaro_glt Icon : (26 March 2013 - 09:46 AM) hellow
Gabaro_glt Icon : (25 March 2013 - 10:48 AM) Asssssssssalam o Alaikum
Gabaro_glt Icon : (22 March 2013 - 05:22 AM) I would like to here something from a tajik brother/sister living in Tajikstan
Gabaro_glt Icon : (22 March 2013 - 05:20 AM) I have traced my ancestors migrated from Panj and Balkh ancient
Gabaro_glt Icon : (22 March 2013 - 05:19 AM) I am desendant of Sultan behram Gabari Tajik living in GilGit pakistan
Gabaro_glt Icon : (22 March 2013 - 05:17 AM) Salam to all brothers
Parsistani Icon : (01 June 2012 - 10:48 AM) we are on facebook. Tajikam on facebook
Parsistani Icon : (01 June 2012 - 10:47 AM) salam guys.
Azim-khan Icon : (19 May 2012 - 11:19 AM) salom bachaho )
Bilal Tajik Icon : (27 January 2012 - 01:17 PM) Can anybody guide me around
Resize Shouts Area

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Tajik to Persian catalysis Rate Topic: -----

#1 User is offline   cnevis Icon

  • Newbie
  • Pip
Group:
Members
Posts:
2
Joined:
27-January 12

Posted 28 January 2012 - 02:19 PM

/**this program is written by Houman Javidpour under GPL3 License
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
import javax.swing.*;
import javax.swing.border.LineBorder;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.security.PublicKey;
import java.util.Scanner;


/**
* Created by IntelliJ IDEA.
* User: houman
* Date: 1/12/12
* Time: 11:34 PM
* To change this template use File | Settings | File Templates.
*/
public class Testrgs {
    //public static Character tempCharNext;
    //public static Character tempCharBefor;
    //public static Character tempCharTowNext;
    public static JTextArea tajik ;//tajik JTextArea
    public static JTextArea persian;//Persian JTextArea
    public static StringBuilder cash;
    public static boolean checkBox1Status =true;
    public static boolean checkBox2Status =false;
    public static boolean checkBox3Status =false;
    public static boolean checkBox4Status =false;
    public static void main(String[] args) throws FileNotFoundException {
        //Scanner input = new Scanner(new File(args[0]));
        //StringBuilder cash = new StringBuilder();
        //PrintWriter file = new PrintWriter(args[0]+"persian"+".txt");//output file
        //tajikToPersian(input,cash,file);
        mainWindow();
         }
            public static void tajikToPersian(Scanner input , StringBuilder cash , PrintWriter file ){
                    Character tempCharNext;
                    Character tempCharBefor;
                    Character tempCharTowNext;
                while(input.hasNextLine()){
            String data = input.nextLine();
            cash.setLength(0);//reset cash
            for (int i=0; data.length()>i;i++){
                char ch =data.charAt(i);//en:return charachter at the specefic index
                if (ch == '\u0411' | ch == '\u0431'){
                    cash.append('ب');
                }
                else if (ch == 'Ҷ' | ch == 'ҷ'){
                    cash.append('ج');
                }
                else if (ch == 'Ч' | ch == 'ч'){
                    cash.append('چ');
                }
                else if (ch == 'Д' | ch == 'д'){
                    cash.append('د');
                }
                 else if (ch == 'Ф' | ch == 'ф'){
                    cash.append('ف');
                }
                 else if (ch == 'Г' | ch == 'г'){
                    cash.append('گ');
                }
                 else if (ch == 'Ж' | ch == 'ж'){
                    cash.append('ژ');
                }
                 else if (ch == 'К' | ch == 'к'){
                    cash.append('ک');
                }
                 else if (ch == 'Л' | ch == 'л'){
                    cash.append('ل');
                }
                 else if (ch == 'М' | ch == 'м'){
                    cash.append('م');
                }
                 else if (ch == 'Н' | ch == 'н'){
                    cash.append('ن');
                }
                 else if (ch == 'П' | ch == 'п'){
                    cash.append('پ');
                }
                 else if (ch == 'Ғ' | ch == 'ғ'){
                    cash.append('غ');
                }
                 else if (ch == 'Р' | ch == 'р'){
                    cash.append('ر');
                }
                 else if (ch == 'С' | ch == 'с'){
                    cash.append('س');
                }
                 else if (ch == 'Ш' | ch == 'ш'){
                    cash.append('ش');
                }
                 else if (ch == 'Т' | ch == 'т'){
                    cash.append('ت');
                }
                 else if (ch == 'В' | ch == 'в'){
                    cash.append('و');
                }
                 else if (ch == 'Ъ' | ch == 'ъ'){
                    cash.append('ع');
                }
                 else if (ch == 'Х' | ch == 'х'){
                    cash.append('خ');
                }
                 else if (ch == 'Ҳ' | ch == 'ҳ'){
                    cash.append('ه');
                }
                 else if (ch == 'Й' | ch == 'й'){
                    cash.append('ی');
                }
                 else if (ch == 'З' | ch == 'з'){
                    cash.append('ز');
                }
                 else if (ch == 'Қ' | ch == 'қ'){
                    cash.append('ق');

                }
                ///////////////////////////////////////////////////////////
                 else if (ch == 'Я' | ch == 'я'){

                    //baraye jologiri az tavaghofe barname agar belafasele baad az я enter zadeh shode bashad.
                    //dar inja baraye ma payane khad ba space yek maana ra midahad.
                    try{
                     tempCharNext = new Character(data.charAt(i+1));
                    }
                    catch (java.lang.StringIndexOutOfBoundsException exception){
                        tempCharNext = ' ';
                    }
                    if (Character.isWhitespace(tempCharNext)){
                        //fa:tabdil shavad be یه
                       cash.append('ی');
                       cash.append('ه');
                       continue;
                    }
                    //dar baghiyeh mavared
                    cash.append('ی');
                }
                 else if (ch == 'Ё' | ch == 'ё'){
                    cash.append('ی');
                    cash.append('ا');
                }
                //in try catch ha baraye halati hastand ke masalan kalame avale file hastesh va tempCharBefor mishe hichi
                //ya vaghti ke harfe ma akhare file va tempCharNext mishe charachter entehaye file.
                 else if (ch == 'А'){
                    try{
                    tempCharBefor = new Character(data.charAt(i-1));
                    }
                    catch (java.lang.StringIndexOutOfBoundsException exception){
                       tempCharBefor = ' ';
                    }
                    try{
                    tempCharNext = new Character(data.charAt(i+1));
                    }
                    catch (java.lang.StringIndexOutOfBoundsException exception){
                       tempCharNext = ' ';
                    }
                     if(Character.isWhitespace(tempCharBefor) & Character.isLetter(tempCharNext) ){
                        if(checkBox1Status){
                            cash.append("اَ");
                        }
                         else {
                       cash.append('ا');
                       cash.append('(');
                       cash.append('ع');
                       cash.append('َ');
                       cash.append(')');
                        }
                     }

                }
                else if (ch == 'а'){

                    try{
                    tempCharBefor = new Character(data.charAt(i-1));
                    }
                    catch (java.lang.StringIndexOutOfBoundsException exception){
                       tempCharBefor = ' ';
                    }
                    //fa:agar ghablesh yek whitespace bod yani harfe avale kalamast pas "ا" bezar ya عَ
                    if (Character.isWhitespace(tempCharBefor)){
                        if(checkBox1Status){
                            cash.append("اَ");
                        }
                         else {
                       cash.append('ا');
                       cash.append('(');
                       cash.append('ع');
                       cash.append('َ');
                       cash.append(')');
                        }
                        continue;
                    }
                    // baraye piyadesaziye mavaredi mesle кардааст ke mishanad کرده است
                    if(tempCharBefor == 'а'){
                       cash.append('ا');
                        continue;
                    }
                    //fa:agar akhar e kalame bod be tabdil he"ه" beshe mesle talafoze tajiki hamle(mavad) ke mishe hamla
                    //dar akhare kalamat gahan az camma ya sayer neshaneha estefade mishad ke an ham lahaz shode ba
                    //estefadeh az
                    //bejoz vaghti ke harfe maghable akhar و bashad (ke inja manzor moadele harfe в tajiki ast)
                    // dar mavagheyi ke harfe maghable akhar bashad va ghabl az an "о" biyayad mishavad ئه ke
                    //piyadeh sazi shodeh

                    try{
                    tempCharNext = new Character(data.charAt(i+1));
                    }
                    catch (java.lang.StringIndexOutOfBoundsException exception){
                       tempCharNext = ' ';
                    }
                     if((tempCharBefor == 'о') & Character.isWhitespace(tempCharNext) ){
                        cash.append('ئ');
                        cash.append("ه");
                         continue;
                     }
                     if ((Character.isWhitespace(tempCharNext) | !(Character.isLetter(tempCharNext))) & !( (tempCharBefor =='В' ) | (tempCharBefor =='в' ) ) ){
                       cash.append('ه');//fa:agar ghablesh yek whitespace bod yani harfe avale kalamast pas "ا" bezar
                        continue;
                    }
                    // baraye piyadesaziye mavaredi mesle кардааст ke mishanad کرده است
                    if(tempCharNext == 'а'){
                       cash.append('ه');
                       cash.append(' ');
                        continue;
                    }
                    cash.append('َ');
                }
                 // agar avale kalame bashd mishavad ا ya عِ
                 // fa: morede khas ke "Ин" moaadele "این" dar farsi mishad lahaz shode
                 else if (ch == 'И'){

                    try{
                    tempCharNext = new Character(data.charAt(i+1));
                    }
                    catch (java.lang.StringIndexOutOfBoundsException exception){
                       tempCharNext = ' ';
                    }
                    try{
                    tempCharBefor = new Character(data.charAt(i-1));
                    }
                    catch (java.lang.StringIndexOutOfBoundsException exception){
                       tempCharBefor = ' ';
                    }
                    try{
                    tempCharTowNext = new Character(data.charAt(i+2));
                    }
                    catch (java.lang.StringIndexOutOfBoundsException exception){
                        tempCharTowNext = ' ';
                    }
                    if (Character.isWhitespace(tempCharTowNext) & (tempCharNext == 'н')){
                        cash.append('ا');
                        cash.append('ی');
                        continue;
                    }

                     if (Character.isWhitespace(tempCharBefor)){
                         if(checkBox2Status){
                             cash.append("اِ");
                         }
                         else {
                       cash.append('ا');
                       cash.append('(');
                       cash.append('ع');
                       cash.append('ِ');
                       cash.append('/');
                       cash.append('ا');
                       cash.append('ی');
                       cash.append(')');
                         }
                     }
                }
                else if (ch == 'и'){

                    try{
                    tempCharBefor = new Character(data.charAt(i-1));
                    }
                    catch (java.lang.StringIndexOutOfBoundsException exception){
                       tempCharBefor = ' ';
                    }
                    try{
                    tempCharNext = new Character(data.charAt(i+1));
                    }
                    catch (java.lang.StringIndexOutOfBoundsException exception){
                       tempCharNext = ' ';
                    }
                    try{
                    tempCharTowNext = new Character(data.charAt(i+2));
                    }
                    catch (java.lang.StringIndexOutOfBoundsException exception){
                        tempCharTowNext = ' ';
                    }
                    //fa:be dalile inke dar kalameye "ин" ke moaadele این ast harofe bozorg va kochik avale kalame
                    //ra reeayat nmikonnand in mord inja ham lahaz shode
                    if (Character.isWhitespace(tempCharTowNext) & Character.isWhitespace(tempCharBefor) & (tempCharNext == 'н')){
                        cash.append('ا');
                        cash.append('ی');
                        continue;
                    }
                    if (Character.isWhitespace(tempCharBefor)){
                         if(checkBox2Status){
                             cash.append("اِ");
                         }
                         else {
                       cash.append('ا');
                       cash.append('(');
                       cash.append('ع');
                       cash.append('ِ');
                       cash.append('/');
                       cash.append('ا');
                       cash.append('ی');
                       cash.append(')');
                         }//fa:agar ghablesh yek whitespace bod yani harfe avale kalamast pas "ا" yaعِbezar
                        continue;
                    }
                    cash.append(ch);//dar baghiyeye mavared.
                }
                //en:assume that first letter is capital
                 else if (ch == 'О'){
                    cash.append('آ');
                }
                else if (ch == 'о'){

                    try{
                    tempCharBefor = new Character(data.charAt(i-1));
                    }
                    catch (java.lang.StringIndexOutOfBoundsException exception){
                     tempCharBefor = ' ';
                    }
                    //agar harfe avale kalame bood.
                    if(Character.isWhitespace(tempCharBefor)){
                        cash.append('آ');
                        continue;
                    }
                    //dar vasate kalameh
                       cash.append('ا');
                }
                  //assume that first letter is capital
                  // fa:vaghti Ӯ  bozorg bashd avale kalame amadeh ast va 2 halat pish miayad
                  // 1) agar tanha bashad mishad او
                  // 2) agar harfe avale kalame bashd mishavad عُ ya اُ  mesle kalameye عهده ӯҳда
                  // ya kalameye ازبکستان Ӯзбакистон

                 else if (ch == 'Ӯ'){

                    try{
                    tempCharNext = new Character(data.charAt(i+1));
                    }
                    catch (java.lang.StringIndexOutOfBoundsException exception){
                       tempCharNext = ' ';
                    }
                    //dar akhare kalamat gahan az camma ya sayer neshaneha estefade mishad ke an ham lahaz shode ba
                    if ((Character.isWhitespace(tempCharNext) | !(Character.isLetter(tempCharNext))) ){
                    cash.append('ا');
                    cash.append('و');
                        continue;
                    }
                    //fa:baraye halate 2
                    if (Character.isLetter(tempCharNext) ){
                        if(checkBox4Status){
                            cash.append("اُ");
                        }
                        else{
                       cash.append('ا');
                       cash.append('(');
                       cash.append('ع');
                       cash.append('ُ');
                       cash.append(')');
                        }

                    }

                }
                //fa: dar halate 2 dar bala ke naghse عُ ya اُ ra bazi mikonad momken ast dar avale kalame be shekleke
                //kochack neveshte shavad benabarin  dar inja ham in halat piyadeh mishavad.
                //dar morede kalameye او ham ke tak harfi ast gahan bozorg bodan kalameye tak harifye Ӯ ra reaayat
                //nemikonand . be nachar dar inja ham piyadesazi shode
                else if (ch == 'ӯ'){
                    try{
                    tempCharBefor = new Character(data.charAt(i-1));
                    }
                    catch (java.lang.StringIndexOutOfBoundsException exception){
                       tempCharBefor = ' ';
                    }
                    try{
                    tempCharNext = new Character(data.charAt(i+1));
                    }
                    catch (java.lang.StringIndexOutOfBoundsException exception){
                       tempCharNext = ' ';
                    }
                    if( Character.isWhitespace(tempCharBefor) & Character.isLetter(tempCharNext) ){
                        if(checkBox4Status){
                            cash.append("اُ");
                        }
                        else {
                       cash.append('ا');
                       cash.append('(');
                       cash.append('ع');
                       cash.append('ُ');
                       cash.append(')');
                        }
                        continue;
                    }
                    if( Character.isWhitespace(tempCharBefor) & !(Character.isLetter(tempCharNext)) ){
                       cash.append('ا');
                       cash.append('و');
                        continue;
                    }
                    //agar vasate kalame biyayade va baadash "я" bashad meshavad و mesle "می‌گوید" мегӯяд
                    // ehtemalan dar barkhord e ba baazi vakehaye digar ham in sharayet pish ayad. niyaz be baresi darad
                    if(Character.isLetter(tempCharBefor) & tempCharNext == 'я'){
                       cash.append('و');
                        continue;
                    }
                    /* javab nadad
                    //fa:agar harfe baadi yeki az horofi bod ke be horofe baad az khod nemichasband و ra chap kon
                    //dar ghire in sorat mishad zame(pish) ke az neveshtan an sarfenazar mishavad.
                    String horofeNachasb = new String (" د ژ ر و ز ذ ");
                    String lastCharacterInCash = cash.substring(cash.length()-1);
                    if(horofeNachasb.lastIndexOf(lastCharacterInCash) > 0){
                       cash.append('و');
                    }
                    */
                    //agar akhare kalame bashe be و tabdil beshe mesle سو --> cӯ
                    //inja nemikhad check konim ke ghablesh yeki az horofe tajik hast ya na chone agar ghablesh harf
                    // nabashe be in if nemirese.
                    if(!(Character.isLetter(tempCharNext))){
                        cash.append('و');
                        continue;
                    }
                    //fa:dar sayere mavared
                    cash.append(ch);
                }
                //agar be tanhayi biyayad mishavd و
                //agar avale kalame biyayad mishavad اُ ya عُ mesleافتاده
                //ya mesle علوم ya عقاب  уқоб
                else if (ch == 'У' | ch == 'у'){

                    try{
                    tempCharBefor = new Character(data.charAt(i-1));
                    }
                    catch (java.lang.StringIndexOutOfBoundsException exception){
                       tempCharBefor = ' ';
                    }
                    try{
                    tempCharNext = new Character(data.charAt(i+1));
                    }
                    catch (java.lang.StringIndexOutOfBoundsException exception){
                       tempCharNext = ' ';
                    }
                    if(Character.isWhitespace(tempCharBefor) & !(Character.isLetter(tempCharNext))){
                       cash.append('و');
                       continue;
                    }
                     if(Character.isWhitespace(tempCharBefor)){
                         if(checkBox3Status){
                             cash.append("اُ");
                         }
                         else{
                       cash.append('ا');
                       cash.append('(');
                       cash.append('ع');
                       cash.append('ُ');
                       cash.append(')');
                         }
                     }
                    //dar baghiyeye mavared
                    cash.append(ch);

                }
                //fa:baraye loghati ke az roosi be tajiki amadand.
                else if (ch == 'Ю' | ch == 'ю'){
                    cash.append('ی');
                    cash.append('و');
                }

                //in other case
                else{
                    cash.append(ch);
                }


            }
             /*
             //cash.append('\n');//new line
             System.out.println(cash);
             */
            file.println(cash.toString());
        }
        file.close();//after compeleting file close it

    }
  public static  void mainWindow(){

//panjereye asli
      JFrame mainFrame = new JFrame();
      mainFrame.setSize(800,600);
      mainFrame.setLocationByPlatform(true);
      BorderLayout b1 = new BorderLayout();
      mainFrame.setLayout(b1);

      //baraye safahate tajiki va farsi kenare ham
      JPanel topPanel = new JPanel();
      topPanel.setPreferredSize(new Dimension(640,480));//andaze daste khodemon mishe
      GridLayout g1 = new GridLayout(1,1);
      topPanel.setLayout(g1);

      //ghesmate tarjome ro be balaye panjere mifrestim
      mainFrame.add(BorderLayout.NORTH, topPanel);

      //ghesmate button ha
      JPanel leftPanel = new JPanel();
      BoxLayout boxLayout1 = new BoxLayout(leftPanel,BoxLayout.Y_AXIS);
      leftPanel.setLayout(boxLayout1);

      tajik = new JTextArea("tajiki");
      tajik.setBorder(new LineBorder(Color.gray ,3));
      tajik.setSize(200,200);
      tajik.setLineWrap(true);
      tajik.setEditable(true);
      tajik.setWrapStyleWord(true);
      persian = new JTextArea("فارسی");
      persian.setBorder(new LineBorder(Color.gray, 3));
      persian.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
      persian.setSize(200,200);
      persian.setLineWrap(true);
      persian.setEditable(true);
      persian.setWrapStyleWord(true);
      //JScrole
      JScrollPane scrolLeft = new JScrollPane(tajik);
      JScrollPane scrolRight = new JScrollPane(persian);
      topPanel.add(scrolLeft);
      topPanel.add(scrolRight);

      //convert buttom
      JButton convertButton = new JButton("Convert");
      convertButton.addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent actionEvent) {
              try {
                  getContent(tajik.getText());
              } catch (FileNotFoundException e) {
                  e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
              }
              try {
                  arrangeAndShow();
              } catch (FileNotFoundException e) {
                  e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
              }
          }
      });

      JPanel southPanel = new JPanel();
      //GridLayout gSouth = new GridLayout(4,2);
      FlowLayout  gSouth = new FlowLayout();
      southPanel.setLayout(gSouth);
      southPanel.add(convertButton);
      mainFrame.add(BorderLayout.WEST, southPanel);

      //checkBox
      JCheckBox checkBox1 = new JCheckBox("همه А/а های اول کلمات را \"اَ\" ببین به جای \"ا(عَ)\"");
      JCheckBox checkBox2 = new JCheckBox("همه И/и های اول کلمات را \"اِ\" ببین به جای \"ا(عِ/ای)\"");
      JCheckBox checkBox3 = new JCheckBox("همه У/у های اول کلمات را \"اُ\" ببین به جای  \"ا(عُ)\"");
      JCheckBox checkBox4 = new JCheckBox("همه Ӯ/ӯ های اول کلمات را \"اُ\" ببین به جای  \"ا(عُ)\"");
      checkBox1.setSelected(true);//ticke box aval ra mizanim .
      JPanel checkBoxPanel = new JPanel();
      checkBoxPanel.add(checkBox1);
      checkBoxPanel.add(checkBox2);
      checkBoxPanel.add(checkBox3);
      checkBoxPanel.add(checkBox4);
      GridLayout g2 = new GridLayout(3,1) ;
      checkBoxPanel.setLayout(g2);
      mainFrame.add(BorderLayout.EAST ,checkBoxPanel);

      //
      checkBox1.addItemListener(new ItemListener() {
          public void itemStateChanged(ItemEvent itemEvent) {
              checkBox1Status = !checkBox1Status;
          }
      });
      checkBox2.addItemListener(new ItemListener() {
          public void itemStateChanged(ItemEvent itemEvent) {
              checkBox2Status = !checkBox2Status;
          }
      });
      checkBox3.addItemListener(new ItemListener() {
          public void itemStateChanged(ItemEvent itemEvent) {
              checkBox3Status = !checkBox3Status;
          }
      });
      checkBox4.addItemListener(new ItemListener() {
          public void itemStateChanged(ItemEvent itemEvent) {
              checkBox4Status = !checkBox4Status;
          }
      });

      mainFrame.setVisible(true);
      mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    }
    //ye file vase matne tajiki va yeki vase matne farsi dorost mikone va be taikToPersian() pas mideh
    public static void  getContent(String s) throws FileNotFoundException {
        PrintWriter tajikFile = new PrintWriter("Tajik.txt");
        tajikFile.write(s);
        tajikFile.close();
        Scanner input = new Scanner(new File("Tajik.txt"));
        cash = new StringBuilder();
        PrintWriter persianFile = new PrintWriter("Persian.txt");
        tajikToPersian(input,cash,persianFile);
        persianFile.close();
        input.close();

    }
    public static void arrangeAndShow() throws FileNotFoundException {
        String persianLetter = " ب ج چ د ف گ ژ ک ل م ن پ غ ر س ش ت و ع خ ه ی ز ق اَ َ ِ ُ ئ آ ";
        //String notFullyConvertedLetter = " И а и ӯ У у Э э Й й ";
        PrintWriter persianFinal = new PrintWriter("PersianArranged.txt");
        String line;
        int j=0;
        char ch;
        //char letterBefor='ب';
        //char chtemp;
        cash.setLength(0);
        Scanner persianFileRead = new Scanner(new File("Persian.txt"));
         while(persianFileRead.hasNextLine()){
            line = persianFileRead.nextLine();
             cash.setLength(0);
             int i=0;
             while (line.length()>i){

                             try{
                            if( !(persianLetter.lastIndexOf(line.charAt(i)) > 0 ) &  (Character.isWhitespace(line.charAt(i-1)) ) )
                                cash.append("(متن‌تنظیم)");
                             }

                            catch (java.lang.StringIndexOutOfBoundsException exception){
                            cash.append(line.charAt(i));
                            i++;
                            continue;
                            }

                            cash.append(line.charAt(i));
                            i++;
                    }

             persianFinal.println(cash);
            }
            persianFinal.close();

        Scanner input = new Scanner(new File("PersianArranged.txt"));
        cash.setLength(0);//reset cash
         while(input.hasNextLine()){
                   cash.append(input.nextLine());
                   cash.append("\n");
        }
        input.close();
        String akhar;
        akhar=cash.toString();
        persian.setText(akhar);
         }






}


jar file for Linux


http://cnevis.com/?p=207
0

#2 User is offline   Khurasani Icon

  • Advanced Member
  • Icon
Group:
Administrators
Posts:
763
Joined:
30-July 07

Posted 07 February 2012 - 08:35 PM

Thanks for this useful code. Did you write this?
آتش بگير، تا كه بداني چه مي‌كشم
احساسِ سوختن، به تماشا نمي‌شود
0

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

2 User(s) are reading this topic
0 members, 2 guests, 0 anonymous users