STEAM-GRUPP
Divinity: Original Sin 2 日本語化プロジ DOS2日本語化
STEAM-GRUPP
Divinity: Original Sin 2 日本語化プロジ DOS2日本語化
4
SPELAR
112
ONLINE
Grundades
12 september 2017
Språk
Japanska
Plats
Japan 
Visar 121–130 av 256 poster
109
作業履歴
作業所の改修作業7

結局原文にも改行が入っているものがあったので、ライブラリを使ったプログラムに書き換え

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;

using CsvHelper;
using CsvHelper.Configuration;

namespace ExtractAdditionalDataforDivinityOriginalSin2
{

public class GameText
{
public string UUID { get; set; } = "";
public string Text { get; set; } = "";
public string Context { get; set; } = "";
public string Filename { get; set; } = "";
public string SpeakerType { get; set; } = "";
public string Speaker { get; set; } = "";
public string Comment { get; set; } = "";
public string Sex { get; set; } = "";
public string Race { get; set; } = "";
}

public class WorkspaceMap : ClassMap<GameText>
{
public WorkspaceMap()
{
Map(x => x.UUID).Index(6);
Map(x => x.Text).Index(5);
}
}

public class FullTextMap : ClassMap<GameText>
{
public FullTextMap()
{
Map(x => x.UUID).Index(2);
Map(x => x.Text).Index(3);
Map(x => x.Comment).Index(9);
Map(x => x.Context).Index(10);
Map(x => x.Filename).Index(11);
Map(x => x.SpeakerType).Index(13);
Map(x => x.Speaker).Index(14);

}
}


class Program
{
static void Main(string[] args)
{

string workspaceFile = @"C:\Temp\dos2\full\workspace\Divinity_ Original Sin 2 日本語化作業所 第一翻訳室 - 翻訳データ(オリジン、Fort Joy).tsv";
string outputFile = @"C:\Temp\dos2\full\第一翻訳室.tsv";

//string workspaceFile = @"C:\Temp\dos2\full\workspace\Divinity_ Original Sin 2 日本語化作業所 第二翻訳室 - 翻訳データ(Reapers Coast).tsv";
//string outputFile = @"C:\Temp\dos2\full\第二翻訳室.tsv";

//string workspaceFile = @"C:\Temp\dos2\full\workspace\Divinity_ Original Sin 2 日本語化作業所 第三翻訳室 - 翻訳データ(その他).tsv";
//string outputFile = @"C:\Temp\dos2\full\第三翻訳室.tsv";

string fulltextFolder = @"C:\Temp\dos2\full\tsv";


Console.WriteLine("作業所データの読み込み");
List<GameText> ws_texts = new List<GameText>();

using (var ws_sr = new StreamReader(workspaceFile, Encoding.UTF8))
using (var ws_tsv = new CsvHelper.CsvReader(ws_sr))
{
// CsvHelperの設定。上から順に[ヘッダ有無の設定][区切り文字の設定][Mappingするクラスの設定]
ws_tsv.Configuration.HasHeaderRecord = false;
ws_tsv.Configuration.Delimiter = "\t";
ws_tsv.Configuration.RegisterClassMap<WorkspaceMap>();
ws_tsv.Configuration.BadDataFound = null;
ws_tsv.Configuration.MissingFieldFound = null;

// Mapping処理
ws_texts = ws_tsv.GetRecords<GameText>().ToList();

}


Console.WriteLine("公式テキストデータのファイル名取得");
List<string> fulltextFileNames = new List<string>();

// ファイル名の取得(パス含まず)
IEnumerable<string> ienu_files = Directory.EnumerateFiles(fulltextFolder, "*.tsv", SearchOption.AllDirectories);

foreach (string file in ienu_files)
{
fulltextFileNames.Add(file);
//Console.WriteLine(file);
}


Console.WriteLine("公式テキストデータの読み込み");
//List<List<GameText>> ft_texts_list = new List<List<GameText>>();
List<GameText> ft_texts = new List<GameText>();

foreach (string fulltextFile in fulltextFileNames)
{
Console.WriteLine(fulltextFile);

using (var ft_sr = new StreamReader(fulltextFile, Encoding.UTF8))
using (var ft_tsv = new CsvHelper.CsvReader(ft_sr))
{
// CsvHelperの設定。上から順に[ヘッダ有無の設定][区切り文字の設定][Mappingするクラスの設定]
ft_tsv.Configuration.HasHeaderRecord = false;
ft_tsv.Configuration.Delimiter = "\t";
ft_tsv.Configuration.RegisterClassMap<FullTextMap>();
ft_tsv.Configuration.BadDataFound = null;
ft_tsv.Configuration.MissingFieldFound = null;

// Mapping処理
//ft_texts_list.Add(ft_tsv.GetRecords<GameText>().ToList());
ft_texts.AddRange(ft_tsv.GetRecords<GameText>().ToList());

}
}


Console.WriteLine("データを抜き出す");
List<GameText> output_texts = new List<GameText>();

for (int i = 0; i < ws_texts.Count; i++)
{
GameText temp_text = new GameText();

temp_text.UUID = ws_texts.UUID;

for (int j = 0; j < ft_texts.Count; j++)
{

if (temp_text.UUID == ft_texts[j].UUID)
{
temp_text.Text = ft_texts[j].Text;
temp_text.Context = ft_texts[j].Context;
temp_text.Filename = ft_texts[j].Filename;
temp_text.SpeakerType = ft_texts[j].SpeakerType;
temp_text.Speaker = ft_texts[j].Speaker;
temp_text.Comment = ft_texts[j].Comment;


// 話者のデータから、性別と種族情報を抜き出す
if (temp_text.Speaker.Contains("GROUP_Players"))
{
temp_text.Race = "全";
}
else if (temp_text.Speaker.Contains("Narrator"))
{
temp_text.Race = "語";
}
else if (temp_text.Speaker.Contains("GROUP_Animals"))
{
temp_text.Race = "動";
}
else if (temp_text.Speaker.Contains("GROUP_Voidwoken"))
{
temp_text.Race = "虚";
}
else
{
if (temp_text.Speaker.Contains("FEMALE"))
{
temp_text.Sex = "女";
}
else if (temp_text.Speaker.Contains("MALE"))
{
temp_text.Sex = "男";
}

if (temp_text.Speaker.Contains("HUMAN"))
{
temp_text.Race = "人";
}
else if (temp_text.Speaker.Contains("ELF"))
{
temp_text.Race = "樹";
}
else if (temp_text.Speaker.Contains("DWARF"))
{
temp_text.Race = "髭";
}
else if (temp_text.Speaker.Contains("LIZARD"))
{
temp_text.Race = "爬";
}
else if (temp_text.Speaker.Contains("ANIMAL"))
{
temp_text.Race = "動";
}
else if (temp_text.Speaker.Contains("VOIDWOKEN"))
{
temp_text.Race = "虚";
}
}



break;
}

}

// データを変数に追加
output_texts.Add(temp_text);

}


Console.WriteLine("結果を出力");
using (var sw = new StreamWriter(outputFile))
using (var output_tsv = new CsvWriter(sw))
{
output_tsv.Configuration.Delimiter = "\t";
output_tsv.WriteRecords(output_texts);
}


}
}
}[/quote]
作業所の改修作業5

