[Solved] Word count
[Solved] Word count
Hi,
Here's somebody can tell me if it's possible to know how many caracters with and without spaces in a text. Actually, the statistics availables in the Word count (Tools) don't make any difference between the caracters with and without spaces.
Thanks!
Here's somebody can tell me if it's possible to know how many caracters with and without spaces in a text. Actually, the statistics availables in the Word count (Tools) don't make any difference between the caracters with and without spaces.
Thanks!
Last edited by Hagar Delest on Tue Jul 01, 2008 1:29 pm, edited 1 time in total.
Reason: tagged the thread as Solved.
Reason: tagged the thread as Solved.
-
- Posts: 1
- Joined: Tue Apr 15, 2008 4:08 am
Re: Word count
Well I don't know if there is a real solution, but while you're waiting for an answer you might want to try a work around.
OpenOffice counts your spaces as characters, now if your goal is to NOT include spaces, you might want to remove them and then do a word count. When you hit Ctrl+F, you'll do a word find, but you can also replace or remove words or spaces. Simply make a space in the "Search For" box (first box) and then click on the replace all button. This will remove all single spaces, allowing you to count the exact number of characters in your document.
When you're done, undo the space removal by hitting Ctrl+Z or close your document WITHOUT Saving. Do NOT save your document with the space removed or you'll end up having to redo them one at the time
Hope that helps for now
OpenOffice counts your spaces as characters, now if your goal is to NOT include spaces, you might want to remove them and then do a word count. When you hit Ctrl+F, you'll do a word find, but you can also replace or remove words or spaces. Simply make a space in the "Search For" box (first box) and then click on the replace all button. This will remove all single spaces, allowing you to count the exact number of characters in your document.
When you're done, undo the space removal by hitting Ctrl+Z or close your document WITHOUT Saving. Do NOT save your document with the space removed or you'll end up having to redo them one at the time
Hope that helps for now
Re: Word count
Thanks a lot for the tip, The_Importer.
It's very appreciated.
Good night!
It's very appreciated.
Good night!
Re: Word count
That seems like a good answer.
As an aside, if you make a "replace all," the dialog will tell you how many replacements were made, so in your example you would know how many spaces were found and replaced in the text.
If you need to count how many times a word or phrase appears, put it in both the Find and in the Replace windows and select Replace All. Nothing will really get changed in your text (I "copy/paste" between the windows to ensure I don't introduce a typo), but it will indicate how many were "replaced."
As an aside, if you make a "replace all," the dialog will tell you how many replacements were made, so in your example you would know how many spaces were found and replaced in the text.
If you need to count how many times a word or phrase appears, put it in both the Find and in the Replace windows and select Replace All. Nothing will really get changed in your text (I "copy/paste" between the windows to ensure I don't introduce a typo), but it will indicate how many were "replaced."
Re: Word count
I recommend using the Alternative dialog Find & Replace for Writer. It's a great extension anyway!
It allows to use regular expressions (like does the standard writer search dialog as well), but it additionally allows to count the hits without modifying the text.
Also, there are pop-down menus for standard regular expression searches, i.e. Any letter and Any space for your case.
Some more information about regular expressions is found in the OOoAuthors Users Manual. Detailed information is found in Wikipedia.
KR, phil
It allows to use regular expressions (like does the standard writer search dialog as well), but it additionally allows to count the hits without modifying the text.
Also, there are pop-down menus for standard regular expression searches, i.e. Any letter and Any space for your case.
Some more information about regular expressions is found in the OOoAuthors Users Manual. Detailed information is found in Wikipedia.
KR, phil
OOo 3.0.1 & DEV-3.1 • WinXP pro 32-bit + SP3 + current patches
Looking for OpenOffice-related information? Try the search engine on OpenOfficeNinja - a great tool!
My favorite extension: Alt. Find & Replace for Writer. All you need and much more...
OOo 2.4.X on Ms Windows XP
Looking for OpenOffice-related information? Try the search engine on OpenOfficeNinja - a great tool!
My favorite extension: Alt. Find & Replace for Writer. All you need and much more...
OOo 2.4.X on Ms Windows XP
- Hagar Delest
- Moderator
- Posts: 32665
- Joined: Sun Oct 07, 2007 9:07 pm
- Location: France
Re: Word count
Here is a small macro taken from the French forum and adapted to your needs:
here is how it looks like (type 'dt' and hit F3 then run the macro):
Code: Select all
Sub CharactersCount
Dim oDoc As Object
Dim oText As Object
Dim b As String
Dim t As String
' Counters definition
Dim sc As Long ' space
Dim lc As Long ' letter
Dim dc As Long ' digit
Dim rc As Long ' carriage return
Dim oc As Long ' other
oDoc = ThisComponent
oText = oDoc.Text
' Get the counts
n = 1
Do
t = Mid(oText.String, n, 64000)
n = n + 64000
For p = 1 To Len(t)
Select Case Mid(t, p, 1)
Case "a" To "z", "A" To "Z" ' letters
lc = lc + 1
Case " ", Chr(9) ' tabulation and spaces
sc = sc + 1
Case "0" To "9" ' digits
dc = dc + 1
Case Chr(13) ' carriage returns
rc = rc + 1
Case Chr(10)
' to be ignored
Case else
oc = oc + 1
End Select
Next p
Loop While Len(t) = 64000
' Show the results
t = "Alphanumerical characters: " & Str( lc + dc ) & Chr(13) & Chr(10) _
& "Spaces and tabulations : " & Str(sc) & Chr(13) & Chr(10) _
& "Others (punctuation, ...): " & Str(oc) & Chr(13) & Chr(10) _
& "Total: " & Str(lc+dc+sc+oc) & Chr(13) & Chr(10) _
& "Total minus spaces and tabs: " & Str(lc+dc-sc)
MsgBox t,0,"Custom count"
End Sub
Edit: July 24th, 2008: cleaned some code. |
LibreOffice 7.6.2.1 on Xubuntu 23.10 and 7.6.4.1 portable on Windows 10
-
- Posts: 1
- Joined: Sat Jul 19, 2008 8:24 am
Re: [Solved] Word count
Thank you, The Importer. Pressing CTRL+F, counting, then CTRL+Z seems a very natty (good) solution which I will certainly use.
The makers of Open Office have done a wonderful job with loads of Word-like applications, surely it cannot be beyond them to include a character count without spaces in the next version of Open Office.
Cheers,
Cassyjanek
The makers of Open Office have done a wonderful job with loads of Word-like applications, surely it cannot be beyond them to include a character count without spaces in the next version of Open Office.
Cheers,
Cassyjanek
OOo 2.4.X on Ms Windows XP
Re: [Solved] Word count
It probably wouldn't, but this is a user to user forum and developers don't come here.
OpenOffice 4.1.11 on Ubuntu; LibreOffice 6.4 on Linux Mint, LibreOffice 7.6.2.1 on Ubuntu
If your problem has been solved or your question has been answered, please edit the first post in this thread and add [Solved] to the title bar.
Nederlandstalig forum
If your problem has been solved or your question has been answered, please edit the first post in this thread and add [Solved] to the title bar.
Nederlandstalig forum
Re: [Solved] Word count
Hagar's macro working only with simple documents. If documents consist TOC, all count results are zero. Can anybody show me the solution?
AOO 4.0 and LibO 4 on Win 8
Hungarian forum co-admin
Hungarian forum co-admin
- Hagar Delest
- Moderator
- Posts: 32665
- Joined: Sun Oct 07, 2007 9:07 pm
- Location: France
Re: [Solved] Word count
Could you upload a sample file?
It works fine for me even if there is a ToC.
It works fine for me even if there is a ToC.
LibreOffice 7.6.2.1 on Xubuntu 23.10 and 7.6.4.1 portable on Windows 10
Re: [Solved] Word count
Andrew Pitonyak's Base macro file, gives zeros. http://www.pitonyak.org/database/AndrewBase.odt, and http://dba.openoffice.org/specification ... signer.odt.
I tried it with OOo 2.4.1 Novell under openSuSE 11.0, and 2.4.1 and Dev300m26 under WinXP, same results.
Tried others and others look like working, but same strange differences in characters totals and Tools>Word counts results, with http://dba.openoffice.org/specification ... atting.odt, with macro: 14118, word count 8447 .
I tried it with OOo 2.4.1 Novell under openSuSE 11.0, and 2.4.1 and Dev300m26 under WinXP, same results.
Tried others and others look like working, but same strange differences in characters totals and Tools>Word counts results, with http://dba.openoffice.org/specification ... atting.odt, with macro: 14118, word count 8447 .
AOO 4.0 and LibO 4 on Win 8
Hungarian forum co-admin
Hungarian forum co-admin
- Hagar Delest
- Moderator
- Posts: 32665
- Joined: Sun Oct 07, 2007 9:07 pm
- Location: France
Re: [Solved] Word count
Right, the macro doesn't work on text longer than 65536 characters (including non printing ones).
Seems to come from oText = oDoc.Text or oText.String. One or both of these variables can't hold more than 65536 characters.
In my document, max char number is 65452? Since I've 42 paragraphs: 42 x 2 + 65452 = 65536 (why 2 chars for each paragraph?)
NB: I've cleaned some code in the macro BTW.
Seems to come from oText = oDoc.Text or oText.String. One or both of these variables can't hold more than 65536 characters.
In my document, max char number is 65452? Since I've 42 paragraphs: 42 x 2 + 65452 = 65536 (why 2 chars for each paragraph?)
NB: I've cleaned some code in the macro BTW.
LibreOffice 7.6.2.1 on Xubuntu 23.10 and 7.6.4.1 portable on Windows 10
- Hagar Delest
- Moderator
- Posts: 32665
- Joined: Sun Oct 07, 2007 9:07 pm
- Location: France
Re: [Solved] Word count
LibreOffice 7.6.2.1 on Xubuntu 23.10 and 7.6.4.1 portable on Windows 10
Re: [Solved] Word count
There's a difference between OOo 3.3.0 and LibO 3.3.1Stef wrote:[...] Here's somebody can tell me if it's possible to know how many caracters with and without spaces in a text. Actually, the statistics availables in the Word count (Tools) don't make any difference between the caracters with and without spaces. [...]
(no manual check ):
Tools > Word Count — OOo 3.3.0 Tools > Word Count — LibO 3.3.1 There will be an improvement in OOo 3.4:
→ Bug 89042 - Word count is incorrect with certain special characters in the text (i.e. custom quotes, dashes)
[Status: VERIFIED FIXED]
From Comment #22:
"Fixed means: word count for text with typographical quotes (single and double
quote) as listed in the attached bugdoc now do behave similar to MS Word 2007
again. This means especially that
French « savoir calculer »
is still counted as 5, since I was told the main 'feature' of the word count
implementation is to give the same result as MS Word."
LibreOffice 4.0.4 · WinXP
- Hagar Delest
- Moderator
- Posts: 32665
- Joined: Sun Oct 07, 2007 9:07 pm
- Location: France
Re: [Solved] Word count
franx wrote:From Comment #22:[...]
French « savoir calculer » is still counted as 5, since I was told the main 'feature' of the word count implementation is to give the same result as MS Word."
How to prevent OOo from being better than the others...
Shame shame shame.
LibreOffice 7.6.2.1 on Xubuntu 23.10 and 7.6.4.1 portable on Windows 10