Word Cloud of Words Occurring just before instances of "its", in the corpus

The larger the size of the word, the more the number of times it has occurred in that specific position.

Word Cloud of Words Occurring just before instances of "it's", "it is" or "it has", in the corpus

The larger the size of the word, the more the number of times it has occurred in that specific position.

Word Cloud of Words Occurring just after instances of "its", in the corpus

The larger the size of the word, the more the number of times it has occurred in that specific position.

Word Cloud of Words Occurring just after instances of "it's", "it is" or "it has", in the corpus

The larger the size of the word, the more the number of times it has occurred in that specific position.

The Task

The task at hand was fairly direct - given a sentence with occurrences of it’s or its blanked out - what would you fill up the blanks with: its or it’s? A corpus with a large amount of text is also provided.

The main hints were provided within the body of the question itself! “It’s” is the compressed version of “it is” or “it has” and “Its” indicates possession. The most basic key for getting started with a simple solution to this problem, is to identify whether Its or It’s needs to be inserted into a blank based on the word(s) which occur immediately after, and immediately before the blank.

For example here are some places where “It’s” is appropriate:

It's been ages.  
It's raining heavily.  
Alex said that the flight was delayed, and it's going to be another hour before it takes off. 

Here are some places where “Its” is appropriate:

 The snake shed its skin.  
 The cat at its food.  
 The mouse fled from its hole.  

Note, that in the second set of sentences you cannot replace “Its” by either “It is” or “It has”.

How can the corpus be used?

Maintain two frequency distributions, of the words which occur immediately before, or immediately after
(1)It’s or (2)Its

A common observation is, that the corpus does not contain enough instances of “it’s”. This is perfectly fine - all you need to do is, also take into account all cases of “it is” and “it has” as “it’s” and make a note of the words immediately before and after them.

The difference in the histograms of preceding/trailing words for its and it’s will give us an idea of which word fits in which blank.

When the word after the blank is a verb, the correct way to fill up the blank is generally “it’s”. If the word following a blank ends with “-ing” it is (likely to be) a very and so, the blank should be filled up with “its”. Similarly, when the next word is an adjective, the blank generally needs to be filled up with “it’s”. In case of a noun, the answer is generally “Its”.

A POS Tagger would automatically detect the parts of speech and make the task rather direct. (Our current environment doesn’t support the external file dependencies of POS tagging, otherwise it would take away most of the fun involved in this challenge.)

The winning solution by Tusshar Singh uses this idea and constructs 4 histograms.

(1)Words occurring just before it's  
(2)Words occurring just before its  
(3)Words occurring just after it's  
(4)Words occurring just after its  

Apart from that he makes minor additions to the histograms, with common words like “been”, “only” etc.
While processing the test sentences, whenever the program encounters a set of question marks (???) it looks at the word immediately before and after it, and uses the histograms to identify whether it is closer to the words occurring before or after it’s or its - and then makes a decision accordingly.

The solution by mjuresic uses a similar idea - it is based on a “model” which is basically the words which often occur after an instance of “it’s”. It also uses a position-based heuristic. Note, that if blank occurs in the very first word of the sentence, it is more often, “it’s” rather than “its”. The solution by Dumbear is also based on similar techniques, and builds a bigram distribution of word pairs of the following type: (xyz its, its xyz, it’s xyz, xyz it’s) where xyz is any word before or after its or it’s.

A look at these word clouds below might help you understand in a more intuitive manner, the relevance of the information contained in these histograms/bigrams about words just before or after its or it’s.