Skip to content

Instantly share code, notes, and snippets.

@skytomo221
Last active March 21, 2020 15:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save skytomo221/19204a669f846bbc57a0b70aef982998 to your computer and use it in GitHub Desktop.
Save skytomo221/19204a669f846bbc57a0b70aef982998 to your computer and use it in GitHub Desktop.
リパライン語の品詞の種類をリストアップします。
namespace LineparinePartOfSpeechListUp
{
public class DicWord
{
public string Word { get; set; }
public string Trans { get; set; }
public string Exp { get; set; }
public string Level { get; set; }
public string Memory { get; set; }
public string Modify { get; set; }
public string Pron { get; set; }
public string Filelink { get; set; }
}
}
using CsvHelper.Configuration;
namespace LineparinePartOfSpeechListUp
{
public class DicWordMap : ClassMap<DicWord>
{
public DicWordMap()
{
Map(m => m.Word).Name("word");
Map(m => m.Trans).Name("trans");
Map(m => m.Exp).Name("exp");
Map(m => m.Level).Name("level");
Map(m => m.Memory).Name("memory");
Map(m => m.Modify).Name("modify");
Map(m => m.Pron).Name("pron");
Map(m => m.Filelink).Name("filelink");
}
}
}
using CsvHelper;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
namespace LineparineOneToManyJsonDictionary
{
class Program
{
static void Main(string[] args)
{
// PDIC を使って lineparine.dic を lineparine.csv に変換します
var path = @"lineparine.csv";
var dicwords = Load(path);
var listup = new List<string>();
foreach (var dicword in dicwords)
{
var r = new Regex(@"(【.*】)(.*)($|\n)");
MatchCollection mc = r.Matches(dicword.Trans);
foreach (Match m in mc)
{
if (!listup.Contains(m.Groups[1].Value))
{
listup.Add(m.Groups[1].Value);
}
}
}
foreach (var item in listup)
{
Console.WriteLine(item);
}
}
public static List<DicWord> Load(string path)
{
using (var reader = new StreamReader(path))
using (var csv = new CsvReader(reader, CultureInfo.InvariantCulture))
{
csv.Configuration.RegisterClassMap<DicWordMap>();
csv.Configuration.MissingFieldFound = null;
return csv.GetRecords<DicWord>().ToList();
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment