本文整理汇总了Python中note.Note.sid_list方法的典型用法代码示例。如果您正苦于以下问题:Python Note.sid_list方法的具体用法?Python Note.sid_list怎么用?Python Note.sid_list使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类note.Note
的用法示例。
在下文中一共展示了Note.sid_list方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from note import Note [as 别名]
# 或者: from note.Note import sid_list [as 别名]
def main():
parser = argparse.ArgumentParser()
parser.add_argument("-i",
dest = "txt",
help = "The files to be predicted on (e.g. data/demo.tsv)",
)
parser.add_argument("-m",
dest = "model",
help = "The file to store the pickled model (e.g. models/demo.model)",
)
parser.add_argument("-o",
dest = "out",
help = "The directory to output predicted files (e.g. data/predictions)",
)
# Parse the command line arguments
args = parser.parse_args()
if (not args.txt) or (not args.model) or (not args.out):
parser.print_help()
exit(1)
# Decode arguments
txt_files = glob.glob(args.txt)
model_path = args.model
out_dir = args.out
# Available data
if not txt_files:
print 'no predicting files :('
exit(1)
# Load model
with open(model_path+'.model', 'rb') as fid:
clf = pickle.load(fid)
with open(model_path+'.dict', 'rb') as fid:
vec = pickle.load(fid)
# Predict labels for each file
for pfile in txt_files:
note = Note()
note.read(pfile)
XNotNormalized = zip(note.sid_list(), note.text_list())
X = XNotNormalized
#X = normalize_data_matrix(XNotNormalized)
# Predict
labels = predict( X, clf, vec )
# output predictions
outfile = os.path.join(out_dir, os.path.basename(pfile))
note.write( outfile, labels )