本文整理汇总了Python中note.Note.getIDs方法的典型用法代码示例。如果您正苦于以下问题:Python Note.getIDs方法的具体用法?Python Note.getIDs怎么用?Python Note.getIDs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类note.Note
的用法示例。
在下文中一共展示了Note.getIDs方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from note import Note [as 别名]
# 或者: from note.Note import getIDs [as 别名]
def main():
parser = argparse.ArgumentParser()
parser.add_argument("-i",
dest = "txt",
help = "The files to be predicted on",
default = os.path.join(BASE_DIR, 'data/test-gold-A.txt')
#default = os.path.join(BASE_DIR, 'data/sms-test-gold-A.tsv')
)
parser.add_argument("-m",
dest = "model",
help = "The file to store the pickled model",
default = os.path.join(BASE_DIR, 'models/awesome')
)
parser.add_argument("-o",
dest = "out",
help = "The directory to output predicted files",
default = os.path.join(BASE_DIR, 'data/predictions')
)
# Parse the command line arguments
args = parser.parse_args()
# 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)
# Predict
for txt_file in txt_files:
note = Note()
note.read(txt_file)
X = zip(note.getIDs(),note.getTweets())
labels,confidences = predict_using_model(X, model_path, out_dir)
'''
# Confident predictions
labels_map = {'positive':0, 'negative':1, 'neutral':2}
proxy = []
for t,l,c in zip(note.getTweets(),labels,confidences):
conf = []
for i in range(len(labels_map)):
if i == labels_map[l]: continue
conf.append( c[labels_map[l]] - c[i] )
avg = sum(conf) / len(conf)
start,end,tweet = t
if avg > 1:
#print tweet[start:end+1]
#print l
#print c
#print
#proxy.append(l)
proxy.append('poop')
else:
print 'not conf'
print tweet[start:end+1]
print l
print c
print
proxy.append(l)
#proxy.append('poop')
'''
# output predictions
outfile = os.path.join(out_dir, os.path.basename(txt_file))
note.write( outfile, labels )