Ejemplo n.º 1
0
 def execute(self, command, args):
     dg = DatabaseLogic(self._cm)
     dg.easy_check(command)
     if 'init' == command:
         self._setup()
     elif 'dump' == command:
         self._dump()
     elif 'train' == command:
         if len(args) < 1:
             sys.stderr.write('サブコマンドの引数が足りません:%s %s\n' %
                              (command, 'mail_directory_name'))
             sys.exit(3)
         dg.easy_check(args[0])
         self._imp(args[0])
         mpssid = self._cm.get_mail_profile_set_sid(args[0])
         self._train(mpssid)
     elif 'prob' == command:
         if len(args) < 3:
             sys.stderr.write(
                 'サブコマンドの引数が足りません:%s %s %s %s\n' %
                 (command, 'mail_directory_name', 'message', 'category'))
             sys.exit(3)
         dg.easy_check(args[0])
         dg.easy_check(args[2])
         msid = self._cm.get_model_sid(args[0])
         self._prob(msid, args[1], args[2])
     elif 'dumpmeasurableset' == command:
         if len(args) < 2:
             sys.stderr.write('サブコマンドの引数が足りません:%s %s %s\n' %
                              (command, 'mail_directory_name', 'message'))
             sys.exit(3)
         dg.easy_check(args[0])
         msid = self._cm.get_model_sid(args[0])
         self._dump_measurable_set(msid, args[1])
     else:
         sys.stderr.write('未定義のサブコマンドです: %s\n' % command)
         sys.exit(3)
Ejemplo n.º 2
0
 def _prob(self, msid, message, category):
     dg = DatabaseLogic(self._cm)
     tg = TrainLogic(self._cm)
     model = dg.create_model(msid)
     ms = tg.create_measurable_set(model, message)
     print(tg.prob(model, ms, category))
Ejemplo n.º 3
0
 def _dump_measurable_set(self, msid, message):
     dg = DatabaseLogic(self._cm)
     tg = TrainLogic(self._cm)
     model = dg.create_model(msid)
     ms = tg.create_measurable_set(model, message)
     print(tg.dump_measurable_set(ms))
Ejemplo n.º 4
0
 def _train(self, mpssid):
     dg = DatabaseLogic(self._cm)
     tg = TrainLogic(self._cm)
     mps = dg.create_mail_profile_set(mpssid)
     model = tg.create_model(mps)
     dg.insert_model(model)
Ejemplo n.º 5
0
 def _imp(self, name):
     cg = ContentLogic(self._cm)
     mps = cg.create_mail_profile_set(name)
     dg = DatabaseLogic(self._cm)
     dg.insert_mail_profile_set(mps)
Ejemplo n.º 6
0
 def _dump(self):
     dg = DatabaseLogic(self._cm)
     dg.dump()
Ejemplo n.º 7
0
 def _setup(self):
     dg = DatabaseLogic(self._cm)
     dg.create_tables()