瀏覽代碼

升级 go 到 1.17 ,不然毫秒字符串转时间有bug

Signed-off-by: allan716 <[email protected]>
allan716 4 年之前
父節點
當前提交
51b4fd8eb1
共有 3 個文件被更改,包括 69 次插入20 次删除
  1. 44 2
      go.mod
  2. 1 18
      internal/pkg/sub_timeline_fixer/fixer.go
  3. 24 0
      internal/pkg/sub_timeline_fixer/tfidf.go

+ 44 - 2
go.mod

@@ -1,6 +1,6 @@
 module github.com/allanpk716/ChineseSubFinder
 
-go 1.16
+go 1.17
 
 require (
 	github.com/PuerkitoBio/goquery v1.7.1
@@ -11,7 +11,7 @@ require (
 	github.com/axgle/mahonia v0.0.0-20180208002826-3358181d7394
 	github.com/beevik/etree v1.1.0
 	github.com/bodgit/sevenzip v1.1.0
-	github.com/emirpasic/gods v1.12.0 // indirect
+	github.com/emirpasic/gods v1.12.0
 	github.com/fsnotify/fsnotify v1.4.9 // indirect
 	github.com/go-creed/sat v1.0.3
 	github.com/go-echarts/go-echarts/v2 v2.2.4
@@ -62,4 +62,46 @@ require (
 	modernc.org/sqlite v1.12.0
 )
 
+require (
+	github.com/EDDYCJY/fake-useragent v0.2.0 // indirect
+	github.com/andybalholm/brotli v1.0.0 // indirect
+	github.com/andybalholm/cascadia v1.2.0 // indirect
+	github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310 // indirect
+	github.com/bodgit/plumbing v1.1.0 // indirect
+	github.com/bodgit/windows v1.0.0 // indirect
+	github.com/connesc/cipherio v0.2.1 // indirect
+	github.com/dsnet/compress v0.0.1 // indirect
+	github.com/golang/snappy v0.0.3 // indirect
+	github.com/hashicorp/errwrap v1.0.0 // indirect
+	github.com/hashicorp/go-multierror v1.1.0 // indirect
+	github.com/hashicorp/hcl v1.0.0 // indirect
+	github.com/jinzhu/inflection v1.0.0 // indirect
+	github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect
+	github.com/klauspost/pgzip v1.2.4 // indirect
+	github.com/mattn/go-isatty v0.0.12 // indirect
+	github.com/nwaples/rardecode v1.1.0 // indirect
+	github.com/pierrec/lz4/v4 v4.0.3 // indirect
+	github.com/pkg/errors v0.9.1 // indirect
+	github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0 // indirect
+	github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72 // indirect
+	github.com/subosito/gotenv v1.2.0 // indirect
+	github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 // indirect
+	github.com/ysmood/goob v0.3.0 // indirect
+	github.com/ysmood/leakless v0.7.0 // indirect
+	go4.org v0.0.0-20200411211856-f5505b9728dd // indirect
+	golang.org/x/exp v0.0.0-20210220032938-85be41e4509f // indirect
+	golang.org/x/mod v0.3.1-0.20200828183125-ce943fd02449 // indirect
+	golang.org/x/tools v0.0.0-20201124115921-2c860bdd6e78 // indirect
+	golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
+	lukechampine.com/uint128 v1.1.1 // indirect
+	modernc.org/cc/v3 v3.33.7 // indirect
+	modernc.org/ccgo/v3 v3.9.6 // indirect
+	modernc.org/libc v1.9.11 // indirect
+	modernc.org/mathutil v1.4.1 // indirect
+	modernc.org/memory v1.0.4 // indirect
+	modernc.org/opt v0.1.1 // indirect
+	modernc.org/strutil v1.1.1 // indirect
+	modernc.org/token v1.0.0 // indirect
+)
+
 replace github.com/go-creed/sat => github.com/allanpk716/sat v0.0.0-20210622112535-2e00ce54a80b

+ 1 - 18
internal/pkg/sub_timeline_fixer/fixer.go

@@ -1,13 +1,11 @@
 package sub_timeline_fixer
 
 import (
-	"errors"
 	"fmt"
 	"github.com/allanpk716/ChineseSubFinder/internal/common"
 	"github.com/allanpk716/ChineseSubFinder/internal/types/subparser"
 	"github.com/go-echarts/go-echarts/v2/opts"
 	"github.com/grd/stat"
-	"github.com/james-bowman/nlp"
 	"github.com/james-bowman/nlp/measures/pairwise"
 	"github.com/mndrix/tukey"
 	"gonum.org/v1/gonum/mat"
@@ -45,22 +43,6 @@ func StopWordCounter(inString string, per int) []string {
 	return stopWords
 }
 
-// NewTFIDF 初始化 TF-IDF
-func NewTFIDF(testCorpus []string) (*nlp.Pipeline, mat.Matrix, error) {
-	newCountVectoriser := nlp.NewCountVectoriser(StopWords...)
-	transformer := nlp.NewTfidfTransformer()
-	// set k (the number of dimensions following truncation) to 4
-	reducer := nlp.NewTruncatedSVD(4)
-	lsiPipeline := nlp.NewPipeline(newCountVectoriser, transformer, reducer)
-	// Transform the corpus into an LSI fitting the model to the documents in the process
-	lsi, err := lsiPipeline.FitTransform(testCorpus...)
-	if err != nil {
-		return nil, lsi, errors.New(fmt.Sprintf("Failed to process testCorpus documents because %v", err))
-	}
-
-	return lsiPipeline, lsi, nil
-}
-
 // GetOffsetTime 暂时只支持英文的基准字幕,源字幕必须是双语中英字幕
 func GetOffsetTime(infoBase, infoSrc *subparser.FileInfo, staticLineFPath string) (float64, error) {
 
@@ -271,6 +253,7 @@ func FixSubTimeline(infoSrc *subparser.FileInfo, offsetTime float64, desSaveSubF
 		从解析的实例中,正常来说是可以匹配出所有的 Dialogue 对话的 Start 和 End time 的信息
 		然后找到对应的字幕的文件,进行文件内容的替换来做时间轴的校正
 	*/
+
 }
 
 const timeFormatAss = "15:04:05.00"

+ 24 - 0
internal/pkg/sub_timeline_fixer/tfidf.go

@@ -0,0 +1,24 @@
+package sub_timeline_fixer
+
+import (
+	"errors"
+	"fmt"
+	"github.com/james-bowman/nlp"
+	"gonum.org/v1/gonum/mat"
+)
+
+// NewTFIDF 初始化 TF-IDF
+func NewTFIDF(testCorpus []string) (*nlp.Pipeline, mat.Matrix, error) {
+	vectors := nlp.NewCountVectoriser(StopWords...)
+	transformer := nlp.NewTfidfTransformer()
+	// set k (the number of dimensions following truncation) to 4
+	reducer := nlp.NewTruncatedSVD(4)
+	lsiPipeline := nlp.NewPipeline(vectors, transformer, reducer)
+	// Transform the corpus into an LSI fitting the model to the documents in the process
+	lsi, err := lsiPipeline.FitTransform(testCorpus...)
+	if err != nil {
+		return nil, lsi, errors.New(fmt.Sprintf("Failed to process testCorpus documents because %v", err))
+	}
+
+	return lsiPipeline, lsi, nil
+}