def _read()

in curiosity/reader.py [0:0]


    def _read(self, file_path: str):
        """
        file_path should point to a curiosity dialog file. In addition,
        the directory that contains that file should also contain the
        sqlite database associated with the dialogs named as below
        - wiki_sql.sqlite.db
        """
        with open(file_path) as f:
            dataset = json.load(f)
            dialogs = dataset["dialogs"]

        directory = os.path.dirname(file_path)
        db_path = os.path.join(directory, "wiki_sql.sqlite.db")
        engine, session = create_sql(db_path)
        facts = session.query(Fact).all()
        self._fact_lookup = {f.id: f for f in facts}
        verify_checksum(dataset["db_checksum"], db_path)
        # store = CuriosityStore(db_path)
        # fact_lookup = store.get_fact_lookup()
        # TODO: Add in facts
        for d in dialogs:
            for msg in d["messages"]:
                # Filter out user messages
                if self._filter_user_messages and msg["sender"] == USER:
                    continue

                # Filter out messages without paired facts, if required
                if self._filter_empty_facts:
                    facts_used = [f for f in msg["facts"] if f["used"]]
                    if len(facts_used) == 0:
                        continue

                yield self.text_to_instance(msg, d)

        session.close()