GithubHelp home page GithubHelp logo

sp1ff / elfeed-score Goto Github PK

View Code? Open in Web Editor NEW
59.0 3.0 10.0 464 KB

Gnus-style scoring for elfeed

License: GNU General Public License v3.0

Makefile 0.98% Shell 2.97% M4 0.11% Emacs Lisp 95.93%
emacs emacs-lisp rss rss-reader elfeed elfeed-rss-reader scoring

elfeed-score's People

Contributors

c-j-cundy avatar danielf-amobee avatar danielfleischer avatar fclaude avatar miciah avatar paulporfiroff avatar sp1ff avatar swflint avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

elfeed-score's Issues

Do not let rules sit in memory for too long

Presently, rules & their state (last match time, # hits, &c) are flushed to disk when:

  1. a scoring operation is performed (elfeed-score-score or elfeed-score-search)
  2. it is explicitly requested (elfeed-score-serde-write-score-file)
  3. elfeed-score is unloaded (elfeed-score-unload)

Otherwise, if you simply leave elfeed-score in place, day after day, reading news & relying on the Elfeed new entry hook to score entries, a lot of state accumulates in-memory that won't be written to disk.
Worse, if you update your score file by hand (to add a new rule, say), and then carry out one of the above three operations, your changes will be overwritten.

elfeed-score needs to:

  1. at minimum, check to see if the score file has been touched since last read and refuse to overwrite without confirmation; in practice, this shouldn't be too bad, since in the overwhelming number of cases, the edit will be to add new rules and so the user should be able to copy off the changes, accept the write & just re-add the new rules
  2. better would be to arrange to have rule state written out to disk more regularly, to preclude the case described in 1. This could be done on a timer. It could be done based on some sort of counter (e.g. write state every n times the new entry hook is invoked). It could also be done every time an elfeed-search-fetch operation completes, but since that's asynchronous, it's touchy. We could setup a feed update hook & write every time the work queue goes to zero, but there's no clear "I'm done" signal from that operation.

It is not clear to me what the right answer is, here. @firmart -- you first raised this issue... thoughts?

Typo(?) in the readme

Was reading the documentation and noticed in the example config it uses :type :type, wasn't sure if that was a typo or there was a point to having it twice.

(:text "Julia Evans" :value 100 :type :type s :attr t)

Link Rules Erased When Scoring Applied

Hello,

I'm a big fan of elfeed-score, thanks very much for building and sharing it. I am trying to add some of the new "link" rules and cannot get them to work. I updated elfeed and elfeed-score when I noticed this problem and reviewed the manual but couldn't find how to fix this.

Below is the process I've tried, with some variations:

Before starting elfeed or elfeed-score, I add the following rules to my scoring file:

 ("link"
  (:text "reddit" :value 30 :type s)
  (:text "twitter" :value 30 :type s)

I close the file and then start elfeed and call m-x elfeed-score-score . The messages buffer shows that my score file has been written, and if I re-open it, the two rules in the "link" list are gone. All of my other rules seems to be applying and updating normally. I've also tried calling m-x elfeed-score-load-score-file after making the change and before scoring.

Toggling the debugger hasn't helped, as apparently whatever is happening is not an error and is not getting captured in the messages buffer. My best current guess is that my rules are somehow not formed right and so they're not getting picked up by the scoring function, and then are overwritten by the "pre-existing rules" (in this case, nothing), but I can't figure out what the problem might be.

Any help troubleshooting would be greatly appreciated.

Troubleshooting: elfeed-score rules do not update the entry score

I'm trying to use elfeed-score along with elfeed-org, but somehow elfeed-score rules are not applied.

I was able to write an advice function to add a random score each time I read the content of an entry:

   (defun my/elfeed-show-pre-entry (e) 
     (let* ((score (elfeed-score--get-score-from-entry e))
	    (tags (elfeed-entry-tags e)))
       (when (not (member 'read tags))
	 (elfeed-tag e 'read)
	 (setq score (+ score 1 (random 10)))
	 (message "Entry %s score raised to %s" (elfeed-entry-id e) score)
	 (elfeed-score--set-score-on-entry e score))))

      (advice-add 'elfeed-show-entry :before #'my/elfeed-show-pre-entry)

(BTW, it would be cool if elfeed-score--get-score-from-entry and elfeed-score--set-score-on-entry belongs to the API (not internal))

Just to say that basic operation with elfeed-score works correctly. Moreover, I ran the following command on an entry (on the elfeed-search buffer):

(elfeed-score--score-on-title (car (elfeed-search-selected)))

and it returns a positive value. So elfeed.score is correctly read.

I tried to use the logger, but obviously nothing is logged because the rules was never applied. I don't know what to do now, all entries have a null score despite the remark above. Furthermore, I've even moved my elfeed database elsewhere and done elfeed-update, but nothing happened.

elfeed.score is overwritten by elfeed-score-score-search

I am sorry, I do not know if I have misunderstood the workflow for using elfeed-score.

I presume elfeed-score has to be maintained manually. I wrote the following in my elfeed.score:

((version 7)
 ("title")
 ("content")
 ("title-or-content"
  (:text "kerala" :value 1500 :type w
  :date 1612278560.2936354 :hits 46)
  )
 ("tag")
 ("authors")
 ("feed")
 ("link")
 (mark nil)
 ("adjust-tags"))

But when I run elfeed-score-score-search, it just removes the rule/rules that I have added.

I am unable to understand how am I supposed to create and save these rules.

Would appreciate help.

Vikas

Documentation: `elfeed-score-explain`

The docstring of elfeed-score-explain is a copy-paste of elfeed-score-score.

elfeed-score/elfeed-score.el

Lines 1705 to 1710 in 5fff415

(defun elfeed-score-explain (&optional ignore-region)
"Score some entries.
Score all the selected entries, unless IGNORE-REGION is non-nil,
in which case only the entry under point will be scored. If the
region is not active, only the entry under point will be scored."

elfeed-score/elfeed-score.el

Lines 1838 to 1843 in 5fff415

(defun elfeed-score-score (&optional ignore-region)
"Score some entries.
Score all selected entries, unless IGNORE-REGION is non-nil, in
which case only the entry under point will be scored. If the
region is not active, only the entry under point will be scored."

`elfeed-score-write-score-file` will elide information when the list gets long enough

elfeed-score-write-score-file depends on pp-to-string, which, when its argument is long or complex enough, will elide information (printing elipses instead). pp-to-string in turn uses prin1, whose behaviour in this regard is governed by a few variables (print-level and print-length)-- configuring those first would eliminate this problem.

Everything has 0 score

Somehow, elfeed-score has stopped scoring the items correctly. Everything has a zero score, and my rules are just ignored. It used to work earlier, but has stopped working after I rewrote my .emacs.d, and reinstalled all the emacs packages.

Even after I reload my elfeed.score file (=l), nothing changes. Everthing still has a 0 score.

I am not sure how to debug this.

Feature Request: "link" attribute for feed rule

I just started using this package and it is awesome! However, I was wondering if there is a way to add a rule based on the "Link" text in the entry and not just the url of the feed. For example, when I use some goolge alert rss feed, it generates a url that contains some meaningless numbers, but within this feed each entry has a link that is meaningful (words containing the source webpage, etc.) I would like to be able to run a text match or a regexp against this link text and not the feed url!

for example, look at the image below. I would like to set a filter and reduce the score for the "foodpoisonjournal". I tried to manually add a rule using elfeed-score-maint-add-feed-rule but the resulting rule is not useful because the feed url is a google link with some random numbers which won't affect future feeds from that same websit "foodpoisonjournal":

("feed"
(:text "https://www.google.com/alerts/feeds/11200774227803531995/15432672011287531238" :value -2000 :type s :attr u))

screenshot

Some typos

In the Readme,

  1. (Introduction) the sample elfeed.score file has a key "author". It should be "authors".
  2. There is a link to Elfeed whose the domain is gitub.com instead of github.com.

possibility to run a function on an entry for scoring

Is it possible to run a function on an entry that is responsible for computing a score? I guess you would implement it as a separate category of rules.

Maybe something like this

(:function func :comment "Computes the score from the word count")

The function would be called with something like this:

(funcall func entry)

and it would be expected to return a numeric score. The main thing I want to be able to do is

compare an entry to entries with a specific tag somehow, e.g. if it is similar to them it gets a higher score, or if it is similar to entries I tagged as not interesting, a lower score.

Maybe there are other things too, e.g. fancier tagging or something. WDYT?

Migrate from score file version 5 to version 6

Suddenly, I cannot use elfeed-score anymore after an update. I got weird error like

Debugger entered--Lisp error: (file-already-exists "File already exists" "~/.emacs.d/elfeed.score.~5~")

By inspecting the source code, I realized that we move to a version 6 which uses plist. But currently, for older score files, the code do nothing more than copying it to elfeed.score.~VERSION~. It would be nice to have a message/error announcing the version change and even nicer to have a function to migrate from old versions.

BTW, it's excellent to have plist. It was a little pain to know which parameter has what purpose without checking the source code or the README.

Score based on link content

Is there a way to score based on the link of an entry?

For clarity:
Say I subscribe to the feed example.com/feed.rss that contains items that links to articles like example.com/news/content.html and example.com/sports/content.html. Can I in this instance have one score for news-links and another for sports-links?

Suggestion: define `elfeed-score-load`

The function elfeed-score-enable installs (or not) the sort function and load the score file. It would be nice to separate the snippet which loads the score file to a separate function so that loading and unloading functions are both available. When I modified my score file, I used elfeed-score-enable to load it, but the denomination sounds unnatural.

Performance issues - elfeed-update is slow with scoring

Hello,

Thank you for this useful package!

I have experienced an issue of elfeed-update (especially at the fresh startup) being slow and freezing the emacs.

And, as suggested here Only redraw search buffer after refresh completes #293, I have advised the elfeed-update-feed as below, which solves my problem.

(use-package! elfeed
  :config
  (setq rmh-elfeed-org-files
        (list "~/org/gtd/elfeed.org")))

;; REF fix for freezing during elfeed-update
;; caused by search ui
(defvar ap/elfeed-update-complete-hook nil
  "Functions called with no arguments when `elfeed-update' is finished.")

(defvar ap/elfeed-updates-in-progress 0
  "Number of feed updates in-progress.")

(defvar ap/elfeed-search-update-filter nil
  "The filter when `elfeed-update' is called.")

(defun ap/elfeed-update-complete-hook (&rest ignore)
  "When update queue is empty, run `ap/elfeed-update-complete-hook' functions."
  (when (= 0 ap/elfeed-updates-in-progress)
    (run-hooks 'ap/elfeed-update-complete-hook)))

(add-hook 'elfeed-update-hooks #'ap/elfeed-update-complete-hook)

(defun ap/elfeed-update-message-completed (&rest _ignore)
  (message "Feeds updated"))

(add-hook 'ap/elfeed-update-complete-hook #'ap/elfeed-update-message-completed)

(defun ap/elfeed-search-update-restore-filter (&rest ignore)
  "Restore filter after feeds update."
  (when ap/elfeed-search-update-filter
    (elfeed-search-set-filter ap/elfeed-search-update-filter)
    (setq ap/elfeed-search-update-filter nil)))

(add-hook 'ap/elfeed-update-complete-hook #'ap/elfeed-search-update-restore-filter)

(defun ap/elfeed-search-update-save-filter (&rest ignore)
  "Save and change the filter while updating."
  (setq ap/elfeed-search-update-filter elfeed-search-filter)
  (setq elfeed-search-filter "#0"))

;; NOTE: It would be better if this hook were run before starting the feed updates, but in
;; `elfeed-update', it happens afterward.
(add-hook 'elfeed-update-init-hooks #'ap/elfeed-search-update-save-filter)

(defun ap/elfeed-update-counter-inc (&rest ignore)
  (cl-incf ap/elfeed-updates-in-progress))

(advice-add #'elfeed-update-feed :before #'ap/elfeed-update-counter-inc)

(defun ap/elfeed-update-counter-dec (&rest ignore)
  (cl-decf ap/elfeed-updates-in-progress)
  (when (< ap/elfeed-updates-in-progress 0)
    ;; Just in case
    (setq ap/elfeed-updates-in-progress 0)))

(add-hook 'elfeed-update-hooks #'ap/elfeed-update-counter-dec)

However, when I use it with elfeed-score, emacs freezes again at the initial elfeed-update call. Here is the config:

(use-package! elfeed-score
  :after elfeed
  :config
  (setq elfeed-score-serde-score-file "~/org/feed/elfeed.score")
  (setq elfeed-score-log-level 'debug)
  (elfeed-score-enable)
  (define-key elfeed-search-mode-map "=" elfeed-score-map))

Note that I have around 300 RSS entries. Is this expected or am I missing something?

Feature Request: `elfeed-score-explain` function

I've been using elfeed-score for quite a few months now, and it's working brilliantly.

One feature that would be really useful is some sort of interactive 'explain' function. At the moment, I have an elfeed.score file which is almost 500 lines long, and so sometimes it's a bit of a mystery why a particular entry that I expect to have a high score has a low score. It would be really useful to be able to press e.g. = e and have a list of (match text, score contribution) pop up in the minibuffer, in a similar way that currently I can press = g and have the entry's score pop up.

I know it's possible to set the debug state and look at the log to see this, but having it on an interactive function would make the workflow much easier.

I took a quick look but couldn't quite see how to get this to work.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.