From e1c2a58009b6523abdffcbeee57ea02abd6f4171 Mon Sep 17 00:00:00 2001 From: moriaki3193 Date: Sat, 26 Jan 2019 21:06:02 +0900 Subject: [PATCH] close #4 add data class --- cdfm/consts.py | 8 ++++++++ cdfm/data.py | 8 ++++++++ cdfm/types.py | 4 +++- 3 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 cdfm/data.py diff --git a/cdfm/consts.py b/cdfm/consts.py index 40a96af..cb81d2d 100644 --- a/cdfm/consts.py +++ b/cdfm/consts.py @@ -1 +1,9 @@ # -*- coding: utf-8 -*- +"""Constants +""" +LABEL = 'label' +QID = 'qid' +EID = 'eid' +CIDS = 'cids' +FEATURES = 'features' +PROXIMITIES = 'proximities' diff --git a/cdfm/data.py b/cdfm/data.py new file mode 100644 index 0000000..ad52cc1 --- /dev/null +++ b/cdfm/data.py @@ -0,0 +1,8 @@ +# -*- coding: utf-8 -*- +"""Definition of records in dataset. +""" +from collections import namedtuple +from .consts import LABEL, QID, EID, CIDS, FEATURES, PROXIMITIES + + +Row = namedtuple('Row', (LABEL, QID, EID, CIDS, FEATURES, PROXIMITIES)) diff --git a/cdfm/types.py b/cdfm/types.py index a04f0d2..1c52538 100644 --- a/cdfm/types.py +++ b/cdfm/types.py @@ -1,8 +1,10 @@ # -*- coding: utf-8 -*- """Type annotations. """ -from typing import Dict, Union +from typing import Dict, List, Union +from .data import Row +Dataset = List[Row] EntityID = Union[int, str] EntIndMap = Dict[EntityID, int]