Skip to content

Commit

Permalink
Feat: select files with fzf
Browse files Browse the repository at this point in the history
  • Loading branch information
lbesnard committed Oct 25, 2024
1 parent 8dad8c8 commit 9e2baea
Show file tree
Hide file tree
Showing 3 changed files with 394 additions and 361 deletions.
23 changes: 14 additions & 9 deletions koreader_highlights_2_anki/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import inquirer
import nltk
import torch
from iterfzf import iterfzf
from lupa import LuaRuntime
from tqdm import tqdm
from transformers import BertTokenizer, BertForMaskedLM
Expand Down Expand Up @@ -73,6 +74,7 @@ def get_word_importance(sentence, language="en"):
model = BertForMaskedLM.from_pretrained(model_name)

# Download NLTK stopwords if you haven't already
import nltk
nltk.download("stopwords", quiet=True)
from nltk.corpus import stopwords

Expand Down Expand Up @@ -569,15 +571,18 @@ def main():

# If --select-files is passed, present a list for the user to select files
if args.select_files:
questions = [
inquirer.Checkbox(
"selected_files",
message="Select the files to process (use space to select, arrows to navigate):",
choices=lua_files,
)
]
answers = inquirer.prompt(questions)
selected_files = answers.get("selected_files", [])
# questions = [
# inquirer.Checkbox(
# "selected_files",
# message="Select the files to process (use space to select, arrows to navigate):",
# choices=lua_files,
# )
# ]
# answers = inquirer.prompt(questions)
# selected_files = answers.get("selected_files", [])
prompt_message = "Select the files to process with TAB (You can type characters of a book to filter out):"
selected_files = list(iterfzf(lua_files, multi=True, prompt=prompt_message))

else:
selected_files = lua_files

Expand Down
Loading

0 comments on commit 9e2baea

Please sign in to comment.