sirupsen / zk

Zettelkasten on the command-line πŸ“š πŸ”
576 stars 26 forks source link

Error when using zksim, example usage would be helpful in Readme #4

Closed ipochi closed 4 years ago

ipochi commented 4 years ago

I am trying to setup zk for personal use and I am not able to figure out the example usage of zksim

I am getting error when executing the command (p.s I am confused about the input arguments to zksim) but I doubt it matters.

~ zksim dummy
Traceback (most recent call last):
  File "/home/imran/zk/bin/zksim", line 118, in <module>
    TfidfSearch().run()
  File "/home/imran/zk/bin/zksim", line 114, in run
    self.application_logic(args.filename)
  File "/home/imran/zk/bin/zksim", line 101, in application_logic
    for file in relevant_titles(df, filename, title_col="title", text_col="body")[:self.num_files_to_show]:
  File "/home/imran/zk/bin/zksim", line 70, in relevant_titles
    sim_index = similarity_index(searching_index, vectors)
  File "/home/imran/zk/bin/zksim", line 55, in similarity_index
    cosine_similarities = linear_kernel(vectors[search_index], vectors).flatten()
  File "/home/imran/.local/lib/python3.8/site-packages/sklearn/metrics/pairwise.py", line 1002, in linear_kernel
    X, Y = check_pairwise_arrays(X, Y)
  File "/home/imran/.local/lib/python3.8/site-packages/sklearn/utils/validation.py", line 73, in inner_f
    return f(**kwargs)
  File "/home/imran/.local/lib/python3.8/site-packages/sklearn/metrics/pairwise.py", line 144, in check_pairwise_arrays
    X = check_array(X, accept_sparse=accept_sparse, dtype=dtype,
  File "/home/imran/.local/lib/python3.8/site-packages/sklearn/utils/validation.py", line 73, in inner_f
    return f(**kwargs)
  File "/home/imran/.local/lib/python3.8/site-packages/sklearn/utils/validation.py", line 651, in check_array
    raise ValueError("Found array with %d sample(s) (shape=%s) while a"
ValueError: Found array with 0 sample(s) (shape=(0, 4)) while a minimum of 1 is required by check_pairwise_arrays.
jcd13d commented 4 years ago

zksim is actually meant to take a note title (filename) as an argument. It assumes you have zk set up and working - so you would have an "index.db" sqlite table file with some notes stored in it.

Something like...

$ zksim 202006030622 Your note title.md

Would return the top 20 similar files by filename in plain-text. This is meant to be used in conjunction with zks using Alt-s.

I actually just realized, however, I have an issue using the Alt-s bind currently in master for zks. I have been using a slightly different version I'm tweaking personally so if you still have issues let us know.

Edit: As far as changing the README, I am hesitant to add usage for the command line as it is meant to be used within zks... I am adding error handling that I hope will make that error more clear, though.

sirupsen commented 4 years ago

From the README: zksim. Finds similar notes to the note passed as an argument. See #1 for more., yeah, I think the error improvement should be good enough for now πŸ‘