Index: gc_lang/fr/oxt/DictOptions/SearchWords.py ================================================================== --- gc_lang/fr/oxt/DictOptions/SearchWords.py +++ gc_lang/fr/oxt/DictOptions/SearchWords.py @@ -111,17 +111,16 @@ nX2 = nX1 + 130 nY0 = 5 nY1 = nY0 + 20 nY2 = nY1 + 60 - nY3 = nY2 + 95 nHeight = 10 #### Search self._addWidget("search_section", 'FixedLine', nX1, nY0, 120, nHeight, Label = self.dUI.get("search_section", "#err"), FontDescriptor = xFDTitle) - self._addWidget("similar_search_section", 'FixedLine', nX1, nY1, 120, nHeight, Label = self.dUI.get("similar_search_section", "#err"), FontDescriptor = xFDTitle) + self._addWidget("similar_search_section", 'FixedLine', nX1, nY1, 120, nHeight, Label = self.dUI.get("similar_search_section", "#err"), FontDescriptor = xFDSubTitle) self.xWord = self._addWidget('word', 'Edit', nX1, nY1+10, 100, nHeight) self._addWidget('similar_search_button', 'Button', nX1, nY1+22, 55, 12, Label = self.dUI.get('similar_search_button', "#err"), FontDescriptor = xFDSubTitle, TextColor = 0x005500) self._addWidget("regex_search_section", 'FixedLine', nX1, nY2, 120, nHeight, Label = self.dUI.get("regex_search_section", "#err"), FontDescriptor = xFDSubTitle) @@ -128,10 +127,11 @@ self._addWidget('flexion_label', 'FixedText', nX1, nY2+10, 30, nHeight, Label = self.dUI.get('flexion', "#err")) self.xFlexion = self._addWidget('flexion', 'Edit', nX1+35, nY2+10, 85, nHeight) self._addWidget('tags_label', 'FixedText', nX1, nY2+22, 30, nHeight, Label = self.dUI.get('tags', "#err")) self.xTags = self._addWidget('tags', 'Edit', nX1+35, nY2+22, 85, nHeight) self._addWidget('regex_search_button', 'Button', nX1, nY2+34, 55, 12, Label = self.dUI.get('regex_search_button', "#err"), FontDescriptor = xFDSubTitle, TextColor = 0x005500) + self._addWidget('result_warning', 'FixedText', nX1, nY2+50, 120, nHeight*7, Label = self.dUI.get('result_warning', '#err'), MultiLine = True) #### Results self._addWidget("result_section", 'FixedLine', nX2, nY0, 200, nHeight, Label = self.dUI.get("result_section", "#err"), FontDescriptor = xFDTitle) self.xGridModel = self._addGrid("list_grid_search", nX2, nY0+10, 200, 265, [ {"Title": self.dUI.get("res_flexion", "#err"), "ColumnWidth": 70}, @@ -167,10 +167,30 @@ elif xActionEvent.ActionCommand == "Close": self.xContainer.endExecute() except: traceback.print_exc() + def initSpellChecker (self): + if not self.oSpellChecker: + self.oSpellChecker = sc.SpellChecker("fr", "fr.bdic", "", "", "") + def searchSimilar (self): - pass + self.initSpellChecker() + sWord = self.xWord.Text.strip() + if sWord: + xGridDataModel = self.xGridModel.GridDataModel + xGridDataModel.removeAllRows() + lResult = self.oSpellChecker.getSimilarEntries(sWord, 20); + for i, aEntry in enumerate(lResult): + xGridDataModel.addRow(i, aEntry) def searchRegex (self): - pass + self.initSpellChecker() + sFlexPattern = self.xFlexion.Text.strip() + sTagsPattern = self.xTags.Text.strip() + xGridDataModel = self.xGridModel.GridDataModel + xGridDataModel.removeAllRows() + for i, aEntry in enumerate(self.oSpellChecker.select(sFlexPattern, sTagsPattern)): + xGridDataModel.addRow(i, aEntry) + i += 1 + if i >= 2000: + break Index: gc_lang/fr/oxt/DictOptions/sw_strings.py ================================================================== --- gc_lang/fr/oxt/DictOptions/sw_strings.py +++ gc_lang/fr/oxt/DictOptions/sw_strings.py @@ -14,10 +14,11 @@ "regex_search_section": "Expression régulières", "flexion": "Flexion", "tags": "Étiquettes", "regex_search_button": "Chercher", + "result_warning": "La recherche par expressions régulières peut générer un nombre gigantesque de résultats. Seules les 2000 premières occurrences trouvées seront affichées. La recherche peut être longue, parce tout le graphe de mots, qui contient 500 000 flexions, sera parcouru si besoin.", "result_section": "Résultats", "res_flexion": "Flexions", "res_lemma": "Lemmes", "res_tags": "Étiquettes",