Skip to content

Commit

Permalink
Feat : codeconv added & chore code changed
Browse files Browse the repository at this point in the history
Signed-off-by: ymw0407 <yunminwo1211@gmail.com>
  • Loading branch information
ymw0407 committed Apr 7, 2024
1 parent a2db13c commit 7c6485d
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 15 deletions.
18 changes: 18 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Test and coverage

on: [push, pull_request]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
with:
go-version: "stable"
- name: Run coverage
run: go test -race -coverprofile=coverage.txt -covermode=atomic ./...
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
coverage.txt
8 changes: 0 additions & 8 deletions internal/data/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,6 @@ limitations under the License.

package data

type SyllableType int

const (
Undefined SyllableType = iota
Consonant
Vowel
)

type SungType int

const (
Expand Down
29 changes: 22 additions & 7 deletions pkg/jamo/jamo.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,15 @@ import (
"github.com/ymw0407/jamo/pkg/options"
)

// classify hangeul's syllable into consonant, vowel and undefined
type SyllableType int

const (
Undefined SyllableType = iota
Consonant
Vowel
)

// Decompose Hangeul words into Syllables
/*
// example
Expand Down Expand Up @@ -65,12 +74,12 @@ func DecomposeHangeul(hangeuls string, opts ...options.Options) (decomposedHange
return decomposedHangeul
}

// Compose Syllables into hangeul word(not words) //
// Compose Syllables into hangeul word(not words)
/*
// example
fmt.Println(DecomposeHangeul("한글 is hangeul!")) // "ㅎㅏㄴㄱㅡㄹ is hangeul!"
fmt.Println(ComposeHangeul("ㅎㅏㄴㄱㅡㄹ")) // "한글"
*/
//* TODO: Allow to apply serveral option (now only first option can apply)
//* TODO: Flexible to better suit user intent
func ComposeHangeul(syllables string) (composedHangeuls []string, err error) {
sungType := data.ChosungType
composedHangeuls = append(composedHangeuls, "")
Expand Down Expand Up @@ -201,14 +210,20 @@ func ComposeHangeul(syllables string) (composedHangeuls []string, err error) {
return composedHangeuls, err
}

func ClassifySyllables(syllable rune) data.SyllableType {
// Classify Syllables into hangeul's consonant, vowel and undefined
/*
// example
fmt.Println(ClassifySyllables("ㅎ")) // jamo.Consonant
*/
//* TODO: Flexible to better suit user intent
func ClassifySyllables(syllable rune) SyllableType {
switch {
case slices.Contains(data.Consonants, syllable):
return data.Consonant
return Consonant
case slices.Contains(data.JungSung, syllable):
return data.Vowel
return Vowel
default:
return data.Undefined
return Undefined
}
}

Expand Down

0 comments on commit 7c6485d

Please sign in to comment.