def convert(self, input_file_path, output_file_path):
        self.add_ont_defs()

        with open(input_file_path) as f:
            for line in f:
                res = self._get_next_res()
                parts = line.strip().split(',')

                if len(parts) == 1:
                    continue

                # 1. sepal length in cm
                l0 = Literal(parts[0], None, xsd_double)
                self._g.add((res, self._p0, l0))

                # 2. sepal width in cm
                l1 = Literal(parts[1], None, xsd_double)
                self._g.add((res, self._p1, l1))

                # 3. petal length in cm
                l2 = Literal(parts[2], None, xsd_double)
                self._g.add((res, self._p2, l2))

                # 4. petal width in cm
                l3 = Literal(parts[3], None, xsd_double)
                self._g.add((res, self._p3, l3))

                # 5. class
                self._g.add((res, a, self._clsid2cls[parts[4]]))

        write_graph(self._g, output_file_path)
    def convert(self, input_file_path, output_file_path):
        self.add_ont_axioms()

        with open(input_file_path) as f:
            for line in f:
                parts = line.strip().split(',')

                if len(parts) == 1:
                    continue

                # 1. Id number: 1 to 214
                r_id = int(parts[0])
                res = self._res(r_id)

                # 2. RI: refractive index
                l1 = Literal(parts[1], None, xsd_double)
                self._g.add((res, self._p1, l1))

                # 3. Na: Sodium (unit measurement: weight percent in
                # corresponding oxide, as are attributes 4-10)
                l2 = Literal(parts[2], None, xsd_double)
                self._g.add((res, self._p2, l2))

                # 4. Mg: Magnesium
                l3 = Literal(parts[3], None, xsd_double)
                self._g.add((res, self._p3, l3))

                # 5. Al: Aluminum
                l4 = Literal(parts[4], None, xsd_double)
                self._g.add((res, self._p4, l4))

                # 6. Si: Silicon
                l5 = Literal(parts[5], None, xsd_double)
                self._g.add((res, self._p5, l5))

                # 7. K: Potassium
                l6 = Literal(parts[6], None, xsd_double)
                self._g.add((res, self._p6, l6))

                # 8. Ca: Calcium
                l7 = Literal(parts[7], None, xsd_double)
                self._g.add((res, self._p7, l7))

                # 9. Ba: Barium
                l8 = Literal(parts[8], None, xsd_double)
                self._g.add((res, self._p8, l8))

                # 10. Fe: Iron
                l9 = Literal(parts[9], None, xsd_double)
                self._g.add((res, self._p9, l9))

                # 11. Type of glass
                cls = self._type2_cls[parts[10]]
                self._g.add((res, a, cls))

        write_graph(self._g, output_file_path)
Ejemplo n.º 3
0
    def save_model(self):
        # Save model checkpoint (Overwrite)
        output_dir = os.path.join(self.args.model_dir)

        if not os.path.exists(output_dir):
            os.makedirs(output_dir)

        write_edge_feature(self.edge_feature, self.args.edge_feature_file)
        write_graph(self.graph, self.args.graph_file)
        write_entity_feature(self.entity_feature,
                             self.args.entity_feature_file)
        model_to_save = self.model.module if hasattr(self.model,
                                                     'module') else self.model
        model_to_save.save_pretrained(output_dir)
        torch.save(self.args, os.path.join(output_dir, 'training_config.bin'))
        logger.info("Saving model checkpoint to %s", output_dir)
 def write_results_to_file(self, out_file_path):
     write_graph(self._g, out_file_path)
    def convert(self, input_file_path, output_file_path):
        self._add_ont_defs()

        with open(input_file_path) as f:
            for line in f:
                res = self._next_resource()
                parts = line.strip().split(',')

                if len(parts) == 1:
                    continue

                # 0) Type
                self._g.add((res, a, self._id2cls[parts[0]]))

                # 1) Alcohol
                l1 = Literal(parts[1], None, xsd_double)
                self._g.add((res, self._p1, l1))

                # 2) Malic acid
                l2 = Literal(parts[2], None, xsd_double)
                self._g.add((res, self._p2, l2))

                # 3) Ash
                l3 = Literal(parts[3], None, xsd_double)
                self._g.add((res, self._p3, l3))

                # 4) Alcalinity of ash
                l4 = Literal(parts[4], None, xsd_double)
                self._g.add((res, self._p4, l4))

                # 5) Magnesium
                l5 = Literal(parts[5], None, xsd_int)
                self._g.add((res, self._p5, l5))

                # 6) Total phenols
                l6 = Literal(parts[6], None, xsd_double)
                self._g.add((res, self._p6, l6))

                # 7) Flavanoids
                l7 = Literal(parts[7], None, xsd_double)
                self._g.add((res, self._p7, l7))

                # 8) Nonflavanoid phenols
                l8 = Literal(parts[8], None, xsd_double)
                self._g.add((res, self._p8, l8))

                # 9) Proanthocyanins
                l9 = Literal(parts[9], None, xsd_double)
                self._g.add((res, self._p9, l9))

                # 10)Color intensity
                l10 = Literal(parts[10], None, xsd_double)
                self._g.add((res, self._p10, l10))

                # 11)Hue
                l11 = Literal(parts[11], None, xsd_double)
                self._g.add((res, self._p11, l11))

                # 12)OD280/OD315 of diluted wines
                l12 = Literal(parts[12], None, xsd_double)
                self._g.add((res, self._p12, l12))

                # 13)Proline
                l13 = Literal(parts[13], None, xsd_int)
                self._g.add((res, self._p13, l13))

        write_graph(self._g, output_file_path)