【问题标题】:How to structure module with interactive methods如何使用交互方法构建模块
【发布时间】:2019-08-01 16:14:50
【问题描述】:

我正在开发一个程序,该程序解析数据并将其呈现给用户进行注释,以便为 ML 模型生成训练数据。我正在寻找有关如何以最合乎逻辑的方式构建此模块的类的建议。我对 OOP 有点陌生;超越典型的“vehicle->car->car_brand”类继承模型是我发现自己的地方。这个程序的基本流程是:

  1. 从外部获取杂乱的数据
  2. 解析数据以创建仅包含与此任务相关的信息的本地表示
  3. 向用户展示数据,然后用户使用注释对其进行标记
  4. 生成有关这些注释的统计信息

交互方法是否应该与清理后的数据属于同一类?生成统计数据的方法呢?

我尝试将这个程序的所有功能都包含在一个类定义下,这很好用,但似乎简化了,其他人可能难以快速掌握。以下是我认为程序可能的结构(对所有伪代码表示歉意):

class AnnotationData:
    # has methods to retrieve messy data and smooth it into what humans need to see to do this task. Populates class attributes to represent that data.
class AnnotationMethods(AnnotationData):
    # has methods to interact with data
class AnnotationStatistics(AnnotationData): 
    # has methods to generate statistics on data which has been augmented by humans

if __name__ == "__main__":
    # create base class
    # populate base class with messy data
    # smooth messy data into human-readable format
    # Instantiate AnnotationMethods class
    # Human does annotation
    # Instantiate AnnotationStatistics class
    # Return sweet sweet stats

将所有这些都包含在一个类中可以正常工作。我只是想知道将人类与之交互的方法与仅填充数据的方法分开的最佳做法是什么。

【问题讨论】:

    标签: python python-3.x oop object


    【解决方案1】:

    检查这个库https://github.com/dedupeio/dedupe。他们的工作流程与您的类似。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-07-31
      • 2021-12-30
      • 1970-01-01
      • 1970-01-01
      • 2011-03-14
      • 2018-11-24
      • 2011-09-23
      • 1970-01-01
      相关资源
      最近更新 更多