【计算出拼音的声调字母是哪个】

import java.io.*;//导入操作要用到的类

  public class main {

  public static void main(String args[]) {

  File file = new File("c:/test.txt");// 源文件位置

  FileReader fr;

  try {

  fr = new FileReader(file);

  BufferedReader in = new BufferedReader(fr);// 包装萝卜家园xp系统下载文件输入流,可整行读取

  String line;

  try {

  while ((line = in.readLine()) != null) {

  String a = pinyin(line);

  int shengdiaoLetter = Integer.parseInt(a.substring(

  a.length() - 1, a.length()));

  a = a.substring(0, a.length() - 1) + " "

  + a.substring(shengdiaoLetter, shengdiaoLetter + 1);

  System.out.println(a);

  }

  } catch (IOException e) {

  // TODO Auto-generated catch block

  e.printStackTrace();

  }

  } catch (FileNotFoundException e) {

  // TODO Auto-generated catch block

  e.printStackTrace();

  }// 创建文件输入流

  }

  private static String pinyin(String input) {

  int position = 0;

  int onlyaeiou = 0;

  input = input.toLowerCase();

  // 单个韵母不必说。 (单个的韵母,当然就标它上面了)

  if (input.contains("a")) {

  onlyaeiou++;

  }

  if (input.contains("e")) {

  onlyaeiou++;

  }

  if (input.contains("i")) {

  onlyaeiou++;

  }

  if (input.contains("o")) {

  onlyaeiou++;

  }

  if (input.contains("u")) {

  onlyaeiou++;

  }

  if (input.contains("v")) {

  onlyaeiou++;

  }

  if (onlyaeiou == 1) {

  if (input.contains("a")) {

  position = input.indexOf("a");

  }

  if (input.contains("e")) {

  position = input.indexOf("e");

  }

  if (input.contains("i")) {

  position = input.indexOf("i");

  }

  if (input.contains("o")) {

  position = input.indexOf("o");

  }

posted on 2013-08-26 14:33  挖掘者者者  阅读(553)  评论(0编辑  收藏  举报