gstring

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2022 License: Apache-2.0 Imports: 5 Imported by: 0

README

字符串操作工具

工具加载

import (
	"github.com/cnlesscode/gotool/string"
)

FirstUpper(s string) string

函数功能 : 首字母大写 返回格式 : string

fmt.Printf("%v\n", gstring.FirstUpper("golang"))

FirstLower(s string) string

函数功能 : 首字母小写 返回格式 : string

fmt.Printf("%v\n", gstring.FirstLower("Golang"))

FindImagesFromHtml(html string) []string

函数功能 : 从 html 中匹配出图片 返回格式 : []string

html := `<div>...</div><img src="http://localhost/a.png" />`
images := gstring.FindImagesFromHtml(html)
fmt.Printf("images: %v\n", images)

TrimHtmlTags(html string) string

函数功能 : 去除 html 标签 返回格式 : string

html := `<div>...</div><img src="http://localhost/a.png" />`
html = gstring.TrimHtmlTags(html)
fmt.Printf("%v\n", html)

NLP 分词

字典位置 : "/resources/dict/zh/s_1.txt"
字典路径 : https://github.com/cnlesscode/gotool/tree/main/resources/dict
字典部署 : 请下载字典文件并部署到您的项目根目录 /resources 文件夹下
排除分词 : 您可以通过修改 /resources/dict/nplNotWords.txt 来排除不需要的分词

使用演示 :

package main
import (
	"fmt"
	"github.com/cnlesscode/gotool/gstring"
)
func main() {
	NLPObject := gstring.NLP{Content: "测试分词文本 : 测试分词频率"}
	words := NLPObject.Cut()
	fmt.Printf("words: %v\n", words)
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FindImagesFromHtml

func FindImagesFromHtml(html string) []string

Find Images From Html

func FirstLower

func FirstLower(s string) string

First Lower

func FirstUpper

func FirstUpper(s string) string

First Upper

func TrimHtmlTags

func TrimHtmlTags(html string) string

Trim html tags

Types

type NLP added in v1.0.3

type NLP struct {
	Content string
}

func (*NLP) Cut added in v1.0.3

func (m *NLP) Cut() []NLPKwd

func (*NLP) SearchNLPKwd added in v1.0.3

func (m *NLP) SearchNLPKwd(slice []NLPKwd, str string) int

type NLPKwd added in v1.0.3

type NLPKwd struct {
	KeyWord string
	Count   int
}

Jump to

Keyboard shortcuts

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