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

Define JSON format #52

Closed wowry closed 2 years ago

wowry commented 2 years ago

Define JSON format that contains node, link and info.

wowry commented 2 years ago

Format

{
    "nodes": {
        "id": string,
        "isMain"?: boolean,
    }[],
    "links": {
        "source": string,
        "target": string
    }[],
    "info": {
        "id": string,
        "isMain"?: boolean,
        "onyomi": string[],
        "kunyomi": string[],
        "meaning": string[]
    }[]
}

Example

{
    "nodes": [ 
        { 
            "id": "山",
            "isMain": true
        },
        {
            "id": "登"
        }
    ],
    "links": [
        {
            "source": "登",
            "target": "山"
        }
    ],
    "info": [
        {
            "id": "山",
            "isMain": true,
            "onyomi": ["サン", "セン"],
            "kunyomi": ["ヤマ"],
            "meaning": ["mountain"]
        },
        {
            "id": "登",
            "onyomi": ["ト", "トウ"],
            "kunyomi": ["ノボる"],
            "meaning": ["ascend", "climb up"]
        }
    ]
}
wowry commented 2 years ago
"links": [
    {
        "source": "登",
        "target": "山"
    }
],

Here, the values of source and target are the node IDs. In this case, the arrow will be connected from "登" to "山", like this: 登→山.

wowry commented 2 years ago

My understanding is that nodes and links will be generated in GraphController, and info will be generated in InfoController. And then, we can combine them into a single JSON in main.py, and send it to the frontend.

wowry commented 2 years ago
"nodes": [ 
    { 
      "id": "山",
      "isMain": true
    },
    { 
      "id": "登"
    }
],

Please set "isMain": true if it is the main node, and do the same for info.

teruto725 commented 2 years ago

Sorry I implemented json response temporary. But don't care. you can update it. https://github.com/ani-hovhannisyan/kanji-visualization/pull/53

wowry commented 2 years ago

OK, thanks. I'll check it.

ani-hovhannisyan commented 2 years ago

The format is ok, I constructed same in GC (GraphController) like this

{
        "nodes": [{
            "id": "山",
            "isMain": "true"
        }, {
            "id": "陰"
        }, {
            "id": "治"
        }, {
            "id": "開"
        }, {
            "id": "道"
        }, {
            "id": "須"
        }, {
            "id": "弥"
        }, {
            "id": "奥"
        }, {
            "id": "青"
        }, {
            "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": "山"
        }, {
            "source": "岩",
            "target": "山"
        }, {
            "source": "山",
            "target": "火"
        }, {
            "source": "火",
            "target": "事"
        }]
    }

Closing because both side have more and less defined the format.