ani-hovhannisyan / kanji-visualization

Kanji words visualization graph draws relational graph for kanjis of particular words in Japanese. Aim is to understand the relational graph of one kanji within different words and it's relations to all possible words.
MIT License
5 stars 1 forks source link

[backend]Implement GraphController class in backend #36

Closed teruto725 closed 2 years ago

teruto725 commented 2 years ago

Implement the Graph Controller class in the server side.

ani-hovhannisyan commented 2 years ago

During exploration of how to interact with the db for Graph, and how to parse the words list I found TheKanjiMap project data is enough for now and easy to process for later Graph Drawing. So will use that instead of JamDict.

ani-hovhannisyan commented 2 years ago

As for preparing the nodes format task I need the format of GraphView nodes, so will wait for the input from Graph View task.

ani-hovhannisyan commented 2 years ago

Renamed graph-controller branch to feature/graph-controller. (deleted graph-controller and added the new one)

ani-hovhannisyan commented 2 years ago

Connecting methods between controllers are done by @teruto725.

ani-hovhannisyan commented 2 years ago

Implemented draft version of constructing graph using local cached DB taken from "The Kanji Map" project data #3 Graph Controller loads the DB, finds necessary kanji, reconstructs the db json. then cleans up and prepares specific format defined by GraphView #52 (#55 not sure).

ani-hovhannisyan commented 2 years ago

The request will get following response, from Graph all nodes and links are constructed as described in #52 :

{
    "graphMatrix": {
        "nodes": [{
            "id": "柳"
        }, {
            "id": "き"
        }, {
            "id": "ゅ"
        }, {
            "id": "う"
        }, {
            "id": "山"
        }, {
            "id": "四"
        }, {
            "id": "川",
            "isMain": "true"
        }, {
            "id": "上"
        }, {
            "id": "堀"
        }, {
            "id": "河"
        }, {
            "id": "下"
        }, {
            "id": "江"
        }, {
            "id": "戸"
        }, {
            "id": "小"
        }],
        "links": [{
            "source": "川",
            "target": "柳"
        }, {
            "source": "川",
            "target": "き"
        }, {
            "source": "き",
            "target": "ゅ"
        }, {
            "source": "ゅ",
            "target": "う"
        }, {
            "source": "山",
            "target": "川"
        }, {
            "source": "四",
            "target": "川"
        }, {
            "source": "川",
            "target": "上"
        }, {
            "source": "堀",
            "target": "川"
        }, {
            "source": "河",
            "target": "川"
        }, {
            "source": "川",
            "target": "下"
        }, {
            "source": "江",
            "target": "戸"
        }, {
            "source": "戸",
            "target": "川"
        }, {
            "source": "小",
            "target": "川"
        }]
    },
    "kanjiInfo": {
        "kunyomi": "かわ",
        "onyomi": "",
        "meaning": "stream"
    }
}

Note: There might happen to have errors, as I still didn't add else case handling in GC(GraphController). The furigana endings and non kanji words aren't handled yet. Should clean from main.py and other responses to have exact matching format for json.

ani-hovhannisyan commented 2 years ago

Closing issue as nor important problems and opening DB clean up and enhancement/bug fixing tasks.