Categorygithub.com/bububa/TimeNLP
modulepackage
1.0.4
Repository: https://github.com/bububa/timenlp.git
Documentation: pkg.go.dev

# README

TimeNLP 中文语句中的时间语义识别的golang版本

Go Reference Go goreleaser GitHub go.mod Go version of a Go module GoReportCard GitHub license GitHub release

使用

go get -u github.com/bububa/TimeNLP

功能说明

用于句子中时间词的抽取和转换

import (
    "log"

    "github.com/bububa/TimeNLP"
)

func main() {
    target := "Hi,all.下周一下午三点开会"
    preferFuture := true
    tn := timenlp.TimeNormalizer(preferFuture)
    ret, err := tn.Parse(target)
    if err != nil {
        log.Fatalln(err)
    }
    log.Printf("%+v\n", ret)
}

Reference

python3 版本 https://github.com/zhanzecheng/Time_NLP

Java 版本https://github.com/shinyke/Time-NLP

PHP 版本https://github.com/crazywhalecc/Time-NLP-PHP

Javascript 版本https://github.com/JohnnieFucker/ChiTimeNLP

# Functions

NewLunarSolarConverter 新建阴历阳历转换结构体.
NewSolarFromInt 从timestamp新建阳历Solar.
NewTimeNormalizer 新建TimeNormalizer isPreferFuture: 是否倾向使用未来时间.
NewTimePointFromTime 基于时间新建TimePoint.
NewTimeUnit 新建TimeUnit.

# Constants

AFTERNOON 下午、午后.
DAY_BREAK 黎明.
DELTA 相对时间.
EARLY_MORNING 早.
LATE_NIGHT 晚、晚间.
MID_NIGHT 深夜.
MORNING 上午.
NIGHT 晚上、傍晚.
NOON 中午、午间.
SPAN 时间段.
TIMESTAMP 时间点.

# Variables

DefaultTimePoint 默认时间表达式单元.

# Structs

Lunar 阴历节气结构体.
LunarSolarConverter 阴历阳历转换结构体.
Result 返回值.
ResultPoint 返回值包含时间点.
Solar 阳历节假日结构体.
SolarTermData 阳历时间点数据.
StringPreHandler 字符串预处理.
TimeNormalizer 时间表达式识别的主要工作类.
TimeUnit 时间语句分析.

# Type aliases

RangeTimeEnum 范围时间的默认时间点.
ResultType 返回值类型.
TimePoint 时间表达式单元规范化对应的内部类, 对应时间表达式规范化的每个字段, 六个字段分别是:年-月-日-时-分-秒, 每个字段初始化为-1.