Grammalecte  Check-in [448cd58d39]

Overview
Comment:[build] make data more readable
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk | build
Files: files | file ages | folders
SHA3-256: 448cd58d39e1d7571775a82df886a1465ac8cf59ed2827a93c7a9e99d0b2988b
User & Date: olr on 2020-04-22 13:59:53
Other Links: manifest | tags
Context
2020-04-22
14:29
[build] code clarification (Python f-strings) check-in: d1aa895785 user: olr tags: trunk, build
13:59
[build] make data more readable check-in: 448cd58d39 user: olr tags: trunk, build
10:58
[build] fix URL id check-in: 959afab163 user: olr tags: trunk, build
Changes

Modified compile_rules_graph.py from [e20a775a4f] to [116d5ebc8e].

1
2
3
4
5
6
7
8
9
10
11
12

13
14
15
16
17
18
19
"""
Grammalecte: compile rules
Create a Direct Acyclic Rule Graphs (DARGs)
"""

import re
import os
import time
import concurrent.futures

import darg
import compile_rules_js_convert as jsconv



#### PROCESS POOL EXECUTOR ####
xProcessPoolExecutor = None

def initProcessPoolExecutor (nMultiCPU=None):
    "process pool executor initialisation"












>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
"""
Grammalecte: compile rules
Create a Direct Acyclic Rule Graphs (DARGs)
"""

import re
import os
import time
import concurrent.futures

import darg
import compile_rules_js_convert as jsconv
import helpers


#### PROCESS POOL EXECUTOR ####
xProcessPoolExecutor = None

def initProcessPoolExecutor (nMultiCPU=None):
    "process pool executor initialisation"
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
    for xFuture in lResult:
        sGraphName, dGraph, dActions, sPy, sJS = xFuture.result()
        dAllGraph[sGraphName] = dGraph
        dAllActions.update(dActions)
        sPyCallables += sPy
        sJSCallables += sJS
    # create a dictionary of URL
    dTempURL = {}
    i = 1
    for sKey, lValue in dAllActions.items():
        if lValue[3] == "-":
            if lValue[-1]:
                if lValue[-1] not in dTempURL:
                    dTempURL[lValue[-1]] = i
                    i += 1
                lValue[-1] = dTempURL[lValue[-1]]
            else:
                lValue[-1] = 0
    dURL = { v: k  for k, v in dTempURL.items() } # reversing key and values
    dURL[0] = ""
    # end
    print("  Total: ", nRule, "rules, ", len(dAllActions), "actions")
    print("  Build time: {:.2f} s".format(time.time() - fStartTimer))

    return {
        # the graphs describe paths of tokens to actions which eventually execute callables
        "rules_graphs": str(dAllGraph),


        "rules_graphsJS": str(dAllGraph),
        "rules_actions": str(dAllActions),
        "rules_actionsJS": jsconv.pyActionsToString(dAllActions),
        "rules_graph_URL": str(dURL),
        "graph_callables": sPyCallables,
        "graph_callablesJS": sJSCallables
    }







|











<






|
>
>

<

|



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
    for xFuture in lResult:
        sGraphName, dGraph, dActions, sPy, sJS = xFuture.result()
        dAllGraph[sGraphName] = dGraph
        dAllActions.update(dActions)
        sPyCallables += sPy
        sJSCallables += sJS
    # create a dictionary of URL
    dTempURL = { "": 0 }
    i = 1
    for sKey, lValue in dAllActions.items():
        if lValue[3] == "-":
            if lValue[-1]:
                if lValue[-1] not in dTempURL:
                    dTempURL[lValue[-1]] = i
                    i += 1
                lValue[-1] = dTempURL[lValue[-1]]
            else:
                lValue[-1] = 0
    dURL = { v: k  for k, v in dTempURL.items() } # reversing key and values

    # end
    print("  Total: ", nRule, "rules, ", len(dAllActions), "actions")
    print("  Build time: {:.2f} s".format(time.time() - fStartTimer))

    return {
        # the graphs describe paths of tokens to actions which eventually execute callables
        "rules_graphs": str(dAllGraph), # helpers.convertDictToString(dAllGraph)
        "rules_actions": helpers.convertDictToString(dAllActions), # str(dAllActions)
        "rules_graph_URL": helpers.convertDictToString(dURL), # str(dURL)
        "rules_graphsJS": str(dAllGraph),

        "rules_actionsJS": jsconv.pyActionsToString(dAllActions),
        "rules_graph_URLJS": str(dURL),
        "graph_callables": sPyCallables,
        "graph_callablesJS": sJSCallables
    }

