Skip to content

MaxKinny/tsg2ms

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

44 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

image

Project Diagram

Table Structure Graph (TSG) to Merging Set (MS)

The expression of table structure

Description:

Directed Acyclic Graph (DAG) with 2 kinds of edge labels ("row" and "column"), which is termed as Table Structure Graph (TSG). A vertex refers to a cell in a table, and a row/column edge indicates a horizontal/vertical intersection.

Diagram:

Web API

import requests
import json

def get_merging_set(row_adj_matrix, col_adj_matrix, flags):
    url_dict1 = {
        "url": f"https://1258763670-8apd76aadv.ap-guangzhou.tencentscf.com",
        "Host": "1258763670-8apd76aadv.ap-guangzhou.tencentscf.comm"
    }
    
    url_dict2 = {
        "url": f"http://service-4yahjjoi-1258763670.gz.apigw.tencentcs.com/release/tsg2ms",
        "Host": "service-4yahjjoi-1258763670.gz.apigw.tencentcs.com"
    }
    
    url_dict = url_dict1  # url_dict2  Can try both
    url = url_dict["url"]
    data = {"matrix1": row_adj_matrix, "matrix2": col_adj_matrix, "flags": flags}
    headers = {
        "Content-Type": "application/json",
        "Accept": "*/*",
        "Cache-Control": "no-cache",
        "Host": url_dict["Host"],
        "Accept-Encoding": "gzip, deflate, br",
        "Connection": "keep-alive",
        "User-Agent": "apifox/1.0.0 (https://www.apifox.cn)",
    }
    r = requests.post(url, headers=headers, data=json.dumps(data))
    json_data = r.json()
    return json_data.get("result")


if __name__ == '__main__':
    ##################### Inputs #############################
    row_adj_matrix = [[0, 1, -9999, -9999],
                      [-9999, 0, -9999, -9999],
                      [-9999, -9999, 0, 1],
                      [-9999, -9999, -9999, 0]]

    col_adj_matrix = [[0, -9999, 1, -9999],
                      [-9999, 0, -9999, 1],
                      [-9999, -9999, 0, -9999],
                      [-9999, -9999, -9999, 0]]

    flags = {'gt_or_prediction': 'gt',
             'isFAS': False,
             'isDeleteConflicts': False,
             'isDetectVacancy': True,
             'isMIP': False,
             'isComputeSL': True}
    ##########################################################

    api_return = get_merging_set(row_adj_matrix, col_adj_matrix, flags)

    # show results
    if api_return["status"] == "failure":
        print("Invalid Table or Graph!", api_return.get("message"))
    elif api_return["status"] == "success":
        print(api_return)

An APP for testing our API

Description:

Draw your table on paper and annotate its TSG using our tool. After that, click the "Merging Set" button, this tool will compute the merging set of your table!

Download Links:

https://doi.org/10.6084/m9.figshare.24633588 Version 2 (Recommended)

Google Drive, 百度网盘 Version 1 (Deprecated)

The demonstration video (with voice):

demo+sound_compressed_CN.mp4

CmpTab Dataset

image

Download Links:

https://doi.org/10.6084/m9.figshare.30899762

Report Bugs

If you have tables with inconsistent merging sets from the tool, there may be implementation bugs in our API program. Please raise an issue and upload images and JSON data for your examples. Thanks a lot!

Authorship

1. Fan Yang, maxgundam@hotmail.com, https://scholar.google.com/citations?user=MZGxAVcAAAAJ&hl=zh-CN
2. Jiancong Ye, jcye1483@outlook.com, https://scholar.google.com/citations?user=_a19A1EAAAAJ&hl=zh-CN

Author Contributions

1. 提出总体的算法思路、提出了拓扑型、提出利用同构比较拓扑型与子图、提出了轨道法用于判别是否存在空缺、提出了轨道法的2个判别条件、提出了轨道法求取的框架(行列优先级拓扑排序+序列跳跃)、提出1阶与2阶行列优先级、提出了倒转行列标签后可重复利用已有代码求另一方向的结果;编写5%的代码。
2. 提出利用垫顶点将图的左右給pad上、提出利用轨道法找出空缺后填入占位顶点这样就能把表格填补为规整的表格、想到了轨道法判别条件1的反例、想到了如何将行列优先级融入拓扑序的算法;编写95%的代码。

About

An application for testing the TableStructureGraph2MergingSet algorithm!

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published