Detect entity type