Kgtk writer no file specified handling used
@@ -684,7 +684,6 @@ class EmbeddingVector:
output_format="kgtk_format", save_embedding_sentence=False, output_file=""):
self._logger.debug("START printing the vectors")
if output_format == "kgtk_format":
- if output_file != "-":
output_mode = KgtkWriter.Mode.NONE
ew: KgtkWriter = KgtkWriter.open(self.column_names,
output_file,
@@ -710,19 +709,11 @@ class EmbeddingVector:
for each_dimension in each_vector[:-1]:
embedding += str(each_dimension) + ","
embedding += str(each_vector[-1])
- if output_file == "-":
- print("{}\t{}\t{}".format(node_id, props, embedding))
- else:
ew.write_kgtk([node_id, props, embedding])
if save_embedding_sentence:
- if output_file == "-":
- print("{}\t{}\t{}\n".format(all_nodes[i], "embedding_sentence",
- self.candidates[all_nodes[i]]["sentence"]))
- else:
ew.write_kgtk([all_nodes[i], "embedding_sentence", self.candidates[all_nodes[i]]["sentence"]])
elif output_format == "tsv_format":
- if output_file != "-":
output_mode = KgtkWriter.Mode.NONE
ew: KgtkWriter = KgtkWriter.open(None,
output_file,
@@ -741,11 +732,7 @@ class EmbeddingVector:
for each_dimension in each_vector[:-1]:
embedding.append(str(each_dimension))
embedding.append(str(each_vector[-1]))
- if output_file == "-":
- print('\t'.join(embedding))
- else:
ew.write_tsv(embedding)
- if output_file != "-":
ew.close()
self._logger.debug("END printing the vectors")
