示例#1
0
 def _generate_alt_title_triples(alt_title, song_uri, dataset_uri, ngram_repo, current_alt_titles):
     for triple in EntityToTriples.generate_str_labelled_triples_and_ngram_variations(entity_uri=song_uri,
                                                                                      primary_predicate=WPRO.alternative_title,
                                                                                      intermediary_entity_uri=
                                                                                      URIRef(song_uri + "/alt_title"
                                                                                              + str(
                                                                                                              current_alt_titles + 1)),
                                                                                      str_text=alt_title,
                                                                                      dataset_uri=dataset_uri,
                                                                                      ngram_repo=ngram_repo):
         yield triple
 def generate_dataset_uri(self, dataset):
     """
     It return a unique URI based on the content of the dataset object and the URIs already
     contained in the graph
     :return:
     """
     candidate_end = EntityToTriples.normalize_for_uri(dataset.title)
     if dataset.date is not None:
         candidate_end += "_" + dataset.date.replace("-", "_")
     candidate_uri = went.term(candidate_end)
     index = 97  # 97 is the ASCII number equivalent of char "a"
     while self._already_exist_in_graph(candidate_uri):
         candidate_uri = went.term(candidate_end + "_" + chr(index))
         index += 1
     return candidate_uri
 def prepare_alt_str_for_raw_artist(artist):
     result = ""
     if artist.country is not None:
         result += EntityToTriples.normalize_for_uri(artist.country)
     return result