本文整理汇总了Python中note.Note类的典型用法代码示例。如果您正苦于以下问题:Python Note类的具体用法?Python Note怎么用?Python Note使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Note类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: getpubs
def getpubs():
"""Get Publisher initials and names from '__Publish Name and Initials'"""
import html2text # pip install html2text
import re
from note import Note
from models import ENNote
id = 90 # in table
title = '__Publish Name and Initials'
pubinitialsguid = '97a296aa-9698-4e29-bf74-3baa8e131ca1'
territorypoisguid = '658ad719-3492-4882-b0f7-f52f67a7f7fa'
#note_pubinitials = ENNote.objects.get(guid=pubinitialsguid)
note_pubinitials = ENNote.objects.get(id=90)
NotePubInitials = Note(note_pubinitials.content)
txt = NotePubInitials.parseNoteContentToMarkDown()
reobj = re.compile(r"(?P<lastname>.+?)\s*,\s*(?P<firstname>.+?)\s*-\s*_(?P<initials>[A-Z]+)")
match = reobj.search(txt)
if not match:
raise Exception("Failed to match publisher initials in: %s" % txt)
publishers = {}
for match in reobj.finditer(txt):
publishers[match.group("initials")] = "%s, %s" % (match.group("lastname"), match.group("firstname"))
return publishers
开发者ID:LarryEitel,项目名称:fltsys,代码行数:27,代码来源:note.py
示例2: main
def main():
"""
main()
Purpose: This program builds an SVM model for Twitter classification
"""
parser = argparse.ArgumentParser()
parser.add_argument("-t",
dest = "txt",
help = "The files that contain the training examples",
default = os.path.join(BASE_DIR, 'data/twitter-train-cleansed-B.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("-g",
dest = "grid",
help = "Perform Grid Search",
action='store_true',
default = False
)
# Parse the command line arguments
args = parser.parse_args()
grid = args.grid
# Decode arguments
txt_files = glob.glob(args.txt)
model_path = args.model
if not txt_files:
print 'no training files :('
sys.exit(1)
# Read the data into a Note object
notes = []
for txt in txt_files:
note_tmp = Note()
note_tmp.read(txt)
notes.append(note_tmp)
# Get data from notes
X = []
Y = []
for n in notes:
X += zip(n.sid_list(), n.text_list())
Y += n.label_list()
# Build model
train(X, Y, model_path, grid)
开发者ID:smartinsightsfromdata,项目名称:SemEval-2015,代码行数:60,代码来源:train.py
示例3: reset
def reset(cls):
"""Reset to default state."""
Box.reset()
Note.reset()
Figure.reset()
Table.reset()
Video.reset()
开发者ID:nunb,项目名称:MaTiSSe,代码行数:7,代码来源:theme.py
示例4: Melody
class Melody(object):
notes = [ ]
def __init__(self):
self.NOTE = Note()
def transpose(self, k):
value = [ ]
for note in self.notes:
i = self.NOTE.index(note)
j = i + k
note2 = self.NOTE.note(j)
value.append(note2)
return value
def reverse(self):
value = [ ]
for note in self.notes:
value = [note] + value
return value
def invert(self):
base = self.NOTE.index(self.notes[0])
value = [ ]
for note in self.notes:
k = self.NOTE.index(note)
kk = 2*base - k
note2 = self.NOTE.note(kk)
value.append(note2)
return value
开发者ID:jxxcarlson,项目名称:sf2sound,代码行数:30,代码来源:melody.py
示例5: parse_metadata
def parse_metadata(root):
notes = {}
for page in root.find('pageList').findall('page'):
pg = int(page.attrib['number'])
annotlist = page.find('annotationList')
for annot in annotlist.findall('annotation'):
if ( annot.attrib['type'] == "1" and
pg <= self.ui.documentWidget.num_pages ):
base = annot.find('base')
try:
author = base.attrib['author']
except KeyError:
author = ''
try:
text = base.attrib['contents']
except KeyError:
text = ''
try:
cdate = base.attrib['creationDate']
except KeyError:
cdate = ''
try:
mdate = base.attrib['modifyDate']
except KeyError:
mdate = ''
try:
preamble = base.attrib['preamble']
except KeyError:
preamble = PREAMBLE
try:
uname = base.attrib['uniqueName']
# notorius-1-0 becomes 0
uid = int(uname.rsplit('-')[-1])
except KeyError:
try:
uid = max(notes.keys())
except ValueError:
uid = 0
boundary = base.find('boundary')
x = float(boundary.attrib['l'])
y = float(boundary.attrib['t'])
size = self.ui.documentWidget.Document.page(
pg).pageSizeF()
pos = QtCore.QPointF(x*size.width(),
y*size.height())
note = Note(text, preamble, page = pg, pos = pos,
uid = uid)
notes[uid] = note
note.cdate = datetime.datetime.strptime(cdate, "%Y-%m-%dT%H:%M:%S")
note.mdate = datetime.datetime.strptime(mdate, "%Y-%m-%dT%H:%M:%S")
note.update()
else:
self.okular_notes.append(annot)
return notes
开发者ID:cako,项目名称:notorius,代码行数:55,代码来源:window.py
示例6: main
def main():
"""
main()
Purpose: This program builds an SVM model for Twitter classification
"""
parser = argparse.ArgumentParser()
parser.add_argument("-t",
dest = "txt",
help = "Files that contain the training examples (e.g. data/demo.tsv)",
)
parser.add_argument("-m",
dest = "model",
help = "The file to store the pickled model (e.g. models/demo.model)",
)
# Parse the command line arguments
args = parser.parse_args()
if (not args.txt) or (not args.model):
parser.print_help()
exit(1)
# Decode arguments
txt_files = glob.glob(args.txt)
model_path = args.model
if not txt_files:
print 'no training files :('
sys.exit(1)
# Read the data into a Note object
notes = []
for txt in txt_files:
note_tmp = Note()
note_tmp.read(txt)
notes.append(note_tmp)
# Get data from notes
X = []
Y = []
for n in notes:
X += zip(n.sid_list(), n.text_list())
Y += n.label_list()
# Build model
train(X, Y, model_path)
开发者ID:smartinsightsfromdata,项目名称:TwitterHawk,代码行数:53,代码来源:train.py
示例7: kick_drum_line
def kick_drum_line(composition, drop_number):
new_note_list = []
duration = 44100 / 8
drop_increment = duration / drop_number
for i, note in enumerate(composition.get_notes()):
effect_start_time = note.get_start_time() - duration
effect_end_time = note.get_start_time()
if effect_start_time < 0 :
new_note_list.append(note)
continue
if i != 0:
if note.is_kick():
rollback = 0
indices_in_notes_list = len(new_note_list) - 1
#keep rolling back until "in drop time" notes are popped off
while True:
last_note = new_note_list[-1]
if last_note.get_start_time() > (last_note.get_end_time() - duration):
new_note_list.pop()
else:
break
last_note = new_note_list[-1]
last_note.set_end_time(effect_start_time)
scale = composition.get_scale()
closest = utilities.find_closest(scale, note.get_frequency())
index = scale.index(closest) + drop_number
ampl = note.get_amplitude()
for x in range(0, drop_number):
new_s_time = int(effect_start_time + x * drop_increment)
new_e_time = int(effect_start_time + (x+1) * drop_increment)
new_freq = scale[index]
nn = Note(new_s_time, new_e_time, new_freq, ampl)
nn.set_kick(True)
new_note_list.append(nn)
index -=1
new_note_list.append(note)
else:
new_note_list.append(note)
composition.notes = new_note_list
开发者ID:jwsmithgit,项目名称:chipifier,代码行数:51,代码来源:retro_conformer.py
示例8: edit_notes
def edit_notes(mn, config_store, args):
"""
Display search results and allow edits.
:param Mininote mn: Mininote instance
:param ConfigStore config_store: User configuration
:param argparse.Namespace args: Command line options
"""
from match_notes import match_notes
text_editor = args.text_editor
before_notes = list(mn.search(args.note))
before_formatted_notes = '\r\n'.join(map(str, before_notes))
after_formatted_notes = text_editor.edit(before_formatted_notes)
try:
nonblank_lines = filter(lambda line: len(line.strip()) > 0, after_formatted_notes.splitlines())
after_notes = map(Note.parse_from_str, nonblank_lines)
except NoteParseError:
logger.error("Unable to parse changes to notes. Session is saved in {}".format(text_editor.path))
return
text_editor.cleanup()
before_notes_reparsed = map(lambda n: Note.parse_from_str(str(n)), before_notes)
pairs = match_notes(before_notes_reparsed, after_notes)
for before, after in pairs:
if before is None:
mn.add_note(after_notes[after])
elif after is None:
mn.delete_note(before_notes[before])
elif before_notes[before].text != after_notes[after].text:
before_notes[before].text = after_notes[after].text
mn.update_note(before_notes[before])
开发者ID:mininote,项目名称:mininote,代码行数:33,代码来源:mn.py
示例9: save
def save(self):
buff = self.get_buffer()
text = buff.get_text(buff.get_start_iter(), buff.get_end_iter())
if not self.note:
import utils
self.note = Note(utils.generate_filename(), utils.user_configurations['TIXPATH'], text)
self.note.write_text_to_file(text)
return self.note
开发者ID:siadat,项目名称:tix,代码行数:8,代码来源:gtk_classes.py
示例10: main
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 )
开发者ID:smartinsightsfromdata,项目名称:TwitterHawk,代码行数:60,代码来源:predict.py
示例11: get_all_notes
def get_all_notes():
G_ = Note('G#', 'Ab', None)
G = Note('G', '', G_)
F_ = Note('F#', 'Gb', G)
F = Note('F', '', F_)
E = Note('E', '', F)
D_ = Note('D#', 'Eb', E)
D = Note('D', '', D_)
C_ = Note('C#', 'Db', D)
C = Note('C', 'C', C_)
B = Note('B', '', C)
A_ = Note('A#', 'Bb', B)
A = Note('A', '', A_)
G_.NextNote = A
A.PrevNote = G_
return [A, A_, B, C, C_, D, D_, E, F, F_, G, G_]
开发者ID:jmescuderojustel,项目名称:music-theory,代码行数:18,代码来源:settings.py
示例12: _import
def _import(self):
self.noteList = {}
for infile in glob.glob(os.path.join(os.path.expanduser("~/.conboy"), "*.note")):
try:
parser = xml.sax.make_parser()
handler = textHandler()
parser.setContentHandler(handler)
parser.parse(infile)
except Exception:
import traceback
print traceback.format_exc()
try:
note = Note()
uuid = handler._content.split("\n", 1)[0].strip(" \t\r\n")
uuid = getValidFilename(uuid)
path = os.path.join(note.NOTESPATH, uuid)
if os.path.exists(path + ".txt"):
index = 2
while os.path.exists(os.path.join(note.NOTESPATH, "%s %s.txt" % (path, unicode(index)))):
index = index + 1
uuid = "%s %s" % (os.path.basename(path), unicode(index))
note.uuid = uuid + ".txt"
note.write(handler._content)
try:
from rfc3339.rfc3339 import strtotimestamp
mtime = strtotimestamp(handler._last_change)
lpath = os.path.join(Note.NOTESPATH, note.uuid)
os.utime(lpath, (-1, mtime))
except Exception:
import traceback
print traceback.format_exc()
except Exception:
import traceback
print traceback.format_exc()
self._set_running(False)
self.on_finished.emit()
开发者ID:harmattan,项目名称:KhtNotes,代码行数:44,代码来源:importer.py
示例13: _import
def _import(self):
self.noteList = {}
for infile in glob.glob( \
os.path.join(os.path.expanduser('~/.conboy'), '*.note')):
try:
parser = xml.sax.make_parser()
handler = textHandler()
parser.setContentHandler(handler)
parser.parse(infile)
except Exception, err:
import traceback
print traceback.format_exc()
try:
note = Note()
uuid = handler._content.split('\n', 1)[0].strip(' \t\r\n')
uuid = getValidFilename(uuid)
path = os.path.join(note.NOTESPATH, uuid)
if os.path.exists(path + '.txt'):
index = 2
while (os.path.exists(os.path.join( \
note.NOTESPATH,'%s %s.txt' \
% (path, \
unicode(index))))):
index = index + 1
uuid = ('%s %s' \
% (os.path.basename(path), \
unicode(index)))
note.uuid = uuid + '.txt'
note.write(handler._content)
try:
from rfc3339.rfc3339 import strtotimestamp
mtime = strtotimestamp(handler._last_change)
lpath = os.path.join(Note.NOTESPATH, note.uuid)
os.utime(lpath, (-1, mtime))
except Exception, err:
import traceback
print traceback.format_exc()
except Exception, err:
import traceback
print traceback.format_exc()
开发者ID:jul,项目名称:KhtNotes,代码行数:43,代码来源:importer.py
示例14: show_notes
def show_notes(noteId=None):
if noteId:
notes = (list(db.notes.find({'noteId': noteId})))
print notes
if notes:
note = Note.from_json(notes[0]) # convert to python object
note_title = note.title
content = note.content
noteId = note.noteId
return render_template('show_note.html', title=note_title, content=content, noteId=noteId)
开发者ID:ssakhi3,项目名称:notetaker,代码行数:10,代码来源:app.py
示例15: __init__
def __init__(self):
logging.debug('Initializing Data class')
self.DueDate = DueDate()
self.Reminder = Reminder()
self.Note = Note()
self.ID = 'Database'
self.dbDict = {
'Database':{
'DueDate':{
DueDate.returndDict()
},
'Reminder':{
Reminder.returnrDict()
},
'Note':{
Note.returnnDict()
}
}
}
开发者ID:galbie,项目名称:Remind-Me,代码行数:20,代码来源:data_rm.py
示例16: from_interval_shorthand
def from_interval_shorthand(self, startnote, shorthand, up=True):
"""Empty the container and add the note described in the startnote and
shorthand.
See core.intervals for the recognized format.
Examples:
>>> nc = NoteContainer()
>>> nc.from_interval_shorthand('C', '5')
['C-4', 'G-4']
>>> nc.from_interval_shorthand('C', '5', False)
['F-3', 'C-4']
"""
self.empty()
if type(startnote) == str:
startnote = Note(startnote)
n = Note(startnote.name, startnote.octave, startnote.dynamics)
n.transpose(shorthand, up)
self.add_notes([startnote, n])
return self
开发者ID:MayankTi,项目名称:python-mingus,代码行数:20,代码来源:note_container.py
示例17: emit_note
def emit_note(t):
if t in punctuation:
return _emit_rest(t)
fv = _word_to_fv(t)
sorted_scores = _score_notes_no_octave(fv)
note = ''
top_scores = selection.choose_top_score(sorted_scores)
if(len(top_scores) > 1):
note = random.choice(top_scores)
else:
note = top_scores[0]
note_to_emit = Note(note+str(octave.choose_octave(t)))
note_to_emit.accidental = accidental.choose_accidental(fv, note_to_emit.pitch)
note_to_emit.duration = duration.calculate_duration(t)
note_to_emit.fv = fv
note_to_emit.text = t
return note_to_emit
开发者ID:msbmsb,项目名称:wordstrument,代码行数:21,代码来源:emitter.py
示例18: show_post
def show_post():
"""Return the random URL after posting the plaintext."""
new_url = request.form["new_url"]
note = Note(new_url)
note.plaintext = request.form['paste']
passphrase = request.form.get('pass', False)
token = request.form['hashcash']
if not utils.verify_hashcash(token):
return redirect(url_for('index', error='hashcash'))
if passphrase:
note.set_passphrase(passphrase)
note.encrypt()
note.duress_key()
return render_template('post.html', random=note.url,
passphrase=note.passphrase, duress=note.dkey)
else:
note.encrypt()
return render_template('post.html', random=note.url)
开发者ID:CypherSystems,项目名称:d-note,代码行数:21,代码来源:__init__.py
示例19: read_file
def read_file(self, filename):
mid = MidiFile(filename)
# An internal clock that keeps track of current time based on the
# cumulative elapsed time delta of each note
current_time = 0
elapsed_time = 0
for _, track in enumerate(mid.tracks):
for message in track:
# Increment internal clock
current_time += message.time
current_time
if message.type == 'note_on':
# Create a new note for this note_on (no time information
# yet)
note = Note(
message.channel, message.note, message.velocity, elapsed_time, current_time)
self.notes.append(note)
elapsed_time = 0
elif message.type == 'note_off':
end_note = Note(
message.channel, message.note, message.velocity)
for note in reversed(self.notes):
if note == end_note and note.duration == None:
note.add_duration(current_time)
break
# If we haven't started a new note, we need to increment
# the elapsed time since the last note
if message.type != 'note_on':
elapsed_time += message.time
开发者ID:chrisranderson,项目名称:music-generation,代码行数:40,代码来源:song.py
示例20: post
def post(self, user_id):
note_id = self.get_argument('note_id', None)
if note_id is None or re.match(r'[a-z0-9]{32}', str(note_id)):
note = Note(
note_id,
user_id,
Note.STATUS_ACTIVE,
self.get_argument('title'),
self.get_argument('text'),
datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
)
self.get_manager().save(note)
self.write(tornado.web.escape.json_encode({
'code': 'OK',
'note': note.as_dict()
}))
else:
self.write(tornado.web.escape.json_encode({
'code': 'WRONG_PARAMS',
'note': None
}))
开发者ID:fobihz,项目名称:nevernote-server,代码行数:22,代码来源:main.py
注:本文中的note.Note类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论