Skip to content

Commit 82570ef

Browse files
committed
Release v0.1.2
1 parent 6faf659 commit 82570ef

File tree

3 files changed

+36
-1
lines changed

3 files changed

+36
-1
lines changed

CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
## [0.1.2] - 2022-03-01
11+
### Fixed
12+
- Fix a bug where a single line would cause a panic
13+
1014
## [0.1.1] - 2022-02-09
1115
### Fixed
1216
- Don't consider empty files to have any lines
@@ -39,7 +43,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3943
### Added
4044
- First functional version
4145

42-
[Unreleased]: https://github.com/SmartBear/lhdiff/compare/v0.1.1...HEAD
46+
[Unreleased]: https://github.com/SmartBear/lhdiff/compare/v0.1.2...HEAD
47+
[0.1.2]: https://github.com/SmartBear/lhdiff/compare/v0.1.1...v0.1.2
4348
[0.1.1]: https://github.com/SmartBear/lhdiff/compare/v0.1.0...v0.1.1
4449
[0.1.0]: https://github.com/SmartBear/lhdiff/compare/v0.0.5...v0.1.0
4550
[0.0.5]: https://github.com/SmartBear/lhdiff/compare/v0.0.4...v0.0.5

lhdiff_test.go

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,33 @@ four`
8888
// 3,3
8989
}
9090

91+
func ExampleLhdiff_oneDifferentLineWithNewLine() {
92+
left := "a\n"
93+
right := "b\n"
94+
mappings, err := Lhdiff(left, right, 4, true)
95+
printErr(err)
96+
err = PrintMappings(mappings)
97+
printErr(err)
98+
99+
// Output:
100+
// 1,_
101+
// 2,2
102+
// _,1
103+
}
104+
105+
func ExampleLhdiff_oneModifiedLineWithNewLine() {
106+
left := "a b c d\n"
107+
right := "a b c d e\n"
108+
mappings, err := Lhdiff(left, right, 4, true)
109+
printErr(err)
110+
err = PrintMappings(mappings)
111+
printErr(err)
112+
113+
// Output:
114+
// 1,1
115+
// 2,2
116+
}
117+
91118
func ExampleLhdiff_withEmptyLeft() {
92119
right := `one
93120
two

tfidf_cosine_similarity.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ func TfIdfCosineSimilarity(docA string, docB string) float64 {
2020
)
2121
allTokens = append(allTokens, tokensA...)
2222
allTokens = append(allTokens, tokensB...)
23+
if len(allTokens) == 0 {
24+
return 1
25+
}
2326
var documentFrequency = map[string]int{}
2427
for _, token := range allTokens {
2528
if documentFrequency[token] == 0 {

0 commit comments

Comments
 (0)