Last active
March 21, 2020 15:19
-
-
Save skytomo221/19204a669f846bbc57a0b70aef982998 to your computer and use it in GitHub Desktop.
リパライン語の品詞の種類をリストアップします。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; } | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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