コード例 #1
0
        public void Write(IEnumerable <FuriganaSolutionSet> solutions)
        {
            int success = 0, total = 0;

            log4net.ILog logger = log4net.LogManager.GetLogger("Writer");
            DateTime     start  = DateTime.Now;

            string jsonFileName = $"{Path.GetFileNameWithoutExtension(OutputPath)}.json";

            using (var stream = new StreamWriter(OutputPath, false, Encoding.UTF8))
                using (var jsonStream = new StreamWriter(jsonFileName, false, Encoding.UTF8))
                    using (var jsonWriter = new JsonTextWriter(jsonStream))
                    {
                        jsonWriter.WriteStartArray();
                        var jsonSerializer = new JsonSerializer();
                        jsonSerializer.Converters.Add(new FuriganaSolutionJsonSerializer());
                        foreach (FuriganaSolutionSet solution in solutions)
                        {
                            FuriganaSolution singleSolution = solution.GetSingleSolution();

                            if (solution.Any())
                            {
                                if (singleSolution == null)
                                {
                                    logger.InfoFormat("➕   {0}", solution);
                                }
                                else
                                {
                                    logger.InfoFormat("◯   {0}", solution);
                                }
                            }
                            else
                            {
                                logger.InfoFormat("X    {0}|{1}|???", solution.Vocab.KanjiReading, solution.Vocab.KanaReading);
                            }

                            if (singleSolution != null && !AlreadyWritten.Contains(singleSolution.ToString()))
                            {
                                stream.WriteLine(singleSolution.ToString());
                                AlreadyWritten.Add(singleSolution.ToString());
                                jsonSerializer.Serialize(jsonWriter, singleSolution);
                            }

                            if (singleSolution != null)
                            {
                                success++;
                            }

                            total++;
                        }
                        jsonWriter.WriteEndArray();
                    }

            TimeSpan duration = DateTime.Now - start;

            logger.InfoFormat("Successfuly ended process with {0} out of {1} successfuly found furigana strings.", success, total);
            logger.InfoFormat("Process took {0} seconds.", duration.TotalSeconds);
        }
コード例 #2
0
        public void Write(IEnumerable <FuriganaSolutionSet> solutions)
        {
            int      success = 0, total = 0;
            var      logger = LogManager.GetCurrentClassLogger();
            DateTime start  = DateTime.Now;

            string jsonFileName = $"{Path.GetFileNameWithoutExtension(OutputPath)}.json";

            using (var stream = new StreamWriter(OutputPath, false, Encoding.UTF8))
                using (var jsonStream = new StreamWriter(jsonFileName, false, Encoding.UTF8))
                    using (var jsonWriter = new JsonTextWriter(jsonStream))
                    {
                        jsonWriter.WriteStartArray();
                        var jsonSerializer = new JsonSerializer();
                        jsonSerializer.Converters.Add(new FuriganaSolutionJsonSerializer());
                        foreach (FuriganaSolutionSet solution in solutions)
                        {
                            FuriganaSolution singleSolution = solution.GetSingleSolution();

                            if (solution.Any())
                            {
                                if (singleSolution == null)
                                {
                                    logger.Info($"➕   {solution}");
                                }
                                else
                                {
                                    logger.Info($"◯   {solution}");
                                }
                            }
                            else
                            {
                                logger.Info($"X    {solution.Vocab.KanjiReading}|{solution.Vocab.KanaReading}|???");
                            }

                            if (singleSolution != null && !AlreadyWritten.Contains(singleSolution.ToString()))
                            {
                                stream.WriteLine(singleSolution.ToString());
                                AlreadyWritten.Add(singleSolution.ToString());
                                jsonSerializer.Serialize(jsonWriter, singleSolution);
                            }

                            if (singleSolution != null)
                            {
                                success++;
                            }

                            total++;
                        }
                        jsonWriter.WriteEndArray();
                    }

            TimeSpan duration = DateTime.Now - start;

            logger.Info($"Successfuly ended process with {success} out of {total} successfuly found furigana strings.");
            logger.Info($"Process took {duration}.");
        }
コード例 #3
0
        public void Write(IEnumerable <FuriganaSolutionSet> solutions)
        {
            int success = 0, total = 0;

            log4net.ILog logger = log4net.LogManager.GetLogger("Writer");
            DateTime     start  = DateTime.Now;

            using (StreamWriter stream = new StreamWriter(OutputPath, false, Encoding.UTF8))
            {
                foreach (FuriganaSolutionSet solution in solutions)
                {
                    FuriganaSolution singleSolution = solution.GetSingleSolution();

                    if (solution.Any())
                    {
                        if (singleSolution == null)
                        {
                            logger.InfoFormat("➕   {0}", solution);
                        }
                        else
                        {
                            logger.InfoFormat("◯   {0}", solution);
                        }
                    }
                    else
                    {
                        logger.InfoFormat("X    {0}|{1}|???", solution.Vocab.KanjiReading, solution.Vocab.KanaReading);
                    }

                    if (singleSolution != null && !AlreadyWritten.Contains(singleSolution.ToString()))
                    {
                        stream.WriteLine(singleSolution.ToString());
                        AlreadyWritten.Add(singleSolution.ToString());
                    }

                    if (singleSolution != null)
                    {
                        success++;
                    }

                    total++;
                }
            }

            TimeSpan duration = DateTime.Now - start;

            logger.InfoFormat("Successfuly ended process with {0} out of {1} successfuly found furigana strings.", success, total);
            logger.InfoFormat("Process took {0} seconds.", duration.TotalSeconds);
        }