Skip to content

Commit 7c6485d

Browse files
committed
Feat : codeconv added & chore code changed
Signed-off-by: ymw0407 <yunminwo1211@gmail.com>
1 parent a2db13c commit 7c6485d

File tree

4 files changed

+41
-15
lines changed

4 files changed

+41
-15
lines changed

.github/workflows/test.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: Test and coverage
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
build:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: actions/checkout@v4
10+
- uses: actions/setup-go@v4
11+
with:
12+
go-version: "stable"
13+
- name: Run coverage
14+
run: go test -race -coverprofile=coverage.txt -covermode=atomic ./...
15+
- name: Upload coverage to Codecov
16+
uses: codecov/codecov-action@v4
17+
env:
18+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
coverage.txt

internal/data/data.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,6 @@ limitations under the License.
1616

1717
package data
1818

19-
type SyllableType int
20-
21-
const (
22-
Undefined SyllableType = iota
23-
Consonant
24-
Vowel
25-
)
26-
2719
type SungType int
2820

2921
const (

pkg/jamo/jamo.go

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,15 @@ import (
2424
"github.com/ymw0407/jamo/pkg/options"
2525
)
2626

27+
// classify hangeul's syllable into consonant, vowel and undefined
28+
type SyllableType int
29+
30+
const (
31+
Undefined SyllableType = iota
32+
Consonant
33+
Vowel
34+
)
35+
2736
// Decompose Hangeul words into Syllables
2837
/*
2938
// example
@@ -65,12 +74,12 @@ func DecomposeHangeul(hangeuls string, opts ...options.Options) (decomposedHange
6574
return decomposedHangeul
6675
}
6776

68-
// Compose Syllables into hangeul word(not words) //
77+
// Compose Syllables into hangeul word(not words)
6978
/*
7079
// example
71-
fmt.Println(DecomposeHangeul("한글 is hangeul!")) // "ㅎㅏㄴㄱㅡㄹ is hangeul!"
80+
fmt.Println(ComposeHangeul("ㅎㅏㄴㄱㅡㄹ")) // "한글"
7281
*/
73-
//* TODO: Allow to apply serveral option (now only first option can apply)
82+
//* TODO: Flexible to better suit user intent
7483
func ComposeHangeul(syllables string) (composedHangeuls []string, err error) {
7584
sungType := data.ChosungType
7685
composedHangeuls = append(composedHangeuls, "")
@@ -201,14 +210,20 @@ func ComposeHangeul(syllables string) (composedHangeuls []string, err error) {
201210
return composedHangeuls, err
202211
}
203212

204-
func ClassifySyllables(syllable rune) data.SyllableType {
213+
// Classify Syllables into hangeul's consonant, vowel and undefined
214+
/*
215+
// example
216+
fmt.Println(ClassifySyllables("ㅎ")) // jamo.Consonant
217+
*/
218+
//* TODO: Flexible to better suit user intent
219+
func ClassifySyllables(syllable rune) SyllableType {
205220
switch {
206221
case slices.Contains(data.Consonants, syllable):
207-
return data.Consonant
222+
return Consonant
208223
case slices.Contains(data.JungSung, syllable):
209-
return data.Vowel
224+
return Vowel
210225
default:
211-
return data.Undefined
226+
return Undefined
212227
}
213228
}
214229

0 commit comments

Comments
 (0)