Grammalecte  Check-in [a5edfddfa8]

Overview
Comment:[build][core] rules graph: merge lemmas in key <lemmas>
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | core | build | rg
Files: files | file ages | folders
SHA3-256: a5edfddfa854273fcdac6d9054769ce38559d217c8c503cfc6c29a143764478e
User & Date: olr on 2018-05-23 12:19:37
Original Comment: [build][core] agregate lemmas in one node
Other Links: branch diff | manifest | tags
Context
2018-05-24
09:25
[build][core] regex for token value and token morphologies check-in: fea041c0de user: olr tags: build, core, rg
2018-05-23
12:19
[build][core] rules graph: merge lemmas in key <lemmas> check-in: a5edfddfa8 user: olr tags: build, core, rg
12:10
[graphspell][js][bug] remove prefix sign from lemmas check-in: 13109802df user: olr tags: graphspell, rg
Changes

Modified darg.py from [bf378d22b5] to [7e9f6a7653].

   155    155           return self.__str__() == other.__str__()        
   156    156   
   157    157       def getNodeAsDict (self):
   158    158           "returns the node as a dictionary structure"
   159    159           dNode = {}
   160    160           dRegex = {}
   161    161           dRules = {}
   162         -        for arc, oNode in self.dArcs.items():
   163         -            if type(arc) == str and arc.startswith("~"):
   164         -                dRegex[arc[1:]] = oNode.__hash__()
   165         -            elif arc.startswith("##"):
   166         -                dRules[arc[1:]] = oNode.__hash__()
          162  +        dLemmas = {}
          163  +        for sArc, oNode in self.dArcs.items():
          164  +            if sArc.startswith("~") and len(sArc) > 1:
          165  +                dRegex[sArc[1:]] = oNode.__hash__()
          166  +            elif sArc.startswith(">") and len(sArc) > 1:
          167  +                dLemmas[sArc[1:]] = oNode.__hash__()
          168  +            elif sArc.startswith("##"):
          169  +                dRules[sArc[1:]] = oNode.__hash__()
   167    170               else:
   168         -                dNode[arc] = oNode.__hash__()
          171  +                dNode[sArc] = oNode.__hash__()
   169    172           if dRegex:
   170    173               dNode["<regex>"] = dRegex
          174  +        if dLemmas:
          175  +            dNode["<lemmas>"] = dLemmas
   171    176           if dRules:
   172    177               dNode["<rules>"] = dRules
   173    178           #if self.bFinal:
   174    179           #    dNode["<final>"] = 1
   175    180           return dNode

Modified gc_core/py/lang_core/gc_engine.py from [070a603bc6] to [de8dd5167f].

   605    605           return dErr
   606    606   
   607    607       def _getNextMatchingNodes (self, dToken, dNode):
   608    608           # token value
   609    609           if dToken["sValue"] in dNode:
   610    610               yield dGraph[dNode[dToken["sValue"]]]
   611    611           # token lemmas
   612         -        for sLemma in _oSpellChecker.getLemma(dToken["sValue"]):
   613         -            if sLemma in dNode:
   614         -                yield dGraph[dNode[sLemma]]
          612  +        if "<lemmas>" in dNode:
          613  +            for sLemma in _oSpellChecker.getLemma(dToken["sValue"]):
          614  +                if sLemma in dNode["<lemmas>"]:
          615  +                    yield dGraph[dNode["<lemmas>"][sLemma]]
   615    616           # universal arc
   616    617           if "*" in dNode:
   617    618               yield dGraph[dNode["*"]]
   618    619           # regex arcs
   619         -        if "~" in dNode:
          620  +        if "<regex>" in dNode:
   620    621               for sRegex in dNode["~"]:
   621    622                   for sMorph in _oSpellChecker.getMorph(dToken["sValue"]):
   622    623                       if re.search(sRegex, sMorph):
   623         -                        yield dGraph[dNode["~"][sRegex]]
          624  +                        yield dGraph[dNode["regex"][sRegex]]
   624    625   
   625    626       def _executeActions (self, dNode, nOffset):
   626    627           for sLineId, nextNodeKey in dNode.items():
   627    628               for sArc in dGraph[nextNodeKey]:
   628    629                   print(sArc)
   629    630                   bCondMemo = None
   630    631                   sFuncCond, cActionType, sWhat, *eAct = dRule[sArc]