Comment: | [core][graphspell][fx][cli] new lexicographer |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk | cli | core | fx | graphspell |
Files: | files | file ages | folders |
SHA3-256: |
4fdd6a933713d643442e24bc83115c08 |
User & Date: | olr on 2020-09-10 15:30:12 |
Other Links: | manifest | tags |
2020-09-10
| ||
18:15 | [fr] ajustements check-in: 6a6ad52cca user: olr tags: trunk, fr | |
15:30 | [core][graphspell][fx][cli] new lexicographer check-in: 4fdd6a9337 user: olr tags: trunk, cli, core, fx, graphspell | |
13:15 | [graphspell][fx] lexicographer update: same code for Python and JavaScript (remove deprecated code) Closed-Leaf check-in: 891500b92a user: olr tags: fx, graphspell, salxg | |
2020-09-09
| ||
11:37 | [fr] add perf_memo.txt file check-in: 88998f6977 user: olr tags: trunk, fr | |
Modified gc_core/js/lang_core/gc_engine.js from [2bae51d547] to [5b16fd7058].
︙ | |||
193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 | 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 | + + - + - + - + - - - - - - + - - + + + + + + + + + + | // parse paragraph try { this.parseText(this.sText, this.sText0, true, 0, sCountry, dOpt, bShowRuleId, bDebug, bContext); } catch (e) { console.error(e); } this.lTokens = null; this.lTokens0 = null; let lParagraphErrors = null; if (bFullInfo) { lParagraphErrors = Array.from(this.dError.values()); this.dSentenceError.clear(); } // parse sentence let sText = this._getCleanText(); let lSentences = []; let oSentence = null; for (let [iStart, iEnd] of text.getSentenceBoundaries(sText)) { try { this.sSentence = sText.slice(iStart, iEnd); this.sSentence0 = this.sText0.slice(iStart, iEnd); this.nOffsetWithinParagraph = iStart; |
︙ | |||
371 372 373 374 375 376 377 | 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 | - + - + | if (this.dTokenPos.gl_get(oToken["nStart"], {}).hasOwnProperty("lMorph")) { oToken["lMorph"] = this.dTokenPos.get(oToken["nStart"])["lMorph"]; } if (this.dTokenPos.gl_get(oToken["nStart"], {}).hasOwnProperty("aTags")) { oToken["aTags"] = this.dTokenPos.get(oToken["nStart"])["aTags"]; } } |
︙ | |||
613 614 615 616 617 618 619 | 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 | - + | } parseGraph (oGraph, sCountry="${country_default}", dOptions=null, bShowRuleId=false, bDebug=false, bContext=false) { // parse graph with tokens from the text and execute actions encountered let lPointer = []; let bTagAndRewrite = false; try { |
︙ | |||
665 666 667 668 669 670 671 | 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 | - - + + - + - - + + - + - - + + - + - - + + - + - + - - + + - - + + | // Suggestion [ option, condition, "-", replacement/suggestion/action, iTokenStart, iTokenEnd, cStartLimit, cEndLimit, bCaseSvty, nPriority, sMessage, iURL ] // TextProcessor [ option, condition, "~", replacement/suggestion/action, iTokenStart, iTokenEnd, bCaseSvty ] // Disambiguator [ option, condition, "=", replacement/suggestion/action ] // Tag [ option, condition, "/", replacement/suggestion/action, iTokenStart, iTokenEnd ] // Immunity [ option, condition, "!", "", iTokenStart, iTokenEnd ] // Test [ option, condition, ">", "" ] if (!sOption || dOptions.gl_get(sOption, false)) { |
︙ | |||
807 808 809 810 811 812 813 | 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 | - - + + - + - - + + | return this._createError(nStart, nEnd, sLineId, sRuleId, sOption, sMessage, lSugg, sURL, bContext); } _createErrorFromTokens (sSugg, nTokenOffset, nLastToken, iFirstToken, nStart, nEnd, sLineId, sRuleId, bCaseSvty, sMsg, sURL, bShowRuleId, sOption, bContext) { // suggestions let lSugg = []; if (sSugg.startsWith("=")) { |
︙ | |||
852 853 854 855 856 857 858 | 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 | - + - + | return oErr; } _expand (sText, nTokenOffset, nLastToken) { let m; while ((m = /\\(-?[0-9]+)/.exec(sText)) !== null) { if (m[1].slice(0,1) == "-") { |
︙ | |||
893 894 895 896 897 898 899 | 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 | - + - + - + - + - + - - + + - + - + - + - + - + + | } _tagAndPrepareTokenForRewriting (sWhat, nTokenRewriteStart, nTokenRewriteEnd, nTokenOffset, nLastToken, bCaseSvty, bDebug) { // text processor: rewrite tokens between <nTokenRewriteStart> and <nTokenRewriteEnd> position if (sWhat === "*") { // purge text if (nTokenRewriteEnd - nTokenRewriteStart == 0) { |
︙ | |||
1011 1012 1013 1014 1015 1016 1017 | 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 | - - + + | delete oToken["sNewValue"]; } } } if (bDebug) { console.log(" TEXT REWRITED: " + this.sSentence); } |
︙ |
Modified gc_core/py/lang_core/gc_engine.py from [31a9f5bc44] to [20a4e92e8f].
︙ | |||
231 232 233 234 235 236 237 | 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 | - + - + + + - - + + - - - - - + - - + + + + + + + + + | def __init__ (self, sText): self.sText = sText self.sText0 = sText self.sSentence = "" self.sSentence0 = "" self.nOffsetWithinParagraph = 0 |
︙ | |||
378 379 380 381 382 383 384 | 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 | - - + + - - + + | self.sText = sText else: self.sSentence = sText def update (self, sSentence, bDebug=False): "update <sSentence> and retokenize" self.sSentence = sSentence |
︙ | |||
549 550 551 552 553 554 555 | 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 | - + | dPointer2 = { "iToken1": iToken1, "iNode": dNode["<>"], "bKeep": True } yield from self._getNextPointers(dToken, dGraph, dPointer2, bDebug) def parseGraph (self, dGraph, sCountry="${country_default}", dOptions=None, bShowRuleId=False, bDebug=False, bContext=False): "parse graph with tokens from the text and execute actions encountered" lPointer = [] bTagAndRewrite = False |
︙ | |||
590 591 592 593 594 595 596 | 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 | - + - + - - + + - + - + - + - - + + - + - + - - + + - - + + | # Suggestion [ option, condition, "-", replacement/suggestion/action, iTokenStart, iTokenEnd, cStartLimit, cEndLimit, bCaseSvty, nPriority, sMessage, iURL ] # TextProcessor [ option, condition, "~", replacement/suggestion/action, iTokenStart, iTokenEnd, bCaseSvty ] # Disambiguator [ option, condition, "=", replacement/suggestion/action ] # Tag [ option, condition, "/", replacement/suggestion/action, iTokenStart, iTokenEnd ] # Immunity [ option, condition, "!", "", iTokenStart, iTokenEnd ] # Test [ option, condition, ">", "" ] if not sOption or dOptions.get(sOption, False): |
︙ | |||
693 694 695 696 697 698 699 | 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 | - + - + - + | if _bWriterError: return self._createErrorForWriter(nStart, nEnd - nStart, sRuleId, sOption, sMessage, lSugg, sURL) return self._createErrorAsDict(nStart, nEnd, sLineId, sRuleId, sOption, sMessage, lSugg, sURL, bContext) def _createErrorFromTokens (self, sSugg, nTokenOffset, nLastToken, iFirstToken, nStart, nEnd, sLineId, sRuleId, bCaseSvty, sMsg, sURL, bShowRuleId, sOption, bContext): # suggestions if sSugg[0:1] == "=": |
︙ | |||
751 752 753 754 755 756 757 | 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 | - + - + | dErr['sBefore'] = self.sText0[max(0,nStart-80):nStart] dErr['sAfter'] = self.sText0[nEnd:nEnd+80] return dErr def _expand (self, sText, nTokenOffset, nLastToken): for m in re.finditer(r"\\(-?[0-9]+)", sText): if m.group(1)[0:1] == "-": |
︙ | |||
780 781 782 783 784 785 786 | 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 | - + - + - + - + - + - + - + - + - + - + + - + - + + + + - + + - + - - + + | return sText[0:m.start(iGroup)] + sNew + sText[m.end(iGroup):] def _tagAndPrepareTokenForRewriting (self, sWhat, nTokenRewriteStart, nTokenRewriteEnd, nTokenOffset, nLastToken, bCaseSvty, bDebug): "text processor: rewrite tokens between <nTokenRewriteStart> and <nTokenRewriteEnd> position" if sWhat == "*": # purge text if nTokenRewriteEnd - nTokenRewriteStart == 0: |
Modified gc_lang/fr/webext/content_scripts/init.js from [d6a977e5a7] to [b54947b0d1].
︙ | |||
340 341 342 343 344 345 346 | 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 | - - + + - - + + | this.send("parseAndSpellcheck", { sText: sText, sCountry: "FR", bDebug: false, bContext: false }, { sDestination: sDestination }); }, parseAndSpellcheck1: function (sText, sDestination, sParagraphId) { this.send("parseAndSpellcheck1", { sText: sText, sCountry: "FR", bDebug: false, bContext: false }, { sDestination: sDestination, sParagraphId: sParagraphId }); }, |
︙ | |||
418 419 420 421 422 423 424 | 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 | - + + + + - - - - - + + + + + + | break; case "parseAndSpellcheck1": if (oInfo.sDestination == "__GrammalectePanel__") { oGrammalecte.oGCPanel.refreshParagraph(oInfo.sParagraphId, result); } break; case "parseFull": |
︙ |
Modified gc_lang/fr/webext/content_scripts/panel_gc.css from [9a73dd19f8] to [89a25fc756].
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | + + - - - - | /* Grammar checker */ div#grammalecte_gc_panel_content { position: absolute; height: 100%; width: 100%; margin: 0; overflow: auto; } div.grammalecte_paragraph_block { margin: 5px 5px 0 5px; background-color: hsl(0, 0%, 96%); border-radius: 2px; } |
︙ | |||
43 44 45 46 47 48 49 50 51 52 53 54 55 56 | 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | + + + + + + + | cursor: pointer; font-family: "Trebuchet MS", "Fira Sans", "Liberation Sans", sans-serif; font-size: 14px; color: hsl(0, 0%, 96%); border-radius: 2px; } div.grammalecte_paragraph_actions .grammalecte_blue { color: hsl(0, 0%, 80%); } div.grammalecte_paragraph_actions .grammalecte_blue:hover { background-color: hsl(210, 50%, 40%); color: hsl(0, 0%, 100%); } div.grammalecte_paragraph_actions .grammalecte_green { color: hsl(0, 0%, 80%); } div.grammalecte_paragraph_actions .grammalecte_green:hover { background-color: hsl(120, 50%, 40%); color: hsl(0, 0%, 100%); } |
︙ |
Modified gc_lang/fr/webext/content_scripts/panel_gc.js from [5158e88aeb] to [6fa57d1aea].
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | + + + | // JavaScript /* jshint esversion:6, -W097 */ /* jslint esversion:6 */ /* global GrammalectePanel, oGrammalecte, oGrammalecteBackgroundPort, showError, window, document, console */ "use strict"; function onGrammalecteGCPanelClick (xEvent) { try { let xElem = xEvent.target; if (xElem.id) { if (xElem.id.startsWith("grammalecte_sugg")) { oGrammalecte.oGCPanel.applySuggestion(xElem.id); } else if (xElem.id === "grammalecte_tooltip_ignore") { oGrammalecte.oGCPanel.ignoreError(xElem.id); } else if (xElem.id.startsWith("grammalecte_analysis")) { oGrammalecte.oGCPanel.sendParagraphToGrammaticalAnalysis(parseInt(xElem.dataset.para_num, 10)); } else if (xElem.id.startsWith("grammalecte_check")) { oGrammalecte.oGCPanel.recheckParagraph(parseInt(xElem.dataset.para_num, 10)); } else if (xElem.id.startsWith("grammalecte_hide")) { xElem.parentNode.parentNode.style.display = "none"; } else if (xElem.id.startsWith("grammalecte_err") && xElem.className !== "grammalecte_error_corrected" && xElem.className !== "grammalecte_error_ignored") { |
︙ | |||
62 63 64 65 66 67 68 69 70 71 72 73 74 75 | 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 | + + + + + + + + + + + + | this.oTextControl = null; this.nLastResult = 0; this.iLastEditedParagraph = -1; this.nParagraph = 0; // Lexicographer this.nLxgCount = 0; this.xLxgPanelContent = oGrammalecte.createNode("div", {id: "grammalecte_lxg_panel_content"}); this.xLxgInputBlock = oGrammalecte.createNode("div", {id: "grammalecte_lxg_input_block"}); this.xLxgInput = oGrammalecte.createNode("div", {id: "grammalecte_lxg_input", lang: "fr", contentEditable: "true"}); this.xLxgInputButton = oGrammalecte.createNode("div", {id: "grammalecte_lxg_input_button", textContent: "Analyse grammaticale"}); this.xLxgInputButton.addEventListener("click", () => { this.grammaticalAnalysis(); }, false); this.xLxgInputButton2 = oGrammalecte.createNode("div", {id: "grammalecte_lxg_input_button", textContent: "Analyse lexicale"}); this.xLxgInputButton2.addEventListener("click", () => { this.getListOfTokens(); }, false); this.xLxgInputBlock.appendChild(this.xLxgInput); this.xLxgInputBlock.appendChild(this.xLxgInputButton); this.xLxgInputBlock.appendChild(this.xLxgInputButton2); this.xLxgPanelContent.appendChild(this.xLxgInputBlock); this.xLxgResultZone = oGrammalecte.createNode("div", {id: "grammalecte_lxg_result_zone"}); this.xLxgPanelContent.appendChild(this.xLxgResultZone); this.xPanelContent.appendChild(this.xLxgPanelContent); // Conjugueur this.xConjPanelContent = oGrammalecte.createNode("div", {id: "grammalecte_conj_panel_content"}); this.xConjPanelContent.innerHTML = sGrammalecteConjugueurHTML; // @Reviewers: sGrammalecteConjugueurHTML is a const value defined in <content_scripts/html_src.js> this.xPanelContent.appendChild(this.xConjPanelContent); this.sVerb = ""; this.bListenConj = false; |
︙ | |||
110 111 112 113 114 115 116 | 125 126 127 128 129 130 131 132 133 134 135 136 137 138 | - - - - | oGrammalecte.bAutoRefresh = this.bAutoRefresh; browser.storage.local.set({"autorefresh_option": this.bAutoRefresh}); this.setAutoRefreshButton(); } this.xLxgButton.onclick = () => { if (!this.bWorking) { this.showLexicographer(); |
︙ | |||
236 237 238 239 240 241 242 | 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 | - + + - - - + + + | this.oTextControl.clear(); } addParagraphResult (oResult) { try { this.resetTimer(); if (oResult && (oResult.sParagraph.trim() !== "" || oResult.aGrammErr.length > 0 || oResult.aSpellErr.length > 0)) { |
︙ | |||
528 529 530 531 532 533 534 | 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 | - - + + + - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - - + + + + + - + + + + - + - - + + + + - - - - - - - - - - - + + + + + + + + + + + + + + - - - - - - | } } // Lexicographer clearLexicographer () { this.nLxgCount = 0; |
︙ |
Modified gc_lang/fr/webext/content_scripts/panel_lxg.css from [ae4f6ddf8d] to [b335aa8c9f].
1 2 3 4 5 6 7 8 9 10 11 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + + + + + + + + + + + + + + - + - + | /* Lexicographer */ div#grammalecte_lxg_panel_content { display: none; position: absolute; height: 100%; width: 100%; font-size: 13px; } div#grammalecte_lxg_input_block { padding: 10px; /*background-color: hsl(210, 50%, 95%);*/ /*border-bottom: solid 1px hsl(210, 0%, 90%);*/ text-align: right; } div#grammalecte_lxg_result_zone { } div#grammalecte_lxg_input { min-height: 100px; padding: 10px; background-color: hsl(210, 0%, 100%); border: solid 1px hsl(210, 20%, 80%); border-radius: 3px; font-family: "Courier New", Courier, "Lucida Sans Typewriter", "Lucida Typewriter", monospace; text-align: left; } div#grammalecte_lxg_input_button { display: inline-block; margin: 0 10px 0 0; padding: 3px 10px; background-color: hsl(210, 50%, 50%); color: hsl(210, 50%, 98%); text-align: center; cursor: pointer; border-radius: 0 0 3px 3px; } |
︙ | |||
40 41 42 43 44 45 46 | 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 | - - - + + + | div.grammalecte_lxg_token_block { margin: 4px 0; } div.grammalecte_lxg_token_subblock { margin: 2px 0 2px 20px; padding: 5px; |
︙ | |||
83 84 85 86 87 88 89 90 91 92 93 94 95 96 | 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 | + + + + + + | font-family: "Trebuchet MS", "Fira Sans", "Ubuntu Condensed", "Liberation Sans", sans-serif; color: hsl(0, 0%, 0%); } div.grammalecte_lxg_morph_elem { font-family: "Trebuchet MS", "Fira Sans", "Ubuntu Condensed", "Liberation Sans", sans-serif; color: hsl(0, 0%, 0%); } div.grammalecte_lxg_other_tags { padding-left: 20px; font-family: "Trebuchet MS", "Fira Sans", "Ubuntu Condensed", "Liberation Sans", sans-serif; color: hsl(0, 0%, 50%); } div.grammalecte_lxg_token_LOC { background-color: hsla(150, 50%, 30%, 1); } div.grammalecte_lxg_token_WORD { background-color: hsla(150, 50%, 50%, 1); } div.grammalecte_lxg_token_WORD_ELIDED { |
︙ |
Modified gc_lang/fr/webext/gce_worker.js from [e351d5e6fd] to [879c183120].
︙ | |||
227 228 229 230 231 232 233 | 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 | - + - - + - - - + + - - - - + + + + + - + | function parseAndSpellcheck1 (sParagraph, sCountry, bDebug, bContext, oInfo={}) { sParagraph = sParagraph.replace(//g, "").normalize("NFC"); let aGrammErr = gc_engine.parse(sParagraph, sCountry, bDebug, null, bContext); let aSpellErr = oSpellChecker.parseParagraph(sParagraph); postMessage(createResponse("parseAndSpellcheck1", {sParagraph: sParagraph, aGrammErr: aGrammErr, aSpellErr: aSpellErr}, oInfo, true)); } |
︙ |
Modified grammalecte-cli.py from [0e5de0a660] to [4b02966a37].
︙ | |||
128 129 130 131 132 133 134 135 136 137 138 139 140 141 | 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 | + + + + | else: vSugg = m.group(2)[1:] return (nError, cAction, vSugg) def main (): "launch the CLI (command line interface)" if sys.version < "3.7": print("Python 3.7+ required") return xParser = argparse.ArgumentParser() xParser.add_argument("-f", "--file", help="parse file (UTF-8 required!) [on Windows, -f is similar to -ff]", type=str) xParser.add_argument("-ff", "--file_to_file", help="parse file (UTF-8 required!) and create a result file (*.res.txt)", type=str) xParser.add_argument("-iff", "--interactive_file_to_file", help="parse file (UTF-8 required!) and create a result file (*.res.txt)", type=str) xParser.add_argument("-owe", "--only_when_errors", help="display results only when there are errors", action="store_true") xParser.add_argument("-j", "--json", help="generate list of errors in JSON (only with option --file or --file_to_file)", action="store_true") xParser.add_argument("-cl", "--concat_lines", help="concatenate lines not separated by an empty paragraph (only with option --file or --file_to_file)", action="store_true") |
︙ | |||
334 335 336 337 338 339 340 | 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 | - + - + - - - - - - - - + + + + + + + + + + + + + + + + + | # reload (todo) pass elif sText.startswith("$"): for sParagraph in txt.getParagraph(sText[1:]): if xArgs.textformatter: sParagraph = oTextFormatter.formatText(sParagraph) lParagraphErrors, lSentences = oGrammarChecker.gce.parse(sParagraph, bDebug=xArgs.debug, bFullInfo=True) |
︙ |
Modified graphspell-js/ibdawg.js from [544f660d8a] to [80e916efdb].
︙ | |||
309 310 311 312 313 314 315 316 317 318 319 320 321 322 | 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 | + + + | } } return Boolean(this._convBytesToInteger(this.byDic.slice(iAddr, iAddr+this.nBytesArc)) & this._finalNodeMask); } getMorph (sWord) { // retrieves morphologies list, different casing allowed if (!sWord) { return []; } sWord = str_transform.spellingNormalization(sWord); let l = this.morph(sWord); if (sWord[0].gl_isUpperCase()) { l.push(...this.morph(sWord.toLowerCase())); if (sWord.gl_isUpperCase() && sWord.length > 1) { l.push(...this.morph(sWord.gl_toCapitalize())); } |
︙ |
Modified graphspell-js/lexgraph_fr.js from [9858773647] to [816b039883].
︙ | |||
162 163 164 165 166 167 168 | 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 | - - - + + + + + + | [':e', [" épicène", "épicène"]], [':m', [" masculin", "masculin"]], [':f', [" féminin", "féminin"]], [':s', [" singulier", "singulier"]], [':p', [" pluriel", "pluriel"]], [':i', [" invariable", "invariable"]], |
︙ | |||
209 210 211 212 213 214 215 | 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 | - + - - + + - - - - - - + + + + + + | [':Oi', [" pronom indéfini,", "Pronom indéfini"]], [':On', [" pronom indéfini négatif,", "Pronom indéfini négatif"]], [':Ot', [" pronom interrogatif,", "Pronom interrogatif"]], [':Or', [" pronom relatif,", "Pronom relatif"]], [':Ow', [" pronom adverbial,", "Pronom adverbial"]], [':Os', [" pronom personnel sujet,", "Pronom personnel sujet"]], [':Oo', [" pronom personnel objet,", "Pronom personnel objet"]], |
︙ | |||
275 276 277 278 279 280 281 | 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 | - - - - - - - - - - + + + + + + + + + + - - - - + + + + - - - - - - - - - - - + + + + + + + + + + + + + + + - - + + - - - + + + - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - + + + + - - - - + + + + - - | ['i', " intransitive"], ['n', " transitive indirecte"], ['t', " transitive directe"], ['p', " pronominale"], ['m', " impersonnelle"], ]), |
︙ | |||
365 366 367 368 369 370 371 | 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 | - - - - - - + + - - - - - - - - + - + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - + - - - - - + - - - - - + - - - - - + - - - - - + - - - - - + - - - - - + - - - - - + - - - - - - + - - - - - + - - - - - + - - - - - + - - - - - + - - - - - - + + + + + + + + + + - - - + + + - - - - + - - - - - - - - - - - - - + + - - - - + - - - - - - - + + + - - - - - - + + + + - - - - + + + - - - - + + + + - - + + + - - - - + - + + + - - - - + - - - - - - - + - - - - - - + - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | ['>', "supérieur à"], ['⩽', "inférieur ou égal à"], ['⩾', "supérieur ou égal à"], ['%', "signe de pourcentage"], ['‰', "signe pour mille"], ]), |
Modified graphspell-js/spellchecker.js from [be4f6fe289] to [a94325f4c6].
︙ | |||
130 131 132 133 134 135 136 | 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 | + + + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | // Lexicographer loadLexicographer (sLangCode) { // load default suggestion module for <sLangCode> if (typeof(process) !== 'undefined') { this.lexicographer = require(`./lexgraph_${sLangCode}.js`); } else if (self && self.hasOwnProperty("lexgraph_"+sLangCode)) { // self is the Worker this.lexicographer = self["lexgraph_"+sLangCode]; } } |
︙ |
Modified graphspell/ibdawg.py from [f1a1c3c7ab] to [e07922ff50].
︙ | |||
297 298 299 300 301 302 303 304 305 306 307 308 309 310 | 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 | + + | iAddr = self._lookupArcNode(self.dChar[c], iAddr) if iAddr is None: return False return bool(int.from_bytes(self.byDic[iAddr:iAddr+self.nBytesArc], byteorder='big') & self._finalNodeMask) def getMorph (self, sWord): "retrieves morphologies list, different casing allowed" if not sWord: return [] sWord = st.spellingNormalization(sWord) l = self.morph(sWord) if sWord[0:1].isupper(): l.extend(self.morph(sWord.lower())) if sWord.isupper() and len(sWord) > 1: l.extend(self.morph(sWord.capitalize())) return l |
︙ |
Modified graphspell/lexgraph_fr.py from [06640299ad] to [f36c3bc666].
1 2 3 4 5 6 7 8 9 10 11 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | - + + | """ Lexicographer for the French language """ # Note: # This mode must contains at least: # <dSugg> : a dictionary for default suggestions. # <bLexicographer> : a boolean False # if the boolean is True, 4 functions are required: # split(sWord) -> returns a list of string (that will be analyzed) # analyze(sWord) -> returns a string with the meaning of word |
︙ | |||
168 169 170 171 172 173 174 | 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 | - - - + + + + + + | ':e': (" épicène", "épicène"), ':m': (" masculin", "masculin"), ':f': (" féminin", "féminin"), ':s': (" singulier", "singulier"), ':p': (" pluriel", "pluriel"), ':i': (" invariable", "invariable"), |
︙ | |||
215 216 217 218 219 220 221 | 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 | - + - - + + - - - - - - + + + + + + | ':Oi': (" pronom indéfini,", "Pronom indéfini"), ':On': (" pronom indéfini négatif,", "Pronom indéfini négatif"), ':Ot': (" pronom interrogatif,", "Pronom interrogatif"), ':Or': (" pronom relatif,", "Pronom relatif"), ':Ow': (" pronom adverbial,", "Pronom adverbial"), ':Os': (" pronom personnel sujet,", "Pronom personnel sujet"), ':Oo': (" pronom personnel objet,", "Pronom personnel objet"), |
︙ | |||
270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 | 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 | + + + - - + + | 'puisqu’': "(puisque), conjonction de subordination", 'quoiqu’': "(quoique), conjonction de subordination", 'jusqu’': "(jusque), préposition", '-je': " pronom personnel sujet, 1ʳᵉ pers. sing.", '-tu': " pronom personnel sujet, 2ᵉ pers. sing.", '-il': " pronom personnel sujet, 3ᵉ pers. masc. sing.", '-iel': " pronom personnel sujet, 3ᵉ pers. sing.", '-on': " pronom personnel sujet, 3ᵉ pers. sing. ou plur.", '-elle': " pronom personnel sujet, 3ᵉ pers. fém. sing.", '-t-il': " “t” euphonique + pronom personnel sujet, 3ᵉ pers. masc. sing.", '-t-on': " “t” euphonique + pronom personnel sujet, 3ᵉ pers. sing. ou plur.", '-t-elle': " “t” euphonique + pronom personnel sujet, 3ᵉ pers. fém. sing.", '-t-iel': " “t” euphonique + pronom personnel sujet, 3ᵉ pers. sing.", '-nous': " pronom personnel sujet/objet, 1ʳᵉ pers. plur. ou COI (à nous), plur.", '-vous': " pronom personnel sujet/objet, 2ᵉ pers. plur. ou COI (à vous), plur.", '-ils': " pronom personnel sujet, 3ᵉ pers. masc. plur.", '-elles': " pronom personnel sujet, 3ᵉ pers. masc. plur.", '-iels': " pronom personnel sujet, 3ᵉ pers. plur.", |
︙ | |||
322 323 324 325 326 327 328 329 330 331 332 333 334 335 | 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | "-t’y": " (te) pronom personnel objet + (y) pronom adverbial", "-s’y": " (se) pronom personnel objet + (y) pronom adverbial", '-en': " pronom adverbial", "-m’en": " (me) pronom personnel objet + (en) pronom adverbial", "-t’en": " (te) pronom personnel objet + (en) pronom adverbial", "-s’en": " (se) pronom personnel objet + (en) pronom adverbial", '.': "point", '·': "point médian", '…': "points de suspension", ':': "deux-points", ';': "point-virgule", ',': "virgule", '?': "point d’interrogation", '!': "point d’exclamation", '(': "parenthèse ouvrante", ')': "parenthèse fermante", '[': "crochet ouvrant", ']': "crochet fermant", '{': "accolade ouvrante", '}': "accolade fermante", '-': "tiret", '—': "tiret cadratin", '–': "tiret demi-cadratin", '«': "guillemet ouvrant (chevrons)", '»': "guillemet fermant (chevrons)", '“': "guillemet ouvrant double", '”': "guillemet fermant double", '‘': "guillemet ouvrant", '’': "guillemet fermant", '"': "guillemets droits (déconseillé en typographie)", '/': "signe de la division", '+': "signe de l’addition", '*': "signe de la multiplication", '=': "signe de l’égalité", '<': "inférieur à", '>': "supérieur à", '⩽': "inférieur ou égal à", '⩾': "supérieur ou égal à", '%': "signe de pourcentage", '‰': "signe pour mille" } _zElidedPrefix = re.compile("(?i)^([ldmtsnjcç]|lorsqu|presqu|jusqu|puisqu|quoiqu|quelqu|qu)[’'‘`ʼ]([\\w-]+)") _zCompoundWord = re.compile("(?i)(\\w+)(-(?:(?:les?|la)-(?:moi|toi|lui|[nv]ous|leur)|t-(?:il|elle|on)|y|en|[mts]’(?:y|en)|les?|l[aà]|[mt]oi|leur|lui|je|tu|ils?|elles?|on|[nv]ous|ce))$") _zTag = re.compile("[:;/][\\w*][^:;/]*") |
︙ | |||
354 355 356 357 358 359 360 | 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 | - + + + - + - - - + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | "return meaning of <sWord> if found else an empty string" sWord = sWord.lower() if sWord in _dValues: return _dValues[sWord] return "" |
Modified graphspell/spellchecker.py from [b9cca64fbd] to [0ef2e9e17a].
︙ | |||
96 97 98 99 100 101 102 | 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 | - + | self.bCommunityDic = False def deactivatePersonalDictionary (self): "deactivate personal dictionary" self.bPersonalDic = False |
︙ | |||
118 119 120 121 122 123 124 | 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 | - + + + + + + + + + + + + + + + + + + + + + + | for sElem in self.lexicographer.split(sWord): if sElem: lMorph = self.getMorph(sElem) sLex = self.lexicographer.analyze(sElem) if sLex: aRes = [ (" | ".join(lMorph), sLex) ] else: |
︙ | |||
231 232 233 234 235 236 237 | 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 | - + | if sWord not in self._dLemmas: self.getMorph(sWord) return self._dLemmas[sWord] return { s[1:s.find("/")] for s in self.getMorph(sWord) } def suggest (self, sWord, nSuggLimit=10): "generator: returns 1, 2 or 3 lists of suggestions" |
︙ |