Grammalecte  Check-in [4a53af847f]

Overview
Comment:[core] ibdawg: select entries from dictionary (can uncompress the full dictionary)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk | core | new_feature
Files: files | file ages | folders
SHA3-256: 4a53af847f68e7f968b21612d373c758e5338d87934ab88444201e4483575516
User & Date: olr on 2017-06-30 19:38:27
Other Links: manifest | tags
Context
2017-07-01
03:28
[core] ibdawg: use regex in select() check-in: ea16ae6a5b user: olr tags: core, trunk
2017-06-30
19:38
[core] ibdawg: select entries from dictionary (can uncompress the full dictionary) check-in: 4a53af847f user: olr tags: core, new_feature, trunk
08:15
[fx] special message in gc_panel check-in: f1ea6bc055 user: olr tags: fx, trunk, v0.5.17.1
Changes

Modified cli.py from [2ae9df701e] to [ed7458a4d3].

    17     17              "Je suit sidéré par la brutales arrogance de cette homme-là. Quelle salopard ! Un escrocs de la pire espece. " \
    18     18              "Quant sera t’il châtiés pour ses mensonge ?             Merde ! J’en aie marre."
    19     19   
    20     20   _HELP = """
    21     21       /help                       /h      show this text
    22     22       ?word1 [word2] ...                  words analysis
    23     23       !word                               suggestion
           24  +    >word                               draw path of word in the word graph
           25  +    =filter                             show all entries whose morphology fits to filter
    24     26       /lopt                       /lo     list options
    25     27       /+ option1 [option2] ...            activate grammar checking options
    26     28       /- option1 [option2] ...            deactivate grammar checking options
    27     29       /lrules [pattern]           /lr     list rules
    28     30       /--rule1 [rule2] ...                deactivate grammar checking rule
    29     31       /++rule1 [rule2] ...                reactivate grammar checking rule
    30     32       /quit                       /q      exit
................................................................................
   206    208                               echo("  {:<32} {}".format(sMorph, oLexGraphe.formatTags(sMorph)))
   207    209               elif sText.startswith("!"):
   208    210                   for sWord in sText[1:].strip().split():
   209    211                       if sWord:
   210    212                           echo(" | ".join(oDict.suggest(sWord)))
   211    213               elif sText.startswith(">"):
   212    214                   oDict.drawPath(sText[1:].strip())
          215  +            elif sText.startswith("="):
          216  +                for sRes in oDict.select(sText[1:].strip()):
          217  +                    echo(sRes)
   213    218               elif sText.startswith("/+ "):
   214    219                   gce.setOptions({ opt:True  for opt in sText[3:].strip().split()  if opt in gce.getOptions() })
   215    220                   echo("done")
   216    221               elif sText.startswith("/- "):
   217    222                   gce.setOptions({ opt:False  for opt in sText[3:].strip().split()  if opt in gce.getOptions() })
   218    223                   echo("done")
   219    224               elif sText.startswith("/-- "):

Modified gc_core/py/ibdawg.py from [cbe111edf6] to [1de2d3f67f].

   279    279                   n += 1
   280    280           if not sWord:
   281    281               return
   282    282           if iPos >= 0:
   283    283               print("\n   "+ " " * iPos + "|")
   284    284               self.drawPath(sWord[1:], iNextNodeAddr)
   285    285   
          286  +    def select (self, sFilter=""):
          287  +        "generator: returns all entries which morphology fits <sFilter>"
          288  +        print("Filter: " + sFilter)
          289  +        yield from self._select1(sFilter, 0, "")
          290  +
   286    291   
   287    292       # def morph (self, sWord):
   288    293       #     is defined in __init__
   289    294   
   290    295       # VERSION 1
          296  +    def _select1 (self, sFilter, iAddr, sWord):
          297  +        # recursive generator
          298  +        for nVal, jAddr in self._getArcs1(iAddr):
          299  +            if nVal < self.nChar:
          300  +                # simple character
          301  +                yield from self._select1(sFilter, jAddr, sWord + self.lArcVal[nVal])
          302  +            else:
          303  +                sEntry = sWord + "\t" + self.funcStemming(sWord, self.lArcVal[nVal])
          304  +                for nMorphVal, _ in self._getArcs1(jAddr):
          305  +                    if not sFilter or sFilter in self.lArcVal[nMorphVal]:
          306  +                        yield sEntry + "\t" + self.lArcVal[nMorphVal]
          307  +
   291    308       def _morph1 (self, sWord):
   292    309           "returns morphologies of sWord"
   293    310           iAddr = 0
   294    311           for c in sWord:
   295    312               if c not in self.dChar:
   296    313                   return []
   297    314               iAddr = self._lookupArcNode(self.dChar[c], iAddr)