Summary: | no word count function | ||
---|---|---|---|
Product: | [Applications] kate | Reporter: | David Pashley <kde-bugs> |
Component: | general | Assignee: | KWrite Developers <kwrite-bugs-null> |
Status: | RESOLVED FIXED | ||
Severity: | wishlist | CC: | a.j.ball, andy, bernd.mullet, bugs.kde.org, bugzilla, cruzki123, djjkotze, jessefrgsmith, litimetal, martin.ruessler, matija, mintlars, norbert.lindlbauer, pete, sridhar+bugs, walch.martin |
Priority: | NOR | ||
Version: | 3.14.0 | ||
Target Milestone: | --- | ||
Platform: | Debian testing | ||
OS: | Linux | ||
Latest Commit: | http://commits.kde.org/ktexteditor/97a1fc436f9810c6ba1c35ed42080ef1829871aa | Version Fixed In: | 5.8.0 |
Sentry Crash Report: | |||
Attachments: |
external tool word count script
New Kate word count script for KDE 4 |
Description
David Pashley
2003-10-09 12:12:05 UTC
Subject: Re: New: no word count function On Thursday 09 October 2003 12:12, David Pashley wrote: > Version: (using KDE KDE 3.1.3) > Installed from: Debian testing/unstable Packages > Compiler: gcc 3.3 > > it owuld be usefyul to have a word count function. Iyt would be nice if you > could do a worj=k count of hte current selection. What is a word? Seriously, I've been implementing a word count feature for Kile (LaTeX editor), it is pretty difficult to count words. Just an example, how would you count the following? K\"ahler (= K Hi there, David kindly submitted this bug on my behalf at the Linux Expo in London, and since nothing much has happened with it, I thought I'd add my own comments. Both myself and Nick (I'm Reviews Editor, he's the Editor of Linux Format magazine) use Kate to write all our articles, and we both miss having a word count function in there. I fully understand what Joroen has said - word counting isn't an easy thing to do because of the inherent complexity of the words we use. Right now I use wc to count the words, and even though the word count is probably off by about 5% it's a good enough estimate for me to use when submitting copy. However, what I really want is to be able to select a chunk of text, hit Word Count, and have it only count /those/ words. To do this in wc I usually copy the text, open a new document, copy the text in, save it somewhere temporary, then run wc. Even OOo doesn't have "word count selection", which is quite frustrating! I realise that this is probably a really niche request that would only benefit a few, so I understand why little movement has been made on this request. However, I hope this has helped you understand why it would be helpful to have a built-in word count function - even one that is as rough as wc - for Kate. Thanks, Paul Isn't it also a question of using the correct locale? in the case of ``k I wrote this (in Dutch:) as a tutorial of how to embed scripts in Kate, and it provides a word count function: http://www.kde.nl/doc/kate-scripting/ I think this would be best implemented by added a 'word' definition (in some regex format or another) in the definition for file types. In theory, that would mean I could even do word-counting in HTML and get the word-count for the resulting page, not the markup, if the definition were designed to do that. This would be wonderful for those of us that use tex and the like for word-processing. In the meantime, the main app could just do the lazy word definition that wc uses if nothing was defined, and the system would be useable from day one. If this allowed me to get word-counts of selected text, I would be completely sold, as right now I use Kate for all of my writing, but need to cat text through wc in a console to get a word-count for my work. this is OT, sorry:
> To do this in wc I usually copy the text, open a new document, copy the text in,
> save it somewhere temporary, then run wc.
just a hint: instead of creating a new file, just call wc an drag an drop the text into wc. then press <CTRL+d> ...
hhm, perhaps one can even make a desktop file.... but how does one tell it to accept text for dropping and what it should do with it....
If Gedit can have a wordcount, then Kate should too. As a journalist I am not too fussy about the accuracy of the count as words vary in length, so an additional character count including spaces would be good. I unearthed a KDE scripts solution but it does not work in Kubuntu or Fedora Core 4 KDE - Kate can't find the shell script. But that is a different bug. Someone ought to write a plugin for katepart. Me, probably :) Meanwhile, kates 'external tools' feature provides you with a easy way to do this. Here is a very simple implementation, note though that this does not work with non-local files, and that it saves the document if it has changes. The next version (3.0) of kate will allow to pipe text into commands used for external tools. But adding the following to $KDEHOME/share/apps/kate/externaltools would provide you with a command "Tools->External tools->Word count" that will work with local files: [externaltool_Wordcount] acname=externaltool_Wordcount cmdname= command=url=`echo %URL|sed -r 's,^\\w+\\:/+,/,'`\nkdialog --msgbox "Word count for\\n%URL:\\n$(wc -lwm $url|sed -r 's,\\s*(\\w+)\\s+(\\w+)\\s+(\\w+).*,Lines: \\1\\nWords: \\2\\nCharacters: \\3,')" executable=wc icon= mimetypes= name=Word count save=1 Brilliant. Thanks. Andy Goss On Wed, 2005-11-23 at 19:48 +0000, Anders Lund wrote: [bugs.kde.org quoted mail] For the this worked (two lines): url=`echo %URL|sed -r 's,^\\w+\\:/+,/,'` kdialog --msgbox "Word count for\n%URL:\n$(wc -lwm $url|sed -r 's,\s*(\w+)\s+(\w+)\s+(\w+).*,Lines: \1\nWords: \2\nCharacters: \3,')" *** Bug 134177 has been marked as a duplicate of this bug. *** *** Bug 121992 has been marked as a duplicate of this bug. *** Created attachment 17798 [details]
external tool word count script
Step by step howto for Kate Application:
- Settings > Configure Kate...
- 'External Tools' page
- Create new external tool
Label: Word Count
Script: copy&paste from attached file.
Executable: wc
Mime Types: leave blank
Save: Current Document
Command Line Name: leave blank or type 'word-count'
- Save & Apply
Use: Tools > External Tools > Word Count
Dominik Haumann wrote: [bugs.kde.org quoted mail] Thanks for you speedy reply! However, you have forgotten to attach the attachment you refer to :-)) Thanks again. God bless, The attachement resides in our bug tracking system. It's not attached to your mail, you have to follow the link. Could this be used to have an up-to-date word count in the status bar as well or would that be a different RFE? There is a solution at http://muzso.hu/node/3979 However, it only works when there is _one_ kate instance open. If you have multiple kates open (e.g. if you use different sessions), it will not work. *** Bug 216721 has been marked as a duplicate of this bug. *** With KDE 4.4 we now have inline spell-checking which only applies to areas marked in the highlight files. Now we could use these ranges and only do the word count in them. This would also probably fix bug 149955 and greatly improve the accuracy overall. I'll see what I can do, but I hope to implement it for 4.5. I agree that a word count wouldn't have to be overly accurate, as long as it gives an estimate. I'm fine with "rail-road" being counted as one or two words, for example. As someone else pointed out, Gedit does something along these lines where it gives a count of words, characters and character excluding spaces. That would be really handy to have in Kate/Kwrite. *** Bug 264082 has been marked as a duplicate of this bug. *** Created attachment 66615 [details] New Kate word count script for KDE 4 I found this solution at http://www.linuxquestions.org/questions/showthread.php?p=4546996#post4546996 It works for Kate 3.5.3 in Mepis 11. The version (3.8.4) of Kate that comes with Netrunner 4.2 (KDE 4.8.4) has lost External Tools, so I can't use Kate until another solution is found. Maybe with KDE 4.9 the Python plugins will provide one. Meanwhile I am stuck with the inferior Gedit. Better start learning Python :) The version (3.8.4) of Kate that comes with Netrunner 4.2 (KDE 4.8.4) has lost External Tools, so I can't use Kate until another solution is found. Maybe with KDE 4.9 the Python plugins will provide one. Meanwhile I am stuck with the inferior Gedit. Better start learning Python :) IMHO this should be a default feature in an advanced editor like kate. Are there any plans to implement word counting? I'd expect it to be in the status bar as an option or a default script you could optionally turn on/put in the bar below the status bar. I would also like to see this as a default feature or script. Kate is extremely useful for me as a journalist since it's completely unformatted text (e.g. easy to send to editors without having to bother about compatability issues). The only thing missing is character/word count. Git commit 97a1fc436f9810c6ba1c35ed42080ef1829871aa by Michal Humpula. Committed on 14/02/2015 at 19:01. Pushed by michalhumpula into branch 'master'. add word count statistics in statusbar This option is disabled by default, because it adds some nontrivial CPU and memory overhead, though the implementation tries to keep it as minimal as possible. Whenewer the change in document is triggered, the timer is fired to wait for 500ms of inactivity. The trigger is reseted every time the change happens so as long as she keeps changing the document every 500ms or so, the counting wont stall the editor and her experience. Longer reculculations are done in batches of size 100 with the help of 500ms trigger. Which means 10000 lines long document will take 20s to compute. Subsequent counting of changes will be much faster because of the internal computation cache. Interface changes includes adding signal KTextEditor::DocumentPrivate::loaded to monitor document reload. GUI: menu: View -> Show Word Count REVIEW: 122571 FIXED-IN: 5.8.0 M +2 -1 src/CMakeLists.txt M +2 -1 src/data/katepartui.rc M +9 -8 src/document/katedocument.cpp M +6 -3 src/document/katedocument.h M +22 -0 src/utils/kateconfig.cpp M +4 -0 src/utils/kateconfig.h M +44 -0 src/view/katestatusbar.cpp M +14 -2 src/view/katestatusbar.h M +11 -0 src/view/kateview.cpp M +2 -0 src/view/kateview.h A +189 -0 src/view/wordcounter.cpp [License: LGPL (v2)] A +63 -0 src/view/wordcounter.h [License: LGPL (v2)] http://commits.kde.org/ktexteditor/97a1fc436f9810c6ba1c35ed42080ef1829871aa (In reply to Michal Humpula from comment #27) > > add word count statistics in statusbar > > This option is disabled by default, because it adds some nontrivial CPU and > memory overhead, though the implementation tries to keep it as minimal > as possible. How do I activate this? (16.08.3) (In reply to Erik Quaeghebeur from comment #28) > (In reply to Michal Humpula from comment #27) > > > > add word count statistics in statusbar > > > > This option is disabled by default, because it adds some nontrivial CPU and > > memory overhead, though the implementation tries to keep it as minimal > > as possible. > > How do I activate this? (16.08.3) Second last item on the View menu. |