From 9c69cd737566b93801c958987556b7b2ecb3e76c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A1szl=C3=B3=20N=C3=A9meth?= Date: Mon, 5 Dec 2011 19:18:07 +0100 Subject: [PATCH] English sentence checking --- dictionaries/en/Lightproof.py | 410 ++++++++++++++++++++ dictionaries/en/Linguistic.xcu | 18 + dictionaries/en/README_lightproof_en.txt | 3 + dictionaries/en/description.xml | 2 +- dictionaries/en/dialog/OptionsDialog.xcs | 74 ++++ dictionaries/en/dialog/OptionsDialog.xcu | 37 ++ dictionaries/en/dialog/en.xdl | 26 ++ dictionaries/en/dialog/en_en_US.properties | 37 ++ dictionaries/en/makefile.mk | 14 +- dictionaries/en/manifest.xml | 9 + dictionaries/en/pythonpath/lightproof_en.py | 1 + .../en/pythonpath/lightproof_handler_en.py | 121 ++++++ dictionaries/en/pythonpath/lightproof_impl_en.py | 6 + dictionaries/en/pythonpath/lightproof_opts_en.py | 4 + 14 files changed, 760 insertions(+), 2 deletions(-) create mode 100644 dictionaries/en/Lightproof.py create mode 100644 dictionaries/en/Linguistic.xcu create mode 100644 dictionaries/en/README_lightproof_en.txt create mode 100644 dictionaries/en/dialog/OptionsDialog.xcs create mode 100644 dictionaries/en/dialog/OptionsDialog.xcu create mode 100644 dictionaries/en/dialog/en.xdl create mode 100644 dictionaries/en/dialog/en_en_US.default create mode 100644 dictionaries/en/dialog/en_en_US.properties create mode 100644 dictionaries/en/pythonpath/lightproof_en.py create mode 100644 dictionaries/en/pythonpath/lightproof_handler_en.py create mode 100644 dictionaries/en/pythonpath/lightproof_impl_en.py create mode 100644 dictionaries/en/pythonpath/lightproof_opts_en.py diff --git a/dictionaries/en/Lightproof.py b/dictionaries/en/Lightproof.py new file mode 100644 index 0000000..a6b669c --- /dev/null +++ b/dictionaries/en/Lightproof.py @@ -0,0 +1,410 @@ +# -*- encoding: UTF-8 -*- +# Lightproof grammar checker for LibreOffice and OpenOffice.org +# http://launchpad.net/lightproof +# version 1.4.3 (2011-12-05) +# +# 2009-2011 (c) László Németh (nemeth at numbertext org), license: MPL 1.1 / GPLv3+ / LGPLv3+ + +import uno, unohelper, sys, traceback, re +from lightproof_impl_en import locales +from lightproof_impl_en import pkg +import lightproof_handler_en +from string import join + +from com.sun.star.linguistic2 import XProofreader, XSupportedLocales +from com.sun.star.linguistic2 import ProofreadingResult, SingleProofreadingError +from com.sun.star.lang import XServiceInfo, XServiceName, XServiceDisplayName +from com.sun.star.lang import Locale +from com.sun.star.text.TextMarkupType import PROOFREADING + +# loaded rules +langrule = {} +# ignored rules +ignore = {} + +# cache for morphogical analyses +analyses = {} +stems = {} +suggestions = {} + +# assign Calc functions +calcfunc = None + +# check settings +def option(lang, opt): + return lightproof_handler_en.get_option(lang.Language + "_" + lang.Country, opt) + +# filtering affix fields (ds, is, ts etc.) +def onlymorph(st): + if st != None: + st = re.sub(r"^.*(st:|po:)", r"\1", st) # keep last word part + st = re.sub(r"\b(?=[dit][sp]:)","@", st) # and its affixes + st = re.sub(r"(?" + word + "", rLoc, ()) + if not x: + return None + t = x.getAlternatives() + if not t: + t = [""] + analyses[word] = t[0] + a = analyses[word].split("")[:-1] + result = None + p = re.compile(pattern) + for i in a: + if onlyaffix: + i = onlymorph(i) + result = p.search(i) + if result: + result = result.group(0) + if not all: + return result + elif all: + return None + return result + +def morph(rLoc, word, pattern, all=True): + return _morph(rLoc, word, pattern, all, False) + +def affix(rLoc, word, pattern, all=True): + return _morph(rLoc, word, pattern, all, True) + +def spell(rLoc, word): + if word == None: + return None + return spellchecker.isValid(word, rLoc, ()) + +# get the tuple of the stem of the word or an empty array +def stem(rLoc, word): + global stems + if word == None: + return [] + if not word in stems: + x = spellchecker.spell(u"" + word + "", rLoc, ()) + if not x: + return [] + t = x.getAlternatives() + if not t: + t = [] + stems[word] = list(t) + return stems[word] + +# get the tuple of the morphological generation of a word or an empty array +def generate(rLoc, word, example): + if word == None: + return [] + x = spellchecker.spell(u"" + word + "" + example + "", rLoc, ()) + if not x: + return [] + t = x.getAlternatives() + if not t: + t = [] + return list(t) + +# get suggestions +def suggest(rLoc, word): + global suggestions + if word == None: + return word + if word not in suggestions: + x = spellchecker.spell("_" + word, rLoc, ()) + if not x: + return word + t = x.getAlternatives() + suggestions[word] = join(t, "\n") + return suggestions[word] + +# get the nth word of the input string or None +def word(s, n): + a = re.match("(?u)( [-.\w%]+){" + str(n-1) + "}( [-.\w%]+)", s) + if not a: + return None + return a.group(2)[1:] + +# get the (-)nth word of the input string or None +def wordmin(s, n): + a = re.search("(?u)([-.\w%]+ )([-.\w%]+ ){" + str(n-1) + "}$", s) + if not a: + return None + return a.group(1)[:-1] + +def calc(funcname, par): + global calcfunc + global SMGR + if calcfunc == None: + calcfunc = SMGR.createInstance( "com.sun.star.sheet.FunctionAccess") + if calcfunc == None: + return None + return calcfunc.callFunction(funcname, par) + +def proofread( nDocId, TEXT, LOCALE, nStartOfSentencePos, nSuggestedSentenceEndPos, rProperties ): + global ignore + aErrs = [] + s = TEXT[nStartOfSentencePos:nSuggestedSentenceEndPos] + for i in get_rule(LOCALE): + if i[0] and not str(i[0]) in ignore: + for m in i[0].finditer(s): + if not i[3] or eval(i[3]): + aErr = uno.createUnoStruct( "com.sun.star.linguistic2.SingleProofreadingError" ) + aErr.nErrorStart = nStartOfSentencePos + m.start(0) # nStartOfSentencePos + aErr.nErrorLength = m.end(0) - m.start(0) + aErr.nErrorType = PROOFREADING + aErr.aRuleIdentifier = str(i[0]) + iscap = (i[4] and m.group(0)[0:1].isupper()) + if i[1][0:1] == "=": + aErr.aSuggestions = tuple(cap(eval(i[1][1:]).split("\n"), iscap, LOCALE)) + else: + aErr.aSuggestions = tuple(cap(m.expand(i[1]).split("\n"), iscap, LOCALE)) + comment = i[2] + if comment[0:1] == "=": + comment = eval(comment[1:]) + aErr.aShortComment = comment.split("\n")[0] + aErr.aFullComment = comment.split("\n")[-1] + aErr.aProperties = () + aErrs = aErrs + [aErr] + return tuple(aErrs) + +def cap(a, iscap, rLoc): + if iscap: + for i in range(0, len(a)): + if a[i][0:1] == "i": + if rLoc.Language == "tr" or rLoc.Language == "az": + a[i] = u"\u0130" + a[i][1:] + elif a[i][1:2] == "j" and rLoc.Language == "nl": + a[i] = "IJ" + a[i][2:] + else: + a[i] = "I" + a[i][1:] + else: + a[i] = a[i].capitalize() + return a + +def get_rule(rLocale): + module = rLocale.Language + if rLocale.Country != "": + module = module + "_" + rLocale.Country + try: + return langrule[module] + except: + try: + module = rLocale.Language + return langrule[module] + except: + try: + d = __import__("lightproof_" + pkg) + except: + print "Error: missing language data: " + module + return None + # compile regular expressions + for i in d.dic: + try: + if re.compile("[(][?]iu[)]").match(i[0]): + i += [True] + i[0] = re.sub("[(][?]iu[)]", "(?u)", i[0]) + else: + i += [False] + i[0] = re.compile(i[0]) + except: + print "Lightproof: bad rule -- ", i[0] + i[0] = None + langrule[module] = d.dic + return langrule[module] + +class Lightproof( unohelper.Base, XProofreader, XServiceInfo, XServiceName, XServiceDisplayName, XSupportedLocales): + + def __init__( self, ctx, *args ): + global spellchecker + global SMGR + self.ctx = ctx + self.ServiceName = "com.sun.star.linguistic2.Proofreader" + self.ImplementationName = "org.openoffice.comp.pyuno.Lightproof." + pkg + self.SupportedServiceNames = (self.ServiceName, ) + self.locales = [] + for i in locales: + l = locales[i] + self.locales += [Locale(l[0], l[1], l[2])] + self.locales = tuple(self.locales) + currentContext = uno.getComponentContext() + SMGR = currentContext.ServiceManager + spellchecker = SMGR.createInstanceWithContext("com.sun.star.linguistic2.SpellChecker", currentContext) + lightproof_handler_en.load(currentContext) + + # XServiceName method implementations + def getServiceName(self): + return self.ImplementationName + + # XServiceInfo method implementations + def getImplementationName (self): + return self.ImplementationName + + def supportsService(self, ServiceName): + return (ServiceName in self.SupportedServiceNames) + + def getSupportedServiceNames (self): + return self.SupportedServiceNames + + # XSupportedLocales + def hasLocale(self, aLocale): + if aLocale in self.locales: + return True + for i in self.locales: + if (i.Country == aLocale.Country or i.Country == "") and aLocale.Language == i.Language: + return True + return False + + def getLocales(self): + return self.locales + + # XProofreader + def isSpellChecker(self): + return False + + def doProofreading(self, nDocId, rText, rLocale, nStartOfSentencePos, \ + nSuggestedSentenceEndPos, rProperties): + aRes = uno.createUnoStruct( "com.sun.star.linguistic2.ProofreadingResult" ) + aRes.aDocumentIdentifier = nDocId + aRes.aText = rText + aRes.aLocale = rLocale + aRes.nStartOfSentencePosition = nStartOfSentencePos + aRes.nStartOfNextSentencePosition = nSuggestedSentenceEndPos + l = rText[nSuggestedSentenceEndPos:nSuggestedSentenceEndPos+1] + while l == " ": + aRes.nStartOfNextSentencePosition = aRes.nStartOfNextSentencePosition + 1 + l = rText[aRes.nStartOfNextSentencePosition:aRes.nStartOfNextSentencePosition+1] + if aRes.nStartOfNextSentencePosition == nSuggestedSentenceEndPos and l!="": + aRes.nStartOfNextSentencePosition = nSuggestedSentenceEndPos + 1 + aRes.nBehindEndOfSentencePosition = aRes.nStartOfNextSentencePosition + + try: + aRes.aErrors = proofread( nDocId, rText, rLocale, \ + nStartOfSentencePos, aRes.nBehindEndOfSentencePosition, rProperties) + except: + traceback.print_exc(file=sys.stdout) + aRes.aErrors = () + aRes.aProperties = () + aRes.xProofreader = self + return aRes + + def ignoreRule(self, rid, aLocale): + global ignore + ignore[rid] = 1 + + def resetIgnoreRules(self): + global ignore + ignore = {} + + # XServiceDisplayName + def getServiceDisplayName(self, aLocale): + return "Lightproof Grammar Checker (" + pkg + ")" + +g_ImplementationHelper = unohelper.ImplementationHelper() +g_ImplementationHelper.addImplementation( Lightproof, \ + "org.openoffice.comp.pyuno.Lightproof." + pkg, + ("com.sun.star.linguistic2.Proofreader",),) + +g_ImplementationHelper.addImplementation( lightproof_handler_en.LightproofOptionsEventHandler, \ + "org.openoffice.comp.pyuno.LightproofOptionsEventHandler." + pkg, + ("com.sun.star.awt.XContainerWindowEventHandler",),) +# pattern matching for common English abbreviations +abbrev = re.compile("(?i)\\b([a-z]|acct|approx|appt|apr|apt|assoc|asst|aug|ave|avg|co(nt|rp)?|ct|dec|defn|dept|dr|eg|equip|esp|est|etc|excl|ext|feb|fri|ft|govt?|hrs?|ib(id)?|ie|in(c|t)?|jan|jr|jul|lit|ln|mar|max|mi(n|sc)?|mon|Mrs?|mun|natl?|neg?|no(rm|s|v)?|nw|obj|oct|org|orig|pl|pos|prev|proj|psi|qty|rd|rec|rel|reqd?|resp|rev|sat|sci|se(p|pt)?|spec(if)?|sq|sr|st|subj|sun|sw|temp|thurs|tot|tues|univ|var|vs)\\.") + + +punct = { "?": "question mark", "!": "exclamation mark", + ",": "comma", ":": "colon", ";": "semicolon", + "(": "opening parenthesis", ")": "closing parenthesis", + "[": "opening square bracket", "]": "closing square bracket", + u"\u201c": "opening quotation mark", u"\u201d": "closing quotation mark"} + + +aA = set(["eucalypti", "eucalyptus", "Eucharist", "Eucharistic", +"euchre", "euchred", "euchring", "Euclid", "euclidean", "Eudora", +"eugene", "Eugenia", "eugenic", "eugenically", "eugenicist", +"eugenicists", "eugenics", "Eugenio", "eukaryote", "Eula", "eulogies", +"eulogist", "eulogists", "eulogistic", "eulogized", "eulogizer", +"eulogizers", "eulogizing", "eulogy", "eulogies", "Eunice", "eunuch", +"eunuchs", "Euphemia", "euphemism", "euphemisms", "euphemist", +"euphemists", "euphemistic", "euphemistically", "euphonious", +"euphoniously", "euphonium", "euphony", "euphoria", "euphoric", +"Euphrates", "euphuism", "Eurasia", "Eurasian", "Eurasians", "eureka", +"eurekas", "eurhythmic", "eurhythmy", "Euridyce", "Euripides", "euripus", +"Euro", "Eurocentric", "Euroclydon", "Eurocommunism", "Eurocrat", +"eurodollar", "Eurodollar", "Eurodollars", "Euromarket", "Europa", +"Europe", "European", "Europeanisation", "Europeanise", "Europeanised", +"Europeanization", "Europeanize", "Europeanized", "Europeans", "europium", +"Eurovision", "Eustace", "Eustachian", "Eustacia", "euthanasia", +"Ewart", "ewe", "Ewell", "ewer", "ewers", "Ewing", "once", "one", +"oneness", "ones", "oneself", "onetime", "oneway", "oneyear", "u", +"U", "UART", "ubiquitous", "ubiquity", "Udale", "Udall", "UEFA", +"Uganda", "Ugandan", "ugric", "UK", "ukase", "Ukraine", "Ukrainian", +"Ukrainians", "ukulele", "Ula", "ululated", "ululation", "Ulysses", +"UN", "unanimity", "unanimous", "unanimously", "unary", "Unesco", +"UNESCO", "UNHCR", "uni", "unicameral", "unicameralism", "Unicef", +"UNICEF", "unicellular", "Unicode", "unicorn", "unicorns", "unicycle", +"unicyclist", "unicyclists", "unidimensional", "unidirectional", +"unidirectionality", "unifiable", "unification", "unified", "unifier", +"unifilar", "uniform", "uniformally", "uniformed", "uniformer", +"uniforming", "uniformisation", "uniformise", "uniformitarian", +"uniformitarianism", "uniformity", "uniformly", "uniformness", "uniforms", +"unify", "unifying", "unijugate", "unilateral", "unilateralisation", +"unilateralise", "unilateralism", "unilateralist", "unilaterally", +"unilinear", "unilingual", "uniliteral", "uniliteralism", "uniliteralist", +"unimodal", "union", "unionism", "unionist", "unionists", "unionisation", +"unionise", "unionised", "unionising", "unionization", "unionize", +"unionized", "unionizing", "unions", "unipolar", "uniprocessor", +"unique", "uniquely", "uniqueness", "uniquer", "Uniroyal", "unisex", +"unison", "Unisys", "unit", "Unitarian", "Unitarianism", "Unitarians", +"unitary", "unite", "united", "unitedly", "uniter", "unites", "uniting", +"unitize", "unitizing", "unitless", "units", "unity", "univ", "Univac", +"univalent", "univalve", "univariate", "universal", "universalisation", +"universalise", "universalised", "universaliser", "universalisers", +"universalising", "universalism", "universalist", "universalistic", +"universality", "universalisation", "universalization", "universalize", +"universalized", "universalizer", "universalizers", "universalizing", +"universally", "universalness", "universe", "universes", "universities", +"university", "univocal", "Unix", "uracil", "Urals", "uranium", "Uranus", +"uranyl", "urate", "urea", "uremia", "uremic", "ureter", "urethane", +"urethra", "urethral", "urethritis", "Urey", "Uri", "uric", "urinal", +"urinalysis", "urinary", "urinated", "urinating", "urination", "urine", +"urogenital", "urokinase", "urologist", "urologists", "urology", +"Uruguay", "Uruguayan", "Uruguayans", "US", "USA", "usable", "usage", +"usages", "use", "used", "useful", "usefulness", "usefully", "useless", +"uselessly", "uselessness", "Usenet", "user", "users", "uses", "using", +"usual", "usually", "usurer", "usurers", "usuress", "usurial", "usurious", +"usurp", "usurpation", "usurped", "usurper", "usurping", "usurps", +"usury", "Utah", "utensil", "utensils", "uterine", "uterus", "Utica", +"utilitarian", "utilitarianism", "utilities", "utility", "utilizable", +"utilization", "utilize", "utilized", "utilizes", "utilizing", "utopia", +"utopian", "utopians", "utopias", "Utrecht", "Uttoxeter", "uvula", +"uvular"]) + +aAN = set(["f", "F", "FBI", "FDA", "heir", "heirdom", "heired", +"heirer", "heiress", "heiring", "heirloom", "heirship", "honest", +"honester", "honestly", "honesty", "honor", "honorable", "honorableness", +"honorably", "honorarium", "honorary", "honored", "honorer", "honorific", +"honoring", "honors", "honour", "honourable", "honourableness", +"honourably", "honourarium", "honourary", "honoured", "honourer", +"honourific", "honouring", "Honours", "hors", "hour", "hourglass", "hourlong", +"hourly", "hours", "l", "L", "LCD", "m", "M", "MBA", "MP", "mpg", "mph", +"MRI", "MSc", "MTV", "n", "N", "NBA", "NBC", "NFL", "NGO", "NHL", "r", +"R", "s", "S", "SMS", "sos", "SOS", "SPF", "std", "STD", "SUV", "x", +"X", "XML"]) + +aB = set(["H", "hallucination", "haute", "hauteur", "herb", "herbaceous", "herbal", +"herbalist", "herbalism", "heroic", "hilarious", "historian", "historic", "historical", +"homage", "homophone", "horrendous", "hospitable", "horrific", "hotel", "hypothesis", "Xmas"]) + +def measurement(mnum, min, mout, mstr, decimal, remove): + if min == "ft" or min == "in" or min == "mi": + mnum = mnum.replace(" 1/2", ".5").replace(u" \xbd", ".5").replace(u"\xbd",".5") + m = calc("CONVERT_ADD", (float(eval(mnum.replace(remove, "").replace(decimal, ".").replace(u"\u2212", "-"))), min, mout)) + a = list(set([str(calc("ROUND", (m, 0)))[:-2], str(calc("ROUND", (m, 1))), str(calc("ROUND", (m, 2))), str(m)])) # remove duplicated rounded items + a.sort(lambda x, y: len(x) - len(y)) # sort by string length + return join(a, mstr + "\n").replace(".", decimal).replace("-", u"\u2212") + mstr + diff --git a/dictionaries/en/Linguistic.xcu b/dictionaries/en/Linguistic.xcu new file mode 100644 index 0000000..78fdd21 --- /dev/null +++ b/dictionaries/en/Linguistic.xcu @@ -0,0 +1,18 @@ + + + + + + + + en-GB en-US en-PH en-ZA en-NA en-ZW en-AU en-CA en-IE en-IN en-BZ en-BS en-GH en-JM en-NZ en-TT + + + + + + + diff --git a/dictionaries/en/README_lightproof_en.txt b/dictionaries/en/README_lightproof_en.txt new file mode 100644 index 0000000..0e6f33b --- /dev/null +++ b/dictionaries/en/README_lightproof_en.txt @@ -0,0 +1,3 @@ +English sentence checker for LibreOffice +see http://launchpad.net/lightproof and http://numbertext.org/lightproof +2011 (c) László Németh, license: MPL 1.1 / GPLv3+ / LGPLv3+ diff --git a/dictionaries/en/description.xml b/dictionaries/en/description.xml index 0ace9f5..f34df5b 100644 --- a/dictionaries/en/description.xml +++ b/dictionaries/en/description.xml @@ -1,6 +1,6 @@ - + English (Australia, Canada, South Africa, UK, USA) spelling dictionaries, hyphenation rules, and thesaurus diff --git a/dictionaries/en/dialog/OptionsDialog.xcs b/dictionaries/en/dialog/OptionsDialog.xcs new file mode 100644 index 0000000..a5a9963 --- /dev/null +++ b/dictionaries/en/dialog/OptionsDialog.xcs @@ -0,0 +1,74 @@ + + + + +Contains the options data used for the test extensions. + + + + + + The data for one leaf. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dictionaries/en/dialog/OptionsDialog.xcu b/dictionaries/en/dialog/OptionsDialog.xcu new file mode 100644 index 0000000..2ccb6db --- /dev/null +++ b/dictionaries/en/dialog/OptionsDialog.xcu @@ -0,0 +1,37 @@ + + + + + + + Dictionaries + Szótárak + + + + + + + org.openoffice.en.hunspell.dictionaries + + + + + English sentence checking + + + + + %origin%/en.xdl + + + + org.openoffice.comp.pyuno.LightproofOptionsEventHandler.en + + + + + + + + diff --git a/dictionaries/en/dialog/en.xdl b/dictionaries/en/dialog/en.xdl new file mode 100644 index 0000000..6e161bd --- /dev/null +++ b/dictionaries/en/dialog/en.xdl @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dictionaries/en/dialog/en_en_US.default b/dictionaries/en/dialog/en_en_US.default new file mode 100644 index 0000000..e69de29 diff --git a/dictionaries/en/dialog/en_en_US.properties b/dictionaries/en/dialog/en_en_US.properties new file mode 100644 index 0000000..6bc215e --- /dev/null +++ b/dictionaries/en/dialog/en_en_US.properties @@ -0,0 +1,37 @@ +spelling=Grammar checking +hlp_grammar= Check more grammar errors. +grammar=Possible mistakes +hlp_cap= Check missing capitalization of sentences. +cap=Capitalization +hlp_dup= Check repeated words. +dup=Word duplication +hlp_pair= Check missing or extra parentheses and quotation marks. +pair=Parentheses +punctuation=Punctuation +hlp_spaces=Check single spaces between words. +spaces=Word spacing +hlp_mdash=Force unspaced em dash instead of spaced en dash. +mdash=Em dash +hlp_ndash=Force spaced en dash instead of unspaced em dash. +ndash=En dash +hlp_quotation=Check double quotation marks: "x" \u2192 \u201cx\u201d +quotation=Quotation marks +hlp_times=Check true multipliction sign: 5x5 \u2192 5\u00d75 +times=Multiplication sign +hlp_spaces2=Check single spaces between sentences. +spaces2=Sentence spacing +hlp_spaces3=Check more than two extra space characters between words and sentences. +spaces3=More spaces +hlp_minus=Change hyphen characters to real minus signs. +minus=Minus sign +hlp_apostrophe=Change typewriter apostrophe, single quotation marks and correct double primes. +apostrophe=Apostrophe +hlp_ellipsis=Change three dots with ellipsis. +ellipsis=Ellipsis +others=Others +hlp_metric=Measurement conversion from \u00b0F, mph, ft, in, lb, gal and miles. +metric=Convert to metric (\u00b0C, km/h, m, kg, l) +hlp_numsep=Common (1000000 \u2192 1,000,000) or ISO (1000000 \u2192 1 000 000). +numsep=Thousand separation of large numbers +hlp_nonmetric=Measurement conversion from \u00b0C; km/h; cm, m, km; kg; l. +nonmetric=Convert to non-metric (\u00b0F, mph, ft, lb, gal) diff --git a/dictionaries/en/makefile.mk b/dictionaries/en/makefile.mk index e2c7091..fc51ec1 100644 --- a/dictionaries/en/makefile.mk +++ b/dictionaries/en/makefile.mk @@ -77,7 +77,19 @@ COMPONENT_FILES= \ $(EXTENSIONDIR)$/README_hyph_en_US.txt \ $(EXTENSIONDIR)$/README.txt \ $(EXTENSIONDIR)$/th_en_US_v2.dat \ - $(EXTENSIONDIR)$/WordNet_license.txt + $(EXTENSIONDIR)$/WordNet_license.txt \ + $(EXTENSIONDIR)$/README_lightproof_en.txt \ + $(EXTENSIONDIR)$/Lightproof.py \ + $(EXTENSIONDIR)$/Linguistic.xcu \ + $(EXTENSIONDIR)$/pythonpath/lightproof_en.py \ + $(EXTENSIONDIR)$/pythonpath/lightproof_handler_en.py \ + $(EXTENSIONDIR)$/pythonpath/lightproof_impl_en.py \ + $(EXTENSIONDIR)$/pythonpath/lightproof_opts_en.py \ + $(EXTENSIONDIR)$/dialog/en_en_US.default \ + $(EXTENSIONDIR)$/dialog/en_en_US.properties \ + $(EXTENSIONDIR)$/dialog/en.xdl \ + $(EXTENSIONDIR)$/dialog/OptionsDialog.xcu \ + $(EXTENSIONDIR)$/dialog/OptionsDialog.xcs COMPONENT_CONFIGDEST=. COMPONENT_XCU= \ diff --git a/dictionaries/en/manifest.xml b/dictionaries/en/manifest.xml index f54199b..9a1b9c3 100644 --- a/dictionaries/en/manifest.xml +++ b/dictionaries/en/manifest.xml @@ -3,4 +3,13 @@ + + + + diff --git a/dictionaries/en/pythonpath/lightproof_en.py b/dictionaries/en/pythonpath/lightproof_en.py new file mode 100644 index 0000000..d0e48b5 --- /dev/null +++ b/dictionaries/en/pythonpath/lightproof_en.py @@ -0,0 +1 @@ +dic = [[u'(?u)(?[Aa])n(?P<_>[ ][\'\u2018"\u201c]?)(?P[aeiouAEIOU]\\w*)(?P[-\u2013\'\u2019\\w]*)(?![-\\w\u2013\xad])', u'\\g\\g<_>\\g\\g', u'Did you mean:', u'm.group("vow_1") in aA or m.group("vow_1").lower() in aA'], [u'(?u)(?[ ][\'\u2018"\u201c]?)(?P[aeiouAEIOU]\\w*)(?P[-\u2013\'\u2019\\w]*)(?![-\\w\u2013\xad])', u'an\\g<_>\\g\\g', u'Bad article?', u'(m.group("vow_1") <> m.group("vow_1").upper()) and not (m.group("vow_1") in aA or m.group("vow_1").lower() in aA) and spell(LOCALE,m.group("vow_1"))'], [u'(?u)(?[ ][\'\u2018"\u201c]?)(?P[bcdfghj-np-tv-zBCDFGHJ-NP-TV-Z]\\w*)(?P[-\u2013\'\u2019\\w]*)(?![-\\w\u2013\xad])', u'an\\g<_>\\g\\g', u'Did you mean:', u'm.group("con_1") in aAN or m.group("con_1").lower() in aAN'], [u'(?u)(?[Aa])n(?P<_>[ ][\'\u2018"\u201c]?)(?P[bcdfghj-np-tv-zBCDFGHJ-NP-TV-Z]\\w*)(?P[-\u2013\'\u2019\\w]*)(?![-\\w\u2013\xad])', u'\\g\\g<_>\\g\\g', u'Bad article?', u'(m.group("con_1") <> m.group("con_1").upper()) and not (m.group("con_1") in aA or m.group("con_1").lower() in aAN) and not m.group("con_1") in aB and spell(LOCALE,m.group("con_1"))'], [u'(?u)((?<=[!?.] )|^)A(?P<_>[ ][\'\u2018"\u201c]?)(?P[aeiouAEIOU]\\w*)(?P[-\u2013\'\u2019\\w]*)(?![-\\w\u2013\xad])', u'An\\g<_>\\g\\g', u'Bad article?', u'(m.group("vow_1") <> m.group("vow_1").upper()) and not (m.group("vow_1") in aA or m.group("vow_1").lower() in aA) and spell(LOCALE,m.group("vow_1"))'], [u'(?u)((?<=[!?.] )|^)A(?P<_>[ ][\'\u2018"\u201c]?)(?P[bcdfghj-np-tv-zBCDFGHJ-NP-TV-Z]\\w*)(?P[-\u2013\'\u2019\\w]*)(?![-\\w\u2013\xad])', u'An\\g<_>\\g\\g', u'Did you mean:', u'm.group("con_1") in aAN or m.group("con_1").lower() in aAN'], [u'(?u)(?[ ][\'\u2018"\u201c]?)(?P(8[0-9]*|1[18](000)*)(th)?)(?P[-\u2013\'\u2019\\w]*)(?![-\\w\u2013\xad])', u'an\\g<_>\\g\\g', u'Did you mean:', False], [u'(?u)((?<=[!?.] )|^)A(?P<_>[ ][\'\u2018"\u201c]?)(?P(8[0-9]*|1[18](000)*)(th)?)(?P[-\u2013\'\u2019\\w]*)(?![-\\w\u2013\xad])', u'An\\g<_>\\g\\g', u'Did you mean:', False], [u'(?u)(?[Aa])n(?P<_>[ ][\'\u2018"\u201c]?)(?P[0-79][0-9]*)(?P[-\u2013\'\u2019\\w]*)(?![-\\w\u2013\xad])', u'\\g\\g<_>\\g\\g', u'Did you mean:', u'not m.group("ncon_1")[:2] in ["11", "18"]'], [u'(?u)((?<=[!?.] )|^)(?P[a-z]+)(?![-\\w\u2013\xad])', u'= m.group("low_1").capitalize()', u'Missing capitalization?', u're.match("[a-z].*[.?!] [A-Z]", TEXT) and not abbrev.search(TEXT)'], [u'(?u)((?<=[!?.] )|^)(?P[a-z]+)(?![-\\w\u2013\xad])', u'= m.group("low_1").capitalize()', u'Missing capitalization?', u'option(LOCALE,"cap") and not abbrev.search(TEXT)'], [u'(?u) ([.?!,:;)\u201d\\[\\]])\\b', u'\\1 ', u'Reversed space and punctuation?', False], [u'(?u) +[.]', u'.', u'Extra space before the period?', u'LOCALE.Country == "US"'], [u'(?u) +[.]', u'.', u'Extra space before the full stop?', u'LOCALE.Country != "US"'], [u'(?u) +([?!,:;)\u201d\\]])', u'\\1', u'= "Extra space before the " + punct[m.group(1)] + "?"', False], [u'(?u)([([\u201c]) ', u'\\1', u'= "Extra space after the " + punct[m.group(1)] + "?"', False], [u'(?u)\\b(---?| --? )\\b', u' \u2013 \\n\u2014', u'En dash or em dash:', u'not option(LOCALE,"ndash") and not option(LOCALE,"mdash")'], [u'(?u)\\b(---?| --? |\u2014)\\b', u' \u2013 ', u'En dash:', u'option(LOCALE,"ndash") and not option(LOCALE,"mdash")'], [u'(?u)\\b(---?| --? | \u2013 )\\b', u'\u2014', u'Em dash:', u'option(LOCALE,"mdash")'], [u'(?u)(?P\\d+([.]\\d+)?)(x| x )(?P\\d+([.]\\d+)?)', u'\\g\xd7\\g', u'Multiplication sign.', u'option(LOCALE,"times")'], [u'(?u)(?P[a-zA-Z]+)(?P[?!,:;%\u2030\u2031\u02da\u201c\u201d\u2018])(?P[a-zA-Z]+)', u'\\g\\g \\g', u'Missing space?', False], [u'(?u)(?P[a-z]+)[.](?P[A-Z]+)', u'\\g. \\g', u'Missing space?', False], [u'(?u)[)]', u'', u'Extra closing parenthesis?', u'option(LOCALE,"pair") and not "(" in TEXT'], [u'(?u)[(]', u'', u'Extra opening parenthesis?', u'option(LOCALE,"pair") and TEXT[-1] in u"?!;:\u201d\u2019" and not ")" in TEXT'], [u'(?u)(?[?!,:;%\u2030\u2031\u02da\u201c\u201d\u2018])|[.]) {2,3}(\\b|$)', u'\\1 ', u'Extra space.', u'option(LOCALE,"spaces2")'], [u'(?u)(^|\\b|(?P[?!,:;%\u2030\u2031\u02da\u201c\u201d\u2018])|[.]) {4,}(\\b|$)', u'\\1 \\n\t', u'Change multiple spaces to a single space or a tabulator:', u'option(LOCALE,"spaces3")'], [u'(?iu)[\\"\u201c\u201d\u201f\u201e]((?P[a-zA-Z]+)[^\\"\u201c\u201d\u201f\u201e]*)[\\"\u201c\u201f]', u'\u201c\\1\u201d', u'Quotation marks.', u'option(LOCALE,"quotation")'], [u'(?iu)[\\"\u201d\u201f\u201e]((?P[a-zA-Z]+)[^\\"\u201c\u201d\u201f\u201e]*)[\\"\u201c\u201d\u201f]', u'\u201c\\1\u201d', u'Quotation marks.', u'option(LOCALE,"quotation")'], [u"(?iu)'(?P[a-zA-Z]+)'", u'\u2018\\g\u2019', u'Quotation marks.', u'option(LOCALE,"apostrophe")'], [u'(?iu)[\\"\u201d\u201f\u201e]((?P[a-zA-Z]+)[^\\"\u201c\u201d\u201f\u201e]*)[\\"\u201c\u201d\u201f]', u'\u201c\\1\u201d', u'Quotation marks.', u'option(LOCALE,"apostrophe")'], [u"(?iu)(?P[a-zA-ZA-Z]+)'(?P\\w*)", u'\\g\u2019\\g', u'Replace typewriter apostrophe or quotation mark:', u'option(LOCALE,"apostrophe")'], [u"(?u)(?<= )'(?P[a-zA-Z]+)", u'\u2018\\g\\n\u2019\\g', u'Replace typewriter quotation mark or apostrophe:', u'option(LOCALE,"apostrophe")'], [u"(?u)^'(?P[a-zA-Z]+)", u'\u2018\\g\\n\u2019\\g', u'Replace typewriter quotation mark or apostrophe:', u'option(LOCALE,"apostrophe")'], [u'(?u)\\b(?P\\d\\d)(?P\\d\\d\\d)\\b', u'\\g,\\g\\n\\g\u202f\\g', u'Use thousand separator (common or ISO).', u'option(LOCALE,"numsep")'], [u'(?u)\\b(?P\\d{1,3})(?P\\d\\d\\d)(?P\\d\\d\\d)\\b', u'\\g,\\g,\\g\\n\\g\u202f\\g\u202f\\g', u'Use thousand separators (common or ISO).', u'option(LOCALE,"numsep")'], [u'(?u)\\b(?P\\d{1,3})(?P\\d\\d\\d)(?P\\d\\d\\d)(?P\\d\\d\\d)\\b', u'\\g,\\g,\\g,\\g\\n\\g\u202f\\g\u202f\\g\u202f\\g', u'Use thousand separators (common or ISO).', u'option(LOCALE,"numsep")'], [u'(?u)(?[a-zA-Z]+) \\1(?![-\\w\u2013\xad])', u'\\g', u'Word duplication?', u'option(LOCALE,"dup")'], [u'(?u)(?[a-z]+)(?![-\\w\u2013\xad])', u'\\1hese \\g\\n\\1his, \\g', u'Did you mean:', u'option(LOCALE,"grammar") and morph(LOCALE,m.group("abc_1"), "Ns")'], [u"(?u)(?