Questions tagged [word-count]

The word count is the number of words in a document or passage of text.

Word counting may be needed when a text is required to stay within a certain number of words. This may particularly be the case in academia, legal proceedings, journalism and advertising. Word count is commonly used by translators to define the price for a translation job. Word counts may also be used to calculate measures of readability and to measure typing and reading speeds (usually in words per minute).

Most word processors can do automatic word counts; Unix-like systems include a program called wc specifically for word counting. Different word counting programs may give varying results, depending on:

  • the definition of a "word",
  • the text segmentation algorithms,
  • whether words outside the main text such as footnotes or hidden text are counted.

More information on Wikipedia.

685 questions
327
votes
8 answers

WebForms UnobtrusiveValidationMode requires a ScriptResourceMapping for 'jquery'. Please add a ScriptResourceMapping named jquery(case-sensitive)

I'm building a web application using Visual Studio 2012. I'm attempting to add word count into my textbox. However after adding the the javascript codes and the html codes. I receive the error as stated above. Here is my javascript codeds Code :…
Bryan
  • 8,488
  • 14
  • 52
  • 78
107
votes
19 answers

Count the number of all words in a string

Is there a function to count the number of words in a string? For example: str1 <- "How many words are in this sentence" to return a result of 7.
John
  • 41,131
  • 31
  • 82
  • 106
77
votes
9 answers

Correct word-count of a LaTeX document

I'm currently searching for an application or a script that does a correct word count for a LaTeX document. Up till now, I have only encountered scripts that only work on a single file but what I want is a script that can safely ignore LaTeX…
Andreas Grech
  • 105,982
  • 98
  • 297
  • 360
77
votes
11 answers

Word frequency count Java 8

How to count the frequency of words of List in Java 8? List wordsList = Lists.newArrayList("hello", "bye", "ciao", "bye", "ciao"); The result must be: {ciao=2, hello=1, bye=2}
Mouna
  • 3,221
  • 3
  • 27
  • 38
58
votes
9 answers

How to extract the nth word and count word occurrences in a MySQL string?

I would like to have a mysql query like this: select word, count(*) from table group by word; All the regex examples in mysql are used to query if the text matches the expression, but not to extract text out of an expression.…
Noam
  • 681
  • 1
  • 6
  • 5
48
votes
9 answers

Quantifying the amount of change in a git diff?

I use git for a slightly unusual purpose--it stores my text as I write fiction. (I know, I know...geeky.) I am trying to keep track of productivity, and want to measure the degree of difference between subsequent commits. The writer's proxy for…
Alex Feinman
  • 5,393
  • 1
  • 30
  • 48
40
votes
10 answers

How can I use the UNIX shell to count the number of times a letter appears in a text file?

I have a few text files and I'd like to count how many times a letter appears in each? Specifically, I'd like to use the UNIX shell to do this, in the form of: cat file | .... do stuff... Is there a way I can get the wc command to do this?
samoz
  • 56,849
  • 55
  • 141
  • 195
38
votes
11 answers

Spark get collection sorted by value

I was trying this tutorial http://spark.apache.org/docs/latest/quick-start.html I first created a collection from a file textFile = sc.textFile("README.md") Then I tried a command to cound the words: wordCounts = textFile.flatMap(lambda line:…
user3702916
  • 513
  • 1
  • 6
  • 12
37
votes
8 answers

Efficiently count word frequencies in python

I'd like to count frequencies of all words in a text file. >>> countInFile('test.txt') should return {'aaa':1, 'bbb': 2, 'ccc':1} if the target text file is like: # test.txt aaa bbb ccc bbb I've implemented it with pure python following some…
Light Yagmi
  • 5,085
  • 12
  • 43
  • 64
23
votes
5 answers

Using SQL to determine word count stats of a text field

I've recently been working on some database search functionality and wanted to get some information like the average words per document (e.g. text field in the database). The only thing I have found so far (without processing in language of choice…
Rob
  • 7,377
  • 7
  • 36
  • 38
18
votes
8 answers

Regular Expression for accurate word-count using JavaScript

I'm trying to put together a regular expression for a JavaScript command that accurately counts the number of words in a textarea. One solution I had found is as follows: document.querySelector("#wordcount").innerHTML =…
木川 炎星
  • 3,893
  • 13
  • 42
  • 51
17
votes
6 answers

Word count in Rails?

Say I have a blog model with Title and Body. How I do show the number of words in Body and characters in Title? I want the output to be something like this Title: Lorem Body: Lorem Lorem Lorem This post has word count of 3.
sent-hil
  • 18,635
  • 16
  • 56
  • 74
16
votes
4 answers

How to count words in MySQL / regular expression replacer?

How can I, in a MySQL query, have the same behaviour as the Regex.Replace function (for instance in .NET/C#)? I need that because, as many people, I would like to count the number of words in a field. However, I'm not satisfied with the following…
pierroz
  • 7,653
  • 9
  • 48
  • 60
15
votes
10 answers

Validate that input string does not exceed word limit

I want to count the words in a specific string so that I can validate it and prevent users to write more than, for example, 100 words. I wrote this function, but I don't think it's effective enough. I used the explode function with space as a…
Waseem Senjer
  • 1,026
  • 3
  • 14
  • 25
12
votes
10 answers

spark submit "Service 'Driver' could not bind on port" error

I used the following command to run the spark java example of wordcount:- time spark-submit --deploy-mode cluster --master spark://192.168.0.7:6066 --class org.apache.spark.examples.JavaWordCount /home/pi/Desktop/example/new/target/javaword.jar…
itsamineral
  • 1,369
  • 3
  • 14
  • 19
1
2 3
45 46