def _generate_triples_for_new_song(self, song, dataset_uri, isolated_song=False): song_uri = self.generate_entity_uri(entity=song, alt_str=SongToTriples.prepare_alt_str_for_song(song)) # # triple of type yield (song_uri, RDF.type, MO.track) # # canonical for triple in SongToTriples._generate_canonical_triples(song, song_uri, dataset_uri, self._ngram_repo): yield triple # # Triples of the artists for artist in song.artists: if artist.discogs_id in self._index_artist: yield (song_uri, FOAF.maker, URIRef(self._index_artist[artist.discogs_id])) for collaboration in song.collaborations: if collaboration.collaborator.discogs_id in self._index_artist: yield (song_uri, FOAF.maker, URIRef(self._index_artist[collaboration.collaborator.discogs_id])) # # Alternative titles for triple in SongToTriples._generate_alt_titles_triples_of_song(song=song, song_uri=song_uri, dataset_uri=dataset_uri, ngram_repo=self._ngram_repo, ): yield triple # # Country if song.country is not None: for triple in SongToTriples._generate_country_triples(entity=song, entity_uri=song_uri, dataset_uri=dataset_uri): yield triple ## Discogs elems if song.discogs_id is not None: for triple in SongToTriples._generate_discogs_id_triples(entity=song, entity_uri=song_uri): yield triple if song.discogs_index is not None: for triple in SongToTriples._generate_discogs_index_triples(entity=song, entity_uri=song_uri): yield triple increase_song_count(entity_counter_repo=self._entity_counter_repo)
def _generate_triples_for_new_song(self, song, dataset_uri, isolated_song=False): song_uri = self.generate_entity_uri(entity=song, alt_str=SongToTriples.prepare_alt_str_for_song(song)) # # triple of type yield (song_uri, RDF.type, MO.track) # # canonical for triple in SongToTriples._generate_canonical_triples(song, song_uri, dataset_uri, self._ngram_repo): yield triple # # Triples of the artists artist_uri = None for artist in song.artists: is_new_artist = False if not isolated_song: artist_uri = self._artist_to_triples.get_existing_artist_uri(artist=artist) is_new_artist = False else: artist_uri = None if artist_uri is None: artist_uri = self.generate_entity_uri(entity=artist, alt_str=ArtistRawToTriplesUtils.prepare_alt_str_for_raw_artist( artist)) is_new_artist = True for triple in self._artist_to_triples. \ generate_needed_artist_of_unknown_type_triples(artist=artist, dataset_uri=dataset_uri, artist_uri=artist_uri, is_new_artist=is_new_artist): yield triple # # Linking artist and song yield (song_uri, FOAF.maker, artist_uri) # # Alternative titles for triple in SongToTriples._generate_alt_titles_triples_of_song(song=song, song_uri=song_uri, dataset_uri=dataset_uri, ngram_repo=self._ngram_repo, ): yield triple # # Country if song.country is not None: for triple in SongToTriples._generate_country_triples(entity=song, entity_uri=song_uri, dataset_uri=dataset_uri): yield triple # # Discogs elems if song.discogs_id is not None: for triple in SongToTriples._generate_discogs_id_triples(entity=song, entity_uri=song_uri): yield triple if song.discogs_index is not None: for triple in SongToTriples._generate_discogs_index_triples(entity=song, entity_uri=song_uri): yield triple ##USOS elems if song.usos_transaction_id is not None: for triple in SongToTriples._generate_usos_transaction_id(entity=song, entity_uri=song_uri): yield triple if song.usos_isrc is not None: for triple in SongToTriples._generate_usos_isrc(entity=song, entity_uri=song_uri): yield triple increase_song_count(entity_counter_repo=self._entity_counter_repo)