Nigeria's military says troops have rescued more than 25 women and children from Boko Haram.