def generate(filename, intervals): up = count_distance(highest_note) low = count_distance(lowest_note) with open(filename, 'w') as file: file.write(header) file.write(" { \\time %d/4 " % tempo) full_time = bar_count / (4 / tempo) note = Note() file.write(note.pitch + note.octave + str(note.time_stamp) + " ") full_time -= (1 / note.time_stamp) while full_time > 0: possibilities = init_possibilities(note, up, low, intervals) interval, semitones = pick_interval(possibilities) note = count_interval(note, interval, semitones) ind = random.randint(0, len(rhythmic_values) - 1) note.time_stamp, time_str = rhythmic_values[ind] while 1 / note.time_stamp > full_time: ind += 1 note.time_stamp, time_str = rhythmic_values[ind] full_time -= 1 / note.time_stamp file.write(note.pitch + note.octave + time_str + " ") file.write(' \\bar "||" }')
def setfirstbeatmap(self): self.enemy.beatmapspecs["lv"] = self.enemy.lv specs = self.enemy.beatmapspecs self.beatmaps = [randombeatmap.random_beatmap(specs)] self.initiatenewbeatmap() self.reset_time() self.reset_enemy() if self.tutorialp: self.tutorialstate = "starting" # if it is the tutorial, add two notes for the player to fail on, and change first note to a b = self.beatmaps[0] del b.notes[0] b.notes.insert(0, Note(0, b.notes[0].time, 3)) # set it to be an accidental for the accidental tutorial if self.accidentaltutorialp: b.notes[0].accidentalp = True # first add ten to give space for the new notes for note in b.notes: note.time += 24 b.notes[0].time -= 12 if not self.accidentaltutorialp: b.notes = [Note(0, 1, 1), Note(1, 2, 1)] + b.notes else: newn = Note(0, 1, 2, accidentalp=True) b.notes.insert(0, newn)
def add_note( self, note, octave=None, dynamics={}, ): """Adds a note to the container and sorts the notes from low to high. The \ note can either be a string, in which case you could also use the octave \ and dynamics arguments, or a Note object.""" if type(note) == str: if octave is not None: note = Note(note, octave, dynamics) elif len(self.notes) == 0: note = Note(note, 4, dynamics) else: if Note(note, self.notes[-1].octave) < self.notes[-1]: note = Note(note, self.notes[-1].octave + 1, dynamics) else: note = Note(note, self.notes[-1].octave, dynamics) if not hasattr(note, 'name'): raise UnexpectedObjectError, \ "Object '%s' was not expected. Expecting a mingus.containers.Note object."\ % note if note not in self.notes: self.notes.append(note) self.notes.sort() return self.notes
def addnote(notelist, time, ischord, specs, valuestouse, accidentalp): lv = specs['lv'] l = notelist.copy() duration = random_duration(time, l, specs, False, ischord) # so you can specify a value if len(valuestouse) == 0: rv = random_value(time, ischord, l, specs) else: if notecollidep(time, valuestouse[0], duration, l): rv = random_value(time, ischord, l, specs) else: rv = valuestouse[0] # chord notes added before the main note to make it easier to compare to the melody if ischord: appendnotewithspecs( l, Note(rv, time, duration, True, accidentalp=accidentalp), specs) else: appendnotewithspecs(l, Note(rv, time, duration, accidentalp=accidentalp), specs) return (l, duration)
def add_note(cls, text): last_id = get_last_id("/home/" + os.getlogin() + "/.todo/") note = Note(text, last_id) with open("/home/" + os.getlogin() + "/.todo/" + 'store.txt', 'a') as f: note.to_file(f) set_last_id(last_id + 1, "/home/" + os.getlogin() + "/.todo/")
def searchCounter(mode, note, cantus, depth, plagal, lastNode=None): # print('starting serch counter '+str(note)) # print(depth) print('\n start search ' + str(depth)) print('sequence ' + str(note)) if depth == 0: # print('generating counter '+str(note)) newNode = Node(note) else: # print('constructing child '+str(note) + ' from :'+str(lastNode.note)) newNode = Node(note, lastNode) if not newNode.isValid(True, mode): print('---invalid melody ' + str(newNode.sequence)) # print(str(note)+' invalid melody') return else: print('---valid melody') print(newNode.sequence) if not newNode.validateVoice1(cantus): # print(str(note)+' invalid counter') print('---invalid counter') return False else: print('---valid counterpoint') if depth + 1 == maxDepth: counterP.append(newNode) return shift = 4 if plagal else 0 # print('generating children') if depth == 0: print('mode is ' + str(Note(mode).name)) searchCounter(mode, mode - 1, cantus, 1, plagal, newNode) return if depth + 2 == maxDepth: searchCounter(mode, mode, cantus, depth + 1, plagal, newNode) searchCounter(mode, mode + 4, cantus, depth + 1, plagal, newNode) return for i in range(mode - shift, mode + 7 - shift): interval = i - cantus[depth + 1] print('index' + str(i)) print('step ' + str(depth)) print('cantus ' + str(cantus[depth])) print('diatonic interval' + str(Note.diatonic(interval))) interval = Note.diatonic(interval) % 12 if interval == 1: continue if interval == 2: continue if interval == 5: continue if interval == 6: continue if interval == 10: continue if interval == 11: continue searchCounter(mode, i, cantus, depth + 1, plagal, newNode)
def __init__(self): self.title = '' self.meter = 6.0 / 8.0 self.rhythm = 'Jig' self.noteLength = 1.0 / 8.0 self.key = '' self.origin = '' self.currentNote = Note(self.noteLength) self.phraseChain = PhraseChain(self.meter, self.noteLength)
def getNote(self, noteId): objectIds = self.downloadObjectIds() for objectId in objectIds: if str(noteId) == SwiftManager.objIdToId(objectId): noteContent = self._downloadNote(objectId) note = Note(SwiftManager.objIdToTitle(objectId)) note.setObjectId(objectId) note.setContent(noteContent) return note return None
def checkTritone(self, note): if Note.equals(note, Note.B.value) and Note.equals( self.parent, Note.F.value): print('direct tritone ' + str(note) + ' ' + str(self.parent)) return False if Note.equals(note, Note.F.value) and Note.equals( self.parent, Note.B.value): print('direct tritone') return False return True
def createNote(): note = Note.get(request.json) session = get_session() lastNote = session.query(Note).order_by(Note.NoteId.desc()).first() note.NoteId = 1 if lastNote == None else lastNote.NoteId + 1 try: session.add(note) session.flush() except: note = Note() return Response(json.dumps(note.to_dict()), mimetype='application/json')
def testNotes(self): print('testing notes') for i in range(0, 12): if not Note.isWhite(i): continue print('chromatic index :' + str(i)) print('chromatitc name :' + str(Note(i))) d = Diatonic(Diatonic.index(Note(i).value)).name ch = Note(i).name print('diatonic name :' + d) assert(d == ch)
def __init__(self, notes): self.notes = [ note if isinstance(note, Note) else (Note(note) if note in FREQUENCY_FOR_NOTE_LABEL else Note(*note)) for note in notes ] if len(notes) > 0: zeros_mono = np.zeros( np.sum([note.duration_samples for note in self.notes]) + self.notes[-1].adsr.release_samples) self.samples = np.vstack([zeros_mono, zeros_mono]) self.mix()
def extractPhrasesFromLine(self, line): # Detect notes inChord = False for char in line.strip(): # Record everything between " as a single note, as it is a chord if IsChord(char): if inChord: # Close the chord inChord = False else: # Begin a new chord inChord = True self.phraseChain.addNote(self.currentNote) self.currentNote = Note(self.noteLength) self.currentNote.addChar(char) # If a chord is in progress, continue recording that chord until # the chord is closed elif inChord: self.currentNote.addChar(char) # If the character comes before a note and a note has been # recorded in the previous sequence, begin a new note # Otherwise, just add the character elif IsPreNote(char): if self.currentNote.containsNote(): self.phraseChain.addNote(self.currentNote) self.currentNote = Note(self.noteLength) self.currentNote.addChar(char) # If the character is a note, do the same as PreNote above elif IsNote(char): if self.currentNote.containsNote(): self.phraseChain.addNote(self.currentNote) self.currentNote = Note(self.noteLength) self.currentNote.addChar(char) # If the character comes after a note, it will only be added # if a note has been recorded. This may lose some information. elif IsPostNote(char): if self.currentNote.containsNote(): self.currentNote.addChar(char) elif char == '%': # Rest of the line is commented out break elif IsIgnored(char): continue else: print(ord(char)) print("Warning: Unrecognized char [{}] from line [{}]" .format(char, line))
def checkTritoneInside(self, note): index = self.index if Note.equals(note, Note.F.value) and Note.equals( self.sequence[index - 2], Note.B.value): print('surrounding tritone ' + str(note) + ' ' + str(self.sequence[index - 2])) return False if Note.equals(note, Note.B.value) and Note.equals( self.sequence[index - 2], Note.F.value): print('surrounding tritone ' + str(note) + ' ' + str(self.sequence[index - 2])) return False return True
def note_new(): if request.method == "POST": image=request.files.get('image') if not image.filename.endswith('.png'): return 'nah bro png images only!', 403 new_note=Note( request.form.get('title'), request.form.get('content'), image_filename=image.filename ) save_note(new_note, image) return redirect(new_note.get_link()) return render_template('new.html')
def onClickNotes(self): self.changeTab() self.noteBtn.setIcon(QIcon("src/menu/note-pressed.png")) if self.note == None: self.note = Note(self.widget) else: self.note.show() self.current = self.note self.currentBtn = self.noteBtn
def generate_first_note(first_note, rythmic_values, full_time, file): fnote = Note() fnote.pitch = first_note ind = randint(0, len(rythmic_values) - 1) fnote.time_stamp, time_str = rythmic_values[ind] while 1 / fnote.time_stamp > full_time: ind += 1 fnote.time_stamp, time_str = rythmic_values[ind] file.write(fnote.pitch + time_str) print(first_note.replace(" ", "")) return fnote.time_stamp
def printNotes(self): seq = self.sequence.copy() seq.reverse() arr = [] for s in seq: arr.append(Note(s).name) print(arr)
def addEvent(self, event): self.events.append(event) if isinstance(event, TrackNameEvent): self.name = event.trackName elif (isinstance(event, NoteOnEvent) and not (event.isNoteOff())): if event.noteNumber in self.incompleteNotes and self.debug: print("Note on event for note " + str(event.noteNumber) + " already playing, skipping...") else: self.incompleteNotes[event.noteNumber] = Note( event.startTime, event.startTimeTicks, event.noteNumber, event.velocity, event.channel) elif (isinstance(event, NoteOffEvent) or (isinstance(event, NoteOnEvent) and event.isNoteOff())): if event.noteNumber in self.incompleteNotes: self.incompleteNotes[event.noteNumber].setEndTime( event.startTime) self.incompleteNotes[event.noteNumber].setEndTimeTicks( event.startTimeTicks) self.notes.append(self.incompleteNotes[event.noteNumber]) del self.incompleteNotes[event.noteNumber] elif self.debug: print("Note off event for note " + str(event.noteNumber) + " not playing, skipping...") elif isinstance(event, EndOfTrackEvent): self.notes.sort()
def newNoteModify(handler, taskid, id, p_action): handler.title("New Note") requirePriv(handler, "User") if p_action != "delete": ErrorBox.die("Invalid Action", "Unrecognized action <b>%s</b>" % p_action) taskid = int(taskid) task = Task.load(taskid) if not task or task.sprint.isHidden(handler.session["user"]): ErrorBox.die("Invalid Task", "No task with ID <b>%d</b>" % taskid) id = int(id) note = Note.load(id) if not note: ErrorBox.die("Invalid Note", "No note with ID <b>%d</b>" % noteid) elif note.task != task: # Doesn't really matter, but shouldn't happen ErrorBox.die("Task mismatch", "Note/task mismatch") elif note.user != handler.session["user"]: ErrorBox.die("Permission denied", "Notes can only be deleted by their creators") note.delete() delay(handler, SuccessBox("Deleted note", close=3)) Event.deleteNote(handler, note) redirect("/tasks/%d" % task.id)
def Search(note, depth, maxDepth, plagal, lastNode=None): print('depth' + str(depth)) seq = str(lastNode.sequence) if lastNode else '' print('initialize node at :' + str(note) + ' preSequence : ' + seq + ' depth : ' + str(depth)) if depth == 0: # print('starting from: '+str(note)) new_node = Node(note) else: new_node = Node(note, lastNode) if not new_node.validMelody(size=11, counterMode=False, mode=new_node.root): print('invalid ' + str(new_node.sequence)) return else: print('valid ' + str(new_node.sequence)) if depth + 1 == maxDepth: print('depth exceeeeeede!!!!!!!!!!!!!!!' + str(new_node.sequence)) container.append(new_node) return shift = 5 if plagal else 0 root = new_node.root if depth + 2 == maxDepth: Search(new_node.root, depth + 1, maxDepth, plagal, new_node) return for i in range(0, 7): newNote = Note.diatonicScale(root - shift, i) print('searching ' + str(new_node.sequence) + str(newNote)) print('note to search is: ' + str(i)) Search(newNote, depth + 1, maxDepth, plagal, new_node)
def GenerateCounter(cantus): searchCounter(cantus[0] + 7, cantus[0] + 7, cantus, 0, False) print('counter found ' + str(len(counterP))) for c in counterP: # if pruneCounter(cantus, c): # continue print('\n') c.printNotes() # print(c.sequence) for i in range(0, 11): if i == 0: new_node = Node(cantus[0]) previous = new_node else: new_node = Node(cantus[i], previous) previous = new_node new_node.printNotes() c.sequence.reverse() print(c.sequence) intervals = [] for i in range(0, 11): intervals.append( Note.nInterval(new_node.sequence[i], c.sequence[i])) intervals.reverse() print(intervals)
def vk_ready_download_handler(message): group_api.vk.messages.send(user_id=message.user_id, message=u"Погнали!") rand, local_dir = gen_random_dir() title, ext = VkLoader().process(message.user_id, local_dir) if is_correct_name("zip", ext): logger(user_id=message.user_id, log=u"Некорректный формат архиива") return logger(user_id=message.user_id, log=u"Разархивировали") if is_correct_name(format_dir, title): logger(user_id=message.user_id, log=u"Некорректное имя архива") return PdfGenerator().process(local_dir, title) logger(user_id=message.user_id, log=u"Пдф сгенерирована") matches = re.findall(format_dir, title, re.U) global_db.insert_into(Note.from_list(matches[0], rand).__str__()) logger(user_id=message.user_id, log=u"Загружаем на сервер") file_for_upload = local_dir % ("%s.%s" % ("note_pdf", "pdf")) uploader = VkUploader(page_id=55980612, group_id=171785116, menu_title="Меню", doc_title=title, rand_id=rand) is_uploaded = uploader.upload(file_for_upload) if is_uploaded: logger(user_id=message.user_id, log=u"Конспект успешно добавлен") else: logger(user_id=message.user_id, log=u"Что-то пошло не так")
def get_note_and_section_name(self, section_name): note_name = self.get_text("یادداشت جدید", "نام یادداشت:") if not note_name: reply = QMessageBox.question( self, 'پیام', "نام خالی است. دوباره امتحان میکنید؟", QMessageBox.Yes | QMessageBox.No, QMessageBox.No) if reply == QMessageBox.Yes: self.get_note_and_section_name() else: return if section_name is None: section_name = self.get_text("بخش", "نام بخش:") if not note_name: reply = QMessageBox.question( self, 'پیام', "نام بخش خالی است. دوباره امتحان میکنید؟", QMessageBox.Yes | QMessageBox.No, QMessageBox.No) if reply == QMessageBox.Yes: self.get_note_and_section_name() else: return section = None for s in self.notebook.sections: if s.name == section_name: section = s if section is None: section = Section(section_name) self.notebook.add_section(section) note = Note(note_name, "") section.add_note(note) return note, section_name
def add(self, path): #添加路径,并且创建note加入列表 for i in self.files: if i == path: return False self.files.append(path) self.notes.append(Note(path)) return True
def printNotes(self): seq = self.sequence.copy() seq.reverse() arr = [] for s in seq: arr.append(Note(s % 12).name + str(int(s / 12))) print(arr) print(seq)
def validateVoice1(self, cantusFirmus): index = self.index note = self.note reference = cantusFirmus[index] print('index :' + str(index)) if not Note.Consonant(cantusFirmus[index], self.note): # print(cantusFirmus[index]) print(reference) print(note) print('disssonance') return False if index > 0: lastInterval = abs(self.parent - cantusFirmus[index - 1]) if lastInterval == 7: if abs(note - cantusFirmus[index]) == 7: print('parallel fifth') return False referenceJump = abs(cantusFirmus[index] - cantusFirmus[index - 1]) if self.jump() != 0 and referenceJump / self.jump() > 0: if lastInterval == 7: print('direct fifth') return False if lastInterval == 12: if abs(note - cantusFirmus[index]) == 12: print('parallel octave') print(self.sequence) print(cantusFirmus) return False if self.jump() != 0 and referenceJump / self.jump() > 0: print('caca ' + str(lastInterval)) if lastInterval == 0: if cantusFirmus[index] != note: print('direct octave') return False print('COUNTERPOINT') self.printNotesReverse() print(self.sequence[0:index + 1]) cfNotes = [] for n in cantusFirmus: cfNotes.append(Note(n % 12).name + str(n // 12)) print('CANTUS FIRMS \n:' + str(cfNotes[0:index + 1])) print(cantusFirmus[0:index + 1]) print('INTERVAL :' + str(Note.interval(reference, note))) return True
def __init__(self, strings=None, num_frets=21): if strings is None: e = Note(c.NOTE_E) a = Note(c.NOTE_A) d = Note(c.NOTE_D) g = Note(c.NOTE_G) b = Note(c.NOTE_B) strings = [ GuitarString(e), GuitarString(a), GuitarString(d), GuitarString(g), GuitarString(b), GuitarString(e) ] self.set_strings(strings) self.set_num_frets(num_frets)
def __init__(self): self.title = '' self.meter = 6.0/8.0 self.rhythm = 'Jig' self.noteLength = 1.0/8.0 self.key = '' self.origin = '' self.currentNote = Note(self.noteLength) self.phraseChain = PhraseChain(self.meter, self.noteLength)
def deleteNotes(): session = get_session() for n in request.json: note = Note.get(n) found = session.query(Note).filter_by(NoteId=note.NoteId).first() if found != None: session.delete(found) session.flush() return Response(json.dumps(True), mimetype='application/json')
def __init__(self, key='C', meter=(4, 4)): # warning should check types if type(key) == str: key = Note(key) self.key = key self.set_meter(meter) self.empty()
def from_interval_shorthand(self, startnote, shorthand, up = True): """Empties the container and adds the note described in the startnote and shorthand. \ See core.intervals for the recognized format. {{{ >>> 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
def checkEnd(self, index, note, counterMode, scaleMode): if counterMode: if ((scaleMode - 1) - note) % 12 != 0: print('beforeEnd should be sensible') return False elif note != Note.diatonicScale(self.root, 1): print('beforeEnd should be root + 1') return False return True
def ToNote12(sequence): forexample: assert(e[1] is not None) '''check if cf is note7''' if e[0]: length = len(e[1]) s = e[1] for i in range(0, length): s[i] = Note.diatonicScale(0, s[i])
def get_one_note(self, idt): q = "select * from note where id=%d" % (idt) try: NoteDB.cursor.execute(q) result = NoteDB.cursor.fetchall() obj = Note(idt=result[0], msg=result[1], time=result[2]) return obj except Exception as e: raise
def notecollidep(ntime, nvalue, nduration, l): iscopy = False x = 0 while (x < len(l)): if l[x].getscreenvalue() == Note.value_to_screenvalue(nvalue): if l[x].time+l[x].duration > ntime and l[x].time < ntime+nduration: iscopy = True break x += 1 return iscopy
def newNotePost(handler, taskid, p_body, dryrun=False): handler.title("New Note") if dryrun: handler.wrappers = False requirePriv(handler, "User") taskid = int(taskid) task = Task.load(taskid) if not task or task.sprint.isHidden(handler.session["user"]): ErrorBox.die("Invalid Task", "No task with ID <b>%d</b>" % taskid) note = Note(task.id, handler.session["user"].id, p_body) if dryrun: print note.render() else: if p_body == "": ErrorBox.die("Empty Body", "No note provided") note.save() Event.newNote(handler, note) redirect("/tasks/%d#note%d" % (task.id, note.id))
def notecollidebesidesselfp(note, l): ntime = note.time nduration = note.duration nvalue = note.value iscopy = False x = 0 while (x < len(l)): if not note == l[x]: if l[x].getscreenvalue() == Note.value_to_screenvalue(nvalue): if l[x].time+l[x].duration > ntime and l[x].time < ntime+nduration: note.collidedwithanotherp = True iscopy = True break x += 1 return iscopy
def newNote(self, handler, note): usersContacted = [] for username in re.findall("<a href=\"/users/([a-z0-9]+)\">", note.render()): user = User.load(username = username) if user and (user not in usersContacted): usersContacted.append(user) self.sendMessage(handler, user, 'noteMention', "<a href=\"/tasks/%d#note%d\">%s</a>" % (note.task.id, note.id, note.task.safe.name)) for user in note.task.assigned: if user not in usersContacted: usersContacted.append(user) self.sendMessage(handler, user, 'noteRelated', "<a href=\"/tasks/%d#note%d\">%s</a>" % (note.task.id, note.id, note.task.safe.name), "a task assigned to you") for note in Note.loadAll(taskid = note.task.id): if note.user not in usersContacted: usersContacted.append(note.user) self.sendMessage(handler, note.user, 'noteRelated', "<a href=\"/tasks/%d#note%d\">%s</a>" % (note.task.id, note.id, note.task.safe.name), "a task you've also commented on")
def getNotes(self): from Note import Note return Note.loadAll(taskid = self.id, orderby = 'timestamp')
class Tune: def __init__(self): self.title = '' self.meter = 6.0/8.0 self.rhythm = 'Jig' self.noteLength = 1.0/8.0 self.key = '' self.origin = '' self.currentNote = Note(self.noteLength) self.phraseChain = PhraseChain(self.meter, self.noteLength) def setMeter(self, meter): self.meter = meter self.phraseChain.meter = meter def setNoteLength(self, noteLength): self.noteLength = noteLength self.phraseChain.noteLength = noteLength def GetLengthModifier(self, note): return self.noteLength def extractPhrasesFromLine(self, line): # Detect notes inChord = False for char in line.strip(): # Record everything between " as a single note, as it is a chord if IsChord(char): if inChord: # Close the chord inChord = False else: # Begin a new chord inChord = True self.phraseChain.addNote(self.currentNote) self.currentNote = Note(self.noteLength) self.currentNote.addChar(char) # If a chord is in progress, continue recording that chord until # the chord is closed elif inChord: self.currentNote.addChar(char) # If the character comes before a note and a note has been # recorded in the previous sequence, begin a new note # Otherwise, just add the character elif IsPreNote(char): if self.currentNote.containsNote(): self.phraseChain.addNote(self.currentNote) self.currentNote = Note(self.noteLength) self.currentNote.addChar(char) # If the character is a note, do the same as PreNote above elif IsNote(char): if self.currentNote.containsNote(): self.phraseChain.addNote(self.currentNote) self.currentNote = Note(self.noteLength) self.currentNote.addChar(char) # If the character comes after a note, it will only be added # if a note has been recorded. This may lose some information. elif IsPostNote(char): if self.currentNote.containsNote(): self.currentNote.addChar(char) elif char == '%': # Rest of the line is commented out break elif IsIgnored(char): continue else: print(ord(char)) print("Warning: Unrecognized char [{}] from line [{}]" .format(char, line)) def parseFile(self, fileName): if '.abc' not in fileName: print("Warning: The selected file is not a .abc file.") abcFile = open(fileName, 'r') for line in abcFile: if any(x in line for x in [ 'A:', 'B:', 'C:', 'D:', 'E:', 'F:', 'G:', 'H:', 'I:', 'N:', 'O:', 'P:', 'Q:', 'S:', 'W:', 'Z']): continue if 'X:' in line: tuneNumber = ParseAbcInfo(line) if tuneNumber != '1': # Begin parsing the new tune print("New tune {}".format(tuneNumber)) elif 'T:' in line: self.title = ParseAbcInfo(line) elif 'R:' in line: self.rhythm = ParseAbcInfo(line) elif 'K:' in line: self.key = ParseAbcInfo(line) elif 'M:' in line: self.setMeter(ParseAbcFraction(line)) elif 'L' in line: self.setNoteLength(ParseAbcFraction(line)) elif line.strip() == '': continue else: self.extractPhrasesFromLine(line)
def __init__(self, timeml_note_path, annotated_timeml_path=None, verbose=False): if verbose: print "called TimeNote constructor" _Note = Note.__init__(self, timeml_note_path, annotated_timeml_path) # get body of document data = get_text(timeml_note_path) # original text body of timeml doc self.original_text = data # send body of document to NewsReader pipeline. tokenized_text, token_to_offset, sentence_features, dependency_paths, id_to_tok = pre_processing.pre_process(data, timeml_note_path) # {sentence_num: [{token},...], ...} self.pre_processed_text = tokenized_text # contains the char based offsets generated by tokenizer, used for asserting char offsets are correct # {'token':[(start, end),...],...} self.token_to_offset = token_to_offset # contains sentence level information extracted by newsreader self.sentence_features = sentence_features # dependency paths for sentences in the document self.dependency_paths = dependency_paths # map token ids to tokens within self.tokenized_text # {'wid':'token'} self.id_to_tok = id_to_tok self.discourse_connectives = {} self.iob_labels = [] """ print "\n\nself.original_text:\n\n" print self.original_text print "\n\n" print "self.pre_processed_text:\n\n" print tokenized_text print "\n\n" print "self.token_to_offset:\n\n" print self.token_to_offset print "\n\n" print "self.sentence_features:\n\n" print self.sentence_features print "\n\n" """ self.tlinks = [] if self.annotated_note_path is not None: self.get_tlinked_entities() # will store labels in self.iob_labels self.get_labels()