大体完成

かなり適当なプログラムなのは気にしてはいけない...

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;

namespace ExtractAdditionalDataforDivinityOriginalSin2
{
class Program
{
static void Main(string[] args)
{

string workspaceFile = @"C:\Temp\dos2\full\workspace\Divinity_ Original Sin 2 日本語化作業所 第一翻訳室 - 翻訳データ(オリジン、Fort Joy).tsv";
string outputFile = @"C:\Temp\dos2\full\第一翻訳室.tsv";
//string workspaceFile = @"C:\Temp\dos2\full\workspace\Divinity_ Original Sin 2 日本語化作業所 第二翻訳室 - 翻訳データ(Reapers Coast).tsv";
//string outputFile = @"C:\Temp\dos2\full\第二翻訳室.tsv";
//string workspaceFile = @"C:\Temp\dos2\full\workspace\Divinity_ Original Sin 2 日本語化作業所 第三翻訳室 - 翻訳データ(その他).tsv";
//string outputFile = @"C:\Temp\dos2\full\第三翻訳室.tsv";

string fulltextFolder = @"C:\Temp\dos2\full\tsv";

List<string> ws_uuid = new List<string>();
List<string> ws_text = new List<string>();
List<string> ws_context = new List<string>();
List<string> ws_filename = new List<string>();
List<string> ws_speakertype = new List<string>();
List<string> ws_speaker = new List<string>();
List<string> ws_comment = new List<string>();

List<string> ft_uuid = new List<string>();
List<string> ft_text = new List<string>();
List<string> ft_context = new List<string>();
List<string> ft_filename = new List<string>();
List<string> ft_speakertype = new List<string>();
List<string> ft_speaker = new List<string>();
List<string> ft_comment = new List<string>();

List<string> fulltextFileNames = new List<string>();


Console.WriteLine("作業所データの読み込み");
// ファイル名の取得(パス含まず)
IEnumerable<string> ienu_files = Directory.EnumerateFiles(fulltextFolder, "*.tsv", SearchOption.AllDirectories);

foreach (string file in ienu_files)
{
fulltextFileNames.Add(file);
//fulltextFileNames.Add(Path.GetFileName(file)); //ファイル名だけ抽出

//Console.WriteLine(file);
}

foreach (string fulltextFile in fulltextFileNames)
{
Console.WriteLine(fulltextFile);

// 公式のテキストデータファイル(tsv形式)をオープン
if (File.Exists(fulltextFile))
{
using (StreamReader reader_fulltext = new StreamReader(fulltextFile, Encoding.UTF8))
{

// 1行目(見出し行)はスキップ
reader_fulltext.ReadLine();

// ファイル末尾まで、1行ずつ読み込み
while (reader_fulltext.EndOfStream == false)
{
string line = reader_fulltext.ReadLine();

char[] delimiterChars = { '\t' };
string[] words = line.Split(delimiterChars);

string temp_uuid = "";
string temp_text = "";
string temp_context = "";
string temp_filename = "";
string temp_speakertype = "";
string temp_speaker = "";
string temp_comment = "";

int count = 0;

foreach (string word in words)
{
switch (count)
{
case 2:
temp_uuid = word;
break;
case 3:
temp_text = word;
break;
case 9:
temp_comment = word;
break;
case 10:
temp_context = word;
break;
case 11:
temp_filename = word;
break;
case 13:
temp_speakertype = word;
break;
case 14:
temp_speaker = word;
break;
}
count++;
}

//Console.WriteLine("id:{0}\ntext:{1}\ncomment:{2}\ncontext:{3}\nfilename:{4}\nspeakertype:{5}\nspeaker:{6}\n\n",
// temp_uuid, temp_text, temp_comment, temp_context, temp_filename, temp_speakertype, temp_speaker);

// データを変数に追加
ft_uuid.Add(temp_uuid);
ft_text.Add(temp_text);
ft_context.Add(temp_context);
ft_filename.Add(temp_filename);
ft_speakertype.Add(temp_speakertype);
ft_speaker.Add(temp_speaker);
ft_comment.Add(temp_comment);

}

}
}

}

//return;

// 作業所データファイル(tsv形式)をオープン
Console.WriteLine("公式テキストデータの読み込み");
if (File.Exists(workspaceFile))
{
using (StreamReader reader_workspace = new StreamReader(workspaceFile, Encoding.UTF8))
{
// 1行目(見出し行)はスキップ
reader_workspace.ReadLine();

// ファイル末尾まで、1行ずつ読み込み
while (reader_workspace.EndOfStream == false)
{
string line = reader_workspace.ReadLine();

char[] delimiterChars = { '\t' };
string[] words = line.Split(delimiterChars);

string temp_uuid = "";
string temp_text = "";

int count = 0;
foreach (string word in words)
{
switch (count)
{
case 5:
temp_text = word;
break;
case 6:
temp_uuid = word;
break;
}
count++;
}

//Console.WriteLine("{0},{1}", temp_text, temp_uuid);

// データを変数に追加
ws_uuid.Add(temp_uuid);
ws_text.Add(temp_text);


}

}
}



List<string> output_uuid = new List<string>();
List<string> output_text = new List<string>();
List<string> output_context = new List<string>();
List<string> output_filename = new List<string>();
List<string> output_speakertype = new List<string>();
List<string> output_speaker = new List<string>();
List<string> output_comment = new List<string>();

List<string> output_sex = new List<string>();
List<string> output_race = new List<string>();

// データを抜き出す
for (int i = 0; i < ws_uuid.Count; i++)
{
string temp_uuid = "";
string temp_text = "";
string temp_context = "";
string temp_filename = "";
string temp_speakertype = "";
string temp_speaker = "";
string temp_comment = "";

string temp_sex = "";
string temp_race = "";

string target_uuid = ws_uuid;

//Console.WriteLine(target_uuid);

for(int j = 0; j < ft_uuid.Count; j++)
{

if(target_uuid == ft_uuid[j])
{
temp_uuid = target_uuid;
temp_text = ft_text[j];
temp_context = ft_context[j];
temp_filename = ft_filename[j];
temp_speakertype = ft_speakertype[j];
temp_speaker = ft_speaker[j];
temp_comment = ft_comment[j];


// 話者のデータから、性別と種族情報を抜き出す
if (temp_speaker.Contains("GROUP_Players"))
{
temp_race = "全";
}else if (temp_speaker.Contains("Narrator"))
{
temp_race = "語";
}else if (temp_speaker.Contains("GROUP_Animals"))
{
temp_race = "動";
}else if (temp_speaker.Contains("GROUP_Voidwoken"))
{
temp_race = "虚";
}
else
{
if (temp_speaker.Contains("FEMALE"))
{
temp_sex = "女";
}else if (temp_speaker.Contains("MALE"))
{
temp_sex = "男";
}

if (temp_speaker.Contains("HUMAN"))
{
temp_race = "人";
}else if (temp_speaker.Contains("ELF"))
{
temp_race = "樹";
}else if (temp_speaker.Contains("DWARF"))
{
temp_race = "髭";
}else if (temp_speaker.Contains("LIZARD"))
{
temp_race = "爬";
}else if (temp_speaker.Contains("ANIMAL"))
{
temp_race = "動";
}
else if (temp_speaker.Contains("VOIDWOKEN"))
{
temp_race = "虚";
}
}



break;
}

}

// データを変数に追加
output_uuid.Add(temp_uuid);
output_text.Add(temp_text);
output_context.Add(temp_context);
output_filename.Add(temp_filename);
output_speakertype.Add(temp_speakertype);
output_speaker.Add(temp_speaker);
output_comment.Add(temp_comment);
output_sex.Add(temp_sex);
output_race.Add(temp_race);

}


// 結果を出力

// 出力用ファイルを開く
using (StreamWriter writer = new StreamWriter(outputFile, false, Encoding.UTF8))
{

// 見出し行を出力
writer.WriteLine("UUID\tテキスト\tコンテキスト\tファイル名\t話者分類\t話者\t性別\t種族\t開発者コメント");

// データを書き込み
for (int i = 0; i < output_uuid.Count; i++)
{
writer.WriteLine("{0}\t{1}\t{2}\t{3}\t{4}\t{5}\t{6}\t{7}\t{8}",
output_uuid, output_text, output_context, output_filename, output_speakertype,
output_speaker, output_sex, output_race, output_comment);
}

}

}
}
}[/quote]
作業所の改修作業4

