Comments (4)
Hi @BronislavKlucka
Thanks for the hint. The first part of the international formatted number matched exactly with the prefix for all numbers I've tested so far. I couldn't find any infos about the semantics of the international formatting yet and just guessed that the first part after the country code was always the full prefix.
It might also simply be an issue with the formatting itself which is why the spacing ends up being wrong. I have to investigate a bit further to find out why the formatting differs from the other numbers in this case.
Do you have any suggestions on how to improve the prefix matching?
Kind regards
from libphonenumber-geo-carrier.
Hi @mmende
I can confirm, that this spacing / international formatting
+420 779 990 001
for Czech numbers is correct, but prefixes are bit of a mess here.
My suggestion would be something like:
1/ create all versions of phone number (without country prefix) from full number to single digit by cutting digits from the end of number
779990001
77999000
7799900
779990
77999
7799
779
77
7
2/ look for key in BSON from the longest (most specific) version of the number to the shortest until one exists
there are other solutions, but this one is probably the fastest...
also your solution does not cache the loaded BSON file, if I need to find carrier for 100 Czech numbers, it will open and read the same file from filesystem 100 times... (just cache it based on BSON filepath in some object)
and if you cache it, it does not have to by async(promise)... first read will be sync (little stagger) but other will be from memory, you can also allow for precache all BSONs or maybe just some based on prefix/country at the start of consumers script (export some precache functions)...
from libphonenumber-geo-carrier.
Thanks for the suggestion. Narrowing down the number until finding the longest match seems to work fine. I adjusted the algorithm to do just that by using nationalNumber (which returns the national (significant) number without country calling code and whitespaces) and the number you posted now also returns the correct original carrier as expected. Before I publish the fix I however want to do some more testing. I'll close this issue once the new version is out.
Adding caching and an option to preload certain parts of the metadata sounds good. I'll see if I can integrate it in one of the upcoming releases.
Thanks for your contribution
from libphonenumber-geo-carrier.
New version is published (v1.2.5)... Let me know if everything works fine now
If the problem should still exist feel free to reopen the issue
from libphonenumber-geo-carrier.
Related Issues (2)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from libphonenumber-geo-carrier.