Index: compile_rules.py ================================================================== --- compile_rules.py +++ compile_rules.py @@ -549,10 +549,14 @@ print(" options defined for: " + ", ".join([ t[0] for t in lOpt ])) dOptions = { "lStructOpt": lStructOpt, "dOptLabel": dOptLabel } dOptions.update({ "dOpt"+k: v for k, v in lOpt }) return dOptions, dOptPriority + +def printBookmark (nLevel, sComment, nLine): + print(" {:>6}: {}".format(nLine, " " * nLevel + sComment)) + def make (lRules, sLang, bJavaScript): "compile rules, returns a dictionary of values" # for clarity purpose, don’t create any file here @@ -561,12 +565,15 @@ global dDEF lLine = [] lRuleLine = [] lTest = [] lOpt = [] + zBookmark = re.compile("^!!+") + for i, sLine in enumerate(lRules, 1): if sLine.startswith('#END'): + printBookmark(0, "BREAK BY #END", i) break elif sLine.startswith("#"): pass elif sLine.startswith("DEF:"): m = re.match("DEF: +([a-zA-Z_][a-zA-Z_0-9]*) +(.+)$", sLine.strip()) @@ -581,10 +588,15 @@ pass elif sLine.startswith(("OPTGROUP/", "OPTSOFTWARE:", "OPT/", "OPTLANG/", "OPTLABEL/", "OPTPRIORITY/")): lOpt.append(sLine) elif re.match("[  \t]*$", sLine): pass + elif sLine.startswith("!!"): + m = zBookmark.search(sLine) + nExMk = len(m.group(0)) + if sLine[nExMk:].strip(): + printBookmark(nExMk-2, sLine[nExMk:].strip(), i) elif sLine.startswith((" ", "\t")): lRuleLine[len(lRuleLine)-1][1] += " " + sLine.strip() else: lRuleLine.append([i, sLine.strip()]) ADDED doc/build.md Index: doc/build.md ================================================================== --- doc/build.md +++ doc/build.md @@ -0,0 +1,80 @@ + +# How to build Grammalecte + +## Required ## + +* Python 3.6 +* Firefox Nightly +* NodeJS + * npm + * jpm +* Thunderbird + + +## Commands ## + +**Build a language** + +`make.py LANG` + +> Generate the LibreOffice extension and the package folder. +> LANG is the lang code (ISO 639). + +> This script uses the file `config.ini` in the folder `gc_lang/LANG`. + +**First build** + +`make.py LANG -js` + +> This command is required to generate all necessary files. + +**Options** + +`-b --build_data` + +> Launch the script `build_data.py` in the folder `gc_lang/LANG`. + +`-d --dict` + +> Generate the indexable binary dictionary from the lexicon in the folder `lexicons`. + +`-js --javascript` + +> Also generate JavaScript extensions. +> Without this option, only Python modules, data and extensions are generated. + +`-t --tests` + +> Run unit tests. + +`-i --install` + +> Install the LibreOffice extension. + +`-fx --firefox` + +> Launch Firefox Nightly. +> Unit tests can be lanched from Firefox, with CTRL+SHIFT+F12. + +`-tb --thunderbird` + +> Launch Thunderbird. + + +## Examples ## + +Full rebuild: + + make.py LANG -b -d -js + +After modifying grammar rules: + + make.py LANG -t + +If you modify the lexicon: + + make.py LANG -d -js + +If you modify your script `build_data.py`: + + make.py LANG -b -js DELETED doc/build.txt Index: doc/build.txt ================================================================== --- doc/build.txt +++ doc/build.txt @@ -1,72 +0,0 @@ - -BUILDER - -= Required = - - Python 3.6 - Firefox Nightly - NodeJS - npm - jpm - Thunderbird - - -= Commands = - -== build a language == - - make.py LANG - generate the LibreOffice extension and the package folder. - LANG is the lang code (ISO 639). - - This script uses the file `config.ini` in the folder `gc_lang/LANG`. - -== First build == - - Type: - make.py LANG -js - - This command is required to generate all necessary files. - -== options == - - -b --build_data - Launch the script `build_data.py` in the folder `gc_lang/LANG`. - - -d --dict - Generate the indexable binary dictionary from the lexicon in the folder `lexicons`. - - -js --javascript - Also generate JavaScript extensions. - Without this option only Python modules, data and extensions are generated. - - -t --tests - Run unit tests. - - -i --install - Install the LibreOffice extension. - - -fx --firefox - Launch Firefox Nightly. - Unit tests can be lanched from Firefox, with CTRL+SHIFT+F12. - - -tb --thunderbird - Launch Thunderbird. - - -= Examples = - - Full rebuild: - make.py LANG -b -d -js - - After modifying grammar rules: - make.py LANG -t - - If you modify the lexicon: - make.py LANG -d -js - - If you modify your script build_data.py: - make.py LANG -b -js - - - Index: doc/syntax.txt ================================================================== --- doc/syntax.txt +++ doc/syntax.txt @@ -1,388 +1,435 @@ - WRITING RULES FOR GRAMMALECTE +Note: This documentation is obsolete right now. -= Principles = +# Principles # -Grammalecte is a multi-passes grammar checker engine. On the first pass, the -engine checks the text paragraph by paragraph. On the next passes, the engine +Grammalecte is a bi-passes grammar checker engine. On the first pass, the +engine checks the text paragraph by paragraph. On the second passe, the engine check the text sentence by sentence. -The command to add a new pass is: -[++] - -You shoudn’t need more than two passes, but you can create as many passes as -you wish. +The command to switch to the second pass is `[++]`. In each pass, you can write as many rules as you need. A rule is defined by: -- a regex pattern trigger -- a list of actions (can’t be empty) -- [optional] flags “LCR” for the regex word boundaries and case sensitiveness -- [optional] user option name for activating/disactivating the rule + +* [optional] flags “LCR” for the regex word boundaries and case sensitiveness +* a regex pattern trigger +* a list of actions (can’t be empty) +* [optional] user option name for activating/disactivating the rule +* [optional] rule name There is no limit to the number of actions and the type of actions a rule can launch. Each action has its own condition to be triggered. There are three kind of actions: -- Error warning, with a message and optionaly suggestions and optionally an URL -- Text transformation, modifying internally the checked text -- Disambigation action, setting tags on a position + +* Error warning, with a message, and optionally suggestions, and optionally an URL +* Text transformation, modifying internally the checked text +* Disambiguation action, setting tags on a position The rules file for your language must be named “rules.grx”. -The options file must be named “option.txt”. The settings file must be named “config.ini”. All these files are simple utf-8 text file. UTF-8 is mandatory. -= Rule syntax = +# Rule syntax # -__LCR__ pattern - <<- condition ->> error_suggestions # message_error|http://awebsite.net... - <<- condition ~>> text_rewriting - <<- condition =>> commands_for_disambigation - ... + __LCR/option(rulename)__ pattern + <<- condition ->> error_suggestions # message_error|http://awebsite.net... + <<- condition ~>> text_rewriting + <<- condition =>> commands_for_disambiguation + ... Patterns are written with the Python syntax for regular expressions: http://docs.python.org/library/re.html There can be one or several actions for each rule, executed the order they are written. Conditions are optional, i.e.: - <<- ~>> replacement + + <<- ~>> replacement LCR flags means: -- Left boundary for the regex -- Case sensitiveness -- Right boundary for the regex - -Left boundary: [ word boundary or < no word boundary -right boundary: ] word boundary or > no word boundary -Case sensitiveness: - i: case insensitive - s: case sensitive - u: uppercase allowed for lowercased characters - i.e.: "Word" becomes "W[oO][rR][dD]" + +* L: Left boundary for the regex +* C: Case sensitiveness +* R: Right boundary for the regex + +Left boundary (L): + +> `[` word boundary + +> `<` no word boundary + +right boundary (R): + +> `]` word boundary + +> `>` no word boundary + +Case sensitiveness (C): + +> `i` case insensitive + +> `s` case sensitive + +> `u` uppercase allowed for lowercase characters + +>> i.e.: "Word" becomes "W[oO][rR][dD]" Examples: -__[i]__ pattern -____ pattern -____ pattern -... + + __[i]__ pattern + ____ pattern + ____ pattern + User option activating/disactivating is possible with an option name placed just after the LCR flags, i.e.: -__[i]/useroption1__ pattern -__[u]/useroption2__ pattern -__[s>/useroption1__ pattern -__/useroption3__ pattern -__/useroption3__ pattern -... + + __[i]/option1__ pattern + __[u]/option2__ pattern + __[s>/option1__ pattern + __/option3__ pattern + __/option3__ pattern + +Rules can be named: + + __[i]/option1(name1)__ pattern + __[u]/option2(name2)__ pattern + __[s>/option1(name3)__ pattern + __(name4)__ pattern + __(name5)__ pattern + +Each rule name must be unique. + The LCR flags are also optional. If you don’t set these flags, the default LCR flags will be: -__[i]__ + + __[i]__ Example. Report “foo” in the text and suggest "bar": -foo <<- ->> bar # Use bar instead of foo. + foo <<- ->> bar # Use bar instead of foo. Example. Recognize and suggest missing hyphen and rewrite internally the text with the hyphen: -__[s]__ foo bar - <<- ->> foo-bar # Missing hyphen. - <<- ~>> foo-bar + __[s]__ foo bar + <<- ->> foo-bar # Missing hyphen. + <<- ~>> foo-bar -== Simple-line or multi-line rules == +## Simple-line or multi-line rules ## Rules can be break to multiple lines by leading tabulators or spaces. You should use 4 spaces. Examples: -____ pattern <<- condition - ->> replacement - # message - <<- condition ->> suggestion # message - <<- condition - ~>> text_rewriting - <<- =>> disambiguation - -____ pattern <<- condition ->> replacement # message + ____ pattern + <<- condition ->> replacement + # message + <<- condition ->> suggestion # message + <<- condition + ~>> text_rewriting + <<- =>> disambiguation + + ____ pattern <<- condition ->> replacement # message -== Comments == +## Comments ## Lines beginning with # are comments. -Example. No action done. -# pattern <<- ->> foo bar # message - - -== End of file == +## End of file ## With the command: -#END + #END -the compiler won’t go further. Whatever is written after will be considered -as comments. +at the beginning of a line, the compiler won’t go further. +Whatever is written after will be considered as comments. -== Whitespaces at the border of patterns or suggestions == +## Whitespaces at the border of patterns or suggestions ## -Example. Recognize double or more spaces and suggests a single space: +Example: Recognize double or more spaces and suggests a single space: -____ " +" <<- ->> " " # Extra space(s). + ____ " +" <<- ->> " " # Extra space(s). ASCII " characters protect spaces in the pattern and in the replacement text. -== Pattern groups and back references == +## Pattern groups and back references ## It is usually useful to retrieve parts of the matched pattern. We simply use parenthesis in pattern to get groups with back references. Example. Suggest a word with correct quotation marks: -\"(\w+)\" <<- ->> “\1” # Correct quotation marks. + \"(\w+)\" <<- ->> “\1” # Correct quotation marks. Example. Suggest the missing space after the !, ? or . signs: -__> \1 \2 # Missing space? + __> \1 \2 # Missing space? Example. Back reference in messages. -(fooo) bar <<- ->> foo bar # “\1” should be: + (fooo) bar <<- ->> foo # “\1” should be: -== Name definitions == +## Name definitions ## Grammalecte supports name definitions to simplify the description of the complex rules. -Example. +Example: -DEF: name pattern + DEF: name pattern Usage in the rules: -({name}) (\w+) ->> "\1-\2" # Missing hyphen? + ({name}) (\w+) ->> "\1-\2" # Missing hyphen? -== Multiple suggestions == +## Multiple suggestions ## -Use | in the replacement text to add multiple suggestions: +Use `|` in the replacement text to add multiple suggestions: -Example 7. Foo, FOO, Bar and BAR suggestions for the input word "foo". +Example. Foo, FOO, Bar and BAR suggestions for the input word "foo". -foo <<- ->> Foo|FOO|Bar|BAR # Did you mean: + foo <<- ->> Foo|FOO|Bar|BAR # Did you mean: -== No suggestion == +## No suggestion ## You can display message without making suggestions. For this purpose, use a single character _ in the suggestion field. Example. No suggestion. -foobar <<- ->> _ # Message + foobar <<- ->> _ # Message -== Positioning == +## Positioning ## Positioning is valid only for error creation and text rewriting. By default, the full pattern will be underlined with blue. You can shorten the underlined text area by specifying a back reference group of the pattern. Instead of writing ->>, write -n>> n being the number of a back reference group. Actually, ->> is similar to -0>> -Example. +Example: -(ying) and yang <<- -1>> yin # Did you mean: -__[s]__ (Mr.) [A-Z]\w+ <<- ~1>> Mr + (ying) and yang <<- -1>> yin # Did you mean: -=== Comparison === + __[s]__ (Mr.) [A-Z]\w+ <<- ~1>> Mr + + +### Comparison ### Rule A: -ying and yang <<- ->> yin and yang # Did you mean: + + ying and yang <<- ->> yin and yang # Did you mean: Rule B: -(ying) and yang <<- -1>> yin # Did you mean: + + (ying) and yang <<- -1>> yin # Did you mean: With the rule A, the full pattern is underlined: - ying and yang - ^^^^^^^^^^^^^ + + ying and yang + ^^^^^^^^^^^^^ With the rule B, only the first group is underlined: - ying and yang - ^^^^ + + ying and yang + ^^^^ -== Longer explanations with URLs == +## Longer explanations with URLs ## -Warning messages can contain optional URL for longer explanations separated by "|": +Warning messages can contain optional URL for longer explanations. -(your|her|our|their)['’]s - <<- ->> \1s - # Possessive pronoun:|http://en.wikipedia.org/wiki/Possessive_pronoun + your’s + <<- ->> yours + # Possessive pronoun:|http://en.wikipedia.org/wiki/Possessive_pronoun -= Text rewriting = +# Text rewriting # -Example. Replacing a string by another +Example. Replacing a string by another. -Mr. [A-Z]\w+ <<- ~>> Mister + Mr. [A-Z]\w+ <<- ~>> Mister WARNING: The replacing text must be shorter than the replaced text or have the same length. Breaking this rule will misplace following error reports. You have to ensure yourself the rules comply with this constraint, Grammalecte won’t do it for you. -Specific commands for text rewriting - -~>> * - replace by whitespaces - -~>> @ - replace by arobases, useful mostly at firt pass, where it is advised to - check usage of punctuations and whitespaces. - @ are automatically removed at the beginning of the second pass. +Specific commands for text rewriting: + +`~>> *` + +> replace by whitespaces + +`~>> @` + +> replace by arrobas, useful mostly at first pass, where it is advised to +> check usage of punctuations and whitespaces. +> @ are automatically removed at the beginning of the second pass. You can use positioning with text rewriting actions. -Mr(. [A-Z]\w+) <<- ~1>> * + Mr(. [A-Z]\w+) <<- ~1>> * You can also call Python expressions. -__[s]__ Mr. ([a-z]\w+) <<- ~1>> =\1.upper() + __[s]__ Mr. ([a-z]\w+) <<- ~1>> =\1.upper() -= Disambiguation = +# Disambiguation # When Grammalecte analyses a word with morph or morphex, before requesting the POS tags to the dictionary, it checks if there is a stored marker for the position where the word is. If there is a marker, Grammalecte uses the stored data and don’t make request to the dictionary. -The disambigation commands store POS tags at the position of a word. +The disambiguation commands store POS tags at the position of a word. -There is 3 commands for disambigation. -- select(n, pattern) - stores at position n only the POS tags of the word matching the pattern. -- exclude(n, pattern) - stores at position n the POS tags of the word, except those matching the +There is 3 commands for disambiguation. + +`select(n, pattern)` + +> stores at position n only the POS tags of the word matching the pattern. + +`exclude(n, pattern)` + +> stores at position n the POS tags of the word, except those matching the pattern. -- define(n, definition) - stores at position n the POS tags in definition. - -Examples. - =>> select(\1, "po:noun is:pl") - =>> exclude(\1, "po:verb") - =>> define(\1, "po:adv") - =>> exclude(\1, "po:verb") and define(\2, "po:adv") and select(\3, "po:adv") + +`define(n, definition)` + +> stores at position n the POS tags in definition. + +Examples: + + =>> select(\1, "po:noun is:pl") + =>> exclude(\1, "po:verb") + =>> define(\1, "po:adv") + =>> exclude(\1, "po:verb") and define(\2, "po:adv") and select(\3, "po:adv") Note: select, exclude and define ALWAYS return True. If select and exclude generate an empty list, no marker is set. With define, you can set a list of POS tags. Example: -define(\1, "po:nom is:plur|po:adj is:sing|po:adv") + define(\1, "po:nom is:plur|po:adj is:sing|po:adv") This will store a list of tags at the position of the first group: -["po:nom is:plur", "po:adj is:sing", "po:adv"] + + ["po:nom is:plur", "po:adj is:sing", "po:adv"] -= Conditions = +# Conditions # Conditions are Python expressions, they must return a value, which will be evaluated as boolean. You can use the usual Python syntax and libraries. You can call pattern subgroups via \0, \1, \2… Example: - - these (\w+) - <<- \1 == "man" -1>> men # Man is a singular noun. Use the plural form: + + these (\w+) + <<- \1 == "man" -1>> men # Man is a singular noun. Use the plural form: You can also apply functions to subgroups like: - \1.startswith("a") - \3.islower() - re.match("pattern", \2) - … - - -== Standard functions == - -word(n) - catches the nth next word after the pattern (separated only by white spaces). - returns None if no word catched - -word(-n) - catches the nth next word before the pattern (separated only by white spaces). - returns None if no word catched - -after(regex[, neg_regex]) - checks if the text after the pattern matches the regex. - -before(regex[, neg_regex]) - checks if the text before the pattern matches the regex. - -textarea(regex[, neg_regex]) - checks if the full text of the checked area (paragraph or sentence) matches the regex. - -morph(n, regex[, strict=True][, noword=False]) - checks if all tags of the word in group n match the regex. - if strict = False, returns True only if one of tags matches the regex. - if there is no word at position n, returns the value of noword. - -morphex(n, regex, neg_regex[, noword=False]) - checks if one of the tags of the word in group n match the regex and - if no tags matches the neg_regex. - if there is no word at position n, returns the value of noword. - -option(option_name) - returns True if option_name is activated else False + + \1.startswith("a") + \3.islower() + re.search("pattern", \2) + + +## Standard functions ## + +`word(n)` + +> catches the nth next word after the pattern (separated only by white spaces). +> returns None if no word catched + +`word(-n)` + +> catches the nth next word before the pattern (separated only by white spaces). +> returns None if no word catched + +`after(regex[, neg_regex])` + +> checks if the text after the pattern matches the regex. + +`before(regex[, neg_regex])` + +> checks if the text before the pattern matches the regex. + +`textarea(regex[, neg_regex])` + +> checks if the full text of the checked area (paragraph or sentence) matches the regex. + +`morph(n, regex[, strict=True][, noword=False])` + +> checks if all tags of the word in group n match the regex. +> if strict = False, returns True only if one of tags matches the regex. +> if there is no word at position n, returns the value of noword. + +`morphex(n, regex, neg_regex[, noword=False])` + +> checks if one of the tags of the word in group n match the regex and +> if no tags matches the neg_regex. +> if there is no word at position n, returns the value of noword. + +`option(option_name)` + +> returns True if option_name is activated else False Note: the analysis is done on the preprocessed text. -== Default variables == +## Default variables ## + +`sCountry` -sCountry +> It contains the current country locale of the checked paragraph. -It contains the current country locale of the checked paragraph. - -colour <<- sCountry == "US" ->> color # Use American English spelling. + colour <<- sCountry == "US" ->> color # Use American English spelling. -= Expressions in the suggestions = +# Expressions in the suggestions # Suggestions (and warning messages) started by an equal sign are Python string expressions extended with possible back references and named definitions: Example: -foo\w+ ->> = '"' + \0.upper() + '"' # With uppercase letters and quoation marks + foo\w+ ->> = '"' + \0.upper() + '"' # With uppercase letters and quoation marks All words beginning with "foo" will be recognized, and the suggestion is the uppercase form of the string with ASCII quoation marks: eg. foom ->> "FOOM". @@ -397,66 +444,66 @@ The text preprocessor is useful to simplify texts and write simplier checking rules. For example, sentences with the same grammar mistake: -These “cats” are blacks. -These cats are “blacks”. -These cats are absolutely blacks. -These stupid “cats” are all blacks. -These unknown cats are as per usual blacks. + + These “cats” are blacks. + These cats are “blacks”. + These cats are absolutely blacks. + These stupid “cats” are all blacks. + These unknown cats are as per usual blacks. Instead of writting complex rules or several rules to find mistakes for all possible cases, you can use the text preprocessor to simplify the text. To remove the chars “”, write: -[“”] ->> * + + [“”] ->> * The * means: replace text by whitespaces. -as per usual ->> * Similarly to grammar rules, you can add conditions: -\w+ly <<- morph(\0, "adverb") ->> * + + \w+ly <<- morph(\0, "adverb") ->> * You can also remove a group reference: -these (\w+) (\w+) <<- morph(\1, "adjective") and morph(\2, "noun") -1>> * -(am|are|is|were|was) (all) -2>> * + + these (\w+) (\w+) <<- morph(\1, "adjective") and morph(\2, "noun") -1>> * + (am|are|is|were|was) (all) <<- -2>> * With these rules, you get the following sentences: -These cats are blacks. -These cats are blacks . -These cats are blacks. -These cats are blacks. -These cats are blacks. + + These cats are blacks. + These cats are blacks . + These cats are blacks. + These cats are blacks. + These cats are blacks. These grammar mistakes can be detected with one simple rule: -these +(\w+) +are +(\w+s) - <<- morph(\1, "noun") and morph(\2, "plural") - -2>> _ # Adjectives are invariable. + these +(\w+) +are +(\w+s) + <<- morph(\1, "noun") and morph(\2, "plural") + -2>> _ # Adjectives are invariable. Instead of replacing text with whitespaces, you can replace text with @. -https?://\S+ ->> @ + https?://\S+ ->> @ This is useful if at first pass you write rules to check successive whitespaces. @ are automatically removed at the second pass. You can also replace any text as you wish. -Mister ->> Mr -(Mrs?)[.] ->> \1 + Mister <<- ->> Mr + (Mrs?)[.] <<- ->> \1 With the multi-passes checking and the text preprocessor, it is advised to remove or simplify the text which has been checked on the previous pass. - - -= Typical problems = - == Pattern matching == Repeating pattern matching of a single rule continues after the previous matching, so ADDED gc_lang/fr/build.py Index: gc_lang/fr/build.py ================================================================== --- gc_lang/fr/build.py +++ gc_lang/fr/build.py @@ -0,0 +1,95 @@ +# Builder for French language + +import os +import zipfile +from distutils import dir_util, file_util + +import helpers + + +def build (sLang, dVars, spLangPack): + "complementary build launched from make.py" + createFirefoxExtension(sLang, dVars) + createThunderbirdExtension(sLang, dVars, spLangPack) + + +def createFirefoxExtension (sLang, dVars): + "create extension for Firefox" + print("Building extension for Firefox") + helpers.createCleanFolder("_build/xpi/"+sLang) + dir_util.copy_tree("gc_lang/"+sLang+"/xpi/", "_build/xpi/"+sLang) + dir_util.copy_tree("grammalecte-js", "_build/xpi/"+sLang+"/grammalecte") + sHTML, dProperties = _createOptionsForFirefox(dVars) + dVars['optionsHTML'] = sHTML + helpers.copyAndFileTemplate("_build/xpi/"+sLang+"/data/about_panel.html", "_build/xpi/"+sLang+"/data/about_panel.html", dVars) + for sLocale in dProperties.keys(): + spfLocale = "_build/xpi/"+sLang+"/locale/"+sLocale+".properties" + if os.path.exists(spfLocale): + helpers.copyAndFileTemplate(spfLocale, spfLocale, dProperties) + else: + print("Locale file not found: " + spfLocale) + with helpers.cd("_build/xpi/"+sLang): + os.system("jpm xpi") + + +def _createOptionsForFirefox (dVars): + sHTML = "" + for sSection, lOpt in dVars['lStructOpt']: + sHTML += '\n
\n

