1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
|
using System;
using System.IO;
using System.Collections.Generic;
using org.kbinani;
using org.kbinani.java.util;
using org.kbinani.vsq;
class AutoLyricInsertPostProcess{
public static void Main( string[] args ){
int count = 0;
List<string> list = new List<string>();
while( true ){
count++;
string dirname = count + "";
if( !Directory.Exists( dirname ) ){
break;
}
int i = 0;
while( true ){
i++;
string fname = Path.Combine( dirname, i + ".vsq" );
if( !File.Exists( fname ) ){
break;
}
Console.Write( "\r" + fname + " " );
VsqFile vsq = new VsqFile( fname, "Shift_JIS" );
VsqTrack vsq_track = vsq.Track.get( 1 );
string cache_phrase = "";
string cache_symbol = "";
bool all_symbol_default = true;
for( Iterator<VsqEvent> itr = vsq_track.getNoteEventIterator(); itr.hasNext(); ){
VsqEvent item = itr.next();
string phrase = item.ID.LyricHandle.L0.Phrase;
string symbol = item.ID.LyricHandle.L0.getPhoneticSymbol();
if( symbol != "u:" ){
all_symbol_default = false;
}
if( cache_phrase == "" ){
cache_phrase = phrase;
cache_symbol = symbol;
}else{
cache_phrase += "\t" + phrase;
cache_symbol += "\t" + symbol;
}
if( !phrase.EndsWith( "-" ) ){
if( cache_phrase != "a" && cache_symbol != "u:" && !all_symbol_default ){
list.Add( cache_phrase + "\t\t" + cache_symbol );
}
all_symbol_default = true;
cache_phrase = "";
cache_symbol = "";
}
}
}
}
list.Sort();
string last = "";
int c = list.Count;
using( StreamWriter sw = new StreamWriter( "extracted.txt" ) ){
for( int i = 0; i < c; i++ ){
string s = list[i];
if( s != last ){
sw.WriteLine( s );
last = s;
}
}
}
}
}
|