Modified gc_core/js/lang_core/gc_rules_graph.js from [8c47453ba6] to [001ce9daa6].

10
11
12
13
14
15
16
17
18
19
20
21
22
23
24


var gc_rules_graph = {
    dAllGraph: ${rules_graphsJS},

    dRule: ${rules_actionsJS},

    dURL: ${rules_graph_URL}
};


if (typeof(exports) !== 'undefined') {
    exports.dAllGraph = gc_rules_graph.dAllGraph;
    exports.dRule = gc_rules_graph.dRule;
    exports.dURL = gc_rules_graph.dURL;







|







10
11
12
13
14
15
16
17
18
19
20
21
22
23
24


var gc_rules_graph = {
    dAllGraph: ${rules_graphsJS},

    dRule: ${rules_actionsJS},

    dURL: ${rules_graph_URLJS}
};


if (typeof(exports) !== 'undefined') {
    exports.dAllGraph = gc_rules_graph.dAllGraph;
    exports.dRule = gc_rules_graph.dRule;
    exports.dURL = gc_rules_graph.dURL;

Modified gc_lang/fr/rules.grx from [bb86697156] to [21771c1a6c].

7461
7462
7463
7464
7465
7466
7467
7468
7469
7470
7471
7472
7473
7474
7475
TEST: Il y a qui au dîner ce soir ?


# m’a tuer
__conf_m_a_tuer__
    m’ a tuer
        <<- /conf/ -3>> tué|tuée
        # Cliché. Évitez cette erreur de grammaire délibérée, faite d’innombrables fois, pour mimer l’affaire Omar Raddad.|https://fr.wikipedia.org/wiki/Omar_m'a_tuer

TEST: la réalité m’a {{tuer}}


# après avoir
__conf_après_avoir__
    [à|a] [>prêt|>pré|près] [a|à] [voire|voir]







|







7461
7462
7463
7464
7465
7466
7467
7468
7469
7470
7471
7472
7473
7474
7475
TEST: Il y a qui au dîner ce soir ?


# m’a tuer
__conf_m_a_tuer__
    m’ a tuer
        <<- /conf/ -3>> tué|tuée
        # Cliché. Évitez cette erreur de grammaire délibérée, faite d’innombrables fois, pour mimer l’affaire Omar Raddad.|https://fr.wikipedia.org/wiki/Omar_m%27a_tuer

TEST: la réalité m’a {{tuer}}


# après avoir
__conf_après_avoir__
    [à|a] [>prêt|>pré|près] [a|à] [voire|voir]

Modified helpers.py from [f66c7bb7d2] to [20b8bddd75].

1
2
3
4
5
6
7
8
9
10
11















12
13
14
15
16
17
18
"""
Tools for handling files
"""

import os
import shutil
import errno
import zipfile

from string import Template

















class CD:
    "Context manager for changing the current working directory"
    def __init__ (self, newPath):
        self.newPath = os.path.expanduser(newPath)
        self.savedPath = ""












>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







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
"""
Tools for handling files
"""

import os
import shutil
import errno
import zipfile

from string import Template


def convertDictToString (dDict, nDepth=1, nIndent=2):
    "returns <dDict> as a indented string"
    sResult = "{\n"
    sIndent = " " * nIndent
    for key, val in dDict.items():
        sKey = f"'{key}'"  if type(key) is str  else str(key)
        if nDepth > 0 and type(val) is dict:
            sVal = convertDictToString(val, nDepth-1, nIndent+nIndent)
        else:
            sVal = f"'{val}'"  if type(val) is str  else str(val)
        sResult += f'{sIndent}{sKey}: {sVal},\n'
    sResult = sResult + sIndent[:-2] + "}"
    return sResult


class CD:
    "Context manager for changing the current working directory"
    def __init__ (self, newPath):
        self.newPath = os.path.expanduser(newPath)
        self.savedPath = ""