jarun / buku

:bookmark: Personal mini-web in text
GNU General Public License v3.0
6.47k stars 295 forks source link

Multiple tag exclusion doesn't work #253

Closed jarun closed 6 years ago

jarun commented 6 years ago

The following query gives wrong results:

$ buku -t computer science - digital logic - assembly programming -z
OR
$ buku -t computer science - 'digital logic' - 'assembly programming' -z

[DEBUG] Version 3.6
[',computer science,']
OR
,digital logic - assembly programming,
2
[DEBUG] query: "SELECT id, url, metadata, tags, desc FROM (SELECT *, CASE WHEN tags LIKE '%' || ? || '%' THEN 1 ELSE 0 END AS score FROM bookmarks WHERE score > 0 AND tags NOT REGEXP ?  ORDER BY score DESC)", args: [',computer science,', ',digital logic - assembly programming,']
1. NPTEL [179]
   > http://nptel.ac.in/course.php
   # computer science,interview

2. 50+ Free Online Course Torrents (Video Lectures) – Free Courses [185]
   > http://freevideolectures.com/blog/2010/11/50-free-online-course-torrents-video-lectures/
   # computer science,interview

3. Simply Scheme contents [211]
   > http://www.cs.berkeley.edu/~bh/simply-toc.html
   # computer science,interview

4. How to Write a Master's Thesis in Computer Science [229]
   > http://cs.fit.edu/~wds/guides/howto/howto.html
   # computer science,interview

5. Computer Science from the Bottom Up [243]
   > http://www.bottomupcs.com/
   # computer science,interview

6. strchr.com [250]
   > https://www.strchr.com/
   + Resources on programming and algorithms.
   # algorithms,computer science,interview

7. Tips for Writing Technical Papers [255]
   > http://cs.stanford.edu/people/widom/paper-writing.html
   # algorithms,computer science,interview

8. CMSC 311 - Class Notes [263]
   > http://www.cs.umd.edu/class/sum2003/cmsc311/Notes/Overall/index.html
   # algorithms,computer science,interview

9. PC Architecture. A book by Michael B. Karbo [264]
   > http://www.karbosguide.com/books/pcarchitecture/start.htm
   + The way desktop PCs work.
   # algorithms,computer architecture,computer science,interview

10. Dictionary of Algorithms and Data Structures [267]
   > https://xlinux.nist.gov/dads/
   # algorithms,computer science,interview

11. Computer Science from the Bottom Up [297]
   > https://www.bottomupcs.com/
   + A shop class for computer science.
   # computer science

12. B441 Home Page [298]
   > https://www.cs.indiana.edu/classes/b441-sjoh/
   + Digital Hardware Design
   # computer science,digital logic

13. Computers [304]
   > http://yarchive.net/comp/index.html
   # algorithms,computer science,interview

14. GitHub - mewrev/dissection: The dissection of a simple "hello world" ELF binary. [305]
   > https://github.com/mewrev/dissection
   # assembly programming,binary analysis,computer science,interview

15. Algorithms | Computer science | Computing |Khan Academy [323]
   > https://www.khanacademy.org/computing/computer-science/algorithms
   + Introductory computer science algorithms, including searching, sorting, recursion, and graph theory.
   # computer science

16. Two's Complement [329]
   > https://www.cs.cornell.edu/~tomf/notes/cps104/twoscomp.html
   + What two's complement is and how to use it.
   # computer science

17. Cossack Labs / Zero Knowledge Protocols without magic [339]
   > https://www.cossacklabs.com/zero-knowledge-protocols-without-magic.html
   + ZKP authentication vs. traditional security models.
   # computer science

18. Most Visited Courses | MIT OpenCourseWare | Free Online Course Materials [341]
   > https://ocw.mit.edu/courses/most-visited-courses/
   + Most visited courses based on the site traffic of the previous month.
   # computer science

19. Demystifying Floating Point Precision « The blog at the bottom of the sea [390]
   > https://blog.demofox.org/2017/11/21/floating-point-precision/
   + What precision do I have at a number? When will I hit precision issues?
   # computer science

20. Teach Yourself Computer Science [407]
   > https://teachyourselfcs.com/
   + A well-designed Computer Science course.
   # computer science

The tags after the first - are combined together as a single tag and result 14 shows up.

jarun commented 6 years ago

@mosegontar could you please take a look? It seems we need to tweak prep_tag_search to handle multiple tags separated by -. It should also work with the following patterns:

+ - + -
and
- + - +
jarun commented 6 years ago

I think for simplification we should support just:

+ tag4
tag1 + tag2 - tag3 - tag4
- tag4
jarun commented 6 years ago

OK, I see that exclusion list can be separated by , however the the check for both + and , comes before that and trumps it.

jarun commented 6 years ago

@rachmadaniHaryono we need test cases for the api prep_tag_search().