Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
ethen8181
GitHub Repository: ethen8181/machine-learning
Path: blob/master/deep_learning/multi_label/fasttext_module/utils.py
1488 views
1
import os
2
3
4
__all__ = ['prepend_file_name']
5
6
7
def prepend_file_name(path: str, name: str) -> str:
8
"""
9
Prepend the name to the base file name of the input path.
10
e.g. data/cooking.stackexchange.txt, prepend 'train' to the base file name
11
data/train_cooking.stackexchange.txt
12
13
Parameters
14
----------
15
path : str
16
Path to a file.
17
18
name : str
19
Name that we'll prepend to the base file name.
20
21
Returns
22
-------
23
prepended_file_name : str
24
"""
25
directory = os.path.dirname(path)
26
file_name = os.path.basename(path)
27
return os.path.join(directory, name + '_' + file_name)
28
29