concept time in category nlp

This is an excerpt from Manning's book Getting Started with Natural Language Processing.
That is, based on what you’ve seen so far (and you make sure that you’ve seen enough and the data that you observed was not abnormal), you can expect 90% of the time to see “Natural Language Processing”. Note that together the estimations add up to 100%. Note also that we can directly compare these probabilities and say that “Processing” is more likely given that the beginning of the phrase is “Natural Language”.
So far, you have evaluated the performance of your algorithm using one specific metric – accuracy. It’s time now to further discuss its informativeness.
To this end, let’s introduce a new feature type that will estimate the number of times each stopword is used in a sentence, and a feature estimating the proportion of stopwords in a sentence. As opposed to calculating the number of times various words are used in texts, in the case of stopwords we are talking about a much more compact set of words (e.g., the spaCy’s list of stopwords contains 305 words only) that frequently occur across sentences. Code Listing 6.5 shows how to implement a method that counts the number of times each word occurs in text as well as the proportion of times words of a certain type occur in a sentence:
Listing 6.5 Code to calculate the number and proportion of times certain words occur def word_counts(text): counts = {} for word in text: counts[word.lower()] = counts.get(word.lower(), 0) + 1 #A return counts def proportion_words(text, wordlist): count = 0 for word in text: if word.lower() in wordlist: count += 1 return float(count)/float(len(text)) #BNow let’s calculate the number of times we see each of the stopwords in sentences written by each of the authors, as well as the proportion of stopwords in their sentences using these methods. We are going to use the stopwords list from spaCy, and for each of the 305 words we are going to add one feature to the feature set representing the number of times this particular stopword occurs in a particular sentence, and then add one extra feature representing the proportion of all stopwords as opposed to all words used in each sentence by each writer. This means that our feature set at this point will contain 308 features. For instance, one of the new features in this new feature set corresponds to the count of the stopword ‘a’: for the sentence “It is yet too early in life to despair of such a happiness” this count equals 1.0, while for the sentence “Not so happy, yet much happier” it is 0.0. At the same time, for the feature representing the count for the stopword ‘not’ the feature values are exactly the opposite: 0.0 and 1.0. 9 out of the total of 13 words in the sentence “It is yet too early in life to despair of such a happiness” are stopwords (all underlined), therefore the stopwords proportion for this sentence equals to 0.69. There are 7 words in the sentence “Not so happy, yet much happyer” in total, and 4 of them (underlined) are stopwords, making the proportion for this sentence equal to 0.57, as Figure 6.11 illustrates:
Figure 7.13 You’ve got the data and analyzed it. Now is the time to implement the baseline approach
![]()

This is an excerpt from Manning's book Natural Language Processing in Action: Understanding, analyzing, and generating text with Python.
But let’s think for a moment about what information has been lost in our effort to count all the words in the messages we receive. We assign the words to bins and store them away as bit vectors like a coin or token sorter directing different kinds of tokens to one side or the other in a cascade of decisions that piles them in bins at the bottom. Our sorting machine must take into account hundreds of thousands if not millions of possible token “denominations,” one for each possible word that a speaker or author might use. Each phrase or sentence or document we feed into our token sorting machine will come out the bottom, where we have a “vector” with a count of the tokens in each slot. Most of our counts are zero, even for large documents with verbose vocabulary. But we haven’t lost any words yet. What have we lost? Could you, as a human, understand a document that we presented you in this way, as a count of each possible word in your language, without any sequence or order associated with those words? I doubt it. But if it was a short sentence or tweet, you’d probably be able to rearrange them into their intended order and meaning most of the time.
Chapter 7 showed how convolutional neural nets can analyze a fragment or sentence all at once, keeping track of nearby words in the sequence by passing a filter of shared weights over those words (convolving over them). Words that occurred in clusters could be detected together. If those words jostled a little bit in position, the network could be resilient to it. Most importantly, concepts that appeared near to one another could have a big impact on the network. But what if you want to look at the bigger picture and consider those relationships over a longer period of time, a broader window than three or four tokens of a sentence. Can you give the net a concept of what went on earlier? A memory?
We are speaking about tokens as the input to each time step of the network, but recurrent neural nets work identically with any sort of time series data. Your tokens can be anything, discrete or continuous: readings from a weather station, musical notes, characters in a sentence, you name it.