同じように公式テキストデータの読み込み
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;

namespace ExtractAdditionalDataforDivinityOriginalSin2
{
class Program
{
static void Main(string[] args)
{

string workspaceFile = @"C:\Temp\dos2\full\workspace\Divinity_ Original Sin 2 日本語化作業所 第一翻訳室 - 翻訳データ(オリジン、Fort Joy).tsv";
string fulltextFile = @"C:\Temp\dos2\full\tsv\DIALOGUES_LADYVENGEANCE_HUB.tsv";

List<string> ws_uuid = new List<string>();
List<string> ws_text = new List<string>();

List<string> ws_context = new List<string>();
List<string> ws_filename = new List<string>();
List<string> ws_speakertype = new List<string>();
List<string> ws_speaker = new List<string>();
List<string> ws_comment = new List<string>();

List<string> ft_uuid = new List<string>();
List<string> ft_text = new List<string>();
List<string> ft_context = new List<string>();
List<string> ft_filename = new List<string>();
List<string> ft_speakertype = new List<string>();
List<string> ft_speaker = new List<string>();
List<string> ft_comment = new List<string>();

// 公式のテキストデータファイル(tsv形式)をオープン
if (File.Exists(fulltextFile))
{
using (StreamReader reader_fulltext = new StreamReader(fulltextFile, Encoding.UTF8))
{

// 1行目(見出し行)はスキップ
reader_fulltext.ReadLine();

// ファイル末尾まで、1行ずつ読み込み
while (reader_fulltext.EndOfStream == false)
{
string line = reader_fulltext.ReadLine();

char[] delimiterChars = { '\t' };
string[] words = line.Split(delimiterChars);

string temp_uuid = "";
string temp_text = "";
string temp_context = "";
string temp_filename = "";
string temp_speakertype = "";
string temp_speaker = "";
string temp_comment = "";

int count = 0;

foreach (string word in words)
{
switch (count)
{
case 2:
temp_uuid = word;
break;
case 3:
temp_text = word;
break;
case 9:
temp_comment = word;
break;
case 10:
temp_context = word;
break;
case 11:
temp_filename = word;
break;
case 13:
temp_speakertype = word;
break;
case 14:
temp_speaker = word;
break;
}
count++;
}

Console.WriteLine("id:{0}\ntext:{1}\ncomment:{2}\ncontext:{3}\nfilename:{4}\nspeakertype:{5}\nspeaker:{6}\n\n",
temp_uuid, temp_text, temp_comment, temp_context, temp_filename, temp_speakertype, temp_speaker);

// データを変数に追加
ft_uuid.Add(temp_uuid);
ft_text.Add(temp_text);
ft_context.Add(temp_context);
ft_filename.Add(temp_filename);
ft_speakertype.Add(temp_speakertype);
ft_speaker.Add(temp_speaker);
ft_comment.Add(temp_comment);


}


return;

}

}
}
}
}
Visar 121–130 av 256 poster