Text this: An arbitrary segmentation method for loss allocation in power grids with distributed generation