Pagina 1 di 1

Contatore caratteri open office

Inviato: lunedì 19 novembre 2007, 21:09
da Mago Nick
Ho notato che open office non ha il conteggio caratteri spazi esclusi, come posso rimediare? devo fare un lavoro per cui mi è richiesto un preciso numero di caratteri, sono disperato  >:( >:( >:(
help please!

Re: Contatore caratteri open office

Inviato: lunedì 19 novembre 2007, 22:11
da Kitpou
Ho provato e funziona.
Se vai in Strumenti-> Conteggio Parole ti da il numero delle parole e dei caratteri dell'intero documento.
Se selezioni una parte del testo e fai la stessa operazione, oltre a darti le parole e i caratteri dell'intero documento fornisce anche i dati relativi alla parte selezionata.

Re: Contatore caratteri open office

Inviato: lunedì 19 novembre 2007, 22:15
da Mago Nick
i caratteri però sono spazi inclusi, o sbaglio?

Re: Contatore caratteri open office

Inviato: lunedì 19 novembre 2007, 22:18
da jepessen
Mi pare ci fosse una macro in giro su internet che fa quello che vuoi... prova a fare una ricerca

Daniele

Re: Contatore caratteri open office

Inviato: lunedì 19 novembre 2007, 22:29
da Mago Nick
ti ringrazio!!!! sei il mio dio!!!

Re: Contatore caratteri open office

Inviato: lunedì 19 novembre 2007, 22:37
da jepessen
Fanciulle in sacrificio... ricorda....

Comunque vedi se lo trovi, prima di convertirti...

Daniele

Re: Contatore caratteri open office

Inviato: lunedì 19 novembre 2007, 22:39
da Kitpou
jepessen ha scritto: Fanciulle in sacrificio... ricorda....

Comunque vedi se lo trovi, prima di convertirti...

Daniele
Dai gli\ti do una mano  ;)
Vedi un pò qua:
http://www.ooomacros.org/user.php

Re: Contatore caratteri open office

Inviato: martedì 20 novembre 2007, 10:18
da Mago Nick
hem ho provato l'unica macro che conteneva un contatore caratteri migliorato rispetto a quello di openoffice, però è sempre spazi inclusi... >:( :( >:( :( >:(

Re: Contatore caratteri open office

Inviato: martedì 20 novembre 2007, 12:52
da Kitpou
A questo punto alzo le mani...speriamo intervenga qualcuno che risolva questo dettaglio  :-[

Re: Contatore caratteri open office

Inviato: martedì 20 novembre 2007, 15:56
da jepessen
Posta qua il codice della macro, vediamo se riusciamo a modificarlo...

Daniele

Re: Contatore caratteri open office

Inviato: martedì 20 novembre 2007, 16:16
da Mago Nick
come devo fare?

Re: Contatore caratteri open office

Inviato: martedì 20 novembre 2007, 17:50
da jepessen
Andando in strumenti macro, dovresti poter selezionare le macro presenti nel documento, ed eventualmente modificarle.. appena ti si apre l'editor, copi tutto e posti qua...

Daniele

Re: Contatore caratteri open office

Inviato: martedì 20 novembre 2007, 19:43
da Mago Nick
ecchilo

Codice: Seleziona tutto

REM  *****  BASIC  *****

Sub Main
acbwc
End Sub

Sub acbwc
' v3.0 with hotcount
' 12 October 2004
'  
' the test for this is that that it is very fast, and, if you select 
' a whole document, will give you the same number of words in the selection as
' OOo returns for the whole doc.
' there is one exception: fields such as page numbers and dates are not counted 
' in the OOo word count statistics. They are counted by the selected text macro.
' If anything, that makes it more accurate :-)
' 
' there is one possible snag: the language it counts selected text in 
' is officially declared as English. Translated versions need to change
' the line in hotcount aLocale.Language="en" to their locale.
' Someone with time on their hands could write code to detect the language in use
' and make that change automatically.
' This version written almost entirely by Andrew Brown.
dim xDoc, xSel, nSelcount
dim nAllChars
dim nAllWords
dim nAllPars 
dim thisrange, sRes
dim nSelChars, nSelwords, nSel 
dim atext, bigtext
dim fnotes, thisnote, nfnotes, fnotecount
	xDoc = thiscomponent
	xSel = xDoc.getCurrentSelection()
	nSelCount = xSel.getCount()

	' by popular demand ...
	fnotes=xdoc.getFootNotes()
	if fnotes.hasElements() then
		fnotecount=0
		for nfnotes=0 to fnotes.getCount()-1
			thisnote=fnotes.getbyIndex(nfnotes)
			fnotecount=fnotecount+hotcount(thisnote)
		next nfnotes
	end if
	
	' this next "if" works around the problem that if you have made a selection, then
	' collapsed it, then count again, the empty selection is still counted which was confusing and ugly
	if nSelCount=1 and xSel.getByIndex(0).getString()="" then
		nSelCount=0
	end if

	' access easy document statistics
	nAllChars = xDoc.CharacterCount
	nAllWords = xDoc.WordCount
	nAllPars = xDoc.ParagraphCount

	' initialize counts
	nSelChars = 0
	nSelWords = 0
		' the fancy bit starts here
	  	' iterate over multiple selection
  	for nSel = 0 to nSelCount - 1
	  	thisrange=xSel.GetByIndex(nSel)
	  	atext=thisrange.getString()
		nselwords=nSelWords+hotcount(atext)
		nSelChars=nSelChars+len(atext)
  	next nSel
	
	' dialog code rewritten for legibility
	if fnotes.hasElements() then
		sRes="Document count (with footnotes): "  + nAllWords + " words. "  + chr(13)
		sRes=sRes+"Word count without footnotes: "+ str(nAllWords-fnotecount) + " words. "  + chr(13)+"(Total: " +nAllChars +" Chars in "
	else 
		sRes= "Document count: "  + nAllWords +"  words. "  + chr(13)+"(" +nAllChars +" Chars in "  
	end if
	sRes=sRes + nAllPars +" Paragraphs.)"+ chr(13)+ chr(13)
	if nselCount>0 then 
		sRes=sRes  + "Selected text count: " + nSelWords  + "  words" + chr(13) + "(" + nSelChars  + " chars"
		if nSelcount=1 then
			sRes=sRes  + " In " + str(nselCount) + " selection.)"
			else
			sRes=sRes +  " In " + str(nselCount-1) +" selections.)" ' don't know why, but need this adjustment
		end if
		sRes=sRes+chr(13)+chr(13)+"Document minus selected:" + chr(13)+ str(nAllWords-nSelWords) + " words." +chr(13) +chr(13)
	end if
	if fnotes.hasElements() then
		if fnotes.getCount()=1 then
			sRes=sRes+"There are "+ str(fnotecount) + " words in the "+ fnotes.getCount() +" footnote." +chr(13) +chr(13)			
		else
			sRes=sRes+"There are "+ str(fnotecount) + " words in "+ fnotes.getCount() +" footnotes." +chr(13) +chr(13)
		end if
	end if
msgbox(sRes,64,"Word Count 3.0")
End Sub

function hotcount(aString)
' the ultimate, using the same breakiterator as the program
' 
dim mystartpos as long
dim numwords,nw 
dim nextwd as new com.sun.star.i18n.Boundary
dim aLocale as new com.sun.star.lang.Locale
aLocale.Language="en"
' Urska, you may need to change the line above. 
numwords=1 ' don't ask me why we need this
mystartpos=0
brk=createUnoService("com.sun.star.i18n.BreakIterator")
nextwd=brk.nextWord(aString,startpos,aLocale,com.sun.star.i18n.WordType.WORD_COUNT)
Do while nextwd.startPos<> nextwd.endPos
	numwords=numwords+1
	nw=nextwd.startPos
	nextwd=brk.nextWord(aString,nw,aLocale,com.sun.star.i18n.WordType.WORD_COUNT)
Loop
hotcount=numwords
end Function
thx ^^
m.

Re: Contatore caratteri open office

Inviato: venerdì 23 novembre 2007, 21:03
da Mago Nick
up please T.T

Re: Contatore caratteri open office

Inviato: lunedì 10 dicembre 2007, 17:47
da Rosiel
A. Nicastro ha scritto: up please T.T
questo interessa anche a me, ho il suo stesso problema (:P) e necessito del conteggio caratteri spazi esclusi T_T

qualcuno sa dare una mano?

Re: Contatore caratteri open office

Inviato: martedì 11 dicembre 2007, 10:47
da jepessen
Mmmm....

Scusate tutti, avevo perso l'aggiornamento di questo thread...

Stasera uppate per ricordarmelo, che se sono a casa do uno sguardo al codice...

Daniele

Re: Contatore caratteri open office

Inviato: martedì 11 dicembre 2007, 19:57
da Rosiel
jepessen ha scritto: Mmmm....

Scusate tutti, avevo perso l'aggiornamento di questo thread...

Stasera uppate per ricordarmelo, che se sono a casa do uno sguardo al codice...

Daniele
io te lo uppo e mi affido a te :P

dover loggare su winzoz per qualsiasi motivo che non sia giocare ad un qualche gioco demenziale che gira solo li mi deprime profondamente, e dato che dovrò lavorare ancora per 3 anni con il conteggio caratteri spazi esclusi preferirei dover evitare questa sofferenza eheh ^^

comunque aspetto e spero che qualcuno sappia risolvere^^

Re: Contatore caratteri open office

Inviato: martedì 11 dicembre 2007, 23:03
da jepessen
Allora, cercando documentazione ho trovato un'altra macro che fa più o meno la stessa cosa...

L'ho modificata un pochetto, ma non completamente, anche perchè c'ho sonno...

Aprite l'editor (Strumenti->Macro->Organizza Macro->Macro): su Macro Personali cliccate su Nuovo, e copiate il seguente codice:

Codice: Seleziona tutto

' Based on the original* "dvwc" macro by Daniel Vogelheim   *see end of doc
' Displays a message box with number of words & characters
' in the document and the current selection.
' John Vigor edited this in 2003 to provide both a character count
' and a character count with exclusions. DV's had one of these.
' Does not normally count in frames, headers, footers or footnotes
' although these items may be individually selected. Selected text
' cannot exceed 64K of characters. (About 18 dense single spaced pages
' using New Times Roman size 12 and 1 inch margins all around. This
' size takes about 20 seconds on a 770MHz machine, so go get a cup
' of coffee or just be patient.)
' OO's word count, as of OO1.1 rc4, does not count in fields but does
' count in the other areas mentioned above. OO's character count
' counts a line break (Shift+Enter) as a character (Issue filed #16918).   

Sub SelectionCount
'DEFINE CHARACTER COUNT BELOW. The default exclusions from character count are
'spaces & tabs, i.e., one of each of these is contained in the definition of e$.
'You can add characters between the quotes and/or delete the space and/or tab. 
e$ = Chr(32) + Chr(9)  ' Chr(32) is a space, Chr(9) is a tab. Valid replacements would
'be e$ = Chr(32) or e$ = Chr(9) or e$ = "" with the latter being no exclusions. If you
'did not change e$ and if the line below read:
' sExcludeFromCharacterCount$ = e$ + "a" then spaces, tabs and the letter "a" would not
'be counted.   
sExcludeFromCharCount$ = e$ +  " "
'DEFINE WORD SEPERATORS BELOW. The default word separators are spaces and
'hyphens (true hyphenated words like "half-dollar" will be counted as two words
'instead of one). You can add separators between the quotes and/or delete the hyphen.
'Examples: "/" to count "and/or" as two words. "&" to count "Johnson & Johnson" as
'two words instead of three. A period is not normally needed but you can add one
'to count "www.website.com" as three words instead of one.   
sWordSeps = " -"
' This section is basically all DV's code with small modifications needed by JV
sWordSeps = sWordSeps + chr(9) + chr(10) + chr(13)'a tab, line break and paragraph break
sNeverCountChars = chr(10) & chr(13)'never include line or paragraph breaks in char count
oDocument = thisComponent
oSelection = oDocument.getCurrentSelection()
nSelCount = oSelection.getCount()
' access the program's document statistics
nAllChars = oDocument.CharacterCount
nAllWords = oDocument.WordCount
' initialize counts
nSelWords = 0 : nSelChars = 0 : nSelCharEx = 0
' iterate over multiple selections
Do
sText = oSelection.getByIndex(nSel).getString()
' count word in sText by scanning the selected text character for character
nCount = Len(sText)
bLastWasSeparator = true
bWord = false
'first letter starts a word
i = 1
Do ' DV used different logic for this section and there was nothing wrong
   ' with it. A programing exercise for JV and it better fit his needs.
sChr = Mid(sText,i,1)
If instr(sWordSeps, sChr) = 0 then 'if true then it's part of a word
  bWord = true
  GoSub CountIt 'count this character?
 Elseif bWord = True then 'is a seperator and at end of word.
  nSelWords = nSelWords + 1
  bWord = false
  GoSub CountIt
 Else
  GoSub CountIt 'is seperator but not the at end of a word.
EndIf
' End of JV's logic.
i = i + 1
Loop Until i > nCount 'get the next character in the string
nSel = nSel + 1
Loop while nSel < nSelCount
' Begin JV stuff
if bWord then nSelWords = nSelWords + 1
sExclude$ = " "
if Len(sExcludeFromCharCount$) = 0 then
 sExclude$ = "* No exclusions."
 else sExclude$ = Build_sExclude(sExcludeFromCharCount$)
endif
' JV altered DV's message box.
sT = chr(9): sP = chr(13) 'a Tab and Paragraph Break
a$ = "Program Document Count" + sP + sT & " All words:  " + nAllWords + sP
b$ = sT & " All chars:   " + nAllChars + sP + "Macro Selection Count" + sP
sMsg = a$ & b$
If nSelChars > 0 then
  a$ = sT & " Words:  " + nSelWords + sP + sT & " Chars:   " + nSelChars + sP + sT
  b$ = "   *  Chars:   " + nSelCharEx + sP & sExclude$
  sMsg = sMsg + a$ + b$
 Else a$ = "No text was selected or the selection" & sP & sT & "exceeded 64K characters."
  sMsg = sMsg + sT & a$
EndIf
msgbox sMsg
Exit Sub
CountIt: 'Going to count this character/excluded char count?
Select Case instr(sNeverCountChars,sChr)
 case = 0
         If instr(sExcludeFromCharCount$, sChr) = 0 then
          nSelCharEx = nSelCharEx + 1 : nSelChars = nSelChars + 1
         Else nSelChars = nSelChars + 1
        Endif          
End Select
Return
End Sub

' This JV function constructs the string that shows
' the excluded characters for the character count.
Function Build_sExclude(sExcludeFromCharCount$)
sExclude$ = "* Excluding "
sOthers = sExcludeFromCharCount$
iPos = instr(sOthers," ")
If iPos > 0 then
 Mid(sOthers,iPos,1,"")
 select Case len(sOthers)
  case 0 : sExclude$ = sExclude$ & "spaces."
  case > 0: If instr(sOthers,chr(9)) = 0 then
             sExclude$ = sExclude$ & "spaces and "
            Else sExclude$ = sExclude$ & "spaces"
            EndIf   
 end select
EndIf
iPos = instr(sOthers,chr(9))
If iPos > 0 then
 Mid(sOthers,iPos,1,"")
 Select Case len(sOthers)
  Case 0 : If len(sExclude$) < 13 then
            sExclude$ = sExclude$ & "tabs."
           Else sExclude$ = sExclude$ & " and tabs."
           EndIf   
  Case > 0: If len(sExclude$) < 13 then
             sExclude$ = sExclude$ & "tabs and "
            Else sExclude$ = sExclude$ & ", tabs and "
            EndIf    
 End Select 
EndIf
Build_sExclude = sExclude$ & sOthers
End Function
Salvate con un bel nome. A questo punto, nella finestra di gestione macro, se scegliete la vostra compaiono due funzioni: selezionate la funzione SelectionCount e vi da una statistica di tutte le parole e lettere.

Ora, se volete escludere gli spazi, dovete selezionare il testo, quindi eventualmente selezionate tutto il documento (un bel CTRL+a dovrebbe bastare), e rieseguite la stessa funzione. Ora nella finestra, oltre al conteggio globale, dovrebbe comparire il conteggio della selezione, con il conteggio dei caratteri spazi esclusi.

Se volete escludere altri caratteri (tipo le virgole), cercate la riga

Codice: Seleziona tutto

sExcludeFromCharCount$ = e$ +  " "
e aggiungete i vari caratteri che volete escludere. Se poi avrò tempo la sistemerò meglio, per fare il lavoro anche senza bisogno di selezionare manualmente tutto il documento.

Daniele

Re: Contatore caratteri open office

Inviato: venerdì 14 dicembre 2007, 14:23
da Rosiel
jepessen ha scritto: Allora, cercando documentazione ho trovato un'altra macro che fa più o meno la stessa cosa...

L'ho modificata un pochetto, ma non completamente, anche perchè c'ho sonno...

Aprite l'editor (Strumenti->Macro->Organizza Macro->Macro): su Macro Personali cliccate su Nuovo, e copiate il seguente codice:

Codice: Seleziona tutto

' Based on the original* "dvwc" macro by Daniel Vogelheim   *see end of doc
' Displays a message box with number of words & characters
' in the document and the current selection.
' John Vigor edited this in 2003 to provide both a character count
' and a character count with exclusions. DV's had one of these.
' Does not normally count in frames, headers, footers or footnotes
' although these items may be individually selected. Selected text
' cannot exceed 64K of characters. (About 18 dense single spaced pages
' using New Times Roman size 12 and 1 inch margins all around. This
' size takes about 20 seconds on a 770MHz machine, so go get a cup
' of coffee or just be patient.)
' OO's word count, as of OO1.1 rc4, does not count in fields but does
' count in the other areas mentioned above. OO's character count
' counts a line break (Shift+Enter) as a character (Issue filed #16918).   

Sub SelectionCount
'DEFINE CHARACTER COUNT BELOW. The default exclusions from character count are
'spaces & tabs, i.e., one of each of these is contained in the definition of e$.
'You can add characters between the quotes and/or delete the space and/or tab. 
e$ = Chr(32) + Chr(9)  ' Chr(32) is a space, Chr(9) is a tab. Valid replacements would
'be e$ = Chr(32) or e$ = Chr(9) or e$ = "" with the latter being no exclusions. If you
'did not change e$ and if the line below read:
' sExcludeFromCharacterCount$ = e$ + "a" then spaces, tabs and the letter "a" would not
'be counted.   
sExcludeFromCharCount$ = e$ +  " "
'DEFINE WORD SEPERATORS BELOW. The default word separators are spaces and
'hyphens (true hyphenated words like "half-dollar" will be counted as two words
'instead of one). You can add separators between the quotes and/or delete the hyphen.
'Examples: "/" to count "and/or" as two words. "&" to count "Johnson & Johnson" as
'two words instead of three. A period is not normally needed but you can add one
'to count "www.website.com" as three words instead of one.   
sWordSeps = " -"
' This section is basically all DV's code with small modifications needed by JV
sWordSeps = sWordSeps + chr(9) + chr(10) + chr(13)'a tab, line break and paragraph break
sNeverCountChars = chr(10) & chr(13)'never include line or paragraph breaks in char count
oDocument = thisComponent
oSelection = oDocument.getCurrentSelection()
nSelCount = oSelection.getCount()
' access the program's document statistics
nAllChars = oDocument.CharacterCount
nAllWords = oDocument.WordCount
' initialize counts
nSelWords = 0 : nSelChars = 0 : nSelCharEx = 0
' iterate over multiple selections
Do
sText = oSelection.getByIndex(nSel).getString()
' count word in sText by scanning the selected text character for character
nCount = Len(sText)
bLastWasSeparator = true
bWord = false
'first letter starts a word
i = 1
Do ' DV used different logic for this section and there was nothing wrong
   ' with it. A programing exercise for JV and it better fit his needs.
sChr = Mid(sText,i,1)
If instr(sWordSeps, sChr) = 0 then 'if true then it's part of a word
  bWord = true
  GoSub CountIt 'count this character?
 Elseif bWord = True then 'is a seperator and at end of word.
  nSelWords = nSelWords + 1
  bWord = false
  GoSub CountIt
 Else
  GoSub CountIt 'is seperator but not the at end of a word.
EndIf
' End of JV's logic.
i = i + 1
Loop Until i > nCount 'get the next character in the string
nSel = nSel + 1
Loop while nSel < nSelCount
' Begin JV stuff
if bWord then nSelWords = nSelWords + 1
sExclude$ = " "
if Len(sExcludeFromCharCount$) = 0 then
 sExclude$ = "* No exclusions."
 else sExclude$ = Build_sExclude(sExcludeFromCharCount$)
endif
' JV altered DV's message box.
sT = chr(9): sP = chr(13) 'a Tab and Paragraph Break
a$ = "Program Document Count" + sP + sT & " All words:  " + nAllWords + sP
b$ = sT & " All chars:   " + nAllChars + sP + "Macro Selection Count" + sP
sMsg = a$ & b$
If nSelChars > 0 then
  a$ = sT & " Words:  " + nSelWords + sP + sT & " Chars:   " + nSelChars + sP + sT
  b$ = "   *  Chars:   " + nSelCharEx + sP & sExclude$
  sMsg = sMsg + a$ + b$
 Else a$ = "No text was selected or the selection" & sP & sT & "exceeded 64K characters."
  sMsg = sMsg + sT & a$
EndIf
msgbox sMsg
Exit Sub
CountIt: 'Going to count this character/excluded char count?
Select Case instr(sNeverCountChars,sChr)
 case = 0
         If instr(sExcludeFromCharCount$, sChr) = 0 then
          nSelCharEx = nSelCharEx + 1 : nSelChars = nSelChars + 1
         Else nSelChars = nSelChars + 1
        Endif          
End Select
Return
End Sub

' This JV function constructs the string that shows
' the excluded characters for the character count.
Function Build_sExclude(sExcludeFromCharCount$)
sExclude$ = "* Excluding "
sOthers = sExcludeFromCharCount$
iPos = instr(sOthers," ")
If iPos > 0 then
 Mid(sOthers,iPos,1,"")
 select Case len(sOthers)
  case 0 : sExclude$ = sExclude$ & "spaces."
  case > 0: If instr(sOthers,chr(9)) = 0 then
             sExclude$ = sExclude$ & "spaces and "
            Else sExclude$ = sExclude$ & "spaces"
            EndIf   
 end select
EndIf
iPos = instr(sOthers,chr(9))
If iPos > 0 then
 Mid(sOthers,iPos,1,"")
 Select Case len(sOthers)
  Case 0 : If len(sExclude$) < 13 then
            sExclude$ = sExclude$ & "tabs."
           Else sExclude$ = sExclude$ & " and tabs."
           EndIf   
  Case > 0: If len(sExclude$) < 13 then
             sExclude$ = sExclude$ & "tabs and "
            Else sExclude$ = sExclude$ & ", tabs and "
            EndIf    
 End Select 
EndIf
Build_sExclude = sExclude$ & sOthers
End Function
Salvate con un bel nome. A questo punto, nella finestra di gestione macro, se scegliete la vostra compaiono due funzioni: selezionate la funzione SelectionCount e vi da una statistica di tutte le parole e lettere.

Ora, se volete escludere gli spazi, dovete selezionare il testo, quindi eventualmente selezionate tutto il documento (un bel CTRL+a dovrebbe bastare), e rieseguite la stessa funzione. Ora nella finestra, oltre al conteggio globale, dovrebbe comparire il conteggio della selezione, con il conteggio dei caratteri spazi esclusi.

Se volete escludere altri caratteri (tipo le virgole), cercate la riga

Codice: Seleziona tutto

sExcludeFromCharCount$ = e$ +  " "
e aggiungete i vari caratteri che volete escludere. Se poi avrò tempo la sistemerò meglio, per fare il lavoro anche senza bisogno di selezionare manualmente tutto il documento.

Daniele
l'ho provata ora e funziona a meraviglia^^

grazie mille ;)