Skip to content

實作文章解析器 #32

@PichuChen

Description

@PichuChen

目前有個重要的任務我忘了開,就是需要解析文章

以前並沒有結構性的去描述 BBS 文章結構的結構,因此這部分得我們自行發明。

初步的話我希望可以解析成以下的格式

"is_header_modify": {{is_header_modified}},
"author_id": {{author_id}},
"author_name": {{author_name}},
"title": {{title}},
"post_time": {{post_time}},
"board_name": {{board_name}},
"text": {
    "text": {{text}},
    "color_map": {{text_color_map}}
},
"signature": {
    "text": {{signature_text}},
    "color_map": {{signature_color_map}}
},
"sender_info": {
    "site": {{sender_site}},
    "ip_address": {{sender_ip_address}},
    "ip_country": {{sender_ip_country}},
},
"edit_record": [{{edit_record}}],
"push_record": [
    {
        "type": {{push_record.type}},
        "id": {{push_record.pusher_id}},
        "ip_address": {{push_record.pusher_ip}},
        "text": {{push_record.type}},
        "time": {{push_record.time}},
    }
]

方法目前沒有特別的想法,也許建議使用regex或者是if else, 如果用 goyacc 寫出一套解析器應該也是可以,雖然我懷疑這個解析器會不會遇到2003以前的文章就失效了。 如果要用 NN 訓練出一個模型出來我覺得也不是不行,雖然這樣的話我可能會先讓傳統 if else 作法的先上線。

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions