Segmentation: Handle the case of repeated references

Example: This is a sentence.[1][2][3][4]
Added more tests to test different possible scenarios

Change-Id: I992d9e02157e0649ff8bcb02992206c8a793548d
Merge "Segmentation: Handle the case of repeated references"