Thanks Peter,
It is true that I test only in the beginning of the text. Maybe I am
going to have problem for the end. I am going to see my algorythm but
...I have resolved my problem !
I must to say that I am a newbee but more, a stupid newbee. My problem
was that the word coming from Word's Document some have space at the
end. When I did
/wrongWord = //self.theWords.Item(self.ltItemsErreurs[self.index]).Text
/I have to write .strip() to clean my string /.
/Conclusion :/
/To have the SpellCkecker's suggestions in a right way I must write/:
/
//self.suggestions = self.mySpellChecker.Suggest( wrongWord.strip() )
//IronPython is very good//!
Cheers,
Bruno
///
/
Le 04/01/2013 00:07, Peter Schwalm a écrit :
Hello bruno,
I dont't expect that to be a solution, but I see a little problem in
your code for loading the word doc. You write:
/for n in xrange(1, self.nbrMots):/
...
If /self.lesMots.Item(...) is indexed starting with 1 (I don't if that
is true), you will miss the last word, if is indexed starting with 0,
you will miss the first word. That is because ranges in python
asymmetric, i.e. in "range(a,b)/" b does not belong the elements of
the range; the last element is (b-1).
So I think you will have to use either
range(0, nbrMots) # 0 ..
or
range(1, nbrMots + 1) # 1 ..
Good luck.
Peter
Am 03.01.2013 23:38, schrieb bruno gallart:
Hi,
First, I wish you a Good Year and a Good Health.
For me I begin the year with a little stupid encoding's problem :
I am doing a spellchecker with the Hunspell ' library for .Net -- >
Nhunspell for a language of south of Europe with many accented
characters. The spellchecker works fine with the words without
accented characters but if there is some I have strange problem,
exemple :
/self.mySpellChecker = NHunspell.Hunspell("xx_FR.aff","xx_FR.dic")//
//self.suggestions = self.mySpellChecker.Suggest("ome") /
If I give directly the word " ome" that is wrong version for "òme"
"the man" the result, (self.suggestions) shall give me "òme" , "the
man" and "íme" , "the hymn"... it is very good.
But if I take all the words of an Word's document 2007 I have
created, when the loop is at the level of "ome" the self.suggestions
give nothing. I think it comes from the character accented.
The difference maybe comes from the
/"self.theWords.Item(self.ltItemsErreurs[self.index]).Text)/" that
gives the word wrong but in a String's format. In .Net if I remember
well the String's object is an Unicode ? I have tried to do unicode,
decode, encode in iso-8859-15, my xx_FR.dic and xx_FR.aff are in
UTF8, the Word's document is a 2007 version etc... I don't understand
now, I am drowned in my error. Somebody can gives me some trails ????
Thanks if somebody can give me some advice and sorry for my poor english,
And, this week, I am going to buy the book " IronPython in Action", I
think that it will be better.
Cheers,
Bruno
_Suggestion's part of the program_/
self.theWords.Item(self.ltItemsErrors[self.index]).Font.Color= 255//
// self.suggestions =
self.mySpellChecker.Suggest(self.theWords.Item(self.ltItemsErreurs[self.index]).Text)//
////
// if self.suggestions://
// for sug in self.suggestions://
// self._ltSuggestions.Items.Add(sug)//
// else://
// self._ltSuggestions.Items.Add("No proposition")//
//
# the word before en black //
////if self.index >= 1://
//self.theWords.Item(self.ltItemsErreurs[self.index-1]).Font.Color =
000//
////
// if self.index == len(self.ltItemsErreurs)-1://
// self._ltSuggestions.Items.Add("End of tractament")//
//self.theWords.Item(self.ltItemsErreurs[self.index]).Font.Color = 000//
// self.index = 0////
// else://
// self.index = self.index + 1/
_Little part of code to charge all the words and spell them:_
/ltItemsErreurs = []/
/ self.doc =
self.word_application.Documents.Open("c:\\test\\LeTestUltime_2007.docx")/
/ self.lesMots = self.doc.Content.Words//
// self.nbrMots = self.doc.Content.Words.Count//
// for n in xrange(1, self.nbrMots)://
// if self.lesMots.Item(n).Text.strip() not in
self.ltLettresAEviter://
// existe =
self.monCorrecteur.Spell(self.lesMots.Item(n).Text.strip())//
// if not existe://
////self.ltItemsErreurs.append(n)/
_______________________________________________
Ironpython-users mailing list
[email protected]
http://mail.python.org/mailman/listinfo/ironpython-users
_______________________________________________
Ironpython-users mailing list
[email protected]
http://mail.python.org/mailman/listinfo/ironpython-users
_______________________________________________
Ironpython-users mailing list
[email protected]
http://mail.python.org/mailman/listinfo/ironpython-users