Individual Word Count?

Individual Word Count?

Anonymous
Not applicable
1,720 Views
5 Replies
Message 1 of 6

Individual Word Count?

Anonymous
Not applicable

I have posted this same question in the regular AutoCAD forum as well, but, I  was curious to know if anyone knows of a way to automatically within AutoCAD count individual words in an entire drawing, this would include within block attributes, MText, regular text?

 

Reason I ask is a client has inquired how long and how expensive it would be to translate an entire drawing package (approximately 190 drawings) to another language.  In Microsoft Word documents and such that's automatically calculated.  But I don't know of a way to do this quickly and efficiently in AutoCAD.

 

Was hoping someone knew of a command or lisp routine that would do this.  Any help is greatly appreciated.

0 Likes
Accepted solutions (1)
1,721 Views
5 Replies
Replies (5)
Message 2 of 6

ВeekeeCZ
Consultant
Consultant

THIS tool might help you... 

0 Likes
Message 3 of 6

serag.hassouna
Advocate
Advocate

By "Individual Words" do you mean that every text object will not be considered a single word, and the sentence must be sliced and categorized to {(words), (prepositions and articles), (symbols that aren't words, prepositions or articles)} ?
If that so, then that would need a special routine/function that receives the text string and return the count for every category, or for at least the ((words)) category, defining the word as any sequence of at least 2 characters that doesn't evaluate to a preposition or an article like {an, the, or, in , ... etc} & doesn't contain any character of the 3rd category, or you can choose to merge the 1st two categories into one unified category to be counted.
Then, comes the known & simple part, which is the selection and iteration through text objects within the model space.
Then comes the tricky part when dealing with block references and their attached attributes, and if these block references do contain any text object within them.
.......
By "text object" I mean both TEXT and MTEXT types of texts.
___________
What I'm saying here is that this needs a specially written lisp command.

0 Likes
Message 4 of 6

Kent1Cooper
Consultant
Consultant

If  you don't care about the distinction between "meaningful" words and mere prepositions and articles and so on, here's a suggestion that could be simpler than the one [over on the AutoCAD-Forum thread] that involves subdividing a text object into all the separate words as separate text objects and then counting them.  [I don't imagine it would be able to do that with Block Attributes, anyway, not to mention that you probably don't want to break all the text objects apart into pieces.]  If all words are separated by single spaces, you can just check for how many spaces there are  in an object's string content, by first taking them all out, and then comparing the length of the string before and after.  One more than that difference is the number of words.

 

Command: (setq test "This is a test of the emergency broadcast system.")
  "This is a test of the emergency broadcast system."
Command: (setq full (strlen test))
  49 <-- number of characters in original string
Command: (while (wcmatch test "* *") (setq test (vl-string-subst "" " " test)))
  "Thisisatestoftheemergencybroadcastsystem."
Command: (setq nospaces (strlen test))
  41 <-- number of characters with all spaces removed
Command: (setq words (1+ (- full nospaces))) <-- difference + 1
  9 <-- number of words in that string

 

A single-word string with no spaces would return 1 [because that difference would be zero], etc.

 

That would have to be applied to all the extracted text-string content from all the appropriate objects [that's the hard part], and added up.  But working with just the string content, and not manipulating actual drawing entities, should be a lot faster.  And it's subject to being thrown off by the possibility of things like two spaces between sentences, or , a comma with a space before it as well as after, etc.  But for purposes of something like estimating the scope of translation work needed, a precise figure probably isn't needed, and it should be a good approximation.

Kent Cooper, AIA
0 Likes
Message 5 of 6

ВeekeeCZ
Consultant
Consultant
Accepted solution

THIS could help too. And it's for free.

0 Likes
Message 6 of 6

Anonymous
Not applicable

This is perfect.  It's almost exactly what I was looking for.

0 Likes