Bonsoir,

J'ai un petit problème avec mon projet sur le parseur . Je cherche a parser des mots séparer par l'espace ou l'apostrophe.

Lorsque j'exécute le programme j'ai ce résultat: <mot>bonjour</mot> et pour le mot l'histoire résultat: <mot>l</mot> et <mot>histoire</mot> l'apostrophe n'est pas pris en compte.

Est ce que quelqu'un à une solution pour avoir ce résultat : <mot>l'</mot> et <mot>histoire</mot>

Voici le bout code :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
int original_txt_lenght = doc.getLength(),
	insertion_count = 0,
	parse_ind = 0;
try {
	String start_balise = "<mot>";
	String end_balise = "</mot>";
 
				boolean openTag = false;
				for (int original_txt_id = 0; original_txt_id < original_txt_lenght; ++original_txt_id) {
					setProgress( (original_txt_id+1) * 100 / original_txt_lenght);// update the progress
 
		char s_char = doc.getText(parse_ind, 1).charAt(0);
		if (s_char != '_' || s_char != '\'' ) {
			if (openTag)
				++parse_ind;
			else{
				doc.insertString(parse_ind, start_balise , null);
				++insertion_count;
				parse_ind += start_balise.length() + 1;
				openTag = true;
			}
		}else{
			if (openTag){
				doc.insertString(parse_ind, end_balise , null);
				++insertion_count;
				parse_ind += end_balise.length()+1;
				openTag = false;
			}else{
				++parse_ind;
			}
		}
	}
	if (openTag){
		doc.insertString(doc.getLength(), end_balise , null);
		++insertion_count;
		openTag = false;
	}
 
} catch (BadLocationException e) {
	e.printStackTrace();
	throw new RuntimeException(e);
}
 
ui.statusInfo.setText (" Parse Parag - sending to text area");
ui.main_txtarea.setDocument(doc);
 
return insertion_count;