public void PlainTextImportAutoSplit_Two_Lines()
        {
            var importer = new PlainTextImporter(splitAtBlankLines: true, removeLinesWithoutLetters: true, numberOfLines: 2, endChars: ".!?", singleLineMaxLength: 43, language: "en");
            var result   = importer.ImportAutoSplit(new List <string> {
                LoremIpsum
            });

            Assert.IsTrue(result.Any(p => p.Contains(Environment.NewLine)));
        }
        public void PlainTextImportAutoSplit5()
        {
            var importer = new PlainTextImporter(splitAtBlankLines: true, removeLinesWithoutLetters: true, numberOfLines: 2, endChars: ".!?", singleLineMaxLength: 43, language: "en");
            var lines    = new List <string>
            {
                "123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789",
            };
            var result = importer.ImportAutoSplit(lines);

            Assert.AreEqual(0, result.Count);
        }
        public void PlainTextImportAutoSplit2()
        {
            var importer = new PlainTextImporter(splitAtBlankLines: true, removeLinesWithoutLetters: false, numberOfLines: 2, endChars: "", singleLineMaxLength: 43, language: "en");
            var lines    = new List <string>
            {
                "How are you? I'm fine.",
                "",
                "Last line."
            };
            var result = importer.ImportAutoSplit(lines);

            Assert.AreEqual(2, result.Count);
            Assert.AreEqual("How are you? I'm fine.", result[0]);
            Assert.AreEqual("Last line.", result[1]);
        }
        public void PlainTextImportAutoSplit_Max_Single_Line_Length()
        {
            var importer = new PlainTextImporter(splitAtBlankLines: true, removeLinesWithoutLetters: true, numberOfLines: 2, endChars: ".!?", singleLineMaxLength: 43, language: "en");
            var result   = importer.ImportAutoSplit(new List <string> {
                LoremIpsum
            });

            foreach (var line in result)
            {
                foreach (var s in line.SplitToLines())
                {
                    Assert.IsFalse(s.Length > 43);
                }
            }
        }
Exemple #5
0
        private void ImportAutoSplit(string[] textLines)
        {
            var sub = new Subtitle();

            foreach (var line in textLines)
            {
                sub.Paragraphs.Add(new Paragraph(line, 0, 0));
            }
            var language = LanguageAutoDetect.AutoDetectGoogleLanguage(sub);

            var plainTextImporter = new PlainTextImporter(checkBoxAutoSplitAtBlankLines.Checked,
                                                          checkBoxAutoSplitRemoveLinesNoLetters.Checked,
                                                          (int)numericUpDownAutoSplitMaxLines.Value,
                                                          checkBoxAutoSplitAtEnd.Checked ? textBoxAsEnd.Text : string.Empty,
                                                          (int)numericUpDownSubtitleLineMaximumLength.Value,
                                                          language);

            ImportLineMode(plainTextImporter.ImportAutoSplit(textLines));
        }