How to use the pinyin.STYLE_FINALS function in pinyin

To help you get started, we’ve selected a few pinyin examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github coalchan / lyricAnalysis / stat.js View on Github external
}
    
    //找出每行从行尾开始第一个汉字
    if(flag == 1) {
      for(var i=line.length-1;i>=0;i--) {
        var lastChar = line.charAt(i);
        if(lastChar.isCN()) {
          words.push(lastChar);
          chars += lastChar;
          break;
        }
      }
    }
        
  }
  var finalRes = pinyin(chars, {style: pinyin.STYLE_FINALS});
  for(var i in finalRes) {
    finals.push(finalRes[i][0]);
  }
  // console.log(finals);
  return {words:words,finals:finals};
}
github coalchan / lyricAnalysis / analyze.js View on Github external
flag = 1;//从下面一行开始就是歌词正文了
      continue;
    }  
    
    //找出每行从行尾开始第一个汉字
    if(flag == 1) {
      for(var i=line.length-1;i>=0;i--) {
        var lastChar = line.charAt(i);
        if(lastChar.isCN()) {
          chars += lastChar;
          break;
        }
      }
    }
  }
  var footRes = pinyin(chars, {style: pinyin.STYLE_FINALS});
  for(var i in footRes) {
    var foot = footRes[i][0];
    foots.push(foot);
    if(!finals_word_map.hasOwnProperty(foot)) {
      finals_word_map[foot] = [];
    } 
    finals_word_map[foot].push(chars[i]);
  }

  var wc = {};
  wordCount(foots,wc);
  var sortedFoot = sort(wc);
  
  if(sortedFoot.length>=1 && sortedFoot.length<=2) {
    specialLyrics.push(filepath.split('/').pop());
  }

pinyin

汉语拼音转换工具。

MIT
Latest version published 5 months ago

Package Health Score

75 / 100
Full package analysis