city

package
v0.0.0-...-b1b21d8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 17, 2023 License: LGPL-3.0 Imports: 10 Imported by: 0

README

功能概述

  • 基于前缀树,快如闪电的全国省市县提取库
  • 全国省市县下载
  • 支持自定义省市县映射关系
  • 只能打分,根据省市县出现的次数选举最大可能
  • 部分城市模糊匹配,尽最大可能匹配结果

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetCity

func GetCity(pre_ctx context.Context, file_name string) error

Types

type City

type City struct {
	Name string `json:"name"`

	Value    int64  `json:"value"`
	Children []Xian `json:"children"`
	// contains filtered or unexported fields
}

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(options ...ClientOption) *Client

创建根据映射关系创建默认的客户端

func (*Client) Search

func (obj *Client) Search(txt string) *Node

返回分数最大的结果

func (*Client) Searchs

func (obj *Client) Searchs(txt string) []*Node

返回所有可能

type ClientOption

type ClientOption struct {
	Datas       []Province
	SubProvince bool
	SubCity     bool
	SubXian     bool
}

type Node

type Node struct {
	Province string //省
	City     string //市
	Xian     string //县

	ProvinceValue int64
	CityValue     int64
	XianValue     int64
	// contains filtered or unexported fields
}

type Province

type Province struct {
	Name  string `json:"name"`
	Value int64  `json:"value"`

	Children []City `json:"children"`
	// contains filtered or unexported fields
}

type Xian

type Xian struct {
	Name string `json:"name"`

	Value int64 `json:"value"`
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL