You shouldn’t need to determine the weight - this is a configuration item. You’ll find the values for v2 of twitter-text in this file
If you’re unclear on the point of “weighting”, this is to enable certain character sets (primarily CJK) to use a different value. Read this document for more information.
Calling the validation function should do what you need, but if you want to count in realtime, you’ll need to reproduce the algorithm from the document linked above.