def add_song_triples_to_graph(self, song_parser):
        dataset_uri = self._dataset_to_triples.generate_dataset_uri(song_parser.dataset)

        # # Triples of the dataset object (source)
        for triple in DatasetToTriples.generate_dataset_triples(song_parser.dataset, dataset_uri):
            self._add_triple(triple)

        # Triples of the different songs
        counter = 0
        millis_tmp = int(round(time.time() * 1000))
        millis = 0
        total_mils = 0
        for song_tuple in song_parser.parse_songs():
            print "Mira una!"

            # ###################
            counter += 1  # ## TIME
            if counter % 100 == 0:  # ## TIME
                millis = int(round(time.time() * 1000))  # ## TIME
                print counter, ",", millis - millis_tmp  # ## TIME
                total_mils += millis - millis_tmp  # ## TIME
                millis_tmp = millis  # ## TIME
            # ###################

            song_uri = song_tuple[0]
            print "____________"
            for triple in self._generate_needed_song_triples(song=song_tuple[1],
                                                             dataset_uri=dataset_uri,
                                                             song_uri=song_uri,
                                                             is_new_song=False):
                self._add_triple(triple)
                print triple
            print "____________"
        print total_mils
        return self._graph
예제 #2
0
    def add_artists_triples_to_graph(self, artist_parser):
        dataset_uri = self._dataset_to_triples.generate_dataset_uri(artist_parser.dataset)

        # # Triples of the dataset object (source)
        for triple in DatasetToTriples.generate_dataset_triples(dataset=artist_parser.dataset,
                                                                dataset_uri=dataset_uri):
            self._add_triple(triple)

        # Triples of the different artists
        for artist in artist_parser.parse_artists():
            artist_uri = self.get_existing_artist_uri(artist)
            is_new_artist = False
            if artist_uri is None:
                artist_uri = self.generate_entity_uri(entity=artist, alt_str=self.prepare_alt_str_for_artist(artist))
                is_new_artist = True
            for triple in self.generate_needed_artist_of_unknown_type_triples(artist=artist,
                                                                              dataset_uri=dataset_uri,
                                                                              artist_uri=artist_uri,
                                                                              is_new_artist=is_new_artist):
                self._add_triple(triple)

        return self._graph
예제 #3
0
    def add_song_triples_to_graph(self, song_parser):
        dataset_uri = self._dataset_to_triples.generate_dataset_uri(song_parser.dataset)

        # # Triples of the dataset object (source)
        for triple in DatasetToTriples.generate_dataset_triples(song_parser.dataset, dataset_uri):
            self._add_triple(triple)

        # Triples of the different songs
        counter = 0
        millis_tmp = int(round(time.time() * 1000))
        millis = 0
        total_mils = 0
        for song in song_parser.parse_songs():

            # ###################
            counter += 1  # ## TIME
            if counter % 100 == 0:  # ## TIME
                millis = int(round(time.time() * 1000))  # ## TIME
                print counter, ",", millis - millis_tmp  # ## TIME
                total_mils += millis - millis_tmp  # ## TIME
                millis_tmp = millis  # ## TIME
            # ###################

            song_uri = self._get_existing_song_uri(song)
            is_new_song = False
            if song_uri is None:
                song_uri = self.generate_entity_uri(entity=song,
                                                    alt_str=self.prepare_alt_str_for_song(song))
                is_new_song = True

            for triple in self._generate_needed_song_triples(song=song,
                                                             dataset_uri=dataset_uri,
                                                             song_uri=song_uri,
                                                             is_new_song=is_new_song):
                self._add_triple(triple)
        print total_mils
        return self._graph