Overview
| Comment: | merge trunk |
|---|---|
| Downloads: | Tarball | ZIP archive | SQL archive |
| Timelines: | family | ancestors | descendants | both | multid |
| Files: | files | file ages | folders |
| SHA3-256: |
1ab530ddfac19eb0c9aecd0dda291615 |
| User & Date: | olr on 2018-02-25 15:39:48 |
| Other Links: | branch diff | manifest | tags |
Context
|
2018-02-25
| ||
| 21:55 | [lo] update: lexicon editor check-in: 89b74dbf1b user: olr tags: lo, multid | |
| 15:39 | merge trunk check-in: 1ab530ddfa user: olr tags: multid | |
| 08:54 | [fr][bug] ocr: problème de casse pour la suggestion <Il/il> check-in: f9c4613c61 user: olr tags: trunk, fr | |
| 08:47 | [lo] lexicon editor check-in: 5a1baacbbb user: olr tags: new_feature, lo, multid | |
Changes
Modified gc_lang/fr/oxt/Lexicographer/Enumerator.py from [753041f6b5] to [8bc3897863].
|
| | < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# Enumerator of Words
# by Olivier R.
# License: MPL 2
import unohelper
import uno
import traceback
import helpers
import enum_strings
import grammalecte.graphspell as sc
from com.sun.star.task import XJobExecutor
from com.sun.star.awt import XActionListener
def hexToRBG (sHexa):
r = int(sHexa[:2], 16)
g = int(sHexa[2:4], 16)
b = int(sHexa[4:], 16)
return (r & 255) << 16 | (g & 255) << 8 | (b & 255)
|
| ︙ | ︙ | |||
52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
self.ctx = ctx
self.xSvMgr = self.ctx.ServiceManager
self.xDesktop = self.xSvMgr.createInstanceWithContext("com.sun.star.frame.Desktop", self.ctx)
self.xDocument = self.xDesktop.getCurrentComponent()
self.xContainer = None
self.xDialog = None
self.oSpellChecker = None
def _addWidget (self, name, wtype, x, y, w, h, **kwargs):
xWidget = self.xDialog.createInstance('com.sun.star.awt.UnoControl%sModel' % wtype)
xWidget.Name = name
xWidget.PositionX = x
xWidget.PositionY = y
xWidget.Width = w
| > | 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
self.ctx = ctx
self.xSvMgr = self.ctx.ServiceManager
self.xDesktop = self.xSvMgr.createInstanceWithContext("com.sun.star.frame.Desktop", self.ctx)
self.xDocument = self.xDesktop.getCurrentComponent()
self.xContainer = None
self.xDialog = None
self.oSpellChecker = None
self.oTokenizer = None
def _addWidget (self, name, wtype, x, y, w, h, **kwargs):
xWidget = self.xDialog.createInstance('com.sun.star.awt.UnoControl%sModel' % wtype)
xWidget.Name = name
xWidget.PositionX = x
xWidget.PositionY = y
xWidget.Width = w
|
| ︙ | ︙ | |||
116 117 118 119 120 121 122 |
nY2 = nY1 + 225
nWidth = self.xDialog.Width - 20
nHeight = 10
# List
self._addWidget("list_section", 'FixedLine', nX, nY1, nWidth, nHeight, Label = self.dUI.get("list_section", "#err"), FontDescriptor = xFDTitle)
| | | | | | | < > | | 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 |
nY2 = nY1 + 225
nWidth = self.xDialog.Width - 20
nHeight = 10
# List
self._addWidget("list_section", 'FixedLine', nX, nY1, nWidth, nHeight, Label = self.dUI.get("list_section", "#err"), FontDescriptor = xFDTitle)
self._addWidget('count_button', 'Button', nX, nY1+12, 70, 11, Label = self.dUI.get('count_button', "#err"))
self._addWidget('count2_button', 'Button', nX+75, nY1+12, 70, 11, Label = self.dUI.get('count2_button', "#err"))
self._addWidget('unknown_button', 'Button', nX+150, nY1+12, 70, 11, Label = self.dUI.get('unknown_button', "#err"))
self.xGridModel = self._addGrid("list_grid", nX, nY1+25, nWidth, 181, \
[ {"Title": self.dUI.get("words", "#err"), "ColumnWidth": 175}, {"Title": "Occurrences", "ColumnWidth": 45} ], \
SelectionModel = uno.Enum("com.sun.star.view.SelectionType", "MULTI") \
)
self._addWidget('num_of_entries', 'FixedText', nX, nY1+210, 60, nHeight, Label = self.dUI.get('num_of_entries', "#err"), Align = 2)
self.xNumWord = self._addWidget('num_of_entries_res', 'FixedText', nX+65, nY1+210, 30, nHeight, Label = "—")
self._addWidget('tot_of_entries', 'FixedText', nX+100, nY1+210, 60, nHeight, Label = self.dUI.get('tot_of_entries', "#err"), Align = 2)
self.xTotWord = self._addWidget('tot_of_entries_res', 'FixedText', nX+165, nY1+210, 30, nHeight, Label = "—")
# Tag
# Note: the only way to group RadioButtons is to create them successively
self._addWidget("dformat_section", 'FixedLine', nX, nY2, 90, nHeight, Label = self.dUI.get("dformat_section", "#err"), FontDescriptor = xFDTitle)
self._addWidget("charstyle_section", 'FixedLine', nX+100, nY2, 90, nHeight, Label = self.dUI.get("charstyle_section", "#err"), FontDescriptor = xFDTitle)
self.xUnderline = self._addWidget('underline', 'RadioButton', nX, nY2+12, 40, nHeight, Label = self.dUI.get('underline', "#err"))
self.xNoUnderline = self._addWidget('nounderline', 'RadioButton', nX+50, nY2+12, 40, nHeight, Label = self.dUI.get('nounderline', "#err"))
self.xAccent = self._addWidget('accentuation', 'RadioButton', nX+100, nY2+12, 50, nHeight, Label = self.dUI.get('accentuation', "#err"))
self.xNoAccent = self._addWidget('noaccentuation', 'RadioButton', nX+155, nY2+12, 40, nHeight, Label = self.dUI.get('noaccentuation', "#err"))
self.xTag = self._addWidget('tag_button', 'Button', self.xDialog.Width-40, nY2+10, 30, 11, Label = self.dUI.get('tag_button', "#err"), FontDescriptor = xFDTitle, TextColor = 0x005500)
# Progress bar
self.xProgressBar = self._addWidget('progress_bar', 'ProgressBar', nX, self.xDialog.Height-25, 160, 14)
self.xProgressBar.ProgressValueMin = 0
self.xProgressBar.ProgressValueMax = 1 # to calculate later
# Close
self._addWidget('close_button', 'Button', self.xDialog.Width-60, self.xDialog.Height-25, 50, 14, Label = self.dUI.get('close_button', "#err"), FontDescriptor = xFDTitle, TextColor = 0x550000)
# container
self.xContainer = self.xSvMgr.createInstanceWithContext('com.sun.star.awt.UnoControlDialog', self.ctx)
self.xContainer.setModel(self.xDialog)
|
| ︙ | ︙ | |||
179 180 181 182 183 184 185 |
elif xActionEvent.ActionCommand == "CountByLemma":
self.count(self.dUI.get("lemmas", "#err"), bByLemma=True)
self.xTag.Enabled = False
elif xActionEvent.ActionCommand == "UnknownWords":
self.count(self.dUI.get("unknown_words", "#err"), bOnlyUnknownWords=True)
self.xTag.Enabled = True
elif xActionEvent.ActionCommand == "Tag":
| | < > | < < | | 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 |
elif xActionEvent.ActionCommand == "CountByLemma":
self.count(self.dUI.get("lemmas", "#err"), bByLemma=True)
self.xTag.Enabled = False
elif xActionEvent.ActionCommand == "UnknownWords":
self.count(self.dUI.get("unknown_words", "#err"), bOnlyUnknownWords=True)
self.xTag.Enabled = True
elif xActionEvent.ActionCommand == "Tag":
if not self.xGridControl.hasSelectedRows():
return
lRow = self.xGridControl.getSelectedRows()
aWord = set([ self.xGridModel.GridDataModel.getCellData(0, n) for n in lRow ])
sAction = ""
if self.xUnderline.State:
sAction = "underline"
elif self.xNoUnderline.State:
sAction = "nounderline"
elif self.xAccent.State:
sAction = "accentuation"
elif self.xNoAccent.State:
sAction = "noaccentuation"
self.tagText(aWord, sAction)
elif xActionEvent.ActionCommand == "Close":
self.xContainer.endExecute()
except:
traceback.print_exc()
# XJobExecutor
def trigger (self, args):
|
| ︙ | ︙ | |||
258 259 260 261 262 263 264 |
i += 1
nTotOccur += w
self.xProgressBar.ProgressValue = self.xProgressBar.ProgressValueMax
self.xNumWord.Label = str(i)
self.xTotWord.Label = nTotOccur
@_waitPointer
| | > > < < < < | < < < < | < | > > > > | | | | | | | | | | | | | > | 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 |
i += 1
nTotOccur += w
self.xProgressBar.ProgressValue = self.xProgressBar.ProgressValueMax
self.xNumWord.Label = str(i)
self.xTotWord.Label = nTotOccur
@_waitPointer
def tagText (self, aWord, sAction=""):
if not sAction:
return
self.xProgressBar.ProgressValueMax = self._countParagraph()
self.xProgressBar.ProgressValue = 0
if not self.oTokenizer:
self.oTokenizer = self.oSpellChecker.getTokenizer()
xCursor = self.xDocument.Text.createTextCursor()
xCursor.gotoStart(False)
self._tagParagraph(xCursor, aWord, sAction)
while xCursor.gotoNextParagraph(False):
self._tagParagraph(xCursor, aWord, sAction)
self.xProgressBar.ProgressValue = self.xProgressBar.ProgressValueMax
def _tagParagraph (self, xCursor, aWord, sAction):
xCursor.gotoEndOfParagraph(True)
sParagraph = xCursor.getString()
xCursor.gotoStartOfParagraph(False)
nPos = 0
for dToken in self.oTokenizer.genTokens(sParagraph):
if dToken["sValue"] in aWord:
xCursor.goRight(dToken["nStart"]-nPos, False) # start of token
nPos = dToken["nEnd"]
xCursor.goRight(nPos-dToken["nStart"], True) # end of token
if sAction == "underline":
xCursor.CharBackColor = hexToRBG("AA0000")
elif sAction == "nounderline":
xCursor.CharBackColor = hexToRBG("FFFFFF")
elif sAction == "accentuation":
xCursor.CharStyleName = "Emphasis"
elif sAction == "noaccentuation":
#xCursor.CharStyleName = "Default Style" # doesn’t work
xCursor.setPropertyToDefault("CharStyleName")
self.xProgressBar.ProgressValue += 1
#g_ImplementationHelper = unohelper.ImplementationHelper()
#g_ImplementationHelper.addImplementation(Enumerator, 'net.grammalecte.enumerator', ('com.sun.star.task.Job',))
|
Modified gc_lang/fr/oxt/Lexicographer/enum_strings.py from [fd05286777] to [4648cd7ebd].
1 2 3 4 5 6 7 8 9 |
def getUI (sLang):
if sLang in dStrings:
return dStrings[sLang]
return dStrings["fr"]
dStrings = {
"fr": {
"title": "Grammalecte · Recenseur de mots",
| | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
def getUI (sLang):
if sLang in dStrings:
return dStrings[sLang]
return dStrings["fr"]
dStrings = {
"fr": {
"title": "Grammalecte · Recenseur de mots",
"list_section": "Énumération des occurrences",
"count_button": "Compter tout",
"count2_button": "Compter par lemme",
"unknown_button": "Mots inconnus",
"num_of_entries": "Nombre d’entrées :",
"tot_of_entries": "Total des entrées :",
"words": "Mots",
|
| ︙ | ︙ | |||
25 26 27 28 29 30 31 |
"accentuation": "Accentuation",
"noaccentuation": "Aucun",
"tag_button": "Taguer",
"close_button": "Fermer",
},
"en": {
| | | | 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
"accentuation": "Accentuation",
"noaccentuation": "Aucun",
"tag_button": "Taguer",
"close_button": "Fermer",
},
"en": {
"title": "Grammalecte · Enumerator of words",
"list_section": "Occurrences enumeration",
"count_button": "Count all",
"count2_button": "Count by lemma",
"unknown_button": "Unknown words",
"num_of_entries": "Number of entries:",
"tot_of_entries": "Total of words:",
"words": "Words",
|
| ︙ | ︙ |
Modified gc_lang/fr/rules.grx from [29eda24584] to [4b78e905cb].
| ︙ | ︙ | |||
2305 2306 2307 2308 2309 2310 2311 |
<<- \0.endswith("s") ->> Ils|ils # Erreur de numérisation ?
<<- __else__ ->> Il|il # Erreur de numérisation ?
TEST: __ocr__ {{Us}} arrive demain.
# il / i1 / if / 11
| | | | 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 |
<<- \0.endswith("s") ->> Ils|ils # Erreur de numérisation ?
<<- __else__ ->> Il|il # Erreur de numérisation ?
TEST: __ocr__ {{Us}} arrive demain.
# il / i1 / if / 11
__[s]/ocr(ocr_il_ils3)__
[iI1][1f]s?
<<- not \0.endswith("s") ->> Il|il # Erreur de numérisation ?
<<- __else__ ->> Ils|ils # Erreur de numérisation ?
TEST: __ocr__ {{i1s}} en savent beaucoup trop pour leur propre bien.
# fa / la
|
| ︙ | ︙ |
Modified graphspell-js/spellchecker.js from [7b8a526c88] to [a4e4ee731d].
| ︙ | ︙ | |||
66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
loadTokenizer () {
if (typeof(tokenizer) !== 'undefined') {
this.oTokenizer = new tokenizer.Tokenizer(this.sLangCode);
} else {
this.oTokenizer = new Tokenizer(this.sLangCode);
}
}
setMainDictionary (dictionary) {
// returns true if the dictionary is loaded
this.oMainDic = this._loadDictionary(dictionary);
return Boolean(this.oMainDic);
}
| > > > > > > > | 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
loadTokenizer () {
if (typeof(tokenizer) !== 'undefined') {
this.oTokenizer = new tokenizer.Tokenizer(this.sLangCode);
} else {
this.oTokenizer = new Tokenizer(this.sLangCode);
}
}
getTokenizer () {
if (!this.oTokenizer) {
this.loadTokenizer();
}
return this.oTokenizer;
}
setMainDictionary (dictionary) {
// returns true if the dictionary is loaded
this.oMainDic = this._loadDictionary(dictionary);
return Boolean(this.oMainDic);
}
|
| ︙ | ︙ |
Modified graphspell/spellchecker.py from [dbd02131cc] to [4787045da6].
| ︙ | ︙ | |||
44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
print("Error: <" + sfDictionary + "> not loaded.")
traceback.print_exc()
return None
def loadTokenizer (self):
self.oTokenizer = tokenizer.Tokenizer(self.sLangCode)
def setMainDictionary (self, sfDictionary):
"returns True if the dictionary is loaded"
self.oMainDic = self._loadDictionary(sfDictionary)
return bool(self.oMainDic)
def setExtendedDictionary (self, sfDictionary):
"returns True if the dictionary is loaded"
| > > > > > | 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
print("Error: <" + sfDictionary + "> not loaded.")
traceback.print_exc()
return None
def loadTokenizer (self):
self.oTokenizer = tokenizer.Tokenizer(self.sLangCode)
def getTokenizer (self):
if not self.oTokenizer:
self.loadTokenizer()
return self.oTokenizer
def setMainDictionary (self, sfDictionary):
"returns True if the dictionary is loaded"
self.oMainDic = self._loadDictionary(sfDictionary)
return bool(self.oMainDic)
def setExtendedDictionary (self, sfDictionary):
"returns True if the dictionary is loaded"
|
| ︙ | ︙ |