def __add_data_to_dict(self): print("Collecting data to dictionary:") data = ReturnData() for pdf in self.pdf_list: notes = Notes() try: pdf_without_notes, notes = notes.extract_notes(pdf) except: continue #check impact else: if notes is None: data.files_skipped += 1 print("NOT PREPPED: ", pdf_without_notes[:7]) else: product = Product.factory(pdf_without_notes, notes) row = product.merge_notes_without_csv() key = notes["stock"] if notes["type"] == "FLAT": data.rows_flat.setdefault(key,[]).append(row) elif notes["type"] == "BOUND": data.rows_bound.setdefault(key, []).append(row) print("ADDED!!: ", pdf[:7]) data.files_added_to_csv += 1 print("All data in dictionary!") return data
def rename_and_move_pdf(self, pdf_list): for i, pdf in enumerate(pdf_list, 1): tic = timeit.default_timer() notes = Notes() new_pdf = notes.delete_prepp_notes_from(pdf) self.__copy_pdf_to_done_folder(pdf) self.__move_pdf_to_press_ready_pdf(pdf, new_pdf) toc = timeit.default_timer() print(i, new_pdf[:7], "MOVED, time: ", round(toc - tic, 4), "s")
def make_chromatic(key): '''Makes a chromatic array of notes starting from the specified key''' # pre-calculate the forward and backward ranges # needed to build the chromatic scale fr = range(key.distance, 12) br = range(0, key.distance) notes = [Notes.by_distance(i) for i in fr] notes.extend([Notes.by_distance(i) for i in br]) return notes
def __init__(self, graphics: Graphics, note_render: NoteRender, staff: Staff): self.graphics = graphics self.staff = staff self.note_positions = staff.get_note_positions() self.notes = Notes(graphics, note_render, staff, self.note_positions) self.song = None self.tempo_bpm = 60 self.ticks_per_beat = Song.SDQNotesPerBeat self.backing_index = {} self.backing_time = {}
def view_notes(username): n = Notes(username) all_notes = n.read_notes() if all_notes is False: print('No notes exists for {}'.format(username)) return False for savedtime, note in all_notes.items(): print(time.strftime("%d %b %Y %I:%M %p", time.localtime(int(savedtime))), note, sep=' : ')
def __init__(self, access_token=''): self.Account = Account(access_token=access_token) self.Apps = Apps(access_token=access_token) self.Audio = Audio(access_token=access_token) self.Auth = Auth(access_token=access_token) self.Board = Board(access_token=access_token) self.Database = Database(access_token=access_token) self.Docs = Docs(access_token=access_token) self.Other = Other(access_token=access_token) self.Fave = Fave(access_token=access_token) self.Friends = Friends(access_token=access_token) self.Gifts = Gifts(access_token=access_token) self.Groups = Groups(access_token=access_token) self.Likes = Likes(access_token=access_token) self.Market = Market(access_token=access_token) self.Messages = Messages(access_token=access_token) self.Newsfeed = Newsfeed(access_token=access_token) self.Notes = Notes(access_token=access_token) self.Notifications = Notifications(access_token=access_token) self.Pages = Pages(access_token=access_token) self.Photos = Photos(access_token=access_token) self.Places = Places(access_token=access_token) self.Polls = Polls(access_token=access_token) self.Search = Search(access_token=access_token) self.Stats = Stats(access_token=access_token) self.Status = Status(access_token=access_token) self.Storage = Storage(access_token=access_token) self.Users = Users(access_token=access_token) self.Utils = Utils(access_token=access_token) self.Video = Video(access_token=access_token) self.Wall = Wall(access_token=access_token) self.Widgets = Widgets(access_token=access_token)
def __init__(self, strip_number:int, led_number:int): self.strip_number = strip_number self.led_nuber = led_number self.led = Led(led_number=led_number, strip_number=strip_number) self.notes = Notes() self.has_been_assigned = False
def __init__(self, parent=None): QMainWindow.__init__(self) self._ppath = getProgramPath() log('PATH: %s' % self._ppath, True) self.config = SimpleConfig('~/.cn.conf') uic.loadUi(os.path.join(self._ppath, "main.ui"), self) self.connect(self.action_Exit, SIGNAL("triggered()"), self.close) self.connect(self.action_About, SIGNAL("triggered()"), self.showAboutBox) self.dbname = os.path.expanduser(self.config.readStr('WorkDir', '~/Coffee Notes')) self.notes = Notes(self.dbname) self.saving = False self.currentKey = None self.changed = False self.newNote() #### notes list behaviour self.model = QStringListModel() # !! self.noteList.setModel(self.model) self.noteList.setSelectionBehavior(QAbstractItemView.SelectRows) self.connect(self.noteList, SIGNAL("activated(const QModelIndex&)"), self.selectNote) self.connect(self.noteList, SIGNAL("clicked(const QModelIndex&)"), self.selectNote) self.filterNotes() self.connect(self, SIGNAL("indexChanged()"), self.selectCurrent) #### text editor & tag bar self.connect(self.noteEditor, SIGNAL("textChanged()"), self.textChanged) self.connect(self.tagBar, SIGNAL("textChanged(const QString&)"), self.textChanged) self.connect(self.deleteButton, SIGNAL("clicked()"), self.deleteNote) self.noteEditor.setAcceptRichText(False) self.noteEditor.setTabChangesFocus(True) #### search box self.connect(self.searchBar, SIGNAL("textChanged(const QString&)"), self.filterNotes) self.connect(self.searchBar, SIGNAL("returnPressed ()"), self.enterPressed) self.connect(self.addButton, SIGNAL("clicked()"), self.newNote) self.connect(self.syncButton, SIGNAL("clicked()"), self.startSync) #### autosave self.connect(self, SIGNAL('saveRequested()'), self.saveText) sec = self.config.readInt('Autosave', 5) if sec <= 0: sec = 5 self.autosaveThread = CallbackThread(self.autosave, sec) self.autosaveThread.start(QThread.IdlePriority) #### stantard shortcuts shCL = QShortcut(QKeySequence("Ctrl+L"), self) shCL.connect(shCL, SIGNAL("activated()"), self.toggleFocus) shEsc = QShortcut(QKeySequence("Esc"), self) shEsc.connect(shEsc, SIGNAL("activated()"), self.clearSearch) shCN = QShortcut(QKeySequence("Ctrl+N"), self) shCN.connect(shCN, SIGNAL("activated()"), self.newNote) shCD = QShortcut(QKeySequence("Ctrl+D"), self) shCD.connect(shCD, SIGNAL("activated()"), self.deleteNote) shCO = QShortcut(QKeySequence("Ctrl+O"), self) shCO.connect(shCO, SIGNAL("activated()"), self.changeSplitterOrientation) shCS = QShortcut(QKeySequence("Ctrl+S"), self) shCS.connect(shCS, SIGNAL('activated()'), self.startSync) self.setup()
def __init__(self, arg): self.curl = pycurl.Curl() self.option = Option() self.option.parse(arg) self.log = Log(self.option.isVerboseMode()) self.datas = [] config = json.loads(open(Epilader.JSON_CONF).read()) self.login = config["login"] self.password = config["password"] self.notes = Notes(config["projets"], config["modules"])
def loadNotes(self, FileNotes): file_object = open(FileNotes, 'r') corpus = file_object.readlines() file_object.close() notes = [] for j in range(len(corpus)): note = corpus[j].replace('\n', '') m = note.split('\t') notes.append(Notes(m[0], m[1], m[2], m[3])) return notes
def sync(dbpath, user, password): notes = Notes(dbpath) log("LOCAL TO REMOTE:") synced_count = 0 for note in notes.values(): if note["CHANGED"]: note["content"] = notes.getContent(note["key"]) if note["key"].startswith(KEY_PREFIX): log("NEW NOTE") k = note["key"] del note["key"] else: log("CHANGED: %s" % note["key"]) k = None note = api.update(note) note["CHANGED"] = False db.update(note) if k is not None: db.remove(k) synced_count += 1
def newSeq(): seq = request.get_json() #if sequence is correct format, change state of userDict class if match(seq): user = request.cookies['username'] userDictionary[user] = Notes(str.split(seq)) curState = userDictionary[user] return jsonify(curState.next_note()) #tell app that it wasnt correct format else: return jsonify("error")
def add_note(username): n = Notes(username) all_notes = n.read_notes() if all_notes and MAX_NOTES_PER_USER == len(all_notes): print( 'You have reached the limit. Your oldest note will be deleted to save new.' ) n.delete_old_note(all_notes) new_note = take_input('Enter note to save ', 'note') if n.create_note(new_note): print('Note saved successfully.') else: print('something went wrong... please try again')
def notesController(): if request.method == 'GET': userId = request.args.get('userId') app_json = json.dumps(notes[userId].__dict__) #temp = [notes[userId]] #app_json = json.dumps(temp.__dict__) return app_json elif request.method == 'POST': req_data = request.json userId = req_data.get("userId") userName = req_data.get("userName") createdOn = req_data.get("createdOn") title = req_data.get("title") note = req_data.get("note") print(userId) p1 = Notes(userId, userName, createdOn, title, note) print(p1) notes[userId] = p1 return json.dumps(notes[userId].__dict__)
def createWidgets(self): self.selectLabel = ttk.Label(self, text = "Select:") self.selectLabel.grid(column = 0, row = 0, padx = 10, pady = 5) self.select = Select(self, textvariable = self.selectVar) self.select.grid(column = 1, row = 0, sticky = (E, W)) self.searchLabel = ttk.Label(self, text = "Search:") self.searchLabel.grid(column = 2, row = 0, padx = 10, pady = 5) self.search = Search(self, textvariable = self.searchVar) self.search.grid(column = 3, row = 0, sticky = (E, W)) self.filestorage = FileStorage(self) self.filetree = FileTree(self) self.filetree.grid(column = 0, row = 1, rowspan = 4, sticky = (N, S, E, W), columnspan = 4) self.scrollbar = ttk.Scrollbar(self, orient = VERTICAL, command = self.filetree.yview) self.scrollbar.grid(column = 4, row = 1, rowspan = 4, sticky = (N, S, E)) self.filetree.configure(yscrollcommand = self.scrollbar.set) self.tags = Tags(self) self.tags.grid(column = 5, row = 2, sticky = (E, W), padx = 5) self.tagsLab = ttk.Label(text = "Tags") self.tagsLab.grid(column = 5, row = 1, padx = 5, pady = 2) self.notes = Notes(self) self.notes.grid(column = 5, row = 4, sticky = (N, S, E, W), padx = 5) self.notesLab = ttk.Label(text = "Notes") self.notesLab.grid(column = 5, row = 3, padx = 5, pady = 2) self.scrollNotes = ttk.Scrollbar(self, orient = VERTICAL, command = self.notes.yview) self.scrollNotes.grid(column = 6, row = 4, sticky = (N, S, W)) self.notes.configure(yscrollcommand = self.scrollNotes.set) self.buttons = Buttons(self) self.buttons.grid(row = 5, column = 0, columnspan = 5, pady = 5, sticky = (E, W)) self.statusBar = StatusBar(self) self.statusBar.grid(row = 6, column = 0, columnspan = 5, padx = 5, pady = 5, sticky = (E, W))
#author: brunofurmon (github.com/brunofurmon) import math # import needed modules from pyaudiowrapper import PyAudioWrapper from notes import Notes bitrate = 48000 channels = 1 A5_1 = Notes.A(5, .25, bitrate) A5_2 = Notes.A(5, .5, bitrate) B5_1 = Notes.B(5, .25, bitrate) B5_2 = Notes.B(5, .5, bitrate) Bb4_1 = Notes.Bb(4, .25, bitrate) Bb4_2 = Notes.Bb(4, .5, bitrate) G4_1 = Notes.G(4, .25, bitrate) G4_2 = Notes.G(4, .5, bitrate) C5_1 = Notes.C(5, .25, bitrate) C5_2 = Notes.C(5, .5, bitrate) Ab4_1 = Notes.Ab(4, .25, bitrate) Ab4_2 = Notes.Ab(4, .5, bitrate) Eb4_1 = Notes.Eb(4, .25, bitrate) Eb4_2 = Notes.Eb(4, .5, bitrate)
from notes import Notes from musical.theory import Note ''' Fugues start with a theme that sounds successively in each voice, creating the exposition. ''' scale = Notes.scale('G3','minor') theme = (scale[:3] + Note('G3').triad('minor')) * 2 + scale exposition = theme%0.75 + (theme>>(3,'minor')) % 0.5 + (theme>>(5,'minor')) % 0.25 ''' This is followed by the episode, developed from previously heard material. ''' episode = (~scale)[:4] + scale[3:7].chord(scale[7]) % 0.5 episode = episode * 2 + theme % 0.25 ''' We then bring this simple fugue to a conclusion with the coda. ''' arpeggio = Notes.arpeggio((~scale)[7],'minor') arpeggio = arpeggio + (arpeggio>>(7,'minor')) arpeggio = arpeggio + arpeggio.allChorded().chord('G5') coda = Notes('G4') + (~scale)[:7] + arpeggio ''' Play all the notes! ''' (exposition + episode + coda).play()
#!/usr/bin/python import yaml config = yaml.safe_load(open("config.yml")) dt_format = config["global"]["dt_format"] from notes import Notes, Note notebook = Notes() import sys all_notes = notebook.get_notes() for note in all_notes: print("Note #" + str(all_notes.index(note) + 1)) print("Text: " + note.text) print("Date: " + note.date.strftime(dt_format)) print
def process_notes(self, string): self.set_progress_text("Reading notes...") self.notes = Notes(string) self.add_progress(self.TASK_LENGTH_NOTES)
organiserMenuChoice = queue.Queue() coreObject.addThread( mainMenu.organiserMenu(organiserMenuChoice)) organiserMenuChoice, exitChoice = organiserMenuChoice.get() if organiserMenuChoice == exitChoice: # Exit organiserExit = True if organiserMenuChoice == 1: # calendar pass if organiserMenuChoice == 2: # Notes clearScreen() notesExit = False while not notesExit: notesMenuChoice = queue.Queue() coreObject.addThread( mainMenu.notesMenu(notesMenuChoice)) notes = Notes() notesMenuChoice, notesExitChoice = notesMenuChoice.get( ) if notesMenuChoice == notesExitChoice: notesExit = True if notesMenuChoice == 1: # notesList clearScreen() iter = 1 notesTitles = notes.getNotesTitle() for i in notesTitles: print(iter, i) iter += 1 noteNumber = int(input('Input note number')) clearScreen() print( notes.getNoteTextByTitle(
def main(): # Transcription and Cleaning url = input("Enter the URL = ") sec = pafy.new(url).length print(f"\nVideo duration in sec = {sec}\n") # THRESHOLDS DYNAMIC_INTERVAL = (sec / 60) * 100 if sec <= 900: # 0-15 min NUM_KEYWORDS = 15 SUMMARY_PERCENT = 60 NON_TEXT_LEN = 50 SIMILAR_DISTANCE = 20 INTERVAL_KEYFRAMES = DYNAMIC_INTERVAL SENTENCE_SIMILARITY = 0.35 WORDS_PER_PARA = 20 PERCENT_REDUCE = 0.6 SENTENCES_PER_PARA = 6 # HEADING_TRAINING = 500 # TOP_HEADINGS = 3 elif 900 < sec <= 1800: # 15-30 min NUM_KEYWORDS = 18 SUMMARY_PERCENT = 50 NON_TEXT_LEN = 50 SIMILAR_DISTANCE = 20 INTERVAL_KEYFRAMES = DYNAMIC_INTERVAL SENTENCE_SIMILARITY = 0.35 WORDS_PER_PARA = 20 PERCENT_REDUCE = 0.6 SENTENCES_PER_PARA = 5 # HEADING_TRAINING = 500 # TOP_HEADINGS = 3 elif 1800 < sec <= 2700: # 30-45 min NUM_KEYWORDS = 20 SUMMARY_PERCENT = 40 NON_TEXT_LEN = 50 SIMILAR_DISTANCE = 20 INTERVAL_KEYFRAMES = DYNAMIC_INTERVAL SENTENCE_SIMILARITY = 0.35 WORDS_PER_PARA = 20 PERCENT_REDUCE = 0.6 SENTENCES_PER_PARA = 4 # HEADING_TRAINING = 500 # TOP_HEADINGS = 3 elif 2700 < sec <= 3600: # 45-60 min NUM_KEYWORDS = 22 SUMMARY_PERCENT = 35 NON_TEXT_LEN = 50 SIMILAR_DISTANCE = 20 INTERVAL_KEYFRAMES = DYNAMIC_INTERVAL SENTENCE_SIMILARITY = 0.35 WORDS_PER_PARA = 20 PERCENT_REDUCE = 0.6 SENTENCES_PER_PARA = 4 # HEADING_TRAINING = 500 # TOP_HEADINGS = 3 elif 3600 < sec <= 7200: # 1-2 hr NUM_KEYWORDS = 25 SUMMARY_PERCENT = 30 NON_TEXT_LEN = 50 SIMILAR_DISTANCE = 20 INTERVAL_KEYFRAMES = DYNAMIC_INTERVAL SENTENCE_SIMILARITY = 0.35 WORDS_PER_PARA = 20 PERCENT_REDUCE = 0.6 SENTENCES_PER_PARA = 4 # HEADING_TRAINING = 500 # TOP_HEADINGS = 3 else: # More than 2 hr NUM_KEYWORDS = 30 SUMMARY_PERCENT = 25 NON_TEXT_LEN = 50 SIMILAR_DISTANCE = 20 INTERVAL_KEYFRAMES = DYNAMIC_INTERVAL SENTENCE_SIMILARITY = 0.35 WORDS_PER_PARA = 20 PERCENT_REDUCE = 0.6 SENTENCES_PER_PARA = 4 # HEADING_TRAINING = 500 # TOP_HEADINGS = 3 start = time.perf_counter() yt = YoutubeTranscribe(url) text = yt.youtube_transcribe() # Keywords Extractor num_keywords = NUM_KEYWORDS words = KeywordsExtractor(text, num_keywords) keywords = words.ExtractKeywords() print(f'\nKeywords:\n {keywords}') # Summarization summ = Summarizer() percentage = SUMMARY_PERCENT summary_result = summ.summary(text, percentage) print(f'\nSummary:\n {summary_result}') # Keyframe Extraction (Output : 'out' folder) print("\nExtracting Keyframes\n") ip = ImageProcessing(url, keywords) ip.img_processing(text_threshold=NON_TEXT_LEN, dis_threshold=SIMILAR_DISTANCE, jump=INTERVAL_KEYFRAMES) # Paragraph and Headings (Output : paragraph_headings.txt) print("\nGenerating Paragraphs and Headings\n") pf = ParaFormation(summary_result) list_para = pf.paragraph(similarity_threshold=SENTENCE_SIMILARITY, word_threshold=WORDS_PER_PARA, percent_reduce=PERCENT_REDUCE) ph = ParaHeadings(list_para) # title_para = ph.get_titles_paras(sentence_threshold = SENTENCES_PER_PARA, training = HEADING_TRAINING, heading_threshold = TOP_HEADINGS) title_para = ph.get_titles_paras(sentence_threshold=SENTENCES_PER_PARA) # Final Notes (Includes Web Scraping) print("\nGenerating Final Notes\n") scraped_results = Scrapper(keywords, 2, 2, 2) s = scraped_results.web_scrape() notes = Notes(url, s) notes.generate_notes() print("\nBrevis-Notes.docx and Brevis-Notes.pdf(on Windows) Generated\n") if os.path.exists('res'): shutil.rmtree('res') finish = time.perf_counter() print(f'Serial: Finished in {round(finish-start, 2)} second(s)')
class Music: """A music class is a notes object populated from an on disk midi file. self.notes is a list of all the notes in the file for rendering and scoring self.keys is a dictionary keyed by note number to keep track on note on and note off events.""" def __init__(self, graphics: Graphics, note_render: NoteRender, staff: Staff): self.graphics = graphics self.staff = staff self.note_positions = staff.get_note_positions() self.notes = Notes(graphics, note_render, staff, self.note_positions) self.song = None self.tempo_bpm = 60 self.ticks_per_beat = Song.SDQNotesPerBeat self.backing_index = {} self.backing_time = {} def load(self, song: Song): """ Post-process the raw note data of the music, adding rests and decoration""" self.reset() self.song = song self.tempo_bpm = song.tempo_bpm self.ticks_per_beat = song.ticks_per_beat for id in self.song.backing_tracks: self.backing_index[id] = 0 self.backing_time[id] = 0.0 self.staff.key_signature.set(song.key_signature, self.note_positions) self.notes.assign_notes(song.notes) def rewind(self): """Restore all the notes and backing in the music to the state just after loading.""" self.notes.rewind() self.backing_index = {track: 0 for track in self.backing_index} self.backing_time = {track: 0.0 for track in self.backing_time} def reset(self): self.notes.reset() self.backing_index = {} self.backing_time = {} def update(self, dt: float, music_time: float, devices: MidiDevices): """Play MIDI messages that are not for interactive scoring by the player.""" music_time_in_ticks = (music_time / Song.SDQNotesPerBeat) * self.ticks_per_beat def update_backing_track(id: int, ticks_time: float): b_len = len(self.song.backing_tracks[id]) b_index = self.backing_index[id] b_time = self.backing_time[id] if b_len == 0 or b_index >= b_len: return next_event = self.song.backing_tracks[id][b_index] while b_time <= ticks_time: if devices.output_port: devices.output_port.send(next_event) self.backing_index[id] += 1 b_index = self.backing_index[id] if b_index >= b_len: break next_event = self.song.backing_tracks[id][b_index] self.backing_time[id] += next_event.time b_time = self.backing_time[id] for _, id in enumerate(self.song.backing_tracks): update_backing_track(id, music_time_in_ticks) def draw(self, dt: float, music_time: float, note_width: float) -> dict: """Draw any parts of the scene that involve musical notation.""" return self.notes.draw(dt, music_time, note_width)
def add_object(user): if user not in userDictionary: userDictionary[user] = Notes()
class QuizCreator(Task): def __init__(self, string): """Generates a quiz from the inputted notes""" # The number of each type of question created Task.__init__(self) self.notes = None self.questions = [] self.question_index = -1 self.process_notes(string) def process_notes(self, string): self.set_progress_text("Reading notes...") self.notes = Notes(string) self.add_progress(self.TASK_LENGTH_NOTES) def get_least_to_most_asked_questions(self): """Gets the type of question which appears the least in the list of questions""" questions = {} for Question in [ QuestionFillBlank, QuestionMultipleChoice, QuestionTrueFalse ]: questions[Question] = 0 for question in self.questions: questions[question.__class__] += 1 return sorted(questions, key=questions.get) # TODO: introduce randomness here def create_questions(self): """Creates questions based on the set of notes""" self.set_progress_text("Creating questions...") increment_progress = self.TASK_LENGTH_QUESTIONS / self.notes.get_number_of_statements( ) while self.notes.are_unused_statements(): self.add_progress(increment_progress) # To make an equal balance of questions, find the least asked type of question question_types = self.get_least_to_most_asked_questions() for question_type in question_types: question = question_type.create_from_notes(self.notes) if question is not None: self.questions.append(question) break def reset(self): self.__init__(None) def regenerate_questions(self): self.__init__(self.notes) def add_notes(self, string): # self.notes.add(string) self.regenerate_questions() def generate_template(self): """Generates a filled quiz HTML template""" self.set_progress_text("Generating quiz...") increment_progress = self.TASK_LENGTH_TEMPLATES / len(self.questions) if len(self.questions) == 0: raise Exception("No questions to create quiz!") quiz = "" env = Environment(loader=PackageLoader('quiz', 'templates'), autoescape=select_autoescape(['html', 'xml'])) question_index = 1 for question in self.questions: self.add_progress(increment_progress) if isinstance(question, QuestionChoice): response_template = env.get_template('question_mc.html') response = response_template.render( responses=question.get_responses(), question_id=question_index, question_str=question.get_question(), answer_str=question.get_answer(), answer_response=question.get_answer_response()) else: response_template = env.get_template('question_text.html') response = response_template.render( question_id=question_index, question_str=question.get_question(), answer_str=question.get_answer()) quiz += response question_index += 1 self.set_progress(1) self.set_progress_text("Success!") return quiz
def gen(): global video_url global keywords global path global json_result global text global summary_result global scrape_json global option sec = pafy.new(video_url).length print(f"\nVideo duration in sec = {sec}\n") # THRESHOLDS DYNAMIC_INTERVAL = (sec / 60) * 100 if sec <= 900: # 0-15 min NUM_KEYWORDS = 15 SUMMARY_PERCENT = 60 NON_TEXT_LEN = 50 SIMILAR_DISTANCE = 20 INTERVAL_KEYFRAMES = DYNAMIC_INTERVAL SENTENCE_SIMILARITY = 0.35 WORDS_PER_PARA = 20 PERCENT_REDUCE = 0.6 SENTENCES_PER_PARA = 6 # HEADING_TRAINING = 500 # TOP_HEADINGS = 3 elif 900 < sec <= 1800: # 15-30 min NUM_KEYWORDS = 18 SUMMARY_PERCENT = 50 NON_TEXT_LEN = 50 SIMILAR_DISTANCE = 20 INTERVAL_KEYFRAMES = DYNAMIC_INTERVAL SENTENCE_SIMILARITY = 0.35 WORDS_PER_PARA = 20 PERCENT_REDUCE = 0.6 SENTENCES_PER_PARA = 5 # HEADING_TRAINING = 500 # TOP_HEADINGS = 3 elif 1800 < sec <= 2700: # 30-45 min NUM_KEYWORDS = 20 SUMMARY_PERCENT = 40 NON_TEXT_LEN = 50 SIMILAR_DISTANCE = 20 INTERVAL_KEYFRAMES = DYNAMIC_INTERVAL SENTENCE_SIMILARITY = 0.35 WORDS_PER_PARA = 20 PERCENT_REDUCE = 0.6 SENTENCES_PER_PARA = 4 # HEADING_TRAINING = 500 # TOP_HEADINGS = 3 elif 2700 < sec <= 3600: # 45-60 min NUM_KEYWORDS = 22 SUMMARY_PERCENT = 35 NON_TEXT_LEN = 50 SIMILAR_DISTANCE = 20 INTERVAL_KEYFRAMES = DYNAMIC_INTERVAL SENTENCE_SIMILARITY = 0.35 WORDS_PER_PARA = 20 PERCENT_REDUCE = 0.6 SENTENCES_PER_PARA = 4 # HEADING_TRAINING = 500 # TOP_HEADINGS = 3 elif 3600 < sec <= 7200: # 1-2 hr NUM_KEYWORDS = 25 SUMMARY_PERCENT = 30 NON_TEXT_LEN = 50 SIMILAR_DISTANCE = 20 INTERVAL_KEYFRAMES = DYNAMIC_INTERVAL SENTENCE_SIMILARITY = 0.35 WORDS_PER_PARA = 20 PERCENT_REDUCE = 0.6 SENTENCES_PER_PARA = 4 # HEADING_TRAINING = 500 # TOP_HEADINGS = 3 else: # More than 2 hr NUM_KEYWORDS = 30 SUMMARY_PERCENT = 25 NON_TEXT_LEN = 50 SIMILAR_DISTANCE = 20 INTERVAL_KEYFRAMES = DYNAMIC_INTERVAL SENTENCE_SIMILARITY = 0.35 WORDS_PER_PARA = 20 PERCENT_REDUCE = 0.6 SENTENCES_PER_PARA = 4 # HEADING_TRAINING = 500 # TOP_HEADINGS = 3 start = time.perf_counter() # if option == "Overview": # percentage = 50 # elif option == "Notes": # percentage = 60 # elif option == "Notes+Ref": # percentage = 80 #Running keywords and summary Processes parallely key_ext = multiprocessing.Process(target=Process_Extract_Keywords, args=(video_url, text, NUM_KEYWORDS, NON_TEXT_LEN, SIMILAR_DISTANCE, INTERVAL_KEYFRAMES)) summ_ext = multiprocessing.Process( target=Process_Get_Summary, args=(text, SUMMARY_PERCENT, SENTENCE_SIMILARITY, WORDS_PER_PARA, PERCENT_REDUCE, SENTENCES_PER_PARA)) #Starting both process simultaneously key_ext.start() summ_ext.start() #Checking if the process have finished execution key_ext.join() summ_ext.join() if option == "Overview" or option == "Notes": scrape_json = {} #Generating final notes notes = Notes(video_url, scrape_json) notes.generate_notes() print("\nBrevis-Notes.docx and Brevis-Notes.pdf(on Windows) Generated\n") with ZipFile('Brevis_Notes.zip', 'w') as zip: print("Writing zip") if os.path.exists(os.path.join('res', 'Brevis-Notes.pdf')): zip.write(os.path.join('res', 'Brevis-Notes.pdf'), arcname='Brevis-Notes.pdf') zip.write(os.path.join('res', 'Brevis-Notes.docx'), arcname='Brevis-Notes.docx') path = os.path.abspath("Brevis_Notes.zip") if os.path.exists('res'): shutil.rmtree('res') finish = time.perf_counter() print(f'Gen Function: Finished in {round(finish-start, 2)} second(s)')
class GUI(Tk): "represents GUI" def __init__(self): super().__init__() self.option_add("*tearOff", FALSE) self.initialized = False self.title("Papyer") x, y = 1500, 500 self.minsize(x, y) placeWindow(self, x, y) self.options = Options(self) self["menu"] = TopMenu(self) self.protocol("WM_DELETE_WINDOW", self.closeFun) self.base = os.getcwd() self.selectVar = StringVar() self.searchVar = StringVar() self.createWidgets() self.columnconfigure(1, weight = 1) self.columnconfigure(3, weight = 1) self.columnconfigure(5, weight = 1) self.rowconfigure(4, weight = 1) self.bind("<Control-d>", lambda e: self.filetree.keepDuplicates()) self.bind("<Control-a>", lambda e: self.filetree.selectAll()) self.mainloop() def refresh(self): # do in a smarter way - check changes in the files self.filestorage.save() self.filetree.saveSettings() selected = self.filetree.selection() self.createWidgets() self.filetree.selection_set(selected) def createWidgets(self): self.selectLabel = ttk.Label(self, text = "Select:") self.selectLabel.grid(column = 0, row = 0, padx = 10, pady = 5) self.select = Select(self, textvariable = self.selectVar) self.select.grid(column = 1, row = 0, sticky = (E, W)) self.searchLabel = ttk.Label(self, text = "Search:") self.searchLabel.grid(column = 2, row = 0, padx = 10, pady = 5) self.search = Search(self, textvariable = self.searchVar) self.search.grid(column = 3, row = 0, sticky = (E, W)) self.filestorage = FileStorage(self) self.filetree = FileTree(self) self.filetree.grid(column = 0, row = 1, rowspan = 4, sticky = (N, S, E, W), columnspan = 4) self.scrollbar = ttk.Scrollbar(self, orient = VERTICAL, command = self.filetree.yview) self.scrollbar.grid(column = 4, row = 1, rowspan = 4, sticky = (N, S, E)) self.filetree.configure(yscrollcommand = self.scrollbar.set) self.tags = Tags(self) self.tags.grid(column = 5, row = 2, sticky = (E, W), padx = 5) self.tagsLab = ttk.Label(text = "Tags") self.tagsLab.grid(column = 5, row = 1, padx = 5, pady = 2) self.notes = Notes(self) self.notes.grid(column = 5, row = 4, sticky = (N, S, E, W), padx = 5) self.notesLab = ttk.Label(text = "Notes") self.notesLab.grid(column = 5, row = 3, padx = 5, pady = 2) self.scrollNotes = ttk.Scrollbar(self, orient = VERTICAL, command = self.notes.yview) self.scrollNotes.grid(column = 6, row = 4, sticky = (N, S, W)) self.notes.configure(yscrollcommand = self.scrollNotes.set) self.buttons = Buttons(self) self.buttons.grid(row = 5, column = 0, columnspan = 5, pady = 5, sticky = (E, W)) self.statusBar = StatusBar(self) self.statusBar.grid(row = 6, column = 0, columnspan = 5, padx = 5, pady = 5, sticky = (E, W)) def closeFun(self): "ask for saving files on exit" self.filetree.saveSettings() self.filestorage.save() self.options.save() self.destroy()
class MainWindow(QMainWindow): indexChanged = pyqtSignal() saveRequested = pyqtSignal() def __init__(self, parent=None): QMainWindow.__init__(self) self._ppath = getProgramPath() log('PATH: %s' % self._ppath, True) self.config = SimpleConfig('~/.cn.conf') uic.loadUi(os.path.join(self._ppath, "main.ui"), self) self.connect(self.action_Exit, SIGNAL("triggered()"), self.close) self.connect(self.action_About, SIGNAL("triggered()"), self.showAboutBox) self.dbname = os.path.expanduser(self.config.readStr('WorkDir', '~/Coffee Notes')) self.notes = Notes(self.dbname) self.saving = False self.currentKey = None self.changed = False self.newNote() #### notes list behaviour self.model = QStringListModel() # !! self.noteList.setModel(self.model) self.noteList.setSelectionBehavior(QAbstractItemView.SelectRows) self.connect(self.noteList, SIGNAL("activated(const QModelIndex&)"), self.selectNote) self.connect(self.noteList, SIGNAL("clicked(const QModelIndex&)"), self.selectNote) self.filterNotes() self.connect(self, SIGNAL("indexChanged()"), self.selectCurrent) #### text editor & tag bar self.connect(self.noteEditor, SIGNAL("textChanged()"), self.textChanged) self.connect(self.tagBar, SIGNAL("textChanged(const QString&)"), self.textChanged) self.connect(self.deleteButton, SIGNAL("clicked()"), self.deleteNote) self.noteEditor.setAcceptRichText(False) self.noteEditor.setTabChangesFocus(True) #### search box self.connect(self.searchBar, SIGNAL("textChanged(const QString&)"), self.filterNotes) self.connect(self.searchBar, SIGNAL("returnPressed ()"), self.enterPressed) self.connect(self.addButton, SIGNAL("clicked()"), self.newNote) self.connect(self.syncButton, SIGNAL("clicked()"), self.startSync) #### autosave self.connect(self, SIGNAL('saveRequested()'), self.saveText) sec = self.config.readInt('Autosave', 5) if sec <= 0: sec = 5 self.autosaveThread = CallbackThread(self.autosave, sec) self.autosaveThread.start(QThread.IdlePriority) #### stantard shortcuts shCL = QShortcut(QKeySequence("Ctrl+L"), self) shCL.connect(shCL, SIGNAL("activated()"), self.toggleFocus) shEsc = QShortcut(QKeySequence("Esc"), self) shEsc.connect(shEsc, SIGNAL("activated()"), self.clearSearch) shCN = QShortcut(QKeySequence("Ctrl+N"), self) shCN.connect(shCN, SIGNAL("activated()"), self.newNote) shCD = QShortcut(QKeySequence("Ctrl+D"), self) shCD.connect(shCD, SIGNAL("activated()"), self.deleteNote) shCO = QShortcut(QKeySequence("Ctrl+O"), self) shCO.connect(shCO, SIGNAL("activated()"), self.changeSplitterOrientation) shCS = QShortcut(QKeySequence("Ctrl+S"), self) shCS.connect(shCS, SIGNAL('activated()'), self.startSync) self.setup() def setup(self): '''set up fonts etc ''' dft = '%s, %s' % (unicode(self.noteList.font().family()), self.noteList.font().pointSize()) log('DEFAULT FONT: %s' % dft) lf = self.config.readStr('ListFont', dft) try: (lf, ls) = lf.split(',', 1) ls = int(ls.strip()) except: ls = self.noteList.font().pointSize() ef = self.config.readStr('EditFont', dft) try: (ef, es) = ef.split(',', 1) es = int(es.strip()) except: es = self.noteList.font().pointSize() self.noteList.setFont(QFont(lf, ls)) self.searchBar.setFont(QFont(lf, ls)) self.noteEditor.setCurrentFont(QFont(ef, es)) self.restoreSettings() def quit(self): # self.autosave() qApp.quit() def closeEvent(self, event): self.autosave() self.saveSettings() event.accept() def clearSearch(self): self.searchBar.clear() self.searchBar.setFocus() def toggleFocus(self): if self.searchBar.hasFocus(): self.noteEditor.setFocus() else: self.searchBar.setFocus() def textChanged(self, text=None): self.changed = True self.statusBar().clearMessage() def filterNotes(self, text=''): log('FIND: %s' % unicode(text).encode('utf-8')) self.notes.setFilter(unicode(text)) if text: log('%s' % type(text)) self.noteList.keyboardSearch(text) self.reindex() def reindex(self): log('reindex') self.statusBar().showMessage('Scanning directory...') # self.notes.rescanDir() self.titles, self.keys = self.notes.list() self.model.setStringList(self.titles) self.indexChanged.emit() self.statusBar().showMessage('%s notes' % (len(self.titles))) log('/reindex') def selectCurrent(self): log('selectCurrent') try: cur = self.keys.index(self.currentKey) self.noteList.setCurrentIndex(self.model.index(cur)) except ValueError: pass log('/selectCurrent') def autosave(self): self.saveRequested.emit() def newNote(self): self.autosave() self.noteEditor.clear() self.tagBar.clear() self.currentKey = None self.changed = False self.noteEditor.setFocus() self.statusBar().clearMessage() def openNote(self, key=None): log('openNote(%s)' % key) self.autosave() self.currentKey = key self.noteEditor.setPlainText(self.notes.getContent(self.currentKey)) self.tagBar.setText(self.notes.getTags(self.currentKey)) self.changed = False self.noteEditor.setFocus() self.selectCurrent() self.statusBar().clearMessage() log('/openNote') def enterPressed(self): self.noteList.setFocus() def selectNote(self): log('selectNote') sel = self.noteList.selectedIndexes() if sel: item = sel[0] title = self.titles[item.row()] key = self.keys[item.row()] log('SELECTED: %s: %s [%s]' % (item.row(), title.encode('utf-8'), key)) # self.searchBar.setText(title) self.openNote(key) log('/selectNote') def deleteNote(self): if self.currentKey is None: return ans = QMessageBox.question(self, "Delete", "Delete \"%s\"?" % self.notes.getTitle(self.currentKey), QMessageBox.Yes | QMessageBox.No, QMessageBox.No) if ans != QMessageBox.Yes: return self.notes.deleteNote(self.currentKey) self.noteEditor.clear() # self.tagBar.clear() self.currentKey = None self.changed = False self.reindex() def saveText(self): if self.saving: return self.saving = True if self.changed: log('SAVING...') self.statusBar().showMessage('Saving...') self.currentKey = self.notes.saveNote(self.currentKey, unicode(self.noteEditor.toPlainText()), unicode(self.tagBar.text())) self.reindex() self.changed = False self.statusBar().showMessage('Saved') self.saving = False def showAboutBox(self): QMessageBox.about(self, "About", """<h2>%s</h2> <h4>Version «%s» %s</h4> <p>© Dmitri Brechalov, 2011-2012</p> <p>Crossplatform note-taking application inspired by Notational Velocity</p> <p><small>This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.<br/> This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.<br/> You should have received a copy of the GNU General Public License along with this program. If not, see <a href="http://www.gnu.org/licenses/">http://www.gnu.org/licenses/</a>. """ % (PROG_NAME, CODE_NAME, VERSION)) def changeSplitterOrientation(self): orientation = self.splitter.orientation() if orientation == Qt.Horizontal: orientation = Qt.Vertical else: orientation = Qt.Horizontal self.splitter.setOrientation(orientation) def saveSettings(self): settings = QSettings("dmych", PROG_NAME) settings.setValue("geometry", self.saveGeometry()) settings.setValue("state", self.saveState()) settings.setValue("splitter", self.splitter.saveState()) def restoreSettings(self): settings = QSettings("dmych", PROG_NAME) self.restoreGeometry(settings.value("geometry").toByteArray()) self.restoreState(settings.value("state").toByteArray()) self.splitter.restoreState(settings.value("splitter").toByteArray()) def startSync(self): self.statusBar().showMessage('Sync started...')
from flask import Flask, request, jsonify from flask_restful import Resource, Api from notes import Notes import json from user import User app = Flask(__name__) #api = Api(app) dummyUser = User("s;dgfh", "this@lol", "thisisshit", "*****@*****.**", "Shitty", "Sartaj") users = { "*****@*****.**" : dummyUser } n1 = Notes("12345", "shit", "lol", "this","shit") notes = { "12345" : n1 } @app.route("/login", methods = ['POST']) def loginController(): if request.method == 'POST': req_data = request.json mailId = req_data.get("mailId") password = req_data.get("password") if mailId == None : return "Mail Id is empty" elif users[mailId] == None : return "Your account does not exist, maybe you need to create an account first"
def notes(self): Notes(self.output_panel.get('sel.first', 'sel.last'))
#!/usr/bin/env python """ Test harness for notes """ from notes import Notes import base62 foo = Notes() foo.createDatabase() print "Inserting with ID", foo.addNote("This is a test", title="First Post") print "Inserting with ID", foo.addNote("XXX This is a another test XXX", author="Nick") for row in foo.getAllNotes(): print row print base62.fromInt(row[0]) print foo.getAllNoteIDs() print "Check Hits" print foo.getNoteByID(u"aaaaaaaaaab") print foo.getNoteByID(u"aaaaaaaaaab") foo.deleteNoteByID("aaaaaaaaaab") foo.deleteNoteByKey(2) print foo.getNoteByID(u"aaaaaaaaaab") print "\nPurging notes" foo.purgeOldKeys() print "\nListing notes"
from gameboard import GameBoard from notes import Notes from deck import Deck from player import Player def rollDie(): return np.random.randint(1, 7) if __name__ == "__main__": pygame.init() gameBoard = GameBoard("board_image.png") #gameBoard.setShowTiles(True) my_notes = Notes((gameBoard.size[0], 0)) my_player = Player("mrs_peacock.png", (0, 5), gameBoard) screen = pygame.display.set_mode( (gameBoard.size[0] + my_notes.size[0], max(gameBoard.size[1], my_notes.size[1])), pygame.DOUBLEBUF) clock = pygame.time.Clock() run = True num_moves = 1000 #rollDie() while run: clock.tick(60) for event in pygame.event.get(): if event.type == pygame.QUIT: run = False elif event.type == pygame.KEYDOWN: if event.key == pygame.K_LEFT and num_moves > 0:
from notes import Notes from musical.theory import Note ''' Introduction ''' intro1 = Notes('D4',['A4','D5']) intro2 = Notes('F#4',['C#5','A4']) intro = ((intro1*4+intro2*4) % 0.25 )*2 ''' Verses ''' verseBase = Notes('A4')*5 + Notes('G4','F#4','G4') verseMod = verseBase.replace('B4',3)\ .replace('E4',7)\ + [('F#4',1.0), ('-', 2.0)] verseStart = verseBase.without(0) + verseBase.replace('B4',3) + verseBase + verseMod verse2 = Notes('G4','G4','G4','F#4','E4','D4','E4',('F#4',1.0), ('-', 1.0)) verse3 = Notes('F#4','F#4','D4',('E4',1.0),('-',1.75)) verse = verseStart + verse2 + verse3 verses = (verse*2)%0.5 ''' Verse Background ''' base = Note('B3') afterIntro1 = Notes(base, [base.third('minor'), base.fifth('minor')]) afterIntro2 = Notes([('A4',0.5),('A3',0.5)],'-') base = Note('G3') afterIntro3 = Notes(base, [base.third(), base.fifth()])
def main(): if not os.path.isfile(os.environ['HOME'] + "/.secrets/config"): if len(sys.argv) > 1: if (sys.argv[1] == "init"): print("\twelcome to") print(secrets) firstrun() else: print(secrets) print("\t\tis not initialized. Pass 'init' to set up") # the rest of the options else: notes = Notes() if len(sys.argv) > 1: if (sys.argv[1] == "init"): print(secrets) print("\t\tis already set up!") elif (sys.argv[1] == "list"): print("\tyour") print(secrets) notes.listnotes() elif (sys.argv[1] == "new"): if len(sys.argv) > 2: if sys.argv[2] in notes.notes: notes.editnote(sys.argv[2]) else: notes.newnote(sys.argv[2]) else: print("Error: give it a title!") elif (sys.argv[1] == "echo"): if len(sys.argv) > 2: notes.echonote(sys.argv[2]) elif (sys.argv[1] == "delete"): if len(sys.argv) > 2: notes.deletenote(sys.argv[2]) else: if (sys.argv[1] in notes.notes.keys()): notes.editnote(sys.argv[1]) else: notes.newnote(sys.argv[1]) else: print(secrets) print("\ttry secrets list") print("\tor secrets foo") notes.close()
from notes import Notes notes = Notes() notes.prompt()
#!/usr/bin/python import yaml config = yaml.safe_load(open("config.yml")) from notes import Notes, Note notebook = Notes() import sys if len(sys.argv) < 1: print("usage: add_note.py <text>") sys.exit() filename = sys.argv.pop(0) note_text = " ".join([str(x) for x in sys.argv]) if note_text != "": notebook.add_note(note_text)
def main(): url = input("Enter the URL = ") #Thresholds sec = pafy.new(url).length print(f"\nVideo duration in sec = {sec}\n") # THRESHOLDS DYNAMIC_INTERVAL = (sec/60) * 100 if sec <= 900: # 0-15 min NUM_KEYWORDS = 15 SUMMARY_PERCENT = 60 NON_TEXT_LEN = 50 SIMILAR_DISTANCE = 20 INTERVAL_KEYFRAMES = DYNAMIC_INTERVAL SENTENCE_SIMILARITY = 0.35 WORDS_PER_PARA = 20 PERCENT_REDUCE = 0.6 SENTENCES_PER_PARA = 6 # HEADING_TRAINING = 500 # TOP_HEADINGS = 3 elif 900 < sec <= 1800: # 15-30 min NUM_KEYWORDS = 18 SUMMARY_PERCENT = 50 NON_TEXT_LEN = 50 SIMILAR_DISTANCE = 20 INTERVAL_KEYFRAMES = DYNAMIC_INTERVAL SENTENCE_SIMILARITY = 0.35 WORDS_PER_PARA = 20 PERCENT_REDUCE = 0.6 SENTENCES_PER_PARA = 5 # HEADING_TRAINING = 500 # TOP_HEADINGS = 3 elif 1800 < sec <= 2700: # 30-45 min NUM_KEYWORDS = 20 SUMMARY_PERCENT = 40 NON_TEXT_LEN = 50 SIMILAR_DISTANCE = 20 INTERVAL_KEYFRAMES = DYNAMIC_INTERVAL SENTENCE_SIMILARITY = 0.35 WORDS_PER_PARA = 20 PERCENT_REDUCE = 0.6 SENTENCES_PER_PARA = 4 # HEADING_TRAINING = 500 # TOP_HEADINGS = 3 elif 2700 < sec <= 3600: # 45-60 min NUM_KEYWORDS = 22 SUMMARY_PERCENT = 35 NON_TEXT_LEN = 50 SIMILAR_DISTANCE = 20 INTERVAL_KEYFRAMES = DYNAMIC_INTERVAL SENTENCE_SIMILARITY = 0.35 WORDS_PER_PARA = 20 PERCENT_REDUCE = 0.6 SENTENCES_PER_PARA = 4 # HEADING_TRAINING = 500 # TOP_HEADINGS = 3 elif 3600 < sec <= 7200: # 1-2 hr NUM_KEYWORDS = 25 SUMMARY_PERCENT = 30 NON_TEXT_LEN = 50 SIMILAR_DISTANCE = 20 INTERVAL_KEYFRAMES = DYNAMIC_INTERVAL SENTENCE_SIMILARITY = 0.35 WORDS_PER_PARA = 20 PERCENT_REDUCE = 0.6 SENTENCES_PER_PARA = 4 # HEADING_TRAINING = 500 # TOP_HEADINGS = 3 else: # More than 2 hr NUM_KEYWORDS = 30 SUMMARY_PERCENT = 25 NON_TEXT_LEN = 50 SIMILAR_DISTANCE = 20 INTERVAL_KEYFRAMES = DYNAMIC_INTERVAL SENTENCE_SIMILARITY = 0.35 WORDS_PER_PARA = 20 PERCENT_REDUCE = 0.6 SENTENCES_PER_PARA = 4 # HEADING_TRAINING = 500 # TOP_HEADINGS = 3 #Starting the timer start = time.perf_counter() # Transcription and Cleaning yt = YoutubeTranscribe(url) text = yt.youtube_transcribe() #Declaring a multiprocessing queue to exchange data between various functions Q=multiprocessing.Queue() #Running keywords and summary Processes parallely key_ext=multiprocessing.Process(target=Process_Extract_Keywords , args=(url,text,Q,NUM_KEYWORDS,NON_TEXT_LEN,SIMILAR_DISTANCE,INTERVAL_KEYFRAMES)) summ_ext=multiprocessing.Process(target=Process_Get_Summary , args=(text,SUMMARY_PERCENT,SENTENCE_SIMILARITY,WORDS_PER_PARA,PERCENT_REDUCE,SENTENCES_PER_PARA)) #Starting both process simultaneously key_ext.start() summ_ext.start() #Checking if the process have finished execution key_ext.join() summ_ext.join() #Fetching scraped links from the Queue scraped_res = Q.get() #Generating final notes notes = Notes(url,scraped_res) notes.generate_notes() print("\nBrevis-Notes.docx and Brevis-Notes.pdf(on Windows) Generated\n") #Removing the temporary res folder if os.path.exists('res'): shutil.rmtree('res') #Stopping the timer end=time.perf_counter() #Printing the time taken by the program for execution print(f"Finished in {round(end-start, 3)} second(s)")
def init(self): self.learn = Learn(madcow=self.madcow) self.staff = Staff(madcow=self.madcow) self.company = Company(madcow=self.madcow) self.realname = Realname(madcow=self.madcow) self.notes = Notes(madcow=self.madcow)
def gen(): global video_url global keywords global path global json_result global text global summary_result global scrape_json global option sec = pafy.new(video_url).length print(f"\nVideo duration in sec = {sec}\n") # THRESHOLDS DYNAMIC_INTERVAL = (sec / 60) * 100 if sec <= 900: # 0-15 min NUM_KEYWORDS = 15 SUMMARY_PERCENT = 60 NON_TEXT_LEN = 50 SIMILAR_DISTANCE = 20 INTERVAL_KEYFRAMES = DYNAMIC_INTERVAL SENTENCE_SIMILARITY = 0.35 WORDS_PER_PARA = 20 PERCENT_REDUCE = 0.6 SENTENCES_PER_PARA = 6 # HEADING_TRAINING = 500 # TOP_HEADINGS = 3 elif 900 < sec <= 1800: # 15-30 min NUM_KEYWORDS = 18 SUMMARY_PERCENT = 50 NON_TEXT_LEN = 50 SIMILAR_DISTANCE = 20 INTERVAL_KEYFRAMES = DYNAMIC_INTERVAL SENTENCE_SIMILARITY = 0.35 WORDS_PER_PARA = 20 PERCENT_REDUCE = 0.6 SENTENCES_PER_PARA = 5 # HEADING_TRAINING = 500 # TOP_HEADINGS = 3 elif 1800 < sec <= 2700: # 30-45 min NUM_KEYWORDS = 20 SUMMARY_PERCENT = 40 NON_TEXT_LEN = 50 SIMILAR_DISTANCE = 20 INTERVAL_KEYFRAMES = DYNAMIC_INTERVAL SENTENCE_SIMILARITY = 0.35 WORDS_PER_PARA = 20 PERCENT_REDUCE = 0.6 SENTENCES_PER_PARA = 4 # HEADING_TRAINING = 500 # TOP_HEADINGS = 3 elif 2700 < sec <= 3600: # 45-60 min NUM_KEYWORDS = 22 SUMMARY_PERCENT = 35 NON_TEXT_LEN = 50 SIMILAR_DISTANCE = 20 INTERVAL_KEYFRAMES = DYNAMIC_INTERVAL SENTENCE_SIMILARITY = 0.35 WORDS_PER_PARA = 20 PERCENT_REDUCE = 0.6 SENTENCES_PER_PARA = 4 # HEADING_TRAINING = 500 # TOP_HEADINGS = 3 elif 3600 < sec <= 7200: # 1-2 hr NUM_KEYWORDS = 25 SUMMARY_PERCENT = 30 NON_TEXT_LEN = 50 SIMILAR_DISTANCE = 20 INTERVAL_KEYFRAMES = DYNAMIC_INTERVAL SENTENCE_SIMILARITY = 0.35 WORDS_PER_PARA = 20 PERCENT_REDUCE = 0.6 SENTENCES_PER_PARA = 4 # HEADING_TRAINING = 500 # TOP_HEADINGS = 3 else: # More than 2 hr NUM_KEYWORDS = 30 SUMMARY_PERCENT = 25 NON_TEXT_LEN = 50 SIMILAR_DISTANCE = 20 INTERVAL_KEYFRAMES = DYNAMIC_INTERVAL SENTENCE_SIMILARITY = 0.35 WORDS_PER_PARA = 20 PERCENT_REDUCE = 0.6 SENTENCES_PER_PARA = 4 # HEADING_TRAINING = 500 # TOP_HEADINGS = 3 start = time.perf_counter() if option == "Overview": if not os.path.exists(os.path.join('res', 'out')): os.mkdir(os.path.join('res', 'out')) elif option == "Notes" or option == "Notes+Ref": # Keyframe Extraction (Output : 'out' folder) print("\nExtracting Keyframes\n") ip = ImageProcessing(video_url, keywords) ip.img_processing(text_threshold=NON_TEXT_LEN, dis_threshold=SIMILAR_DISTANCE, jump=INTERVAL_KEYFRAMES) # Paragraph and Headings (Output : paragraph_headings.txt) print("\nGenerating Paragraphs and Headings\n") pf = ParaFormation(summary_result) list_para = pf.paragraph(similarity_threshold=SENTENCE_SIMILARITY, word_threshold=WORDS_PER_PARA, percent_reduce=PERCENT_REDUCE) ph = ParaHeadings(list_para) title_para = ph.get_titles_paras(sentence_threshold=SENTENCES_PER_PARA) # Final Notes (Includes Web Scraping) print("\nGenerating Final Notes\n") if option == "Overview" or option == "Notes": scrape_json = {} #scraped_results = Scrapper(scrape_keywords,2,2,2) #s = scraped_results.web_scrape() notes = Notes(video_url, scrape_json) notes.generate_notes() print("\nBrevis-Notes.docx Generated\n") with ZipFile('Brevis_Notes.zip', 'w') as zip: print("Writing zip") if os.path.exists(os.path.join('res', 'Brevis-Notes.pdf')): zip.write(os.path.join('res', 'Brevis-Notes.pdf'), arcname='Brevis-Notes.pdf') zip.write(os.path.join('res', 'Brevis-Notes.docx'), arcname='Brevis-Notes.docx') path = os.path.abspath("Brevis_Notes.zip") if os.path.exists('res'): shutil.rmtree('res') finish = time.perf_counter() print(f'Gen Function: Finished in {round(finish-start, 2)} second(s)')
parser.add_argument('-ap', '--append', help='Append to note', type=str) parser.add_argument('-d', '--delete', help='Delete note', type=str) parser.add_argument('-da', '--delall', help='Delete all notes', action='store_true') parser.add_argument('-v', '--view', help='View a note', type=str) parser.add_argument('-t', '--tick', help='Check off completed note', type=str) parser.add_argument('--step', help='unknown, required for tick', type=int) args = parser.parse_args() try: notesShelf = shelve.open('notes') if args.add: Notes.add_note(notesShelf, args.add) elif args.append: Notes.add_step(notesShelf, args.append) elif args.delete: Notes.delete_note(notesShelf, args.delete) elif args.delall: Notes.delete_all_notes(notesShelf) elif args.view: Notes.view_note(notesShelf, args.view) elif args.tick: Notes.delete_step(notesShelf, args.tick, args.step) elif args.list: Notes.list_notes(notesShelf) except ImportError: print('There was an error')
def __init__(self, fields): Notes.__init__(self, fields)
#!/usr/bin/python import yaml config = yaml.safe_load(open("config.yml")) from notes import Notes notebook = Notes() import sys if len(sys.argv) < 2: print("usage: delete_note.py <number>") sys.exit() script_name = sys.argv.pop(0) note_index = int(sys.argv.pop(0)) if note_index == 0: print "No note #0 found. Start counting with 1 like a normal person." elif note_index < 0: print "Please try to stay positive." elif note_index > len(notebook.get_notes()): print "You fell off the edge. There aren't that many notes." else: notebook.delete_note(int(note_index) - 1)
def OLD_sync(localdb, user, password, since=None): db = Notes(localdb) api = Simplenote(user, password) log("LOCAL TO REMOTE:") synced_count = 0 for note in db.values(): if note["CHANGED"]: if not note.has_key("key") or note["key"].startswith(KEY_PREFIX): log("NEW NOTE") else: log("CHANGED: %s" % note["key"]) if note["key"].startswith(KEY_PREFIX): k = note["key"] del note["key"] else: k = None note = api.update(note) note["CHANGED"] = False db.update(note) if k is not None: db.remove(k) synced_count += 1 if since: rindex = api.index(since=since) log(">>>> SINCE: %s" % since) else: rindex = api.index() log("REMOTE TO LOCAL:") log(">>>> RINDEX LEN: %s" % len(rindex)) for ritem in rindex: key = ritem["key"] if key not in db.keys(deleted=True): log(" NEW: %s" % (key)) db.update(api.get(key)) synced_count += 1 litem = db.get(key) if ritem["syncnum"] > litem["syncnum"]: log(" UPD: %s" % (key)) db.update(api.get(key)) synced_count += 1 log("CLEAN UP:") if since is None: rkeys = api.keys().keys() for k in db.keys(deleted=True): if k not in rkeys: log(" DEL: %s" % k) db.remove(k) synced_count += 1 else: for k in db.keys(deleted=True): litem = db.get(k) if litem["deleted"] != 0: log(" DEL: %s" % k) db.remove(k) sys.stderr.write("Synced %s notes.\n" % synced_count) return time.time()
def main(): # Parallel url = input("Enter the URL = ") start = time.perf_counter() # Transcription and Cleaning yt = YoutubeTranscribe(url) text = yt.youtube_transcribe() # Level1 with ThreadPoolExecutor() as executor: ''' Type1: level1_results1 = executor.submit(Test(10,20).RecArea) print(type(level1_results1)) print(dir(level1_results1)) print(level1_results1.result()) Type2: level1_results1 = list(executor.map(Test().RecArea,[10],[20])) print(level1_results1[0]) ''' # Keywords Extractor # num_keywords=int(input("Enter number of keywords to be extracted : ")) num_keywords = 10 level1_results1 = executor.submit( KeywordsExtractor(text, num_keywords).ExtractKeywords) # Summarization percentage = 40 level1_results2 = list( executor.map(Summarizer().summary, [text], [percentage])) print(f"\nKeywords:\n {level1_results1.result()}") print(f"\nSummary:\n {level1_results2[0]}") # Level2 with ThreadPoolExecutor() as executor: # Keyframe Extraction (Output : 'out' folder) print("\nExtracting Keyframes\n") level2_results1 = list( executor.map( ImageProcessing(url, level1_results1.result()).img_processing, [50], [20], [1000])) # Paragraph and Headings (Output : paragraph_headings.txt) print("\nGenerating Paragraphs and Headings\n") level2_results2 = executor.submit( ParaFormation(level1_results2[0]).paragraph) print("\nScraping Web\n") level2_results3 = executor.submit( Scrapper(level1_results1.result(), 2, 2, 2).web_scrape) print(len(os.listdir(os.path.join('res', 'out'))), "images extracted in 'out' folder") ph = ParaHeadings(level2_results2.result()) title_para = ph.get_titles_paras(sentence_threshold=2) # Final Notes notes = Notes(url, level2_results3.result()) notes.generate_notes() print("\nBrevis-Notes.docx and Brevis-Notes.pdf(on Windows) Generated\n") if os.path.exists('res'): shutil.rmtree('res') finish = time.perf_counter() print(f'Parallel: Finished in {round(finish-start, 2)} second(s)')
from flask import Flask from flask import jsonify, request from notes import Notes notes = Notes() api = Flask(__name__) def not_found_error(): return "This task ID was not found.", 404 @api.route("/", methods=["GET"]) def get_all_notes(): return jsonify(notes.get_all()) @api.route("/<int:note_id>", methods=["GET"]) def get_note(note_id: int): if notes.valid_id(note_id): return jsonify(notes.get(note_id)) else: return not_found_error() @api.route("/<int:note_id>", methods=["DELETE"]) def delete_note(note_id: int): if notes.valid_id(note_id): notes.delete(note_id) return jsonify(success=True)
def reset_container(self): self.has_been_assigned = False self.led = Led(led_number=led_number, strip_number=strip_number) self.notes = Notes()
class Epilader: INTRA_URL = "https://intra.epitech.eu/" JSON_CONF = "./Config/conf.json" def __init__(self, arg): self.curl = pycurl.Curl() self.option = Option() self.option.parse(arg) self.log = Log(self.option.isVerboseMode()) self.datas = [] config = json.loads(open(Epilader.JSON_CONF).read()) self.login = config["login"] self.password = config["password"] self.notes = Notes(config["projets"], config["modules"]) def __del__(self): self.curl.close() def set_cookies(self): self.curl.setopt(self.curl.POST, 1) self.curl.setopt(self.curl.URL, Epilader.INTRA_URL) self.curl.setopt(self.curl.POSTFIELDS, 'login='******'&password='******'') def find_gpa(self, request_result): request_result = json.loads(request_result) try: gpa = float([x for x in request_result["gpa"] if (x["cycle"] == "bachelor")][0]['gpa']) except: self.log.error(Log.NO_GPA) return -1 return gpa def find_moyenne(self, request_result): self.notes.init() request_result = json.loads(request_result) for note in request_result["notes"]: self.notes.add_note(note) return self.notes.moyenne() def request(self, href): self.curl.setopt(self.curl.URL, href) reponse = io.BytesIO() self.curl.setopt(self.curl.WRITEFUNCTION, reponse.write) try: self.curl.perform() except KeyboardInterrupt: raise KeyboardInterrupt except: self.log.error(Log.REQUEST_FAIL) print ; return "" return reponse.getvalue().decode("utf-8") def launch(self): try: while True: user = input() if user == "" or user == "EOF": return href_gpa = Epilader.INTRA_URL + "user/" + user + "/?format=json" href_note = Epilader.INTRA_URL + "user/" + user + "/notes/?format=json" if user[0] != '#': gpa = self.find_gpa(self.request(href_gpa)) moyenne = self.find_moyenne(self.request(href_note)) self.log.write(user + "\t: " + str(gpa) + "\t: " + str(moyenne)) if gpa > 0: self.datas.append([user, gpa, moyenne]) except (KeyboardInterrupt, EOFError): print("KeyboardInterrupt") ; return def sort(self): self.datas.sort(key=lambda x: x[1], reverse=True) def display(self): rank = 1 for d in self.datas: self.option.write(str(rank) + " " + d[0] + "\t" + str(d[1]) + "\t" + str(d[2]) + "\n") rank += 1