Coder Social home page Coder Social logo

wenerme / telattr Goto Github PK

View Code? Open in Web Editor NEW
0.0 4.0 0.0 1.75 MB

Telephone Attribution - 电话归属地

Home Page: https://apis.wener.me/phone/attribution

License: MIT License

Go 100.00%
telephone-attribution golang protocol-buffers protocol-buffer

telattr's Introduction

Moved to https://github.com/wenerme/tools#teleattr

English 中文

telattr

Telephone Attribution

  • Data source xluohome/phonedata
  • Converted to protobuf
    • can use in web
    • no need to parse
  • Use bind data, so, no need to keep the dat file
    • Use optimized pb data.
  • Pre-generated protodata, csv
  • Optimized index, remove continue prefix with same record index.
    • Original phone.dat 3.2M
    • PB phone.pb 3.8M
    • PB optimized phone-opt.pb 1.9M
  • Useful command line tool

电话归属地

  • 数据源 xluohome/phonedata
  • 转换为 protobuf 格式
    • 可在网页中使用
    • 不需要手动解析
  • 使用绑定数据, 不需要保留原始文件
    • 使用优化有的 protobuf 数据
  • 预生成的 protobuf 数据和 csv
  • 索引优化, 移除有相同记录索引的连续前缀
    • 原始数据 phone.dat 3.2M
    • Protobuf phone.pb 3.8M
    • 优化后的 Protobuf phone-opt.pb 1.9M
  • 非常好用的命令行工具

CLI

go get -u github.com/wenerme/telattr/cmd/telattr
# Query
telattr a 1852159 15807212 15208231563
number:1852159
vendor:**联通
province:上海
city:上海
zone:021
zip:200000
min:1852100
max:1852199

number:15807212
vendor:**移动
province:湖北
city:荆州
zone:0716
zip:434000
min:1580721
max:1580721

number:15208231563
vendor:**移动
province:四川
city:成都
zone:028
zip:610000
min:1520810
max:1520849
# Conversion
# Convert raw data to pb with optimize
telattr conv -f data phone.dat -t pb test.pb -o
# Conver pb to csv
# Output csv idx-test.csv, rec-test.csv
telattr conv -f pb phone.pb -t pb test.csv -o

Demo

package main

import (
	"fmt"
	"github.com/wenerme/telattr"
	_ "github.com/wenerme/telattr/data_proto"
)

func main() {
	rec, err := telattr.Find("18957509123")
	if err != nil {
		panic(err)
	}
	fmt.Printf("%#v\n", rec)
}
&telattr.Record{Version:"1707", Province:"浙江", City:"绍兴", Zip:"312000", Zone:"0575", VendorName:"**电信", MinPrefix:1895750, MaxPrefix:1895759}

Performance

A little bit faster than xluohome/phonedata

goos: darwin
goarch: amd64
pkg: github.com/xluohome/phonedata
BenchmarkFindPhone-8    10000000               181 ns/op

goos: darwin
goarch: amd64
pkg: github.com/wenerme/telattr
BenchmarkFindPhone-8    10000000               136 ns/op

Dev

# Generate proto data
go-bindata -pkg data_proto -o data_proto/bindata.go phone.pb
# Generate pb
protoc --go_out=plugins=grpc,import_path=telattr:$HOME/go/src/ *.proto

telattr's People

Contributors

wenerme avatar

Watchers

 avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.