This repository has been archived by the owner on Jun 15, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
63 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
from evonote.notebook.notebook import Notebook | ||
|
||
|
||
def analyze_notebook_sparsity(notebook: Notebook): | ||
""" | ||
Return the average number of children per note. | ||
""" | ||
notes = notebook.get_note_list() | ||
max_children = -1 | ||
total_children = 0 | ||
n_non_leaf_notes = 0 | ||
for note in notes: | ||
n_children = len(note.children()) | ||
if n_children > 0: | ||
n_non_leaf_notes += 1 | ||
total_children += n_children | ||
max_children = max(max_children, n_children) | ||
average_children = total_children / n_non_leaf_notes | ||
heavy_notes = get_children_heavy_notes(notebook) | ||
print("Total_notes:", len(notes)) | ||
print("Average children per non-leaf note:", average_children) | ||
print("Max children per note:", max_children) | ||
# print heavy notes | ||
for note in heavy_notes: | ||
print("Note:", note.note_path()) | ||
print("Children:", len(note.children())) | ||
print("Content:", note.content) | ||
print("") | ||
|
||
def get_children_heavy_notes(notebook: Notebook, min_children=10): | ||
""" | ||
Return a list of notes with at least min_children children. | ||
""" | ||
notes = notebook.get_note_list() | ||
heavy_notes = [] | ||
for note in notes: | ||
n_children = len(note.children()) | ||
if n_children >= min_children: | ||
heavy_notes.append(note) | ||
return heavy_notes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
from evonote.notebook.analysis import analyze_notebook_sparsity | ||
import evonote | ||
from evonote.transform.module_to_notebook import get_notebook_for_module | ||
|
||
notebook = get_notebook_for_module(evonote) | ||
analyze_notebook_sparsity(notebook) |