Bring the lentils to a boil in the water and simmer, skimming, about 25 minutes, or until nearly tender. Drain the lentils, reserving 1 1/2 cups of cooking liquid. Add more liquid if necessary to make 1 1/2 cups.
Cook the onions in the olive oil for about 5 minutes. Then remove 1 1/2 cups of the onions and cook the rest until they caramelize and begin to get crisp, about 5 to 7 minutes more. Drain the caramelized onions on paper towels.
Add to the saucepan the cooked lentils, the reserved liquid, the softened onions, and the basmati rice, salt and allspice. Cook over low heat, covered, until rice is tender, about 20 minutes. Top with caramelized onions.