\n' + for lLineOpt in lOpt: + for sOpt in lLineOpt: + sHTML += '

\n' + sHTML += '
\n' + # Creating translation data + dProperties = {} + for sLang in dVars['dOptLabel'].keys(): + dProperties[sLang] = "\n".join( [ "option_" + sOpt + " = " + dVars['dOptLabel'][sLang][sOpt][0].replace(" [!]", " [!]") for sOpt in dVars['dOptLabel'][sLang] ] ) + return sHTML, dProperties + + +def createThunderbirdExtension (sLang, dVars, spLangPack): + "create extension for Thunderbird" + print("Building extension for Thunderbird") + sExtensionName = dVars['tb_identifier'] + "-v" + dVars['version'] + '.xpi' + spfZip = "_build/" + sExtensionName + hZip = zipfile.ZipFile(spfZip, mode='w', compression=zipfile.ZIP_DEFLATED) + _copyGrammalecteJSPackageInZipFile(hZip, spLangPack, dVars['js_binary_dic']) + for spf in ["LICENSE.txt", "LICENSE.fr.txt"]: + hZip.write(spf) + dVars = _createOptionsForThunderbird(dVars) + helpers.addFolderToZipAndFileFile(hZip, "gc_lang/"+sLang+"/tb", "", dVars, True) + hZip.write("gc_lang/"+sLang+"/xpi/gce_worker.js", "worker/gce_worker.js") + spDict = "gc_lang/"+sLang+"/xpi/data/dictionaries" + for sp in os.listdir(spDict): + if os.path.isdir(spDict+"/"+sp): + hZip.write(spDict+"/"+sp+"/"+sp+".dic", "content/dictionaries/"+sp+"/"+sp+".dic") + hZip.write(spDict+"/"+sp+"/"+sp+".aff", "content/dictionaries/"+sp+"/"+sp+".aff") + hZip.close() + helpers.unzip(spfZip, dVars['tb_debug_extension_path']) + + +def _createOptionsForThunderbird (dVars): + dVars['sXULTabs'] = "" + dVars['sXULTabPanels'] = "" + # dialog options + for sSection, lOpt in dVars['lStructOpt']: + dVars['sXULTabs'] += ' \n' + dVars['sXULTabPanels'] += ' \n \n' + # translation data + for sLang in dVars['dOptLabel'].keys(): + dVars['gc_options_labels_'+sLang] = "\n".join( [ "' for sOpt in dVars['dOptLabel'][sLang] ] ) + return dVars + + +def _copyGrammalecteJSPackageInZipFile (hZip, spLangPack, sDicName, sAddPath=""): + for sf in os.listdir("grammalecte-js"): + if not os.path.isdir("grammalecte-js/"+sf): + hZip.write("grammalecte-js/"+sf, sAddPath+"grammalecte-js/"+sf) + for sf in os.listdir(spLangPack): + if not os.path.isdir(spLangPack+"/"+sf): + hZip.write(spLangPack+"/"+sf, sAddPath+spLangPack+"/"+sf) + hZip.write("grammalecte-js/_dictionaries/"+sDicName, sAddPath+"grammalecte-js/_dictionaries/"+sDicName) Index: gc_lang/fr/build_data.py ================================================================== --- gc_lang/fr/build_data.py +++ gc_lang/fr/build_data.py @@ -26,11 +26,11 @@ os.chdir(self.savedPath) def makeDictionaries (sp, sVersion): with cd(sp+"/dictionnaire"): - os.system("genfrdic.py -s -v "+sVersion) + os.system("genfrdic.py -s -gl -v "+sVersion) def makeConj (sp, bJS=False): print("> Conjugaisons ", end="") print("(Python et JavaScript)" if bJS else "(Python seulement)") Index: gc_lang/fr/data/phonet_simil.txt ================================================================== --- gc_lang/fr/data/phonet_simil.txt +++ gc_lang/fr/data/phonet_simil.txt @@ -158,10 +158,11 @@ envol envols envole envoles envolent épais épée épées équivalant équivalent équivalents errâmes Éram essai essais essaie essaies essaient essaye essayes essayent +essor essors essore essores essorent étai étais était étaient été étés étain étains éteint éteins étal étals étale étales étalent étang étangs étant étends étend être êtres hêtre hêtres @@ -188,10 +189,11 @@ fil fils file files filent filet filets filer filais filait filaient filez film films filme filmes filment filtrat filtrats filtra filtras filtrât fin fins faim faims feins feint +flair flairs flaire flaires flairent flan flan flanc flancs flic flics flique fliques fliquent flou flous floue floues flouent foi fois foie foies font fonts fond fonds @@ -278,11 +280,11 @@ mec mecs Mecque mél mêle mêles mêlent mess messe messes meurs meurt mœurs mi mie mies mis mit mît -mir mirs mire mires myrrhe myrrhes +mir mirs mire mires mirent myrrhe myrrhes mite mites mythe mythes mol mols mole moles molle molles môle môles mon mont monts monitorat monitorats monitora monitoras monitorât mort morts mors mords mord maure maures @@ -414,24 +416,27 @@ son sons sont sonnet sonnets sonner sonnais sonnait sonnaient sonnez sors sort sorts sortie sorties sortis sortit souci soucis soucie soucies soucient +soupir soupirs soupire soupires soupirent soutien soutiens soutient soufflet soufflets soufflé soufflés souffler soufflais soufflait soufflaient soufflez soufre soufres souffre souffres souffrent souk souks souque souques souquent stress stresse stresses stressent substitut substituts substitue substitues substituent sui suis suit suie suies +su sus sue sues suent survie survies survis survit survol survols survole survoles survolent ta tas taie taies tes thé thés tain teint teints thym thyms tin tins tint teins tant temps tends tend tante tantes tente tentes tentent +tapir tapirs tapirent tapis tapit tapît tare tares tard teinte teintes teintent tinte tintes tintent test tests teste testes testent tête têtes tète tètes tètent Index: gc_lang/fr/dictionnaire/genfrdic.py ================================================================== --- gc_lang/fr/dictionnaire/genfrdic.py +++ gc_lang/fr/dictionnaire/genfrdic.py @@ -549,11 +549,11 @@ self.writeAffixes(spDic, dVars, nMode, bSimplified) self.writeDictionary(spDic, dVars, nMode, bSimplified) copyTemplate('orthographe', spDic, 'README_dict_fr.txt', dVars) createZipFiles(spDic, spDst, sDicName + '.zip') - def createLibreOfficeExtension (self, spBuild, dTplVars, lDictVars, spGL): + def createLibreOfficeExtension (self, spBuild, dTplVars, lDictVars, spDestGL=""): # LibreOffice extension echo(" * Dictionnaire >> extension pour LibreOffice") dTplVars['version'] = self.sVersion sExtensionName = EXT_PREFIX_OOO + self.sVersion spExt = spBuild + '/' + sExtensionName @@ -588,15 +588,15 @@ file_util.copy_file('césures/README_hyph_fr-3.0.txt', spExt+'/dictionaries') file_util.copy_file('césures/README_hyph_fr-2.9.txt', spExt+'/dictionaries') # zip createZipFiles(spExt, spBuild, sExtensionName + '.oxt') # copy to Grammalecte Project - if spGL: + if spDestGL: echo(" extension copiée dans Grammalecte...") - dir_util.copy_tree(spExt+'/dictionaries', spGL) + dir_util.copy_tree(spExt+'/dictionaries', spDestGL) - def createMozillaExtensions (self, spBuild, dTplVars, lDictVars, spDestGL): + def createMozillaExtensions (self, spBuild, dTplVars, lDictVars, spDestGL=""): # Mozilla extension 1 echo(" * Dictionnaire >> extension pour Mozilla") dTplVars['version'] = self.sVersion sExtensionName = EXT_PREFIX_MOZ + self.sVersion spExt = spBuild + '/' + sExtensionName @@ -606,14 +606,15 @@ file_util.copy_file(spDict+'/fr-classique.dic', spExt+'/dictionaries/fr-classic.dic') file_util.copy_file(spDict+'/fr-classique.aff', spExt+'/dictionaries/fr-classic.aff') copyTemplate('orthographe', spExt, 'README_dict_fr.txt', dTplVars) createZipFiles(spExt, spBuild, sExtensionName + '.xpi') # Grammalecte - echo(" * Dictionnaire >> copie des dicos dans Grammalecte") - for dVars in lDictVars: - file_util.copy_file(spDict+'/'+dVars['asciiName']+'.dic', spDestGL+'/'+dVars['mozAsciiName']+"/"+dVars['mozAsciiName']+'.dic') - file_util.copy_file(spDict+'/'+dVars['asciiName']+'.aff', spDestGL+'/'+dVars['mozAsciiName']+"/"+dVars['mozAsciiName']+'.aff') + if spDestGL: + echo(" * Dictionnaire >> copie des dicos dans Grammalecte") + for dVars in lDictVars: + file_util.copy_file(spDict+'/'+dVars['asciiName']+'.dic', spDestGL+'/'+dVars['mozAsciiName']+"/"+dVars['mozAsciiName']+'.dic') + file_util.copy_file(spDict+'/'+dVars['asciiName']+'.aff', spDestGL+'/'+dVars['mozAsciiName']+"/"+dVars['mozAsciiName']+'.aff') def createFileIfqForDB (self, spBuild): echo(" * Dictionnaire >> indices de fréquence pour la DB...") with open(spBuild+'/dictIdxIfq-'+self.sVersion+'.diff.txt', 'w', encoding='utf-8', newline="\n") as hDiff, \ open(spBuild+'/dictIdxIfq-'+self.sVersion+'.notes.txt', 'w', encoding='utf-8', newline="\n") as hNotes: @@ -620,11 +621,11 @@ for oEntry in self.lEntry: if oEntry.fq != oEntry.oldFq: hDiff.write("{0.iD}\t{0.fq}\n".format(oEntry)) hNotes.write("{0.lemma}/{0.flags}\t{0.oldFq} > {0.fq}\n".format(oEntry)) - def createLexiconPackages (self, spBuild, version, oStatsLex, spLexGL): + def createLexiconPackages (self, spBuild, version, oStatsLex, spDestGL=""): sLexName = LEX_PREFIX + version spLex = spBuild + '/' + sLexName dir_util.mkpath(spLex) # write Dicollecte lexicon self.sortLexiconByFreq() @@ -632,30 +633,33 @@ self.writeGrammarCheckerLexicon(spBuild + '/' + sLexName + '.lex', version) copyTemplate('lexique', spLex, 'README_lexique.txt', {'version': version}) # zip createZipFiles(spLex, spBuild, sLexName + '.zip') # copy GC lexicon to Grammalecte - file_util.copy_file(spBuild + '/' + sLexName + '.lex', spLexGL + '/French.lex') - file_util.copy_file('lexique/French.tagset.txt', spLexGL) + if spDestGL: + file_util.copy_file(spBuild + '/' + sLexName + '.lex', spDestGL + '/French.lex') + file_util.copy_file('lexique/French.tagset.txt', spDestGL) - def createDictConj (self, spBuild, spCopy): + def createDictConj (self, spBuild, spDestGL=""): echo(" * Dictionnaire >> fichier de conjugaison...") with open(spBuild+'/dictConj.txt', 'w', encoding='utf-8', newline="\n") as hDst: for oEntry in self.lEntry: if oEntry.po.startswith("v"): hDst.write(oEntry.getConjugation()) - echo(" Fichier de conjugaison copié dans Grammalecte...") - file_util.copy_file(spBuild+'/dictConj.txt', spCopy) + if spDestGL: + echo(" Fichier de conjugaison copié dans Grammalecte...") + file_util.copy_file(spBuild+'/dictConj.txt', spDestGL) - def createDictDecl (self, spBuild, spCopy): + def createDictDecl (self, spBuild, spDestGL=""): echo(" * Dictionnaire >> fichier de déclinaison...") with open(spBuild+'/dictDecl.txt', 'w', encoding='utf-8', newline="\n") as hDst: for oEntry in self.lEntry: if re.match("[SXFWIA]", oEntry.flags) and (oEntry.po.startswith("nom") or oEntry.po.startswith("adj")): hDst.write(oEntry.getDeclination()) - echo(" Fichier de déclinaison copié dans Grammalecte...") - file_util.copy_file(spBuild+'/dictDecl.txt', spCopy) + if spDestGL: + echo(" Fichier de déclinaison copié dans Grammalecte...") + file_util.copy_file(spBuild+'/dictDecl.txt', spDestGL) def generateSpellVariants (self, nReq, spBuild): if nReq < 1: nReq = 1 if nReq > 2: nReq = 2 echo(" * Lexique >> variantes par suppression... n = " + str(nReq)) @@ -807,13 +811,10 @@ echo(" dans : " + self.lemma) def __str__ (self): return "{0.lemma}/{0.flags} {1}".format(self, self.getMorph(2)) - def display (self): - echo(self.__str__()) - def check (self): sErr = '' if self.lemma == '': sErr += 'lemme vide' if not re.match(r"[a-zA-ZéÉôÔàâÂîÎïèÈêÊÜœŒæÆçÇ0-9µåÅΩ&αβγδεζηθικλμνξοπρστυφχψωΔℓΩ_]", self.lemma): @@ -1077,11 +1078,11 @@ def solveOccurMultipleFlexions (self, hDst, oStatsLex): sBlank = " " if self.nAKO >= 0: for oFlex in self.lFlexions: - if oFlex.nMulti > 0 and not oFlex.bFixed: + if oFlex.nMulti > 0 and not oFlex.bBlocked: # on trie les entrées avec AKO et sans AKO lEntWithAKO = [] lEntNoAKO = [] for oEntry in oFlex.lMulti: if oEntry.nAKO >= 0: @@ -1101,25 +1102,25 @@ hDst.write(" * {0.sFlexion}\n".format(oFlex)) hDst.write(" moyenne connue\n") for oFlexD in self.lFlexions: if oFlex.sFlexion == oFlexD.sFlexion: hDst.write(sBlank + "{2:<30} {0.sMorph:<30} {0.nOccur:>10} >> {1:>10}\n".format(oFlexD, self.nAKO, self.getShortDescr())) - oFlexD.setOccur(self.nAKO) + oFlexD.setOccurAndBlock(self.nAKO) for oEntry in lEntWithAKO: hDst.write(" moyenne connue\n") for oFlexM in oEntry.lFlexions: if oFlex.sFlexion == oFlexM.sFlexion: hDst.write(sBlank + "{2:<30} {0.sMorph:<30} {0.nOccur:>10} >> {1:>10}\n".format(oFlexM, oEntry.nAKO, oEntry.getShortDescr())) - oFlexM.setOccur(oEntry.nAKO) + oFlexM.setOccurAndBlock(oEntry.nAKO) # on répercute nDiff sur les flexions sans AKO for oEntry in lEntNoAKO: hDst.write(" sans moyenne connue\n") for oFlexM in oEntry.lFlexions: if oFlex.sFlexion == oFlexM.sFlexion: nNewOccur = oFlexM.nOccur + math.ceil((nDiff / len(lEntNoAKO)) / oFlexM.nDup) hDst.write(sBlank + "{2:<30} {0.sMorph:<30} {0.nOccur:>10} +> {1:>10}\n".format(oFlexM, nNewOccur, oEntry.getShortDescr())) - oFlexM.setOccur(nNewOccur) + oFlexM.setOccurAndBlock(nNewOccur) else: # Toutes les entrées sont avec AKO : on pondère nFlexOccur = oStatsLex.getFlexionOccur(oFlex.sFlexion) nTotAKO = self.nAKO for oEnt in oFlex.lMulti: @@ -1129,17 +1130,17 @@ hDst.write(" moyennes connues\n") for oFlexD in self.lFlexions: if oFlex.sFlexion == oFlexD.sFlexion: nNewOccur = math.ceil((nFlexOccur * (self.nAKO / nTotAKO)) / oFlexD.nDup) if nTotAKO else 0 hDst.write(sBlank + "{2:<30} {0.sMorph:<30} {0.nOccur:>10} %> {1:>10}\n".format(oFlexD, nNewOccur, self.getShortDescr())) - oFlexD.setOccur(nNewOccur) + oFlexD.setOccurAndBlock(nNewOccur) for oEntry in oFlex.lMulti: for oFlexM in oEntry.lFlexions: if oFlex.sFlexion == oFlexM.sFlexion: nNewOccur = math.ceil((nFlexOccur * (oEntry.nAKO / nTotAKO)) / oFlexM.nDup) if nTotAKO else 0 hDst.write(sBlank + "{2:<30} {0.sMorph:<30} {0.nOccur:>10} %> {1:>10}\n".format(oFlexM, nNewOccur, oEntry.getShortDescr())) - oFlexM.setOccur(nNewOccur) + oFlexM.setOccurAndBlock(nNewOccur) def calcFreq (self, nTot): self.fFreq = (self.nOccur * 100) / nTot self.oldFq = self.fq self.fq = getIfq(self.fFreq) @@ -1151,22 +1152,25 @@ self.oEntry = oEntry self.sFlexion = sFlex self.sMorph = sMorph self.cDic = cDic self.nOccur = 0 - self.bFixed = False + self.bBlocked = False self.nDup = 0 # duplicates in the same entry self.nMulti = 0 # duplicates with other entries self.lMulti = [] # list of similar flexions self.fFreq = 0 self.cFq = '' self.metagfx = '' # métagraphe self.metaph2 = '' # métaphone 2 - + def setOccur (self, n): self.nOccur = n - self.bFixed = True + + def setOccurAndBlock (self, n): + self.nOccur = n + self.bBlocked = True def calcOccur (self): self.nOccur = math.ceil((self.nOccur / (self.nMulti+1)) / self.nDup) def calcFreq (self, nTot): @@ -1192,13 +1196,10 @@ sOccurs = '' for v in oStatsLex.dFlexions[self.sFlexion]: sOccurs += str(v) + "\t" return "{0.oEntry.iD}\t{0.sFlexion}\t{0.oEntry.sRadical}\t{0.sMorph}\t{0.metagfx}\t{0.metaph2}\t{0.oEntry.lx}\t{0.oEntry.se}\t{0.oEntry.et}\t{0.oEntry.di}{2}\t{1}{0.nOccur}\t{0.nDup}\t{0.nMulti}\t{0.fFreq:.15f}\t{0.cFq}\n".format(self, sOccurs, "/"+self.cDic if self.cDic != "*" else "") - def display (self): - echo(self.__str__()) - @classmethod def simpleHeader (cls): return "# :POS ;LEX ~SEM =FQ /DIC\n" def getGrammarCheckerRepr (self): @@ -1506,10 +1507,11 @@ xParser.add_argument("-v", "--verdic", help="set dictionary version, i.e. 5.4", type=str, default="X.Y.z") xParser.add_argument("-m", "--mode", help="0: no tags, 1: Hunspell tags (default), 2: All tags", type=int, choices=[0, 1, 2], default=1) xParser.add_argument("-u", "--uncompress", help="do not use Hunspell compression", action="store_true") xParser.add_argument("-s", "--simplify", help="no virtual lemmas", action="store_true") xParser.add_argument("-sv", "--spellvariants", help="generate spell variants", action="store_true") + xParser.add_argument("-gl", "--grammalecte", help="copy generated files to Grammalecte folders", action="store_true") xArgs = xParser.parse_args() if xArgs.simplify: xArgs.mode = 0 xArgs.uncompress = True @@ -1553,19 +1555,25 @@ oStatsLex.write(spBuild+'/test_lex.txt') oFrenchDict.calculateStats(oStatsLex, spfStats) ### écriture des paquets echo("Création des paquets...") + + spLexiconDestGL = "../../../lexicons" if xArgs.grammalecte else "" + spLibreOfficeExtDestGL = "../oxt/Dictionnaires/dictionaries" if xArgs.grammalecte else "" + spMozillaExtDestGL = "../xpi/data/dictionaries" if xArgs.grammalecte else "" + spDataDestGL = "../data" if xArgs.grammalecte else "" + if not xArgs.uncompress: oFrenchDict.defineAbreviatedTags(xArgs.mode, spfStats) oFrenchDict.createFiles(spBuild, [dMODERNE, dTOUTESVAR, dCLASSIQUE, dREFORME1990], xArgs.mode, xArgs.simplify) - oFrenchDict.createLibreOfficeExtension(spBuild, dMOZEXT, [dMODERNE, dTOUTESVAR, dCLASSIQUE, dREFORME1990], "../oxt/Dictionnaires/dictionaries") - oFrenchDict.createMozillaExtensions(spBuild, dMOZEXT, [dMODERNE, dTOUTESVAR, dCLASSIQUE, dREFORME1990], "../xpi/data/dictionaries") - oFrenchDict.createLexiconPackages(spBuild, xArgs.verdic, oStatsLex, "../../../lexicons") + oFrenchDict.createLexiconPackages(spBuild, xArgs.verdic, oStatsLex, spLexiconDestGL) oFrenchDict.createFileIfqForDB(spBuild) - oFrenchDict.createDictConj(spBuild, "../data") - oFrenchDict.createDictDecl(spBuild, "../data") + oFrenchDict.createLibreOfficeExtension(spBuild, dMOZEXT, [dMODERNE, dTOUTESVAR, dCLASSIQUE, dREFORME1990], spLibreOfficeExtDestGL) + oFrenchDict.createMozillaExtensions(spBuild, dMOZEXT, [dMODERNE, dTOUTESVAR, dCLASSIQUE, dREFORME1990], spMozillaExtDestGL) + oFrenchDict.createDictConj(spBuild, spDataDestGL) + oFrenchDict.createDictDecl(spBuild, spDataDestGL) if __name__ == '__main__': main() Index: gc_lang/fr/rules.grx ================================================================== --- gc_lang/fr/rules.grx +++ gc_lang/fr/rules.grx @@ -43,13 +43,16 @@ # ERREURS COURANTES # http://fr.wikipedia.org/wiki/Wikip%C3%A9dia:Fautes_d%27orthographe/Courantes -# -# OPTIONS ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -# +!! +!! +!! Options +!! +!! + OPTGROUP/basic: typo apos, esp tab, nbsp unit, tu maj, num virg, nf chim, ocr mapos, liga OPTGROUP/gramm: conf sgpl gn OPTGROUP/verbs: infi conj ppas, imp inte vmode OPTGROUP/style: bs pleo, redon1 redon2, neg OPTGROUP/misc: date mc @@ -191,13 +194,16 @@ OPTLABEL/debug: Debug OPTLABEL/idrule: Display control rule identifier [!]|Display control rule identifier in the context menu message. -# -# DÉFINITIONS ************************************************************************************ -# +!! +!! +!! Définitions pour les regex +!! +!! + DEF: avoir [aeo]\w* DEF: etre [êeésf]\w+ DEF: avoir_etre [aeêésfo]\w* DEF: aller (?:all|v|ir)\w+ DEF: ppas \w[\w-]+[éiust]e?s? @@ -212,59 +218,59 @@ DEF: w4 \w\w\w\w+ -# -# -# -# -# -# -# -# -# -# -# -# -# -# -# -# -# -# -# -# -# //////////////////////////////////////// PASSE 0 //////////////////////////////////////// -# paragraphe par paragraphe -# -# -# -# -# -# -# -# -# -# -# -# -# -# -# -# -# -# -# -# - - - -# -# //////////////////////////////////////// CONTRÔLE DES ESPACES //////////////////////////////////////// -# - +!! +!! +!! +!! +!! +!! +!! +!! +!! +!! +!! +!! +!! +!! +!! +!! +!! +!! +!! +!! +!! PASSE 0: PARAGRAPHE PAR PARAGRAPHE +!! +!! +!! +!! +!! +!! +!! +!! +!! +!! +!! +!! +!! +!! +!! +!! +!! +!! +!! +!! + + + +!! +!! +!!! Espaces & tabulations +!! +!! # Espaces surnuméraires # Note : les tabulations ne sont pas soulignées dans LibreOffice. Mais l’erreur est bien présente. __/tab(tab_début_ligne)__ ^[    ]+ <<- ->> "" # Espace(s) en début de ligne à supprimer : utilisez les retraits de paragraphe. __/tab(tab_fin_ligne)__ [    ]+$ <<- ->> "" # Espace(s) en fin de ligne à supprimer. @@ -375,14 +381,15 @@ # Tout contrôle des espaces doit se faire avant ce point. # À partir d’ici, toute règle est susceptible de supprimer des caractères et les remplacer par des espaces ou des chaînes de longueur égale. -# -# //////////////////////////////////////// PRÉPROCESSEUR //////////////////////////////////////// -# - +!!! +!!! +!!! Processeur: efface les ponctuations gênantes (URL, sigles, abréviations, IP, heures, etc.) +!!! +!!! # e-mail __(p_email)__ \w[\w.-]*@\w[\w.-]*\w[.]\w+ <<- ~>> * @@ -502,10 +509,16 @@ TEST: Marion Maréchal-Le Pen. Afin que Maréchal ne soit pas analysé comme un impératif, “Le Pen” devient “Le_Pen”. TEST: Car [je] deviendrai plus insaisissable que jamais. #TEST: des {{homme}} #TEST: des [b]{{femme}}[/b] + +!!! +!!! +!!! Processeur: balises HTML et LaTeX +!!! +!!! # HTML __/html(p_html_amp_xxx)__ &[a-zA-Z]+; <<- ~>> _ __/html(p_html_lt)__ < <<- ~>> " <" __/html(p_html_gt)__ > <<- ~>> > @@ -520,18 +533,15 @@ __> * __/latex(p_latex2)__ \\[,;/\\] <<- ~>> * __/latex(p_latex3)__ \{(?:abstract|align|cases|center|description|enumerate|equation|figure|flush(?:left|right)|gather|minipage|multline|quot(?:ation|e)|SaveVerbatim|table|tabular|thebibliography|[vV]erbatim|verse|wrapfigure)\} <<- ~>> * - -# -# //////////////////////////////////////// RÈGLES DE CONTRÔLE //////////////////////////////////////// -# - - -############################## TYPOGRAPHIE ############################## - +!! +!! +!!!! Typographie, virgules, espaces insécables, unités de mesure… +!! +!! ### Écritures épicènes invariables # Attention, lors de la deuxième passe, on se sert du désambiguïsateur __[u](typo_écriture_épicène_pluriel)__ @@ -905,13 +915,11 @@ <<- ->> =\0.replace("2", "₂").replace("3", "₃").replace("4", "₄") # Typographie des composés chimiques. [!] TEST: __chim__ les molécules {{CaCO3}} et {{H2O}}… -# -# GRANDS NOMBRES --------------------------------------------------------------------------------- -# +!!!! Grands nombres __[s]/num(num_grand_nombre_soudé)__ \d\d\d\d\d+ <<- not before("NF[  -]?(C|E|P|Q|X|Z|EN(?:[  -]ISO|)) *") ->> =formatNumber(\0) # Formatage des grands nombres. @@ -941,13 +949,12 @@ TEST: Il a perdu {{20 000}} euros à la Bourse en un seul mois. -# -# DATES ------------------------------------------------------------------------------------------ -# +!!!! Dates + __[i]/date(date_nombres)__ (?> _ # Cette date est invalide. <<- ~>> =\0.replace(".", "-").replace(" ", "-").replace("\/", "-") @@ -956,13 +963,11 @@ TEST: le {{32.03.2018}} TEST: le {{81/01/2012}} TEST: 12-12-2012 -# -# REDONDANCES (dans le paragraphe) --------------------------------------------------------------- -# +!!!! Redondances __[i]/redon1(redondances_paragraphe)__ ({w_4})[  ,.;!?:].*[  ](\1) @@0,$ <<- not morph(\1, ":(?:G|V0)|>(?:t(?:antôt|emps|rès)|loin|souvent|parfois|quelquefois|côte|petit|même) ", False) and not \1[0].isupper() -2>> _ # Dans ce paragraphe, répétition de « \1 » (à gauche). @@ -970,16 +975,15 @@ TEST: __redon1__ Tu es son {{avenir}}. Et lui aussi est ton {{avenir}}. TEST: __redon1__ Car parfois il y en a. Mais parfois il n’y en a pas. - - -# -# //////////////////////////////////////// PRÉPROCESSEUR //////////////////////////////////////// -# Dernier nettoyage avant coupure du paragraphe en phrases -# +!!! +!!! +!!! Processeur: Dernier nettoyage avant coupure du paragraphe en phrases +!!! +!!! # Trait d’union conditionnel (u00AD) __(p_trait_union_conditionnel1)__ \w+‑\w+‑\w+ <<- ~>> =\0.replace("‑", "") __(p_trait_union_conditionnel2)__ \w+‑\w+ <<- ~>> =\0.replace("‑", "") @@ -991,60 +995,58 @@ TEST: “C’est bon !”, croit savoir Marie. TEST: “Parce que… ?” finit par demander Paul. TEST: « Dans quel pays sommes-nous ? » demanda un manifestant. - -# -# -# -# -# -# -# -# -# -# -# -# -# -# -# -# -# -# -# -# -# //////////////////////////////////////// PASSE 1 //////////////////////////////////////// -# phrase par phrase -# -# -# -# -# -# -# -# -# -# -# -# -# -# -# -# -# -# -# -# +!! +!! +!! +!! +!! +!! +!! +!! +!! +!! +!! +!! +!! +!! +!! +!! +!! +!! +!! +!! +!! PASSE 1: PHRASE PAR PHRASE +!! +!! +!! +!! +!! +!! +!! +!! +!! +!! +!! +!! +!! +!! +!! +!! +!! +!! +!! +!! + [++] -# -# DOUBLONS (casse identique) --------------------------------------------------------------------- -# +!!!! Doublons (casse identique) + __[s](doublon)__ ({w1}) {1,3}\1 @@0 <<- not re.search("(?i)^([nv]ous|faire|en|la|lui|donnant|œuvre|h[éoa]|hou|olé|joli|Bora|couvent|dément|sapiens|très|vroum|[0-9]+)$", \1) and not (re.search("^(?:est|une?)$", \1) and before("[’']$")) and not (\1 == "mieux" and before("(?i)qui +$")) @@ -1051,13 +1053,11 @@ ->> \1 # Doublon. TEST: Il y a un {{doublon doublon}}. -# -# NOMBRES : TYPOGRAPHIE -------------------------------------------------------------------------- -# +!!!! Nombres: typographie #(\d\d\d\d)-(\d\d\d\d) <<- ->> \1–\2 # Ne pas séparer deux dates par un trait d’union, mais par un tiret demi-cadratin. __[s]/num(num_lettre_O_zéro1)__ [\dO]+[O][\dO]+ <<- not option("ocr") ->> =\0.replace("O", "0") # S’il s’agit d’un nombre, utilisez le chiffre « 0 » plutôt que la lettre « O ». __[s]/num(num_lettre_O_zéro2)__ [1-9]O <<- not option("ocr") ->> =\0.replace("O", "0") # S’il s’agit d’un nombre, utilisez le chiffre « 0 » plutôt que la lettre « O ». @@ -1075,25 +1075,23 @@ TEST: Non, la {{2è}} fois. ->> 2ᵉ|2e TEST: Le {{XXIème}} siècle. ->> XXIᵉ|XXIe TEST: le {{XXè}} siècle. ->> XXᵉ|XXe -# -# Écritures épicènes invariables -# + +!!!! Écritures épicènes invariables + __[i](d_typo_écriture_épicène_pluriel)__ ({w_1}[éuitsrn])-(?:[nt]|)e-s @@0 <<- morphex(\1, ":[NAQ]", ":G") =>> define(\1, [":N:A:Q:e:p"]) __[i](d_typo_écriture_épicène_singulier)__ ({w_2}[éuitsrn])-e @@0 <<- morph(\1, ":[NAQ]", False) =>> define(\1, [":N:A:Q:e:s"]) -# -# DATES ------------------------------------------------------------------------------------------ -# +!!!! Dates __[i]/date(date_jour_mois_année)__ (\d\d?) (janvier|février|ma(?:rs|i)|a(?:vril|o[ûu]t)|jui(?:n|llet)|septembre|octobre|novembre|décembre) (\d\d\d+) @@0,w,$ <<- not checkDateWithString(\1, \2, \3) ->> _ # Cette date est invalide. @@ -1129,14 +1127,15 @@ TEST: le {{30 février}} -# -# //////////////////////////////////////// PRÉPROCESSEUR //////////////////////////////////////// -# épuration des signes inutiles et quelques simplifications -# +!!! +!!! +!!! Processeur: épuration des signes inutiles et quelques simplifications +!!! +!!! # fin de phrase __(p_fin_de_phrase)__ [.?!:;…][ .?!… »”")]*$ <<- ~>> * # début de phrase @@ -1198,17 +1197,15 @@ TEST: New York {{étaient}} {{devenue}} la plaque tournante de tous les trafics. - -# -# //////////////////////////////////////// RÈGLES DE CONTRÔLE //////////////////////////////////////// -# - - -############################## LIAISONS - TRAITS D’UNION ############################## +!! +!! +!!!! Traits d’union +!! +!! __> -t- # Pour le “t” euphonique, il faut deux traits d’union. __> -t- # Pour le “t” euphonique, il faut deux traits d’union. @@ -1600,10 +1597,12 @@ TEST: Elle y arriva {{lors qu}}’elle trouva l’astuce permettant l’ouverture de la porte. TEST: Dès lors qu’on sait comment s’y prendre, aucune raison de faillir. +!!!! Virgules + # Dialogues __[u]/virg(virgule_dialogue_après_nom_propre)__ ([A-ZÉÈ][\w-]+) (\w+-(?:moi|toi|l(?:ui|a|e(?:ur|s|))|nous|vous|je|tu|ils|elles)) @@0,$ <<- morphex(\1, ":M", ":G") and not morph(\2, ":N", False) and isStart() -1>> \1, # Dialogue ? Ajoutez une virgule pour mettre en incise la personne à qui s’adresse la réplique. @@ -1634,20 +1633,23 @@ TEST: Tu vas les {{donner}} Rachel. TEST: Il va la {{tuer}} Paul. TEST: Cependant les promesses n’engagent que ceux qui les croient, comme aimait à le dire Jacques Chirac. -# Apostrophe manquante (voir règle à la passe précédente) + +!!!! Apostrophe manquante (2) + __/typo(typo_apostrophe_manquante_audace2)__ ^ *([LDSNCJMTÇ] )[aeéiouhAEÉIOUHyîèêôûYÎÈÊÔÛ] @@* <<- option("mapos") -1>> =\1[:-1]+"’" # Il manque peut-être une apostrophe. TEST: __mapos__ {{L }}opinion des gens, elle s’en moquait. -## A / À -# accentuation la préposition en début de phrase + +!!!! A / À: accentuation la préposition en début de phrase + __(?:priori|post[eé]riori|contrario|capella|fortiori) ") -1>> À # S’il s’agit de la préposition « à », il faut accentuer la majuscule. __/typo(typo_À_début_phrase2)__ @@ -1661,13 +1663,15 @@ TEST: — {{A}} t’emmener loin de tout ceci. TEST: A priori, nul ne peut y parvenir sans une aide extérieure. -# -# //////////////////////////////////////// DÉSAMBIGUÏSATEUR //////////////////////////////////////// -# +!!! +!!! +!!! Désambiguïsation +!!! +!!! # mots grammaticaux __[i](d_dans)__ dans <<- not morph(word(-1), ":D.*:p|>[a-z]+ièmes ", False, False) =>> select(\0, ":R") @@ -1735,16 +1739,17 @@ TEST: il s’agit d’{{un}} {{anagramme}} TEST: nul ne sait qui arriva à ce pauvre Paul surpris par la pluie. TEST: elle finit par être très fière de son fils. -# -# //////////////////////////////////////// RÈGLES DE CONTRÔLE //////////////////////////////////////// -# -############################## OCR (expérimental) ############################## +!! +!! +!!!! OCR +!! +!! # ? __> " ?" # Erreur de numérisation ? @@ -2371,12 +2376,15 @@ TEST: __ocr__ trouve {{l£}} temps TEST: __ocr__ elle s’{{avance*}} sur le seuil TEST: __ocr__ par beaucoup d’argent ? {{{Il}} débouche le Jack Daniels -############################## RÈGLES DE BASE ############################## - +!! +!! +!!!! Incohérences de base +!! +!! ### double négation __[i](double_négation)__ pas (personne|aucune?|jamais) @@4 <<- not morph(word(-1), ":D:[me]" ,False, False) ->> \1|pas, \1 @@ -2402,13 +2410,15 @@ TEST: Mon {{il}} est une merveille. TEST: je ne sais {{des}} {{ses}} choses. -################################################## STYLE ################################################## - -########## Basique +!! +!! +!!!! Style +!! +!! #__bs__ Mr <<- ->> M. # M. est l’usage courant pour “Monsieur”. « Mr » est l’abréviation ancienne, française. # à / en __[i]/bs(bs_en_à_ville)__ @@ -2501,22 +2511,24 @@ ->> bien \1 # Tournure populaire. Utilisez « bien que ». TEST: {{Malgré que}} je sois fou. - - ######### Expressions impropres #([mts]e|[nv]ous) (rappel\w+) (de) <<- word(1) != "ne" and not morph(word(1), ":V") # -3>> _ # Expression impropre. « Se rappeler quelque chose » ou « Se souvenir de quelque chose ». #Se rappelle de l’amour #enjoindre à qqn de faire qqch -########## Pléonasmes +!! +!! +!!!! Pléonasmes +!! +!! __[i]/pleo(pleo_abolir)__ (abol\w+) (?:absolument|entièrement|compl[èé]tement|totalement) @@0 <<- morph(\1, ">abolir ", False) ->> \1 # Pléonasme. __[i]/pleo(pleo_acculer)__ (accul\w+) aux? pieds? du mur @@0 <<- morph(\1, ">acculer ", False) ->> \1 # Pléonasme. __[i]/pleo(pleo_achever)__ (ach[eè]v\w+) (?:absolument|entièrement|compl[èé]tement|totalement) @@0 <<- morph(\1, ">achever ", False) ->> \1 # Pléonasme. __[i]/pleo(pleo_en_cours)__ actuellement en cours <<- not after(r" +de?\b") ->> en cours # Pléonasme. @@ -2662,10 +2674,11 @@ TEST: {{Ajourner à une date ultérieure}} ->> Ajourner TEST: {{différer à une date ultérieure}} ->> différer TEST: {{reporter à plus tard}} ->> reporter + # ayants droit __[i]/sgpl(sgpl_ayants_droit)__ [ldcs]es (ayant[- ]droits?) @@4 <<- -1>> ayants droit # Au singulier : « un ayant droit ». Au pluriel : « des ayants droit ». @@ -2681,12 +2694,16 @@ TEST: {{ta}} aimée ->> ton TEST: {{ma}} obligée ->> mon TEST: Ce couple va donner à la France sa très importante collection qui rejoindra le musée d’Orsay +!! +!! +!!!! Confusions +!! +!! -#### CONFUSIONS __[s>/conf(conf_ne_n)__ [nN]e n’ <<- ->> ne m’|n’ # Incohérence. Double négation. __[s>/conf(conf_pronoms1)__ [mtMT]e ([nmst](?:’|e )) @@$ <<- ->> \1 # Incohérence. __[s>/conf(conf_pronoms2)__ [sS]e ([mst](?:’|e )) @@$ <<- ->> \1 # Incohérence. __[s>/conf(conf_de_d)__ [dD][eu] d’(?![A-ZÉÂÔÈ]) <<- ->> d’ # Incohérence. @@ -3848,10 +3865,15 @@ TEST: j’ai l’impression de ne même pas savoir ce qu’est un « juif français ». TEST: C’que j’comprends, c’est qu’il y a des limites à ce qu’on peut supporter. TEST: la tentation pour certains médias de ne tout simplement pas rémunérer notre travail si celui-ci n’est finalement pas publié. TEST: Ne parfois pas être celui qui sabote l’ambiance. +!! +!! +!!!! Formes verbales sans sujet +!! +!! ## Incohérences avec formes verbales 1sg et 2sg sans sujet __[i](p_notre_père_qui_es_au_cieux)__ notre père (qui est? aux cieux) @@11 <<- ~1>> * __[i]/conj(conj_xxxai_sans_sujet)!3__ @@ -3940,11 +3962,15 @@ TEST: il y en a moins que {{prévues}} ->> prévu TEST: comme {{convenus}} ->> convenu -#### TOUT / TOUS / TOUTE / TOUTES +!! +!! +!!!! Tout, tous, toute, toutes +!! +!! __[i](p_fais_les_tous)__ fai(?:tes|sons|s)-(?:les|[nv]ous) (tou(?:te|)s) @@$ <<- ~1>> * __[i](p_tout_débuts_petits)__ (tout) (?:débuts|petits) @@0 <<- before(r"\b(aux|[ldmtsc]es|[nv]os|leurs) +$") ~1>> * @@ -4038,11 +4064,16 @@ TEST: vos tout débuts furent difficiles TEST: aux tout débuts, il y eut bien des erreurs TEST: comment les inégalités sociales impactent la santé des tout petits -#### ADVERBES DE NÉGATION + +!! +!! +!!!! Adverbes de négation +!! +!! __[i]/neg(ne_manquant1)__ (?:je|tu|ils?|on|elles?) ([bcdfgjklmnpqrstvwxz][\w-]*) (pas|rien|jamais|guère) @@w,$ <<- morph(\1, ":[123][sp]", False) and not (re.search("(?i)^(?:jamais|rien)$", \2) and before(r"\b(?:que?|plus|moins) ")) -1>> ne \1 # Ne … \2 : il manque l’adverbe de négation. @@ -4100,15 +4131,15 @@ TEST: Mais gare à ne pas non plus trop surestimer la menace TEST: ne jamais beaucoup bosser, c’est sa devise. - -# -# //////////////////////////////////////// PRÉPROCESSEUR //////////////////////////////////////// -# épuration des adverbes, locutions adverbiales, interjections et expressions usuelles -# +!!! +!!! +!!! Processeur: épuration des adverbes, locutions adverbiales, interjections et expressions usuelles +!!! +!!! # Dates __[s](p_date)__ (?:[dD]epuis le|[lL]e|[dD]u|[aA]u|[jJ]usqu au|[àÀ] compter du) (?:1(?:er|ᵉʳ)|\d\d?) (?:janvier|février|mars|avril|mai|juin|juillet|ao[ûu]t|septembre|octobre|novembre|décembre|vendémiaire|brumaire|frimaire|nivôse|pluviôse|ventôse|germinal|floréal|prairial|messidor|thermidor|fructidor)(?: \d+| dernier| prochain|) <<- ~>> * __[i](p_en_l_an_de_grâce_année)__ @@ -4505,10 +4536,11 @@ __[i](p_sain_de_corps)__ saine?s? (d(?:e corps et d|)’esprit) @@$ <<- ~1>> * __[i](p_sclérose_en_plaques)__ scléroses? (en plaques) @@$ <<- ~1>> * __[i](p_sembler_paraitre_être)__ (sembl\w+|par[au]\w+) +(être|avoir été) +({w_2}) @@0,w,$ <<- morph(\1, ">(?:sembler|para[îi]tre) ") and morphex(\3, ":A", ":G") ~2>> * __[u](p_système)__ systèmes? (d’exploitation|D) @@$ <<- ~1>> * __[i](p_taille)__ taille (\d+) @@$ <<- ~1>> * +__[i](p_taux_de_qqch)__ taux (d’(?:abstention|alcool|alphabétisation|endettement|inflation|intérêt|imposition|occupation|ouverture|œstrogène|urée|usure)|de (?:change|cholest[ée]rol|glycémie|fécondité|participation|testostérone|TVA)) @@$ <<- ~1>> * __[i](p_tête_de_déterré)__ têtes? (de déterrée?s?) @@$ <<- ~1>> * __[i](p_tenir_compte)__ (t[eiî]\w+) +(compte) d(?:es?|u) @@0,w <<- morph(\1, ">tenir ", False) ~2>> * __[i](p_tout_un_chacun)__ (tout un) chacun @@0 <<- ~1>> * __[i](p_tour_de_passe_passe)__ tours? (de passe-passe) @@$ <<- ~1>> * __[i](p_trier_sur_le_volet)__ (tri\w+) (sur le volet) @@0,$ <<- morph(\1, ">trier ", False) ~2>> * @@ -4719,11 +4751,11 @@ ({w_2}) +((?:beige|blanc|bleu|brun|châtain|cyan|gris|jaune|magenta|marron|orange|pourpre|rose|rouge|vert|violet) (?:clair|fluo|foncé|irisé|pâle|pastel|sombre|vif|tendre)) @@0,$ <<- morph(\1, ":[NAQ]", False) ~2>> * # locutions adjectivales, nominales & couleurs __[i](p_locutions_adj_nom_et_couleurs)__ - ({w_2}) +(bas(?: de gamme|se consommation)|bon (?:enfant|marché|teint|chic,? bon genre)|cl(?:é|ef) en mains?|dernier cri|fleur bleue|grand (?:public|luxe)|grandeur nature|haut(?: de gamme|e résolution)|longue (?:distance|portée|durée)|meilleur marché|numéro (?:un|deux|trois|quatre|cinq|six|sept|huit|neuf|dix(?:-sept|-huit|-neuf)|onze|douze|treize|quatorze|quinze|seize|vingt)|plein cadre|top secret|vieux jeu|open source|Créative Commons|pur jus|terre à terre|bleu (?:ciel|marine|saphir|turquoise)|vert (?:émeraude|olive|pomme)|rouge (?:brique|rubis|sang)|jaune sable|blond platine|gris (?:acier|anthracite|perle)|noir (?:d(?:’encre|e jais)|et blanc)) + ({w_2}) +(bas(?: de gamme|se consommation)|bon (?:enfant|marché|teint|chic,? bon genre)|cl(?:é|ef) en mains?|dernier cri|fleur bleue|grand (?:public|luxe)|grandeur nature|haut(?: de gamme|e résolution)|longue (?:distance|portée|durée)|meilleur marché|numéro (?:un|deux|trois|quatre|cinq|six|sept|huit|neuf|dix(?:-sept|-huit|-neuf)|onze|douze|treize|quatorze|quinze|seize|vingt)|plein cadre|top secret|vieux jeu|open source|Créative Commons|pair à pair|pur jus|terre à terre|bleu (?:ciel|marine|roi|saphir|turquoise)|vert (?:émeraude|olive|pomme)|rouge (?:brique|carmin|écarlate|rubis|sang)|jaune sable|blond platine|gris (?:acier|anthracite|perle|souris)|noir (?:d(?:’encre|e jais)|et blanc)) @@0,$ <<- morph(\1, ":(?:N|A|Q|V0e)", False) ~2>> * # tous / tout / toute / toutes __[i](p_tout_déterminant_masculin)__ (tout) (?:le|cet?|[mts]on) @@0 <<- ~1>> * @@ -4852,14 +4884,19 @@ TEST: Ben voyons, c’est sûr, aucun problème ! TEST: ça peut être dans huit jours. TEST: La secrétaire d’Etat à l’égalité entre les femmes et les hommes hérite de la lutte contre les discriminations TEST: les populistes d’Europe centrale et de l’Est ont d’ores et déjà tellement réussi à compromettre les institutions de leur pays TEST: Deirdre, elle aussi légèrement ostracisée, m’interrogea. +TEST: des échanges pair à pair -#### DÉSAMBIGUÏSATION +!!! +!!! +!!! Désambiguïsation (deprecated) +!!! +!!! #__[i]__ ({avoir}) +({w_1}[eiuts]) @@0,$ # <<- morph(\1, ":V0a", False) and morphex(\1, ":Q", ":G") # =>> exclude(\2, ":A") @@ -4889,11 +4926,11 @@ # # //////////////////////////////////////// RÈGLES DE CONTRÔLE //////////////////////////////////////// # -#### Redondances +!!!! Redondances dans la phrase __[i]/redon2(redondances_phrase)__ ({w_4})[ ,].* (\1) @@0,$ <<- not morph(\1, ":(?:G|V0)|>même ", False) -2>> _ # Dans cette phrase, répétition de « \1 » (à gauche). <<- __also__ -1>> _ # Dans cette phrase, répétition de « \1 » (à droite). @@ -4904,11 +4941,15 @@ TEST: __redon2__ De loin en loin, elle passe. TEST: __redon2__ Les mêmes causes produisent/produisant les mêmes effets. (répétition) -############################## GROUPE NOMINAL ############################## +!! +!! +!!!! Groupe nominal (1) +!! +!! #### 1 mot ## Usage impropre @@ -5456,11 +5497,16 @@ -3>> =suggMasSing(@) # Trouver \2 + [adjectif] : l’adjectif s’accorde avec “\2” (au masculin singulier). TEST: ils trouvent ça de plus en plus {{idiots}} ->> idiot -#### 2 mots + +!! +!! +!!!! Groupe nominal (2) +!! +!! ## Sans article __[i]/gn(gn_2m_accord)__ ^ *({w_2}) +({w_2}) @@*,$ @@ -5843,11 +5889,16 @@ TEST: Des {{chambres}} plus ou moins fortement {{éclairé}}. TEST: Les couleurs rouge, jaune et verte ne doivent pas être utilisées TEST: des passeports américain, canadien, néerlandais, allemand et britannique. -#### 3 mots + +!! +!! +!!!! Groupe nominal (3) +!! +!! ## nombre __[i]/gn(gn_3m)__ ^ *({w_2}) +({w_2}) +({w_3}) @@*,w,$ @@ -5883,11 +5934,15 @@ TEST: ces petites sottes {{déjantée}} -#### Accords avec de / des / du +!! +!! +!!!! Groupe nominal: Accords avec de / des / du +!! +!! __[i]/gn(gn_devinette1)__ (?:[lmts]a|une|cette) +{w_2} +d(?:e (?:[lmts]a|cette)|’une) +(?!des )({w_2}) +({w_2}) @@w,$ <<- morphex(\2, ":[NAQ].*:(?:m|f:p)", ":(?:G|P|[fe]:[is]|V0|3[sp])") and not apposition(\1, \2) -2>> =suggFemSing(@, True) # Accord erroné : « \2 » devrait être au féminin singulier. @@ -5940,11 +5995,15 @@ TEST: {{de telles sorte}} -############################## SINGULIERS & PLURIELS ############################## +!! +!! +!!!! Singuliers & Pluriels +!! +!! #### Prépositions # Similaires à prépositions : http://www.synapse-fr.com/manuels/PP_ATTENDU.htm # attendu, compris, non-compris, y compris, entendu, excepté, ôté, ouï, passé, supposé, vu @@ -6314,11 +6373,15 @@ TEST: Son point de {{vus}} prévaudra toujours, faites-vous à cette idée ou dégagez. TEST: de mon point de {{vues}} -############################## CONFUSIONS, HOMONYMES ET FAUX-AMIS ############################### +!! +!! +!!!! Confusions +!! +!! # abuser / abusé / abusif __[i]/conf(conf_abusif)__ c’est +(abus(?:é|er)) @@$ <<- isEnd() -1>> abusif # Confusion. Concernant les actes, on parle de pratiques abusives. On abuse des choses ou des personnes. @@ -6744,11 +6807,10 @@ TEST: il y a une erreur qu’on peut {{desceller}} dans ses analyses. TEST: elle a {{dessellé}} une forte hostilité dans ses propos. - # en train / entrain __[i]/conf(conf_en_train)__ entrain <<- morph(word(-1), ":V0e", False, False) ->> en train # Confusion. L’entrain est une fougue, une ardeur à accomplir quelque chose.|https://fr.wiktionary.org/wiki/entrain TEST: Vous êtes {{entrain}} de vaincre. @@ -6762,10 +6824,26 @@ TEST: Ils s’amusèrent à l’{{envie}} et oublièrent tous leurs soucis. TEST: Je résiste à l’envie de manger du chocolat. TEST: On ne s’intéresse pas à l’école ni à l’âge, mais aux compétences et à l’envie de partager. + +# et / est +__[i]/conf(conf_est)__ + (et) +({w_4}) *$ @@0,$ + <<- before_chk1(r"(?i)^ *(?:l[ea]|ce(?:tte|t|)|mon|[nv]otre) +(\w[\w-]+\w) +$", ":[NA].*:[is]", ":G") + -1>> est # Confusion probable : “et” est une conjonction de coordination. Pour le verbe être à la 3ᵉ personne du singulier, écrivez : + <<- before_chk1(r"(?i)^ *(?:ton) +(\w[\w-]+\w) +$", ":N.*:[is]", ":[GA]") + -1>> est # Confusion probable : “et” est une conjonction de coordination. Pour le verbe être à la 3ᵉ personne du singulier, écrivez : + <<- before_chk1(r"^ *([A-ZÉÈ][\w-]+\w) +$", ":M", ":G") -1>> est # Confusion probable : “et” est une conjonction de coordination. Pour le verbe être à la 3ᵉ personne du singulier, écrivez : + +TEST: ce chien {{et}} malade. +TEST: ton chat {{et}} cinglé. +TEST: Pauline {{et}} fatiguée. +TEST: ton implacable et amère ! +TEST: son cristallin et aigu + # faite / faîte / fait __[i]/conf(conf_faites)__ vous +(?:ne |leur |lui |nous |vous |)(faîtes?) @@$ <<- -1>> faites # Confusion. Le faîte (≠ faire) est le point culminant de quelque chose. __[i]/conf(conf_faites_vous)__ @@ -7602,11 +7680,11 @@ # nouveau / nouvel # TODO -############################## MOTS COMPOSÉS ############################### +!!!! Mots composés __[i]/mc(mc_mot_composé)__ ({w2})-({w2}) @@0,$ <<- not \1.isdigit() and not \2.isdigit() and not morph(\0, ":", False) and not morph(\2, ":G", False) and spell(\1+\2) ->> \1\2 # Vous pouvez ôter le trait d’union. @@ -7616,11 +7694,16 @@ # Mot inconnu du dictionnaire.|http://www.dicollecte.org/dictionary.php?prj=fr&unknownword=on TEST: __mc__ des {{portes-avions}}. -############################## MAJUSCULES & MINUSCULES ############################### + +!! +!! +!!!! Casse: majuscules et minuscules +!! +!! # Les jours __[s]/maj(maj_jours_semaine)__ (?:Lundi|Mardi|Mercredi|Jeudi|Vendredi|Samedi|Dimanche) <<- before(r"[\w,] +$") ->> =\0.lower() @@ -7773,14 +7856,39 @@ TEST: Elle en prendra vingt {{Grammes}}. -################################################################# CONJUGAISONS ############################################################################## +!! +!! +!! +!! +!! +!! +!! +!! +!! +!! +!!! Conjugaisons +!! +!! +!! +!! +!! +!! +!! +!! +!! +!! -#### INFINITIF +!! +!! +!!!! Infinitif +!! +!! + __[i]/infi(infi_à_en)__ à en ({w_2}) @@5 <<- morphex(\1, ":V", ":Y") -1>> =suggVerbInfi(@) # Le verbe devrait être à l’infinitif. TEST: à en {{parlé}} sans cesse @@ -7885,11 +7993,10 @@ -2>> =suggVerbInfi(@) # Le verbe devrait être à l’infinitif. TEST: cessez d’{{anesthésié}} ces gens ! - ## INFINITIFS ERRONÉS __[i]/infi(infi_adjectifs_masculins_singuliers)__ ^ *(?:le|un|cet?|[mts]on|quel) (?!verbe)({w_2}) +({w_2}er) @@w,$ <<- morphex(\1, ":N.*:m:[si]", ":G") and morphex(\2, ":Y", ">aller |:(?:M|N.*:m:s)") and isNextVerb() @@ -7919,22 +8026,24 @@ TEST: les documents {{scanner}} ne sont pas lisibles. TEST: tes doutes {{remâcher}} deviennent difficiles à vivre. -#### PARTICIPES PRÉSENTS +!!!! Particpes présents __[i]/conj(conj_participe_présent)__ (?:ne|lui|me|te|se|nous|vous) ({w_2}ants) @@$ <<- morph(\1, ":A", False) -1>> =\1[:-1] # Un participe présent est invariable.|http://fr.wiktionary.org/wiki/participe_pr%C3%A9sent TEST: nous {{épuisants}} à la tâche pour des clopinettes, nous défaillîmes. -# -# //////////////////////////////////////// PRÉPROCESSEUR //////////////////////////////////////// -# +!!! +!!! +!!! Processeur: simplification des substantifs +!!! +!!! ### @ : we remove @ we introduced after le/la/les in some cases __(p_arobase)__ @ <<- ~>> * ### Avant les verbes (ôter seulement les COI!) @@ -8052,16 +8161,11 @@ TEST: Je me doute bien que vous avez trouvé la réponse. TEST: Nous nous doutons bien qu’il y a une entourloupe derrière cette affaire. -# -# //////////////////////////////////////// RÈGLES DE CONTRÔLE //////////////////////////////////////// -# - - -#### OCR +!!!! OCR # Participes passés __[i]/ocr(ocr_être_participes_passés)__ ({etre}) +({w_2}es?) @@0,$ <<- morph(\1, ":V0e", False) >>> @@ -8094,11 +8198,12 @@ TEST: __ocr__ la longueur de la circonférence étant égale à… # TEST: __ocr__ vous êtes {{presses}} de monter à bord de ce train-ci. # Fonctionne avec nous serons, mais pas nous sommes (bug de JavaScript?) -#### CONFUSIONS + +!!!! Confusions ## guerre / guère __[i]/conf(conf_ne_pronom_pronom_verbe_guère)__ ne (?:[mts]e|la|les?|[nv]ous|lui|leur) (?:la |les? |lui |leur |l’|)\w{w_2} (?:plus |)(guerre) @@$ <<- -1>> guère # Confusion. La guerre est conflit. Pour l’adverbe signifiant “peu”, écrivez : @@ -8154,11 +8259,14 @@ <<- morph(\1, ">aller", False) and not after(" soit ") -2>> soi # Confusion.|https://fr.wiktionary.org/wiki/aller_de_soi TEST: cela ne va pas de {{soit}}. -#### ADVERBES + +!!!! Adverbes après verbe + +# fort __[i]/sgpl(sgpl_verbe_fort)__ ({w_2}) +(forts) @@0,$ <<- morphex(\1, ":V", ":[AN].*:[me]:[pi]|>(?:être|sembler|devenir|re(?:ster|devenir)|para[îi]tre|appara[îi]tre) .*:(?:[123]p|P|Q)|>(?:affirmer|trouver|croire|désirer|estime|préférer|penser|imaginer|voir|vouloir|aimer|adorer|souhaiter) ") and not morph(word(1), ":A.*:[me]:[pi]", False) -2>> fort # Confusion probable. S’il s’agit ici de l’adverbe “fort” (équivalent de “fortement”), écrivez-le au singulier. @@ -8171,10 +8279,11 @@ TEST: elles les veulent forts et astucieux. TEST: les écarts ont été plus forts en une génération TEST: Avec le même nombre de bulletins, les xénophobes apparaîtront plus forts. +# bien __[i]/sgpl(sgpl_bien)__ biens <<- morphex(word(-1), ":V", ":D.*:p|:A.*:p", False) ->> bien # Confusion probable. Ici, “bien” est un adverbe, donc invariable. TEST: Ils vont {{biens}}. @@ -8183,11 +8292,15 @@ TEST: Il a de grands biens. TEST: Ce sont des biens de peu de valeur. -#### INFINITIF +!! +!! +!!!! Infinitif +!! +!! __[i]/infi(infi_d_en_y)__ d’(?:en|y) +({w_2}(?:ée?s?|ai[st]?|ez)) @@$ <<- morph(\1, ":V", False) -1>> =suggVerbInfi(@) # Le verbe devrait être à l’infinitif. @@ -8271,12 +8384,15 @@ <<- morph(\1, ":Q", False) -1>> =suggVerbInfi(@) # Le verbe ne devrait pas être un participe passé. TEST: lui {{mangée}} beaucoup. - -#### USAGE PRONOMINAL : SE + ÊTRE + VERBE +!! +!! +!!!! Participes passés: se +être +verbe +!! +!! __[i]/ppas(ppas_je_me_être_verbe)__ je +(?:ne +|)m(?:e +|’(?:y +|))(?:s[uo]i[st]|étai[st]|fu(?:sses?|s|t)|serai[st]?) +({w_3}) @@$ <<- morphex(\1, ":Q.*:p", ":(?:G|Q.*:[si])") and isRealEnd() and not before(r"\b[qQ]ue? +$") -1>> suggVerbPpas(\1, ":m:s") # Si ce participe passé se rapporte bien à “je”, il devrait être au singulier. @@ -8357,11 +8473,16 @@ TEST: On s’est rencontrées lorsqu’on travaillait là-bas. TEST: des soins que je m’étais donnés. TEST: Si t’es pas contente, t’achètes pas. -#### PRONOM + LAISSER + ADJ + +!! +!! +!!!! Participes passés: se +laisser +adjectif +!! +!! __[i]/ppas(ppas_me_te_laisser_adj)__ ([mt]e|l[ae]) +(laiss\w*) +({w_3}) @@0,w,$ <<- morph(\2, ">laisser ", False) and morphex(\3, ":[AQ].*:p", ":(?:[YG]|[AQ].*:[is])") -3>> =suggSing(@) # Accord avec « \1 » : « \3 » devrait être au singulier. @@ -8385,12 +8506,15 @@ TEST: tu nous laisses indifférentes. TEST: ils nous laisseront étourdis. TEST: nous laisserons étourdi cet homme. - -#### ÊTRE / AVOIR ÉTÉ / SEMBLER (+ÊTRE via PP) / DEVENIR / RESTER / DEVENIR / REDEVENIR / PARAÎTRE + PARTICIPE PASSÉ / ADJ +!! +!! +!!!! Participes passés: être, avoir été, sembler (+être via pp), devenir, rester, (re)devenir, paraître + participe passé / adj +!! +!! __[i]/ppas(ppas_je_verbe)__ j(?:e +|’(?:y +|en +|))(?:ne +|n’|)((?:s[oue]|étai|fus|dev|re(?:dev|st)|par)\w*|a(?:ie?|vais|urais?) +été|eus(?:se|) +été) +({w_2}) @@w,$ <<- (morph(\1, ">(?:être|sembler|devenir|re(?:ster|devenir)|para[îi]tre) ", False) or \1.endswith(" été")) and morphex(\2, ":[NAQ].*:p", ":[GWYsi]") -2>> =suggSing(@) # Accord avec le sujet « je » : « \2 » devrait être au singulier. @@ -8546,11 +8670,15 @@ TEST: J’{{ai été}} {{chercher}} du pain. TEST: Ç’eût été prendre des vessies pour des lanternes. TEST: C’eût été foncer tête baissée dans la gueule du loup. -## pouvoir/sembler/paraître/vouloir/devoir/croire/déclarer/penser/dire/affirmer + être/avoir été +!! +!! +!!!! Participes passés: pouvoir/sembler/paraître/vouloir/devoir/croire/déclarer/penser/dire/affirmer + être/avoir été +!! +!! __[i](p_risque_d_être)__ risqu\w+ +(d’)être @@* <<- ~1>> * __[i]/ppas(ppas_je_verbe_être)__ @@ -8654,11 +8782,13 @@ TEST: elles peuvent avoir été {{trompé}} TEST: elles souhaitent être plus {{considérée}} -## Contrôle de l’accord en nombre avec la conjugaison de « être » +!!!! Participes passés: accord en nombre avec la conjugaison de « être » + +## Contrôle de l’ __[i]/ppas(ppas_être_accord_singulier)__ ({w_2}) +(?:qui +|)(?:ne +|n’|)(?:est|était|f[uû]t|sera(?:it|)|a(?:vait|ura|urait|it|) +été|e[uû]t +été) +({w_2}) @@0,$ <<- morphex(\2, ":[NAQ].*:p", ":[GMWYsi]") and not morph(\1, ":G", False) -2>> =suggSing(@) # Accord avec « être » : « \2 » devrait être au singulier. @@ -8666,12 +8796,12 @@ ({w_2}) +(?:qui +|)(?:ne +|n’|)(?:sont|étaient|fu(?:r|ss)ent|ser(?:ont|aient)|soient|ont +été|a(?:vaient|uront|uraient|ient) +été|eu(?:r|ss)ent +été) +({w_2}) @@0,$ <<- not re.search("(?i)^légion$", \2) and morphex(\2, ":[NAQ].*:s", ":[GWYpi]") and not morph(\1, ":G", False) -2>> =suggPlur(@) # Accord avec « être » : « \2 » devrait être au pluriel. +!!!! Participes passés: accord en genre avec le substantif précédent -## Contrôle de l’accord en genre avec le substantif précédent __[i]/ppas(ppas_sujet_être_accord_genre)__ (?> =suggSing(@) # Si cet adjectif se réfère au pronom « \2 », l’adjectif devrait être au singulier (et accordé en genre). @@ -8762,11 +8893,16 @@ TEST: Elles se sont {{rendues}} compte TEST: La puissance publique s’en est-elle rendu compte ? -## Inversion verbe/sujet + +!! +!! +!!!! Inversion verbe/sujet +!! +!! __[i]/ppas(ppas_inversion_être_je)__ (?:s[ou]is|étais|fus(?:sé|)|serais?)-je +({w_2}) @@$ <<- morphex(\1, ":(?:[123][sp]|Y|[NAQ].*:p)", ":[GWsi]") -1>> =suggSing(@) # Accord avec le sujet « je » : « \1 » devrait être au singulier. __[i]/ppas(ppas_inversion_être_tu)__ @@ -8815,12 +8951,10 @@ TEST: Est-il question de ceci ou de cela ? TEST: Est-ce former de futurs travailleurs ou bien des citoyens - - ## Accord et incohérences __[i]/ppas(ppas_sont)__ sont ({w_2}) @@5 <<- morphex(\1, ":[NAQ]", ":[QWGBMpi]") and not re.search("(?i)^(?:légion|nombre|cause)$", \1) and not before(r"(?i)\bce que?\b") -1>> =suggPlur(@) # Incohérence : « \1 » est au singulier. Ou vous confondez « sont » et « son », ou l’accord en nombre est incorrect. @@ -8828,11 +8962,16 @@ -1>> =suggVerbPpas(\1, ":m:p") # Incohérence : « \1 » n’est pas un participe passé. TEST: après avoir mis à jour sont {{profile}}. -#### SE CROIRE/CONSIDÉRER/MONTRER/PENSER/RÉVÉLER/SAVOIR/SENTIR/VOIR/VOULOIR + PARTICIPE PASSÉ/ADJ + +!! +!! +!!!! Se croire/considérer/montrer/penser/révéler/savoir/sentir/voir/vouloir + participe passé/adj +!! +!! __[i]/ppas(ppas_je_me_verbe)__ je +(?:ne +|)me +((?:s[eauû]|montr|pens|rév|v[oiîe])\w+) +({w_2}) @@w,$ <<- morph(\1, ">(?:montrer|penser|révéler|savoir|sentir|voir|vouloir) ", False) and morphex(\2, ":[NAQ].*:p", ":[GWYsi]") -2>> =suggSing(@) # Accord avec le sujet « je » : « \2 » devrait être au singulier. @@ -8959,11 +9098,15 @@ TEST: une chance pour elle alors qu’il n’a pas choisi TEST: elle se révèle d’ailleurs être une alliée de taille -#### AVOIR + PARTICIPES PASSÉS +!! +!! +!!!! Avoir + participes passés +!! +!! #__[i]/conj__ fait(s|e|es) ({w1}) <<- morph(\2, ":V") and not morph(\2, ":Y") # ->> fait \1 # Le participe passé de faire reste au masculin singulier s’il est suivi par un verbe à l’infinitif. __[i](p_les_avoir_fait_vinfi)__ @@ -9090,11 +9233,16 @@ TEST: elle t’en a {{parle}}. TEST: c’est vous qui m’avez {{convertit}}. TEST: parce que t’as envie que je le fasse -## COD avant que + +!! +!! +!!!! COD précédent que +!! +!! __[i]/ppas(ppas_det_plur_COD_que_avoir)__ ([ldmtsc]es) +({w_2}) +que? +(?:j’|tu |ils? |[nv]ous |elles? |on ) *(?:ne +|n’|)({avoir}) +({w_2}[éiust]e?)(?! [mts]’) @@0,w,w,$ <<- morph(\3, ":V0a", False) and not ((re.search("^(?:décidé|essayé|tenté)$", \4) and after(" +d(?:e |’)")) or (re.search("^réussi$", \4) and after(" +à"))) @@ -9159,11 +9307,13 @@ -1>> à # Confusion probable : “a” est une conjugaison du verbe avoir. Pour la préposition, écrivez : TEST: Avoir {{marcher}} toute la journée m’a épuisée. -## du / dû + +!!!! du / dû + __[i]/ppas(ppas_avoir_dû_vinfi)__ ({avoir}) +(due?s?) +(?:[mts]’|)({w_2}) @@0,w,$ <<- morph(\1, ":V0a", False) and (morph(\3, ":Y") or re.search("^(?:[mtsn]e|[nv]ous|leur|lui)$", \3)) -2>> dû # Participe passé de devoir : « dû ». @@ -9200,11 +9350,16 @@ TEST: Ont-ils {{signer}} le contrat ? TEST: Ai-je déjà {{signez}} le contrat ? TEST: A-t-il déjà {{signer}} le contrat ? -# formes interrogatives +!! +!! +!!!! Participes passés avec formes interrogatives +!! +!! + __[i]/ppas(ppas_avoir_pronom1)__ (?(?:les|[nv]ous|en)|:[NAQ].*:[fp]", False) and not before(r"(?i)\b(?:quel(?:le|)s?|combien) ") -2>> =suggMasSing(@) @@ -9281,14 +9436,27 @@ TEST: se {{crois}} élu par Dieu… TEST: avec ceux se trouvant sur leur chemin +!!!! Confusions ou/où -# -# //////////////////////////////////////// PRÉPROCESSEUR //////////////////////////////////////// -# +__[i]/conf(conf_det_nom_où_pronom)__ + ^ *(?:l(?:es? +|a +|’)|[nv]o(?:s|tre) +|ce(?:t|tte|s|) +|[mts](?:es|on|a) +|des +)({w_2}) +(ou) +(?:je|tu|ils?|elles? +> +\w+|[nv]ous +> +\w+) @@w,w + <<- morphex(\1, ":[NAQ]", ":G") + -2>> où # Confusion probable. Pour évoquer un lieu ou un moment, écrivez :|http://fr.wiktionary.org/wiki/o%C3%B9 + +TEST: L’hôtel {{ou}} ils sont allés l’été dernier. + + + + +!!! +!!! +!!! Processeur avant impératif +!!! +!!! __(p_n_importe_qui_quoi)__ n(’)importe quo?i @@1 <<- ~1>> ` __> > __> > __> > @@ -9295,30 +9463,18 @@ __> > __(p_premier_ne_pro_per_obj5)__ ^ *n’(?:en |y |) <<- ~>> > __(p_premier_ne_pro_per_obj6)__ ^ *ne (?:l’|) <<- ~>> > -# -# //////////////////////////////////////// RÈGLES DE CONTRÔLE //////////////////////////////////////// -# - - -#### CONFUSIONS - -## ou / où -__[i]/conf(conf_det_nom_où_pronom)__ - ^ *(?:l(?:es? +|a +|’)|[nv]o(?:s|tre) +|ce(?:t|tte|s|) +|[mts](?:es|on|a) +|des +)({w_2}) +(ou) +(?:je|tu|ils?|elles? +> +\w+|[nv]ous +> +\w+) @@w,w - <<- morphex(\1, ":[NAQ]", ":G") - -2>> où # Confusion probable. Pour évoquer un lieu ou un moment, écrivez :|http://fr.wiktionary.org/wiki/o%C3%B9 - -TEST: L’hôtel {{ou}} ils sont allés l’été dernier. - - -#### IMPÉRATIF ! + +!! +!! +!!!! Impératif ! +!! +!! # Confusions - __[i]/imp(imp_confusion_2e_pers_pluriel)__ ({w_2}(?:er|ai[st]|ée?s?)) moi @@0 <<- morph(\1, ":V", False) and isStart() ->> =suggVerbTense(\1, ":E", ":2p") + "-moi" # Confusion probable. Pour l’impératif, écrivez : @@ -9449,11 +9605,16 @@ TEST: {{Attend}} la correction. TEST: {{Vas}} au diable ! TEST: {{Écartes}} de moi cette coupe. -## Traits d’union manquants +!! +!! +!!!! Impératif: traits d’union manquants +!! +!! + __[i]/imp(imp_union_moi_toi)__ (?> \1-\2 # S’il s’agit d’un impératif, mettez un trait d’union.|http://66.46.185.79/bdl/gabarit_bdl.asp?id=4206 @@ -9553,14 +9714,15 @@ TEST: {{vas y}}, ce n’est pas dangereux TEST: {{convenez en}}, c’est une belle affaire malgré son prix élevé -# -# //////////////////////////////////////// PRÉPROCESSEUR //////////////////////////////////////// -# Destruction des pronoms qui précèdent un verbe et de l’adverbe de négation “ne”. -# +!!! +!!! +!!! Processeur: destruction des pronoms qui précèdent un verbe et de l’adverbe de négation “ne”. +!!! +!!! # Brainfuck (ici, prudence !) __[i](p_pro_per_obj01)__ ne +(?:l(?:ui|eur|a|es?)|[mts]e|[nv]ous) +(?:l(?:a|es?|ui|eur)|en|y) <<- ~>> > __[i](p_pro_per_obj02)__ ne +(?:[mts](?:e|’(?:en|y))|[nv]ous|l(?:es?|a|ui|eur|’(?:en|y))) <<- ~>> > __[i](p_pro_per_obj03)__ [mts]e +l(?:a|es?) <<- ~>> > @@ -9600,13 +9762,16 @@ __[i](p_pro_per_obj34)__ [nmts]e <<- ~>> > __(p_pro_per_obj35)__ > +> <<- ~>> > # Fin du Brainfuck -# -# //////////////////////////////////////// RÈGLES DE CONTRÔLE //////////////////////////////////////// -# + +!! +!! +!!!! Confusions +!! +!! #### CONFUSION a / à __[i]/conf(conf_pronom_verbe_à)__ ^ *(?:je|tu|ils?|on|elles?) +>? *({w_2}) +(a) @@w,$ <<- morph(\1, ":V", False) and \2 != "A" @@ -9645,11 +9810,15 @@ TEST: Notre communauté vous est redevable. TEST: l’humour est affaire de culture -#### INFINITIF +!! +!! +!!!! Infinitif +!! +!! __[i]/infi(infi_comment_où)__ (?:comment|où) +({w_2}(?:ée?s?|ez)) @@$ <<- morphex(\1, ":V", ":M") and not (\1.endswith("ez") and after(" +vous")) -1>> =suggVerbInfi(@) # Le verbe devrait être à l’infinitif. @@ -9749,11 +9918,15 @@ -2>> =suggVerbPpas(@) # Incohérence. Après « être », le verbe ne doit pas être à l’infinitif. TEST: ils sont {{tromper}} par tous ces hypocrites. -#### CONJUGAISON +!! +!! +!!!! Conjugaison +!! +!! ## 1sg __[i]/conj(conj_j)__ j’({w_1}) @@2 <<- morphex(\1, ":V", ":1s|>(?:en|y)") @@ -10382,11 +10555,15 @@ TEST: Samantha et Eva {{viennes}} demain. TEST: Samantha et Eva leur {{décrive}} une leçon. -#### INVERSION VERBE SUJET +!! +!! +!!!! Inversion verbe sujet +!! +!! __[i]/conj(conj_que_où_comment_verbe_sujet_sing)__ (?:que?|où|comment) +({w1}) (l(?:e(?:ur | )|a |’)|[mts](?:on|a) |ce(?:t|tte|) |[nv]otre |du ) *(?!plupart|majorité)({w1}) @@w,w,$ <<- morphex(\1, ":(?:[12]s|3p)", ":(?:3s|G|W|3p!)") and not after("^ +(?:et|ou) (?:l(?:es? |a |’|eurs? )|[mts](?:a|on|es) |ce(?:tte|ts|) |[nv]o(?:s|tre) |d(?:u|es) )") -1>> =suggVerb(@, ":3s") # Conjugaison erronée. Accord avec « \2 \3… ». Le verbe devrait être à la 3ᵉ personne du singulier. @@ -10434,11 +10611,16 @@ TEST: {{puisse}} les hommes enfin comprendre leurs erreurs. ->> puissent TEST: {{puisses}} notre ennemi trembler de peur devant notre courage. ->> puisse -#### INTERROGATIVES ? + +!! +!! +!!!! Formes interrogatives ? +!! +!! __[i]/inte(inte_union_xxxe_je)__ (?? *$") and not morph(word(1), ":(?:Oo|X|1s)", False, False) ->> =\1[:-1]+"é-je" # Forme interrogative ? Mettez un trait d’union. @@ -10563,11 +10745,16 @@ TEST: je n’{{avais}} pas parti avec eux. TEST: Avais-je partie liée avec lui ? TEST: il {{avait}} parti. -#### CONTRÔLE DES MODES + +!! +!! +!!!! Modes verbaux +!! +!! # conditionnel / futur __[i]/vmode(vmode_j_aimerais_vinfi)__ j(?:e +|’)(aimerai|préf[éè]rerai|apprécierai|voudrai|souhaiterai) +({w_1}) @@w,$ @@ -10677,11 +10864,56 @@ TEST: Après qu’il {{ait}} allé TEST: Après que Paul {{ait}} mangé son repas. TEST: Après qu’il {{soit}} parti, il plut. -# À TRIER + + +!! +!! +!! +!! +!! +!! +!! +!! +!! +!! +!! +!! +!! +!! +!! +!! +!! +!! +!! +!! +!! TESTS: Faux positifs potentiels +!! +!! +!! +!! +!! +!! +!! +!! +!! +!! +!! +!! +!! +!! +!! +!! +!! +!! +!! +!! +!! + +!!! À trier TEST: L’homme sur le bateau de Patrick {{viens}} de temps en temps {{mangé}} chez moi. TEST: Ces marchands {{passe}} leur temps à se quereller. TEST: Ils jugeront en toute impartialité de ce cas {{délirante}}. TEST: Ils sont de manière si étonnante et si admirable {{arrivé}} à ce résultat… TEST: Les tests grand public de Jean-Paul {{montre}} des résultats surprenants. @@ -10716,19 +10948,15 @@ TODO: André Juin était un sculpteur français. TODO: La bataille de Monte Cassino révèle le génie militaire du général Juin. TODO: Les côtes sont dans leur ensemble extrêmement découpées. -####################################################################################################################### -#### FAUX POSITIFS POTENTIELS ######################################################################################### -####################################################################################################################### - -## Indécidable +!!! Indécidable TEST: Du sable fin grippe les rouages (accord avec ce qui précède). TEST: Du monde noir sortent les envahisseurs (accord avec ce qui suit). -## Autres tests +!!! Autres tests TEST: Ça a l’air de t’aller. TEST: Et je m’en sors. TEST: C’est à chacun d’entre nous de suivre le modèle d’Amos. TEST: C’est toi qui voulais y aller. TEST: je ne suis qu’une joueuse en robe de soirée. @@ -10785,10 +11013,12 @@ TEST: Elle prit une pose lascive. TEST: Cela a trait avec l’histoire complexe d’une nation qui a été prise en étau TEST: Enfin, les thèmes de la nouvelle réforme ont été longuement débattus. TEST: Le moral des ménages au plus haut depuis 2007 + +!!! Tests historiques ## Version 0.5.14 TEST: par le léger tissu de rayonne qui les protégeait en ce moment. ## Version 0.5.11 @@ -11559,12 +11789,14 @@ TEST: J’ai mille cent timbres. TEST: À qui mieux mieux, à qui mieux mieux TEST: L’est est loin, la gare de l’est aussi. -## EXEMPLES REPRIS DE LANGUAGETOOL + +!!! Tests repris de LanguageTool ## NOTE : ces textes contiennent parfois des erreurs (corrigées quand repérées par le correcteur) + TEST: Au voisinage du zéro absolu de température. TEST: La couronne périphérique alterne falaises abruptes et plages. TEST: Henri VIII rencontre François Ier. TEST: à ce jour. TEST: avoir un bel avenir @@ -13625,12 +13857,11 @@ TEST: Le 29 février 2016. TEST: Le 29 février 2020. TEST: Le 29-février-2004 -# LE HORLA -# Guy de Maupassant +!!! Le Horla, de Guy de Maupassant # Nouvelle intégrale (228 lignes) # Certains points diffèrent du texte original tiré de Wikisource : # — les paragraphes sont souvent scindés pour des raisons pratiques. # — les virgules avant les points de suspension ont été supprimées # — moyen âge -> Moyen Âge @@ -13998,12 +14229,11 @@ TEST: Après l’homme le Horla. — Après celui qui peut mourir tous les jours, à toutes les heures, à toutes les minutes, par tous les accidents, est venu celui qui ne doit mourir qu’à son jour, à son heure, à sa minute, parce qu’il a touché la limite de son existence ! TEST: Non… non… sans aucun doute, sans aucun doute… il n’est pas mort… Alors… alors… il va donc falloir que je me tue, moi !… # FIN DU HORLA -# DOUBLE ASSASSINAT DANS LA RUE MORGUE -# d’Edgar Poe +!!! Double assassinat dans la rue morgue, d’Edgar Poe # Texte tiré de Wikisource # Les paragraphes ont été découpés pour réduire la longueur des tests. TEST: DOUBLE ASSASSINAT DANS LA RUE MORGUE — Edgar Poe TEST: Quelle chanson chantaient les sirènes ? quel nom Achille avait-il pris, quand il se cachait parmi les femmes ? – Questions embarrassantes, il est vrai, mais qui ne sont pas situées au-delà de toute conjecture. TEST: Sir Thomas Browne. @@ -14543,11 +14773,11 @@ TEST: Mais, après tout, c’est un brave homme. Je l’adore particulièrement pour un merveilleux genre de cant auquel il doit sa réputation de génie. TEST: Je veux parler de sa manie de nier ce qui est, et d’expliquer ce qui n’est pas[2]. # FIN DU DOUBLE ASSASSINAT DANS LA RUE MORGUE -# VERS DORÉS, de Pythagore +!!! Vers Dorés, de Pythagore # Origine? TEST: Aux dieux, suivant les lois, rends de justes hommages ; TEST: Respecte le serment, les héros et les sages ; TEST: Honore tes parents, tes rois, tes bienfaiteurs ; TEST: Choisi parmi tes amis les hommes les meilleurs. @@ -14643,12 +14873,11 @@ TEST: Fin des vers dorés de Pythagore TEST: Note : Chez les Pythagoriciens, la monade ou l’unité représente Dieu-même, parce qu’elle n’est engendrée par aucun nombre, qu’elle les engendre tous, qu’elle est simple et sans aucune composition. La dyade, ou le nombre deux, est l’image de la nature créée, parce qu’elle est le premier produit de l’unité, parce qu’elle est inspirée, parce qu’ayant des parties elle peut se décomposer et se défendre. La monade et la dyade réunies forment le ternaire, et représentent l’immensité de tout ce qui existe, l’être immuable et la matière altérable et changeante. J’ignore par quelle propriété le quaternaire, le nombre quatre, est encore un emblème de la divinité. # FIN DES VERS DORÉS DE PYTHAGORE -# ÉPÎTRE DU FEU PHILOSOPHIQUE -# De Jean Pontanus +!!! Épître du feu philosophique, de Jean Pontanus # Les paragraphes ont été découpés et ne correspondent pas à ceux du texte. TEST: Épître du Feu Philosophique TEST: Lettre concernant la pierre dite philosophale TEST: Jean Pontanus TEST: in Theatrum Chimicum, 1614, t. III ADDED helpers.py Index: helpers.py ================================================================== --- helpers.py +++ helpers.py @@ -0,0 +1,89 @@ +# Useful tools + +import os +import zipfile + +from distutils import dir_util, file_util +from string import Template + + +class cd: + "Context manager for changing the current working directory" + def __init__ (self, newPath): + self.newPath = os.path.expanduser(newPath) + + def __enter__ (self): + self.savedPath = os.getcwd() + os.chdir(self.newPath) + + def __exit__ (self, etype, value, traceback): + os.chdir(self.savedPath) + + +def unzip (spfZip, spDest, bCreatePath=False): + "unzip file at " + if spDest: + if bCreatePath and not os.path.exists(spDest): + dir_util.mkpath(spDest) + print("> unzip in: "+ spDest) + spInstall = os.path.abspath(spDest) + if os.path.isdir(spInstall): + eraseFolder(spInstall) + with zipfile.ZipFile(spfZip) as hZip: + hZip.extractall(spDest) + else: + print("# folder not found") + else: + print("path destination is empty") + + +def eraseFolder (sp): + "erase content of a folder" + # recursive!!! + for sf in os.listdir(sp): + spf = sp + "/" + sf + if os.path.isdir(spf): + eraseFolder(spf) + else: + try: + os.remove(spf) + except: + print("%s not removed" % spf) + + +def createCleanFolder (sp): + "make an empty folder or erase its content if not empty" + if not os.path.exists(sp): + dir_util.mkpath(sp) + else: + eraseFolder(sp) + + +def fileFile (spf, dVars): + "return file as a text filed with variables from " + return Template(open(spf, "r", encoding="utf-8").read()).safe_substitute(dVars) + + +def copyAndFileTemplate (spfSrc, spfDst, dVars): + "write file as with variables filed with " + s = Template(open(spfSrc, "r", encoding="utf-8").read()).safe_substitute(dVars) + open(spfDst, "w", encoding="utf-8", newline="\n").write(s) + + +def addFolderToZipAndFileFile (hZip, spSrc, spDst, dVars, bRecursive): + # recursive function + spSrc = spSrc.strip("/ ") + spDst = spDst.strip("/ ") + for sf in os.listdir(spSrc): + spfSrc = (spSrc + "/" + sf).strip("/ ") + spfDst = (spDst + "/" + sf).strip("/ ") + if os.path.isdir(spfSrc): + if bRecursive: + addFolderToZipAndFileFile(hZip, spfSrc, spfDst, dVars, bRecursive) + else: + if spfSrc.endswith((".css", ".js", ".xcu", ".xul", ".rdf", ".dtd", ".properties")): + #print(spfSrc + " > " + spfDst) + hZip.writestr(spfDst, fileFile(spfSrc, dVars)) + else: + #print(spfSrc + " > " + spfDst) + hZip.write(spfSrc, spfDst) Index: make.py ================================================================== --- make.py +++ make.py @@ -12,96 +12,19 @@ import argparse import importlib import unittest import json -from string import Template from distutils import dir_util, file_util import dialog_bundled import compile_rules +import helpers sWarningMessage = "The content of this folder is generated by code and replaced at each build.\n" - -class cd: - """Context manager for changing the current working directory""" - def __init__ (self, newPath): - self.newPath = os.path.expanduser(newPath) - - def __enter__ (self): - self.savedPath = os.getcwd() - os.chdir(self.newPath) - - def __exit__ (self, etype, value, traceback): - os.chdir(self.savedPath) - - -def fileFile (spf, dVars): - return Template(open(spf, "r", encoding="utf-8").read()).safe_substitute(dVars) - - -def copyAndFileTemplate (spfSrc, spfDst, dVars): - s = Template(open(spfSrc, "r", encoding="utf-8").read()).safe_substitute(dVars) - open(spfDst, "w", encoding="utf-8", newline="\n").write(s) - - -def addFolderToZipAndFileFile (hZip, spSrc, spDst, dVars, bRecursive): - # recursive function - spSrc = spSrc.strip("/ ") - spDst = spDst.strip("/ ") - for sf in os.listdir(spSrc): - spfSrc = (spSrc + "/" + sf).strip("/ ") - spfDst = (spDst + "/" + sf).strip("/ ") - if os.path.isdir(spfSrc): - if bRecursive: - addFolderToZipAndFileFile(hZip, spfSrc, spfDst, dVars, bRecursive) - else: - if spfSrc.endswith((".css", ".js", ".xcu", ".xul", ".rdf", ".dtd", ".properties")): - #print(spfSrc + " > " + spfDst) - hZip.writestr(spfDst, fileFile(spfSrc, dVars)) - else: - #print(spfSrc + " > " + spfDst) - hZip.write(spfSrc, spfDst) - - -def unzip (spfZip, spDest, bCreatePath=False): - if spDest: - if bCreatePath and not os.path.exists(spDest): - dir_util.mkpath(spDest) - print("> unzip in: "+ spDest) - spInstall = os.path.abspath(spDest) - if os.path.isdir(spInstall): - eraseFolder(spInstall) - with zipfile.ZipFile(spfZip) as hZip: - hZip.extractall(spDest) - else: - print("# folder not found") - else: - print("path destination is empty") - - -def eraseFolder (sp): - # recursive!!! - for sf in os.listdir(sp): - spf = sp + "/" + sf - if os.path.isdir(spf): - eraseFolder(spf) - else: - try: - os.remove(spf) - except: - print("%s not removed" % spf) - - -def createCleanFolder (sp): - if not os.path.exists(sp): - dir_util.mkpath(sp) - else: - eraseFolder(sp) - def getConfig (sLang): xConfig = configparser.SafeConfigParser() xConfig.optionxform = str try: @@ -155,37 +78,37 @@ # Package and parser copyGrammalectePyPackageInZipFile(hZip, spLangPack, dVars['py_binary_dic'], "pythonpath/") hZip.write("cli.py", "pythonpath/cli.py") # Extension files - hZip.writestr("META-INF/manifest.xml", fileFile("gc_core/py/oxt/manifest.xml", dVars)) - hZip.writestr("description.xml", fileFile("gc_core/py/oxt/description.xml", dVars)) - hZip.writestr("Linguistic.xcu", fileFile("gc_core/py/oxt/Linguistic.xcu", dVars)) - hZip.writestr("Grammalecte.py", fileFile("gc_core/py/oxt/Grammalecte.py", dVars)) + hZip.writestr("META-INF/manifest.xml", helpers.fileFile("gc_core/py/oxt/manifest.xml", dVars)) + hZip.writestr("description.xml", helpers.fileFile("gc_core/py/oxt/description.xml", dVars)) + hZip.writestr("Linguistic.xcu", helpers.fileFile("gc_core/py/oxt/Linguistic.xcu", dVars)) + hZip.writestr("Grammalecte.py", helpers.fileFile("gc_core/py/oxt/Grammalecte.py", dVars)) for sf in dVars["extras"].split(","): - hZip.writestr(sf.strip(), fileFile(spLang + '/' + sf.strip(), dVars)) + hZip.writestr(sf.strip(), helpers.fileFile(spLang + '/' + sf.strip(), dVars)) if "logo" in dVars.keys() and dVars["logo"].strip(): hZip.write(spLang + '/' + dVars["logo"].strip(), dVars["logo"].strip()) ## OPTIONS # options dialog within LO/OO options panel (legacy) - #hZip.writestr("pythonpath/lightproof_handler_grammalecte.py", fileFile("gc_core/py/oxt/lightproof_handler_grammalecte.py", dVars)) + #hZip.writestr("pythonpath/lightproof_handler_grammalecte.py", helpers.fileFile("gc_core/py/oxt/lightproof_handler_grammalecte.py", dVars)) #lLineOptions = open(spLang + "/options.txt", "r", encoding="utf-8").readlines() #dialog_bundled.c(dVars["implname"], lLineOptions, hZip, dVars["lang"]) # options dialog - hZip.writestr("pythonpath/Options.py", fileFile("gc_core/py/oxt/Options.py", dVars)) + hZip.writestr("pythonpath/Options.py", helpers.fileFile("gc_core/py/oxt/Options.py", dVars)) hZip.write("gc_core/py/oxt/op_strings.py", "pythonpath/op_strings.py") # options dialog within Writer options panel dVars["xdl_dialog_options"] = createDialogOptionsXDL(dVars) dVars["xcs_options"] = "\n".join([ '' for sOpt in dVars["dOptPython"] ]) dVars["xcu_label_values"] = "\n".join([ '' + dVars["dOptLabel"][sLang]["__optiontitle__"] + '' for sLang in dVars["dOptLabel"] ]) - hZip.writestr("dialog/options_page.xdl", fileFile("gc_core/py/oxt/options_page.xdl", dVars)) - hZip.writestr("dialog/OptionsDialog.xcs", fileFile("gc_core/py/oxt/OptionsDialog.xcs", dVars)) - hZip.writestr("dialog/OptionsDialog.xcu", fileFile("gc_core/py/oxt/OptionsDialog.xcu", dVars)) + hZip.writestr("dialog/options_page.xdl", helpers.fileFile("gc_core/py/oxt/options_page.xdl", dVars)) + hZip.writestr("dialog/OptionsDialog.xcs", helpers.fileFile("gc_core/py/oxt/OptionsDialog.xcs", dVars)) + hZip.writestr("dialog/OptionsDialog.xcu", helpers.fileFile("gc_core/py/oxt/OptionsDialog.xcu", dVars)) hZip.writestr("dialog/" + dVars['lang'] + "_en.default", "") for sLangLbl, dOptLbl in dVars['dOptLabel'].items(): hZip.writestr("dialog/" + dVars['lang'] + "_" + sLangLbl + ".properties", createOptionsLabelProperties(dOptLbl)) ## ADDONS OXT @@ -195,11 +118,11 @@ if os.path.isdir(spLang+'/'+spfSrc): for sf in os.listdir(spLang+'/'+spfSrc): hZip.write(spLang+'/'+spfSrc+"/"+sf, spfDst+"/"+sf) else: if spfSrc.endswith(('.txt', '.py')): - hZip.writestr(spfDst, fileFile(spLang+'/'+spfSrc, dVars)) + hZip.writestr(spfDst, helpers.fileFile(spLang+'/'+spfSrc, dVars)) else: hZip.write(spLang+'/'+spfSrc, spfDst) print() hZip.close() @@ -212,82 +135,10 @@ #subprocess.run(cmd) os.system(cmd) else: print("# Error: path and filename of unopkg not set in config.ini") - -def createOptionsForFirefox (dVars): - sHTML = "" - for sSection, lOpt in dVars['lStructOpt']: - sHTML += '\n
\n

