Tutoriels pour détecter tous les clitiques possibles dans un mot arabe

Description

ce tutoriels permet de analyser et détecter tous les clitiques possibles dans un mots arabe. pour analyser il faut écrire le mot dans le champ Mot a analyser puis cliquer sur récupérer les clitiques pour récupérer les clitiques depuis les fichiers textes. en fin cliquer sur détecter le clitiques pour analyser le mot

Source / Exemple :


/*

  • 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 2 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.
* /*
  • Copyright (C) 2012 RAHMANI MOHAMED ELHADI <argelhadi.wordpress.com>
  • University Dr MOULAY TAHAR
  • Master Computer Knowledge Modeling and Reasoning
*
  • /
import java.awt.Color; import java.awt.Container; import java.awt.HeadlessException; import java.awt.TextArea; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.io.BufferedReader; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.util.ArrayList; import java.util.Collections; import javax.swing.*; public class clitiq extends JFrame { /**
  • /
private static final long serialVersionUID = 1L; Container cont; String fichier; JTextField Mot = new JTextField(); TextArea Mot2 = new TextArea(); TextArea Mot3 = new TextArea(); JLabel lb=new JLabel("Mot a analyser:"); JLabel lb1=new JLabel("proclitiques possibles"); JLabel lb2=new JLabel("enclitiques possibles"); JButton recupere_clitiq = new JButton("récupérer les clitiques"); JButton detect_clitiq = new JButton("détecter les clitiques"); int x; String proc_test,enc_test; String line = null, path = null; TextArea textArea1 = new TextArea(); String lig;String txt=""; ArrayList<String> procl=new ArrayList<String>(); ArrayList<String> encl=new ArrayList<String>(); /////////////////////////////////////////////////////////////////// public clitiq(){ this.setTitle("recherche clitique"); this.setBounds(100,100,500,465); this.setVisible(true); this.setDefaultCloseOperation(EXIT_ON_CLOSE); cont=this.getContentPane(); cont.setLayout(null); Mot = new JTextField(); cont.add(textArea1); textArea1.setText(""); textArea1.setBounds(00, 160, 500, 300); textArea1.setEnabled(false); cont.add(Mot); cont.add(lb); lb.setBounds(50, 0, 100, 40); cont .add(lb1); lb1.setBounds(30, 80, 200, 40); cont.add(lb2); lb2.setBounds(260, 80, 200, 40); Mot.setBackground(Color.white); Mot.setBounds(140,0,200,40); Mot.setEditable(true); // Boutton qui récupére les clitiques a partir des fichiers txt proclitiques et enclitiques // et les place dans de Liste procl pour proclitiques et encl pour enclitiques cont.add(recupere_clitiq); recupere_clitiq.setBounds(10,40,200,40); recupere_clitiq.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ev) { try{ String lin,lig; textArea1.setText(txt); BufferedReader ff = new BufferedReader(new FileReader("proclitiques.txt")); while ((lig = ff.readLine())!= null) { procl.add(lig);} System.out.println(procl); BufferedReader ft = new BufferedReader(new FileReader("enclitiques.txt")); while ((lin = ft.readLine())!= null) { encl.add(lin);} System.out.println(encl); }catch(HeadlessException he){ he.printStackTrace(); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } Mot2.setEnabled(true); Mot3.setEnabled(true); detect_clitiq.setEnabled(true); textArea1.setEnabled(true); } }); Mot2 = new TextArea(); cont.add(Mot2); Mot2.setEnabled(false); Mot2.setBounds(10,120,200,40); Mot2.setEditable(false); Mot2.setBackground(Color.white); cont.add(Mot3); Mot3.setBackground(Color.white); Mot3.setEnabled(false); Mot3.setBounds(230,120,200,40); Mot3.setEditable(false); // Boutton qui détecte les clitiques possibles dans le mot ecrit dans le champ "Mot a anlyser" cont.add(detect_clitiq); detect_clitiq.setEnabled(false); detect_clitiq.setBounds(230,40,200,40); detect_clitiq.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ev) { try { x=5;int i,j; Mot2.setText(""); while (x>0){ if (Mot.getText().length()- x>=3){ proc_test = Mot.getText().substring(0, x); enc_test = Mot.getText().substring(Mot.getText().length()-x, Mot.getText().length()); i=Collections.binarySearch(procl, proc_test); j=Collections.binarySearch(encl, enc_test); if (i>-1){ Mot2.append("le mots: "+proc_test+" existe à la ligne:"+i); }else{ textArea1.append("le proclitique:"+proc_test+" n'existe pas"+"\n\n"); } if (j>-1){ Mot3.append("le mots: "+enc_test+" existe à la ligne:"+j); }else{ textArea1.append("l'enc:"+enc_test+"n'existe pas"+"\n\n"); } } x--;} ; }catch(Exception e){ System.out.println("???!!!!!"); } } }); } ///////////////////////////////////////////////////////////////////// public static void main(String args[]){ clitiq clitiq = new clitiq(); } }

Codes Sources

A voir également

Vous n'êtes pas encore membre ?

inscrivez-vous, c'est gratuit et ça prend moins d'une minute !

Les membres obtiennent plus de réponses que les utilisateurs anonymes.

Le fait d'être membre vous permet d'avoir un suivi détaillé de vos demandes et codes sources.

Le fait d'être membre vous permet d'avoir des options supplémentaires.