<commit_before>package main

import (
	"flag"
	"fmt"
	"io/ioutil"
	"os"
	"strings"

	"github.com/mattn/go-isatty"
	"github.com/mozillazg/go-pinyin"
)

func main() {
	heteronym := flag.Bool("e", false, "启用多音字模式")
	style := flag.String("s", "Tone", "指定拼音风格。可选值：Normal, Tone, Tone2, Tone3, Initials, FirstLetter, Finals, FinalsTone, FinalsTone2, FinalsTone3")
	flag.Parse()
	hans := flag.Args()
	stdin := []byte{}
	if !isatty.IsTerminal(os.Stdin.Fd()) {
		stdin, _ = ioutil.ReadAll(os.Stdin)
	}
	if len(stdin) > 0 {
		hans = append(hans, string(stdin))
	}

	if len(hans) == 0 {
		fmt.Println("请至少输入一个汉字: pinyin [-e] [-s STYLE] HANS [HANS ...]")
		os.Exit(1)
	}

	args := pinyin.NewArgs()
	if *heteronym {
		args.Heteronym = true
	}
	switch *style {
	case "Normal":
		args.Style = pinyin.Normal
	case "Tone2":
		args.Style = pinyin.Tone2
	case "Tone3":
		args.Style = pinyin.Tone3
	case "Initials":
		args.Style = pinyin.Initials
	case "FirstLetter":
		args.Style = pinyin.FirstLetter
	case "Finals":
		args.Style = pinyin.Finals
	case "FinalsTone":
		args.Style = pinyin.FinalsTone
	case "FinalsTone2":
		args.Style = pinyin.FinalsTone2
	case "FinalsTone3":
		args.Style = pinyin.FinalsTone3
	default:
		args.Style = pinyin.Tone
	}

	pys := pinyin.Pinyin(strings.Join(hans, ""), args)
	for _, s := range pys {
		fmt.Print(strings.Join(s, ","), " ")
	}
	if len(pys) > 0 {
		fmt.Println()
	}
}<commit_msg>Use example-based command-line option for pinyin style.<commit_after>package main

import (
	"flag"
	"fmt"
	"io/ioutil"
	"os"
	"strings"

	"github.com/mattn/go-isatty"
	"github.com/mozillazg/go-pinyin"
)

func main() {
	heteronym := flag.Bool("e", false, "启用多音字模式")
	style := flag.String("s", "zh4ao", "指定拼音风格。可选值：zhao, zh4ao, zha4o, zhao4, zh, z, ao, 4ao, a4o, ao4")
	flag.Parse()
	hans := flag.Args()
	stdin := []byte{}
	if !isatty.IsTerminal(os.Stdin.Fd()) {
		stdin, _ = ioutil.ReadAll(os.Stdin)
	}
	if len(stdin) > 0 {
		hans = append(hans, string(stdin))
	}

	if len(hans) == 0 {
		fmt.Println("请至少输入一个汉字: pinyin [-e] [-s STYLE] HANS [HANS ...]")
		os.Exit(1)
	}

	args := pinyin.NewArgs()
	if *heteronym {
		args.Heteronym = true
	}
	switch *style {
	case "zhao":
		args.Style = pinyin.Normal
	case "zha4o":
		args.Style = pinyin.Tone2
	case "zhao4":
		args.Style = pinyin.Tone3
	case "zh":
		args.Style = pinyin.Initials
	case "z":
		args.Style = pinyin.FirstLetter
	case "ao":
		args.Style = pinyin.Finals
	case "4ao":
		args.Style = pinyin.FinalsTone
	case "a4o":
		args.Style = pinyin.FinalsTone2
	case "ao4":
		args.Style = pinyin.FinalsTone3
	default:
		args.Style = pinyin.Tone
	}

	pys := pinyin.Pinyin(strings.Join(hans, ""), args)
	for _, s := range pys {
		fmt.Print(strings.Join(s, ","), " ")
	}
	if len(pys) > 0 {
		fmt.Println()
	}
}
{'fraction_non_alphanumeric': 0.1775599128540305, 'fraction_numerical': 0.013071895424836602, 'mean_word_length': 3.6537162162162162, 'pattern_counts': {'":': 18, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6763755', 'n_tokens_mistral': 1358, 'n_tokens_neox': 1301, 'n_words': 234}