\n' - for lLineOpt in lOpt: - for sOpt in lLineOpt: - sHTML += '

\n' - sHTML += '
\n' - # Creating translation data - dProperties = {} - for sLang in dVars['dOptLabel'].keys(): - dProperties[sLang] = "\n".join( [ "option_" + sOpt + " = " + dVars['dOptLabel'][sLang][sOpt][0].replace(" [!]", " [!]") for sOpt in dVars['dOptLabel'][sLang] ] ) - return sHTML, dProperties - - -def createFirefoxExtension (sLang, dVars): - "create extension for Firefox" - print("Building extension for Firefox") - createCleanFolder("_build/xpi/"+sLang) - dir_util.copy_tree("gc_lang/"+sLang+"/xpi/", "_build/xpi/"+sLang) - dir_util.copy_tree("grammalecte-js", "_build/xpi/"+sLang+"/grammalecte") - sHTML, dProperties = createOptionsForFirefox(dVars) - dVars['optionsHTML'] = sHTML - copyAndFileTemplate("_build/xpi/"+sLang+"/data/about_panel.html", "_build/xpi/"+sLang+"/data/about_panel.html", dVars) - for sLocale in dProperties.keys(): - spfLocale = "_build/xpi/"+sLang+"/locale/"+sLocale+".properties" - if os.path.exists(spfLocale): - copyAndFileTemplate(spfLocale, spfLocale, dProperties) - else: - print("Locale file not found: " + spfLocale) - with cd("_build/xpi/"+sLang): - os.system("jpm xpi") - - -def createOptionsForThunderbird (dVars): - dVars['sXULTabs'] = "" - dVars['sXULTabPanels'] = "" - # dialog options - for sSection, lOpt in dVars['lStructOpt']: - dVars['sXULTabs'] += ' \n' - dVars['sXULTabPanels'] += ' \n \n' - # translation data - for sLang in dVars['dOptLabel'].keys(): - dVars['gc_options_labels_'+sLang] = "\n".join( [ "' for sOpt in dVars['dOptLabel'][sLang] ] ) - return dVars - - -def createThunderbirdExtension (sLang, dVars, spLangPack): - "create extension for Thunderbird" - print("Building extension for Thunderbird") - sExtensionName = dVars['tb_identifier'] + "-v" + dVars['version'] + '.xpi' - spfZip = "_build/" + sExtensionName - hZip = zipfile.ZipFile(spfZip, mode='w', compression=zipfile.ZIP_DEFLATED) - copyGrammalecteJSPackageInZipFile(hZip, spLangPack, dVars['js_binary_dic']) - for spf in ["LICENSE.txt", "LICENSE.fr.txt"]: - hZip.write(spf) - dVars = createOptionsForThunderbird(dVars) - addFolderToZipAndFileFile(hZip, "gc_lang/"+sLang+"/tb", "", dVars, True) - hZip.write("gc_lang/"+sLang+"/xpi/gce_worker.js", "worker/gce_worker.js") - spDict = "gc_lang/"+sLang+"/xpi/data/dictionaries" - for sp in os.listdir(spDict): - if os.path.isdir(spDict+"/"+sp): - hZip.write(spDict+"/"+sp+"/"+sp+".dic", "content/dictionaries/"+sp+"/"+sp+".dic") - hZip.write(spDict+"/"+sp+"/"+sp+".aff", "content/dictionaries/"+sp+"/"+sp+".aff") - hZip.close() - unzip(spfZip, dVars['tb_debug_extension_path']) - def createServerOptions (sLang, dOptData): with open("server_options."+sLang+".ini", "w", encoding="utf-8", newline="\n") as hDst: hDst.write("# Server options. Lang: " + sLang + "\n\n[gc_options]\n") for sSection, lOpt in dOptData["lStructOpt"]: @@ -305,11 +156,11 @@ hZip = zipfile.ZipFile(spfZip, mode='w', compression=zipfile.ZIP_DEFLATED) copyGrammalectePyPackageInZipFile(hZip, spLangPack, dVars['py_binary_dic']) for spf in ["cli.py", "server.py", "bottle.py", "server_options._global.ini", "server_options."+sLang+".ini", \ "README.txt", "LICENSE.txt", "LICENSE.fr.txt"]: hZip.write(spf) - hZip.writestr("setup.py", fileFile("gc_lang/fr/setup.py", dVars)) + hZip.writestr("setup.py", helpers.fileFile("gc_lang/fr/setup.py", dVars)) def copyGrammalectePyPackageInZipFile (hZip, spLangPack, sDicName, sAddPath=""): for sf in os.listdir("grammalecte"): if not os.path.isdir("grammalecte/"+sf): @@ -317,20 +168,10 @@ for sf in os.listdir(spLangPack): if not os.path.isdir(spLangPack+"/"+sf): hZip.write(spLangPack+"/"+sf, sAddPath+spLangPack+"/"+sf) hZip.write("grammalecte/_dictionaries/"+sDicName, sAddPath+"grammalecte/_dictionaries/"+sDicName) - -def copyGrammalecteJSPackageInZipFile (hZip, spLangPack, sDicName, sAddPath=""): - for sf in os.listdir("grammalecte-js"): - if not os.path.isdir("grammalecte-js/"+sf): - hZip.write("grammalecte-js/"+sf, sAddPath+"grammalecte-js/"+sf) - for sf in os.listdir(spLangPack): - if not os.path.isdir(spLangPack+"/"+sf): - hZip.write(spLangPack+"/"+sf, sAddPath+spLangPack+"/"+sf) - hZip.write("grammalecte-js/_dictionaries/"+sDicName, sAddPath+"grammalecte-js/_dictionaries/"+sDicName) - def create (sLang, xConfig, bInstallOXT, bJavaScript): oNow = datetime.datetime.now() print("============== MAKE GRAMMALECTE [{0}] at {1.hour:>2} h {1.minute:>2} min {1.second:>2} s ==============".format(sLang, oNow)) @@ -362,14 +203,14 @@ print() dVars["plugins"] = sCodePlugins ## CREATE GRAMMAR CHECKER PACKAGE spLangPack = "grammalecte/"+sLang - createCleanFolder(spLangPack) + helpers.createCleanFolder(spLangPack) for sf in os.listdir("gc_core/py/lang_core"): if not os.path.isdir("gc_core/py/lang_core/"+sf): - copyAndFileTemplate("gc_core/py/lang_core/"+sf, spLangPack+"/"+sf, dVars) + helpers.copyAndFileTemplate("gc_core/py/lang_core/"+sf, spLangPack+"/"+sf, dVars) print("+ Modules: ", end="") for sf in os.listdir(spLang+"/modules"): if not sf.startswith("gce_"): file_util.copy_file(spLang+"/modules/"+sf, spLangPack) print(sf, end=", ") @@ -400,32 +241,36 @@ # options data struct dVars["dOptJavaScript"] = json.dumps(list(dVars["dOptJavaScript"].items())) # create folder spLangPack = "grammalecte-js/"+sLang - createCleanFolder(spLangPack) + helpers.createCleanFolder(spLangPack) # create files for sf in os.listdir("gc_core/js"): if not os.path.isdir("gc_core/js/"+sf) and sf.startswith("jsex_"): dVars[sf[5:-3]] = open("gc_core/js/"+sf, "r", encoding="utf-8").read() for sf in os.listdir("gc_core/js"): if not os.path.isdir("gc_core/js/"+sf) and not sf.startswith("jsex_"): - copyAndFileTemplate("gc_core/js/"+sf, "grammalecte-js/"+sf, dVars) + helpers.copyAndFileTemplate("gc_core/js/"+sf, "grammalecte-js/"+sf, dVars) open("grammalecte-js/WARNING.txt", "w", encoding="utf-8", newline="\n").write(sWarningMessage) for sf in os.listdir("gc_core/js/lang_core"): if not os.path.isdir("gc_core/js/lang_core/"+sf) and sf.startswith("gc_"): - copyAndFileTemplate("gc_core/js/lang_core/"+sf, spLangPack+"/"+sf, dVars) + helpers.copyAndFileTemplate("gc_core/js/lang_core/"+sf, spLangPack+"/"+sf, dVars) print("+ Modules: ", end="") for sf in os.listdir(spLang+"/modules-js"): if not sf.startswith("gce_"): - copyAndFileTemplate(spLang+"/modules-js/"+sf, spLangPack+"/"+sf, dVars) + helpers.copyAndFileTemplate(spLang+"/modules-js/"+sf, spLangPack+"/"+sf, dVars) print(sf, end=", ") print() - createFirefoxExtension(sLang, dVars) - createThunderbirdExtension(sLang, dVars, spLangPack) + try: + build_module = importlib.import_module("gc_lang."+sLang+".build") + except ImportError: + print("# No complementary builder in folder gc_lang/"+sLang) + else: + build_module.build(sLang, dVars, spLangPack) return dVars['version'] def main (): @@ -453,23 +298,23 @@ dVars = xConfig._sections['args'] # copy gc_core common file in Python now to be able to compile dictionary if required for sf in os.listdir("gc_core/py"): if not os.path.isdir("gc_core/py/"+sf): - copyAndFileTemplate("gc_core/py/"+sf, "grammalecte/"+sf, dVars) + helpers.copyAndFileTemplate("gc_core/py/"+sf, "grammalecte/"+sf, dVars) open("grammalecte/WARNING.txt", "w", encoding="utf-8", newline="\n").write(sWarningMessage) # build data - build_module = None + build_data_module = None if xArgs.build_data: # lang data try: - build_module = importlib.import_module("gc_lang."+sLang+".build_data") + build_data_module = importlib.import_module("gc_lang."+sLang+".build_data") except ImportError: print("# Error. Couldn’t import file build_data.py in folder gc_lang/"+sLang) - if build_module: - build_module.before('gc_lang/'+sLang, dVars, xArgs.javascript) + if build_data_module: + build_data_module.before('gc_lang/'+sLang, dVars, xArgs.javascript) if xArgs.dict or not os.path.exists("grammalecte/_dictionaries"): import grammalecte.dawg as fsa from grammalecte.ibdawg import IBDAWG # fsa builder oDAWG = fsa.DAWG(dVars['lexicon_src'], dVars['lang_name'], dVars['stemming_method']) @@ -479,12 +324,12 @@ if xArgs.javascript: dir_util.mkpath("grammalecte-js/_dictionaries") oDic = IBDAWG(dVars['py_binary_dic']) #oDic.writeAsJSObject("gc_lang/"+sLang+"/modules-js/dictionary.js") oDic.writeAsJSObject("grammalecte-js/_dictionaries/"+dVars['js_binary_dic']) - if build_module: - build_module.after('gc_lang/'+sLang, dVars, xArgs.javascript) + if build_data_module: + build_data_module.after('gc_lang/'+sLang, dVars, xArgs.javascript) # make sVersion = create(sLang, xConfig, xArgs.install, xArgs.javascript, ) # tests @@ -503,11 +348,11 @@ hDst = open("./gc_lang/"+sLang+"/perf_memo.txt", "a", encoding="utf-8", newline="\n") if xArgs.perf_memo else None tests.perf(sVersion, hDst) # Firefox if xArgs.firefox: - with cd("_build/xpi/"+sLang): + with helpers.cd("_build/xpi/"+sLang): os.system("jpm run -b nightly") # Thunderbird if xArgs.thunderbird: os.system("thunderbird -jsconsole -P debug") Index: misc/grammalecte.sublime-syntax ================================================================== --- misc/grammalecte.sublime-syntax +++ misc/grammalecte.sublime-syntax @@ -20,10 +20,14 @@ # Numbers - match: '\b(-)?[0-9.]+\b' scope: constant.numeric + # Bookmarks + - match: '^!!.*|^\[\+\+\].*' + scope: bookmark + # Keywords are if, else. # Note that blackslashes don't need to be escaped within single quoted # strings in YAML. When using single quoted strings, only single quotes # need to be escaped: this is done by using two single quotes next to each # other. Index: misc/grammalecte.tmTheme ================================================================== --- misc/grammalecte.tmTheme +++ misc/grammalecte.tmTheme @@ -53,10 +53,23 @@ foreground #607080 + + name + Bookmark + scope + bookmark + settings + + foreground + #A0F0FF + background + #0050A0 + + name String scope string