You cannot determine the pins in this way.
If you are looking into a "black box" that you can't open up and look at the PCB, then you could try the following:
First find the GND pin.
Then, with GND grounded, apply a 1k resistor to pull a pin up to 5V with respect to GND, while measuring the voltage on the other two pins. The ESD protection likely includes diodes which will steer to the 5V pin. If they do, then you will find that pulling 2 of the 3 pins up to 5V will pull up the third pin. Pulling one data pin up shouldn't pull the other data pin up, unless this device has some dedicated charging mode handshaking circuitry in it, but you seem to indicate that the port is for communication, so I am guessing this is not the case and if anything it has what is called CDP which will turn off when you apply the 1k pull up.
If this is successful, then you know which is your 5V wire and which are your data pins, and you can find your data pin polarity by either a process of elimination, or by applying GND/5V and looking at the data pin voltage. Assuming this is a high speed capable device, then you will likely see a pull-up to 3.3V appear on the D- pin right after you apply GND and 5V.