From b74a914278412632be52a0ee096f1e22864afec7 Mon Sep 17 00:00:00 2001 From: Rokas Puzonas Date: Wed, 17 Nov 2021 01:38:49 +0200 Subject: [PATCH 01/28] feat: initial commit --- .gitignore | 388 ++++++++++++++++++++++++++++++++ Lab4.Raides/Duomenys.txt | 6 + Lab4.Raides/InOut.cs | 40 ++++ Lab4.Raides/Lab4.Raides.csproj | 14 ++ Lab4.Raides/LettersFrequency.cs | 80 +++++++ Lab4.Raides/Program.cs | 21 ++ Lab4.sln | 25 ++ README.md | 6 + 8 files changed, 580 insertions(+) create mode 100644 .gitignore create mode 100644 Lab4.Raides/Duomenys.txt create mode 100644 Lab4.Raides/InOut.cs create mode 100644 Lab4.Raides/Lab4.Raides.csproj create mode 100644 Lab4.Raides/LettersFrequency.cs create mode 100644 Lab4.Raides/Program.cs create mode 100644 Lab4.sln create mode 100644 README.md diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..26ab8f4 --- /dev/null +++ b/.gitignore @@ -0,0 +1,388 @@ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +## +## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore + +# User-specific files +*.rsuser +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Mono auto generated files +mono_crash.* + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +[Ww][Ii][Nn]32/ +[Aa][Rr][Mm]/ +[Aa][Rr][Mm]64/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ +[Ll]ogs/ + +# Visual Studio 2015/2017 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# Visual Studio 2017 auto generated files +Generated\ Files/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUnit +*.VisualState.xml +TestResult.xml +nunit-*.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# Benchmark Results +BenchmarkDotNet.Artifacts/ + +# .NET Core +project.lock.json +project.fragment.lock.json +artifacts/ + +# ASP.NET Scaffolding +ScaffoldingReadMe.txt + +# StyleCop +StyleCopReport.xml + +# Files built by Visual Studio +*_i.c +*_p.c +*_h.h +*.ilk +*.meta +*.obj +*.iobj +*.pch +*.pdb +*.ipdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*_wpftmp.csproj +*.log +*.tlog +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# Visual Studio Trace Files +*.e2e + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# AxoCover is a Code Coverage Tool +.axoCover/* +!.axoCover/settings.json + +# Coverlet is a free, cross platform Code Coverage Tool +coverage*.json +coverage*.xml +coverage*.info + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# Note: Comment the next line if you want to checkin your web deploy settings, +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# NuGet Symbol Packages +*.snupkg +# The packages folder can be ignored because of Package Restore +**/[Pp]ackages/* +# except build/, which is used as an MSBuild target. +!**/[Pp]ackages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/[Pp]ackages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets + +# Nuget personal access tokens and Credentials +# nuget.config + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt +*.appx +*.appxbundle +*.appxupload + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!?*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +orleans.codegen.cs + +# Including strong name files can present a security risk +# (https://github.com/github/gitignore/pull/2483#issue-259490424) +#*.snk + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm +ServiceFabricBackup/ +*.rptproj.bak + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings +*.rptproj.rsuser +*- [Bb]ackup.rdl +*- [Bb]ackup ([0-9]).rdl +*- [Bb]ackup ([0-9][0-9]).rdl + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat +node_modules/ + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# CodeRush personal settings +.cr/personal + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Tabs Studio +*.tss + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs + +# OpenCover UI analysis results +OpenCover/ + +# Azure Stream Analytics local run output +ASALocalRun/ + +# MSBuild Binary and Structured Log +*.binlog + +# NVidia Nsight GPU debugger configuration file +*.nvuser + +# MFractors (Xamarin productivity tool) working folder +.mfractor/ + +# Local History for Visual Studio +.localhistory/ + +# BeatPulse healthcheck temp database +healthchecksdb + +# Backup folder for Package Reference Convert tool in Visual Studio 2017 +MigrationBackup/ + +# Ionide (cross platform F# VS Code tools) working folder +.ionide/ + +# Fody - auto-generated XML schema +FodyWeavers.xsd + +# VS Code files for those working on multiple tools +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json +*.code-workspace + +# Local History for Visual Studio Code +.history/ + +# Windows Installer files from build outputs +*.cab +*.msi +*.msix +*.msm +*.msp + +# JetBrains Rider +.idea/ +*.sln.iml diff --git a/Lab4.Raides/Duomenys.txt b/Lab4.Raides/Duomenys.txt new file mode 100644 index 0000000..b0b56c5 --- /dev/null +++ b/Lab4.Raides/Duomenys.txt @@ -0,0 +1,6 @@ +Draugas draugui sako: +- Kà pasakytum, jei sutiktum moterá, kuri visada bûtø ðvelni ir maloni, + viskà tau atleistø, tave dievintø. +- Tokiø nebûna. +- Bûna. Reiktø pasakyti: +- Labas, mama! \ No newline at end of file diff --git a/Lab4.Raides/InOut.cs b/Lab4.Raides/InOut.cs new file mode 100644 index 0000000..2300a28 --- /dev/null +++ b/Lab4.Raides/InOut.cs @@ -0,0 +1,40 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Text; + +namespace Lab4.Raides +{ + static class InOut + { + /** Prints repetition of letters using two columns into a given file. + @param fout – name of the file for the output + @param letters – object having letters and their repetitions */ + public static void PrintRepetitions(string fout, LettersFrequency letters) + { + using (var writer = File.CreateText(fout)) + { + foreach (var pair in letters.GetOrderedFrequencies()) + { + writer.WriteLine("{0, 3:c} {1, 4:d}", pair.Item1, pair.Item2); + } + } + } + + /** Inputs from the given data file and counts repetition of letters. + @param fin – name of data file + @param letters – object having letters and their repetitions*/ + public static void Repetitions(string fin, LettersFrequency letters) + { + using (StreamReader reader = new StreamReader(fin)) + { + string line; + while ((line = reader.ReadLine()) != null) + { + letters.line = line; + letters.CountLetters(); + } + } + } + } +} diff --git a/Lab4.Raides/Lab4.Raides.csproj b/Lab4.Raides/Lab4.Raides.csproj new file mode 100644 index 0000000..3a26489 --- /dev/null +++ b/Lab4.Raides/Lab4.Raides.csproj @@ -0,0 +1,14 @@ + + + + Exe + netcoreapp2.1 + + + + + PreserveNewest + + + + diff --git a/Lab4.Raides/LettersFrequency.cs b/Lab4.Raides/LettersFrequency.cs new file mode 100644 index 0000000..730c944 --- /dev/null +++ b/Lab4.Raides/LettersFrequency.cs @@ -0,0 +1,80 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Text; + +namespace Lab4.Raides +{ + /** To count letters frequency */ + class LettersFrequency + { + private const int CMax = 256; + private Dictionary Frequency; // Frequency of letters + public string line { get; set; } + + public LettersFrequency() + { + line = ""; + Frequency = new Dictionary(); + for (char c = 'a'; c <= 'z'; c++) + { + Frequency.Add(c, 0); + } + for (char c = 'A'; c <= 'Z'; c++) + { + Frequency.Add(c, 0); + } + } + + public int Get(char character) + { + return Frequency[character]; + } + + /** Counts repetition of letters. */ + public void CountLetters() + { + for (int i = 0; i < line.Length; i++) + { + if (Char.IsLetter(line[i])) + { + if (!Frequency.ContainsKey(line[i])) + { + Frequency.Add(line[i], 0); + } + Frequency[line[i]]++; + } + } + } + + public char GetMostFrequent() + { + char mostFrequent = (char)(0); + foreach (var pair in Frequency) + { + if (mostFrequent == 0 || pair.Value > Frequency[mostFrequent]) + { + mostFrequent = pair.Key; + } + } + return mostFrequent; + } + + public List> GetOrderedFrequencies() + { + List> frequencies = new List>(); + foreach (var pair in Frequency) + { + frequencies.Add(new Tuple(pair.Key, pair.Value)); + } + + frequencies.Sort(delegate (Tuple x, Tuple y) + { + return -x.Item2.CompareTo(y.Item2); + }); + + return frequencies; + } + } + +} diff --git a/Lab4.Raides/Program.cs b/Lab4.Raides/Program.cs new file mode 100644 index 0000000..be984b8 --- /dev/null +++ b/Lab4.Raides/Program.cs @@ -0,0 +1,21 @@ +using System; + +namespace Lab4.Raides +{ + class Program + { + static void Main(string[] args) + { + const string CFd = "Duomenys.txt"; + const string CFr = "Rezultatai.txt"; + LettersFrequency letters = new LettersFrequency(); + InOut.Repetitions(CFd, letters); + char mostFrequent = letters.GetMostFrequent(); + if (mostFrequent != 0) + { + Console.WriteLine("Dažniausiai pasikartojanti raidÄ—: {0}", mostFrequent); + } + InOut.PrintRepetitions(CFr, letters); + } + } +} diff --git a/Lab4.sln b/Lab4.sln new file mode 100644 index 0000000..e23f967 --- /dev/null +++ b/Lab4.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.28307.1525 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lab4.Raides", "Lab4.Raides\Lab4.Raides.csproj", "{1966BAA5-C5E8-4F18-A1CB-69A0B2FFD5CE}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {1966BAA5-C5E8-4F18-A1CB-69A0B2FFD5CE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1966BAA5-C5E8-4F18-A1CB-69A0B2FFD5CE}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1966BAA5-C5E8-4F18-A1CB-69A0B2FFD5CE}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1966BAA5-C5E8-4F18-A1CB-69A0B2FFD5CE}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {8BAFACEF-C8ED-4ADA-A33E-7A62B410E9B5} + EndGlobalSection +EndGlobal diff --git a/README.md b/README.md new file mode 100644 index 0000000..24dc07e --- /dev/null +++ b/README.md @@ -0,0 +1,6 @@ +# Lab4 example project + +This project is from the "Object oriented programming" course in KTU. + +It is not polished in any way, so don't expect anything from this. + From e262563742dc060179b24a50ba88198ebb662e4d Mon Sep 17 00:00:00 2001 From: Rokas Puzonas Date: Sun, 21 Nov 2021 01:11:43 +0200 Subject: [PATCH 02/28] style: rename Lab4.Raides -> Lab4.LetterFrequency --- {Lab4.Raides => Lab4.LetterFrequency}/Duomenys.txt | 0 {Lab4.Raides => Lab4.LetterFrequency}/InOut.cs | 2 +- .../Lab4.LetterFrequency.csproj | 0 {Lab4.Raides => Lab4.LetterFrequency}/LettersFrequency.cs | 2 +- {Lab4.Raides => Lab4.LetterFrequency}/Program.cs | 2 +- Lab4.sln | 2 +- 6 files changed, 4 insertions(+), 4 deletions(-) rename {Lab4.Raides => Lab4.LetterFrequency}/Duomenys.txt (100%) rename {Lab4.Raides => Lab4.LetterFrequency}/InOut.cs (97%) rename Lab4.Raides/Lab4.Raides.csproj => Lab4.LetterFrequency/Lab4.LetterFrequency.csproj (100%) rename {Lab4.Raides => Lab4.LetterFrequency}/LettersFrequency.cs (98%) rename {Lab4.Raides => Lab4.LetterFrequency}/Program.cs (94%) diff --git a/Lab4.Raides/Duomenys.txt b/Lab4.LetterFrequency/Duomenys.txt similarity index 100% rename from Lab4.Raides/Duomenys.txt rename to Lab4.LetterFrequency/Duomenys.txt diff --git a/Lab4.Raides/InOut.cs b/Lab4.LetterFrequency/InOut.cs similarity index 97% rename from Lab4.Raides/InOut.cs rename to Lab4.LetterFrequency/InOut.cs index 2300a28..6b667b2 100644 --- a/Lab4.Raides/InOut.cs +++ b/Lab4.LetterFrequency/InOut.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; using System.IO; using System.Text; -namespace Lab4.Raides +namespace Lab4.LetterFrequency { static class InOut { diff --git a/Lab4.Raides/Lab4.Raides.csproj b/Lab4.LetterFrequency/Lab4.LetterFrequency.csproj similarity index 100% rename from Lab4.Raides/Lab4.Raides.csproj rename to Lab4.LetterFrequency/Lab4.LetterFrequency.csproj diff --git a/Lab4.Raides/LettersFrequency.cs b/Lab4.LetterFrequency/LettersFrequency.cs similarity index 98% rename from Lab4.Raides/LettersFrequency.cs rename to Lab4.LetterFrequency/LettersFrequency.cs index 730c944..07e01aa 100644 --- a/Lab4.Raides/LettersFrequency.cs +++ b/Lab4.LetterFrequency/LettersFrequency.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; using System.Globalization; using System.Text; -namespace Lab4.Raides +namespace Lab4.LetterFrequency { /** To count letters frequency */ class LettersFrequency diff --git a/Lab4.Raides/Program.cs b/Lab4.LetterFrequency/Program.cs similarity index 94% rename from Lab4.Raides/Program.cs rename to Lab4.LetterFrequency/Program.cs index be984b8..e9cad4c 100644 --- a/Lab4.Raides/Program.cs +++ b/Lab4.LetterFrequency/Program.cs @@ -1,6 +1,6 @@ using System; -namespace Lab4.Raides +namespace Lab4.LetterFrequency { class Program { diff --git a/Lab4.sln b/Lab4.sln index e23f967..d1e91cf 100644 --- a/Lab4.sln +++ b/Lab4.sln @@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 VisualStudioVersion = 15.0.28307.1525 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lab4.Raides", "Lab4.Raides\Lab4.Raides.csproj", "{1966BAA5-C5E8-4F18-A1CB-69A0B2FFD5CE}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lab4.LetterFrequency", "Lab4.LetterFrequency\Lab4.LetterFrequency.csproj", "{F1797B5C-1541-4821-9485-7C3520C5DD8D}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution From cc64b2190f319476e519f304ac64cd1147c4a0a0 Mon Sep 17 00:00:00 2001 From: Rokas Puzonas Date: Sun, 21 Nov 2021 01:13:31 +0200 Subject: [PATCH 03/28] feat: add Lab4.RemoveLines --- Lab4.RemoveLines/Duomenys.txt | 10 +++ Lab4.RemoveLines/InOut.cs | 95 ++++++++++++++++++++++++ Lab4.RemoveLines/Lab4.RemoveLines.csproj | 14 ++++ Lab4.RemoveLines/Program.cs | 20 +++++ Lab4.sln | 14 ++++ 5 files changed, 153 insertions(+) create mode 100644 Lab4.RemoveLines/Duomenys.txt create mode 100644 Lab4.RemoveLines/InOut.cs create mode 100644 Lab4.RemoveLines/Lab4.RemoveLines.csproj create mode 100644 Lab4.RemoveLines/Program.cs diff --git a/Lab4.RemoveLines/Duomenys.txt b/Lab4.RemoveLines/Duomenys.txt new file mode 100644 index 0000000..9202125 --- /dev/null +++ b/Lab4.RemoveLines/Duomenys.txt @@ -0,0 +1,10 @@ +AÅ¡ atverÄiau knygÄ… kur pakliuvo. +Raidžių formos man buvo niekur nematytos. +Puslapiai apÅ¡iurÄ™, raidÄ—s neryÅ¡kios, tekstas Ä—jo dviem skiltimis. +Puslapiai apÅ¡iurÄ™, raidÄ—s neryÅ¡kios, tekstas Ä—jo dviem skiltimis. +Å riftas buvo tankus ir padalytas į pastraipas. +Ir mažas paveikslÄ—lis, toks, koks pasitaiko žodynuose: +plunksna nupieÅ¡tas inkaras, bet lyg negrabia vaiko ranka. +Puslapiai apÅ¡iurÄ™, raidÄ—s neryÅ¡kios, tekstas Ä—jo dviem skiltimis. + + Jorge Luis Borges. SmÄ—lio knyga. Vilnius, 2006. \ No newline at end of file diff --git a/Lab4.RemoveLines/InOut.cs b/Lab4.RemoveLines/InOut.cs new file mode 100644 index 0000000..094d744 --- /dev/null +++ b/Lab4.RemoveLines/InOut.cs @@ -0,0 +1,95 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Text; + +namespace Lab4.RemoveLines +{ + class InOut + { + public static int LongestLine(string fin) + { + int No = -1; + using (StreamReader reader = new StreamReader(fin, Encoding.UTF8)) + { + string line; + int length = 0; + int lineNo = 0; + while ((line = reader.ReadLine()) != null) + { + if (line.Length > length) + { + length = line.Length; + No = lineNo; + } + lineNo++; + } + } + return No; + } public static List LongestLines(string fin) + { + List lines = new List(); + int longestLength = 0; + + using (StreamReader reader = new StreamReader(fin, Encoding.UTF8)) + { + string line; + int lineNo = 0; + while ((line = reader.ReadLine()) != null) + { + if (line.Length > longestLength) + { + longestLength = line.Length; + lines.Clear(); + lines.Add(lineNo); + } + else if (line.Length == longestLength) + { + lines.Add(lineNo); + } + lineNo++; + } + } + + return lines; + } public static void RemoveLine(string fin, string fout, int No) + { + using (StreamReader reader = new StreamReader(fin, Encoding.UTF8)) + { + string line; + int lineNo = 0; + using (var writer = File.CreateText(fout)) + { + while ((line = reader.ReadLine()) != null) + { + if (No != lineNo) + { + writer.WriteLine(line); + } + lineNo++; + } + } + } + } + + public static void RemoveLines(string fin, string fout, List lines) + { + using (StreamReader reader = new StreamReader(fin, Encoding.UTF8)) + { + string line; + int lineNo = 0; + using (var writer = File.CreateText(fout)) + { + while ((line = reader.ReadLine()) != null) + { + if (!lines.Contains(lineNo)) + { + writer.WriteLine(line); + } + lineNo++; + } + } + } + } + } +} diff --git a/Lab4.RemoveLines/Lab4.RemoveLines.csproj b/Lab4.RemoveLines/Lab4.RemoveLines.csproj new file mode 100644 index 0000000..3a26489 --- /dev/null +++ b/Lab4.RemoveLines/Lab4.RemoveLines.csproj @@ -0,0 +1,14 @@ + + + + Exe + netcoreapp2.1 + + + + + PreserveNewest + + + + diff --git a/Lab4.RemoveLines/Program.cs b/Lab4.RemoveLines/Program.cs new file mode 100644 index 0000000..7eb6f5b --- /dev/null +++ b/Lab4.RemoveLines/Program.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; + +namespace Lab4.RemoveLines +{ + class Program + { + static void Main(string[] args) + { + const string CFd = "Duomenys.txt"; + const string CFr = "Rezultatai.txt"; + List lines = InOut.LongestLines(CFd); + InOut.RemoveLines(CFd, CFr, lines); + foreach (int line in lines) + { + Console.WriteLine("Ilgiausios eilutÄ—s nr. {0, 4:d}", line + 1); + } + } + } +} diff --git a/Lab4.sln b/Lab4.sln index d1e91cf..50b9c14 100644 --- a/Lab4.sln +++ b/Lab4.sln @@ -3,6 +3,8 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 VisualStudioVersion = 15.0.28307.1525 MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lab4.RemoveLines", "Lab4.RemoveLines\Lab4.RemoveLines.csproj", "{5309D21D-2A14-4332-90EC-504AD89CE397}" +EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lab4.LetterFrequency", "Lab4.LetterFrequency\Lab4.LetterFrequency.csproj", "{F1797B5C-1541-4821-9485-7C3520C5DD8D}" EndProject Global @@ -15,6 +17,18 @@ Global {1966BAA5-C5E8-4F18-A1CB-69A0B2FFD5CE}.Debug|Any CPU.Build.0 = Debug|Any CPU {1966BAA5-C5E8-4F18-A1CB-69A0B2FFD5CE}.Release|Any CPU.ActiveCfg = Release|Any CPU {1966BAA5-C5E8-4F18-A1CB-69A0B2FFD5CE}.Release|Any CPU.Build.0 = Release|Any CPU + {5309D21D-2A14-4332-90EC-504AD89CE397}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5309D21D-2A14-4332-90EC-504AD89CE397}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5309D21D-2A14-4332-90EC-504AD89CE397}.Release|Any CPU.ActiveCfg = Release|Any CPU + {5309D21D-2A14-4332-90EC-504AD89CE397}.Release|Any CPU.Build.0 = Release|Any CPU + {4D9B08C9-5735-4C95-8D2A-BDFC888B1E68}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4D9B08C9-5735-4C95-8D2A-BDFC888B1E68}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4D9B08C9-5735-4C95-8D2A-BDFC888B1E68}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4D9B08C9-5735-4C95-8D2A-BDFC888B1E68}.Release|Any CPU.Build.0 = Release|Any CPU + {F1797B5C-1541-4821-9485-7C3520C5DD8D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F1797B5C-1541-4821-9485-7C3520C5DD8D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F1797B5C-1541-4821-9485-7C3520C5DD8D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F1797B5C-1541-4821-9485-7C3520C5DD8D}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE From 30a3aede9031fd50b578accc04caa0a7a1bed5a7 Mon Sep 17 00:00:00 2001 From: Rokas Puzonas Date: Sun, 21 Nov 2021 01:14:29 +0200 Subject: [PATCH 04/28] feat: add Lab4.RemoveComments --- Lab4.RemoveComments/Duomenys.txt | 18 ++++++ Lab4.RemoveComments/InOut.cs | 60 +++++++++++++++++ .../Lab4.RemoveComments.csproj | 14 ++++ Lab4.RemoveComments/Program.cs | 15 +++++ Lab4.RemoveComments/TaskUtils.cs | 64 +++++++++++++++++++ Lab4.sln | 2 + 6 files changed, 173 insertions(+) create mode 100644 Lab4.RemoveComments/Duomenys.txt create mode 100644 Lab4.RemoveComments/InOut.cs create mode 100644 Lab4.RemoveComments/Lab4.RemoveComments.csproj create mode 100644 Lab4.RemoveComments/Program.cs create mode 100644 Lab4.RemoveComments/TaskUtils.cs diff --git a/Lab4.RemoveComments/Duomenys.txt b/Lab4.RemoveComments/Duomenys.txt new file mode 100644 index 0000000..c44a7de --- /dev/null +++ b/Lab4.RemoveComments/Duomenys.txt @@ -0,0 +1,18 @@ +void DuomenysInternet(Grybai & grybai) +{ + ifstream fd(u2); +// string pav, tip; +// GrybasInfo s1; + int ns = 0; + bool yra = true; + while(!fd.eof() && yra) { // kol yra duomenų ir jie telpa į masyvÄ… + fd >> pav >> tip; + s1.DÄ—ti (pav, tip); + if(!fd.eof() && (ns - 1 < Grybai::CMax ) ) + grybai[ns++] = s1; // įraÅ¡o naujÄ… elementÄ… + else + yra = false; + } + fd.close(); + grybai.DÄ—ti(ns); +} \ No newline at end of file diff --git a/Lab4.RemoveComments/InOut.cs b/Lab4.RemoveComments/InOut.cs new file mode 100644 index 0000000..b0e7236 --- /dev/null +++ b/Lab4.RemoveComments/InOut.cs @@ -0,0 +1,60 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Text; + +namespace Lab4.RemoveComments +{ + class InOut + { + public static void Process(string fin, string fout, string finfo) + { + string[] lines = File.ReadAllLines(fin, Encoding.UTF8); + string[] cleanedLines = TaskUtils.RemoveComments(lines); + + File.WriteAllLines(fout, cleanedLines); + + using (var writer = File.CreateText(finfo)) + { + // Check line by line which differ + int j = 0; // Used for cleaned lines + for (int i = 0; i < lines.Length && j < cleanedLines.Length; i++) + { + Console.WriteLine("{0} ============ {1}", lines[i], cleanedLines[j]); + if (lines[i] != cleanedLines[j]) + { + writer.WriteLine(lines[i]); + } + else + { + j++; + } + } + } + + /* + using (var writerF = File.CreateText(fout)) + { + using (var writerI = File.CreateText(finfo)) + { + foreach (string line in lines) + { + if (line.Length > 0) + { + string newLine = line; + if (TaskUtils.RemoveComments(line, out newLine)) + writerI.WriteLine(line); + if (newLine.Length > 0) + writerF.WriteLine(newLine); + } + else + { + writerF.WriteLine(line); + } + } + } + } + */ + } + } +} diff --git a/Lab4.RemoveComments/Lab4.RemoveComments.csproj b/Lab4.RemoveComments/Lab4.RemoveComments.csproj new file mode 100644 index 0000000..3a26489 --- /dev/null +++ b/Lab4.RemoveComments/Lab4.RemoveComments.csproj @@ -0,0 +1,14 @@ + + + + Exe + netcoreapp2.1 + + + + + PreserveNewest + + + + diff --git a/Lab4.RemoveComments/Program.cs b/Lab4.RemoveComments/Program.cs new file mode 100644 index 0000000..5e8d41e --- /dev/null +++ b/Lab4.RemoveComments/Program.cs @@ -0,0 +1,15 @@ +using System; + +namespace Lab4.RemoveComments +{ + class Program + { + static void Main(string[] args) + { + const string CFd = "Duomenys.txt"; + const string CFr = "Rezultatai.txt"; + const string CFa = "Analize.txt"; + InOut.Process(CFd, CFr, CFa); + } + } +} diff --git a/Lab4.RemoveComments/TaskUtils.cs b/Lab4.RemoveComments/TaskUtils.cs new file mode 100644 index 0000000..d87b69a --- /dev/null +++ b/Lab4.RemoveComments/TaskUtils.cs @@ -0,0 +1,64 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Text.RegularExpressions; + +namespace Lab4.RemoveComments +{ + class TaskUtils + { + /** Removes comments and returns an indication about performed activity. + @param line – line having possible comments + @param newLine – line without comments */ + public static string[] RemoveComments(string[] lines) + { + List cleanedLines = new List(); + + foreach (string line in lines) + { + Match case1 = Regex.Match(line, @"^(.*)//.*$"); + if (case1.Success) + { + if (case1.Groups[1].Value.Length > 0) + { + cleanedLines.Add(case1.Groups[1].Value); + } + } + else + { + cleanedLines.Add(line); + } + } + + /* + Match case1 = Regex.Match(line, @"^(.*)//.*$"); + if (case1.Success) + { + newLine = case1.Groups[1].Value; + return true; + } + */ + + return cleanedLines.ToArray(); + + /* + Match case2 = Regex.Match(line, @"^$"); + if (case2.Success) + { + newLine = case2.Captures[1].Value; + return true; + } + */ + + + /*newLine = line; + for (int i = 0; i < line.Length - 1; i++) + if (line[i] == '/' && line[i + 1] == '/') + { + newLine = line.Remove(i); + return true; + } + return false;*/ + } + } +} diff --git a/Lab4.sln b/Lab4.sln index 50b9c14..ed0ec99 100644 --- a/Lab4.sln +++ b/Lab4.sln @@ -5,6 +5,8 @@ VisualStudioVersion = 15.0.28307.1525 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lab4.RemoveLines", "Lab4.RemoveLines\Lab4.RemoveLines.csproj", "{5309D21D-2A14-4332-90EC-504AD89CE397}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Lab4.RemoveComments", "Lab4.RemoveComments\Lab4.RemoveComments.csproj", "{4D9B08C9-5735-4C95-8D2A-BDFC888B1E68}" +EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lab4.LetterFrequency", "Lab4.LetterFrequency\Lab4.LetterFrequency.csproj", "{F1797B5C-1541-4821-9485-7C3520C5DD8D}" EndProject Global From 9ecf4ff17c77b5d9bb6a43c13c3c7755d810f8d4 Mon Sep 17 00:00:00 2001 From: Rokas Puzonas Date: Sun, 21 Nov 2021 02:22:32 +0200 Subject: [PATCH 05/28] feat: finish Lab4.RemoveComments --- Lab4.RemoveComments/Duomenys.txt | 11 +++--- Lab4.RemoveComments/InOut.cs | 31 +++------------- Lab4.RemoveComments/TaskUtils.cs | 61 +++++++++++++++----------------- 3 files changed, 40 insertions(+), 63 deletions(-) diff --git a/Lab4.RemoveComments/Duomenys.txt b/Lab4.RemoveComments/Duomenys.txt index c44a7de..c0b1ff0 100644 --- a/Lab4.RemoveComments/Duomenys.txt +++ b/Lab4.RemoveComments/Duomenys.txt @@ -3,16 +3,17 @@ void DuomenysInternet(Grybai & grybai) ifstream fd(u2); // string pav, tip; // GrybasInfo s1; - int ns = 0; + int ns = 0; /* bool yra = true; + */ while(!fd.eof() && yra) { // kol yra duomenų ir jie telpa į masyvÄ… fd >> pav >> tip; s1.DÄ—ti (pav, tip); if(!fd.eof() && (ns - 1 < Grybai::CMax ) ) - grybai[ns++] = s1; // įraÅ¡o naujÄ… elementÄ… - else - yra = false; + grybai[ns++] = s1; // įraÅ¡o naujÄ… elementÄ… + else + yra = false; } fd.close(); grybai.DÄ—ti(ns); -} \ No newline at end of file +} diff --git a/Lab4.RemoveComments/InOut.cs b/Lab4.RemoveComments/InOut.cs index b0e7236..7469530 100644 --- a/Lab4.RemoveComments/InOut.cs +++ b/Lab4.RemoveComments/InOut.cs @@ -16,14 +16,17 @@ namespace Lab4.RemoveComments using (var writer = File.CreateText(finfo)) { - // Check line by line which differ int j = 0; // Used for cleaned lines + // Check line by line which differ for (int i = 0; i < lines.Length && j < cleanedLines.Length; i++) { - Console.WriteLine("{0} ============ {1}", lines[i], cleanedLines[j]); if (lines[i] != cleanedLines[j]) { writer.WriteLine(lines[i]); + if (lines[i].StartsWith(cleanedLines[j])) + { + j++; + } } else { @@ -31,30 +34,6 @@ namespace Lab4.RemoveComments } } } - - /* - using (var writerF = File.CreateText(fout)) - { - using (var writerI = File.CreateText(finfo)) - { - foreach (string line in lines) - { - if (line.Length > 0) - { - string newLine = line; - if (TaskUtils.RemoveComments(line, out newLine)) - writerI.WriteLine(line); - if (newLine.Length > 0) - writerF.WriteLine(newLine); - } - else - { - writerF.WriteLine(line); - } - } - } - } - */ } } } diff --git a/Lab4.RemoveComments/TaskUtils.cs b/Lab4.RemoveComments/TaskUtils.cs index d87b69a..dfa30f3 100644 --- a/Lab4.RemoveComments/TaskUtils.cs +++ b/Lab4.RemoveComments/TaskUtils.cs @@ -14,14 +14,39 @@ namespace Lab4.RemoveComments { List cleanedLines = new List(); + bool multiLineComment = false; + foreach (string line in lines) { - Match case1 = Regex.Match(line, @"^(.*)//.*$"); - if (case1.Success) + Match case1 = Regex.Match(line, @"^(.*)/\*.*$"); + Match case2 = Regex.Match(line, @"^.*\*/(.*)$"); + Match case3 = Regex.Match(line, @"^(.*)//.*$"); + + if (case1.Success) + { + if (!multiLineComment) { + multiLineComment = true; + if (case1.Groups[1].Value.Length > 0) + { + cleanedLines.Add(case1.Groups[1].Value); + } + } + } + else if (case2.Success) + { + if (multiLineComment) { + multiLineComment = false; + if (case2.Groups[1].Value.Length > 0) + { + cleanedLines.Add(case2.Groups[1].Value); + } + } + } + else if (case3.Success) { - if (case1.Groups[1].Value.Length > 0) + if (case3.Groups[1].Value.Length > 0) { - cleanedLines.Add(case1.Groups[1].Value); + cleanedLines.Add(case3.Groups[1].Value); } } else @@ -30,35 +55,7 @@ namespace Lab4.RemoveComments } } - /* - Match case1 = Regex.Match(line, @"^(.*)//.*$"); - if (case1.Success) - { - newLine = case1.Groups[1].Value; - return true; - } - */ - return cleanedLines.ToArray(); - - /* - Match case2 = Regex.Match(line, @"^$"); - if (case2.Success) - { - newLine = case2.Captures[1].Value; - return true; - } - */ - - - /*newLine = line; - for (int i = 0; i < line.Length - 1; i++) - if (line[i] == '/' && line[i + 1] == '/') - { - newLine = line.Remove(i); - return true; - } - return false;*/ } } } From 3ca49e564a342f88b74553b6241ff88bb3ccf006 Mon Sep 17 00:00:00 2001 From: Rokas Puzonas Date: Mon, 22 Nov 2021 01:26:55 +0200 Subject: [PATCH 06/28] feat: add "Lab4.FirstEqualLast" using strings --- Lab4.FirstEqualLast/Duomenys.txt | 9 +++++ .../Lab4.FirstEqualLast.csproj | 10 +++++ Lab4.FirstEqualLast/Program.cs | 15 ++++++++ Lab4.FirstEqualLast/TaskUtils.cs | 38 +++++++++++++++++++ Lab4.sln | 6 +++ 5 files changed, 78 insertions(+) create mode 100644 Lab4.FirstEqualLast/Duomenys.txt create mode 100644 Lab4.FirstEqualLast/Lab4.FirstEqualLast.csproj create mode 100644 Lab4.FirstEqualLast/Program.cs create mode 100644 Lab4.FirstEqualLast/TaskUtils.cs diff --git a/Lab4.FirstEqualLast/Duomenys.txt b/Lab4.FirstEqualLast/Duomenys.txt new file mode 100644 index 0000000..4a915c7 --- /dev/null +++ b/Lab4.FirstEqualLast/Duomenys.txt @@ -0,0 +1,9 @@ +V. M. Putinas +Margi sakalai +LydÄ—dami gÄ™stanÄiÄ… žarÄ… vÄ—lai +Pakilo į dangų;;, margi sakalai. +PaniekinÄ™ žemÄ—s vylingus sapnus, +PadangÄ—je iÅ¡tiesÄ—,,; savo sparnus. +Ir tarÄ— margieji: negrįšim į žemÄ™, +Kol josios kalnai ir pakalnÄ—s aptemÄ™. +... diff --git a/Lab4.FirstEqualLast/Lab4.FirstEqualLast.csproj b/Lab4.FirstEqualLast/Lab4.FirstEqualLast.csproj new file mode 100644 index 0000000..74abf5c --- /dev/null +++ b/Lab4.FirstEqualLast/Lab4.FirstEqualLast.csproj @@ -0,0 +1,10 @@ + + + + Exe + net6.0 + enable + enable + + + diff --git a/Lab4.FirstEqualLast/Program.cs b/Lab4.FirstEqualLast/Program.cs new file mode 100644 index 0000000..7ae957b --- /dev/null +++ b/Lab4.FirstEqualLast/Program.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; + +namespace Lab4.FirstEqualLast +{ + public class Program + { + public static void Main(string[] args) + { + const string CFd = "Duomenys.txt"; + char [] punctuation = {' ','.',',','!','?',':',';','(',')','\t'}; + Console.WriteLine("SutampanÄių žodžių {0, 3:d}", TaskUtils.Process(CFd, punctuation)); + } + } +} diff --git a/Lab4.FirstEqualLast/TaskUtils.cs b/Lab4.FirstEqualLast/TaskUtils.cs new file mode 100644 index 0000000..52c4993 --- /dev/null +++ b/Lab4.FirstEqualLast/TaskUtils.cs @@ -0,0 +1,38 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Lab4.FirstEqualLast +{ + public class TaskUtils + { + /** Reads file and finds the number of words having same the first and + the last letters. + @param fin – name of data file + @param punctuation – punctuation marks to separate words */ + public static int Process(string fin, char[] punctuation) + { + string[] lines = File.ReadAllLines(fin, Encoding.UTF8); + int equal = 0; + foreach (string line in lines) + if (line.Length > 0) + equal += FirstEqualLast(line, punctuation); + return equal; + } + + /** Splits line into words and counts the words having same the first and the + last letters. + @param line – string of data + @param punctuation – punctuation marks to separate words */ + private static int FirstEqualLast (string line, char[] punctuation) + { + string[] parts = line.Split(punctuation, + StringSplitOptions.RemoveEmptyEntries); + int equal = 0; + foreach (string word in parts) + if (word[0] == word[word.Length - 1]) + equal++; + return equal; + } + } +} diff --git a/Lab4.sln b/Lab4.sln index ed0ec99..c41487d 100644 --- a/Lab4.sln +++ b/Lab4.sln @@ -9,6 +9,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Lab4.RemoveComments", "Lab4 EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lab4.LetterFrequency", "Lab4.LetterFrequency\Lab4.LetterFrequency.csproj", "{F1797B5C-1541-4821-9485-7C3520C5DD8D}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lab4.FirstEqualLast", "Lab4.FirstEqualLast\Lab4.FirstEqualLast.csproj", "{83CB5DEC-25E5-42FF-8601-9BF8DA73E397}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -31,6 +33,10 @@ Global {F1797B5C-1541-4821-9485-7C3520C5DD8D}.Debug|Any CPU.Build.0 = Debug|Any CPU {F1797B5C-1541-4821-9485-7C3520C5DD8D}.Release|Any CPU.ActiveCfg = Release|Any CPU {F1797B5C-1541-4821-9485-7C3520C5DD8D}.Release|Any CPU.Build.0 = Release|Any CPU + {83CB5DEC-25E5-42FF-8601-9BF8DA73E397}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {83CB5DEC-25E5-42FF-8601-9BF8DA73E397}.Debug|Any CPU.Build.0 = Debug|Any CPU + {83CB5DEC-25E5-42FF-8601-9BF8DA73E397}.Release|Any CPU.ActiveCfg = Release|Any CPU + {83CB5DEC-25E5-42FF-8601-9BF8DA73E397}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE From b4b0afba328e51279df92bba5472bb42e64a620e Mon Sep 17 00:00:00 2001 From: Rokas Puzonas Date: Mon, 22 Nov 2021 01:31:51 +0200 Subject: [PATCH 07/28] feat: add "Lab4.FirstEqualLast" using regex --- Lab4.FirstEqualLast/Program.cs | 2 +- Lab4.FirstEqualLast/TaskUtils.cs | 34 ++++++++++++++++++++++++++++++-- 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/Lab4.FirstEqualLast/Program.cs b/Lab4.FirstEqualLast/Program.cs index 7ae957b..5f8de20 100644 --- a/Lab4.FirstEqualLast/Program.cs +++ b/Lab4.FirstEqualLast/Program.cs @@ -8,7 +8,7 @@ namespace Lab4.FirstEqualLast public static void Main(string[] args) { const string CFd = "Duomenys.txt"; - char [] punctuation = {' ','.',',','!','?',':',';','(',')','\t'}; + string punctuation = "[\\s,.;:!?()\\-]+"; Console.WriteLine("SutampanÄių žodžių {0, 3:d}", TaskUtils.Process(CFd, punctuation)); } } diff --git a/Lab4.FirstEqualLast/TaskUtils.cs b/Lab4.FirstEqualLast/TaskUtils.cs index 52c4993..af0fe1d 100644 --- a/Lab4.FirstEqualLast/TaskUtils.cs +++ b/Lab4.FirstEqualLast/TaskUtils.cs @@ -1,11 +1,41 @@ using System; using System.Collections.Generic; using System.Text; +using System.Text.RegularExpressions; namespace Lab4.FirstEqualLast { public class TaskUtils { + /** Reads file and finds the number of words having same the first and + the last letters. + @param fin – name of data file + @param punctuation – punctuation marks to separate words */ + public static int Process(string fin, string punctuation) + { + string[] lines = File.ReadAllLines(fin, Encoding.UTF8); + int equal = 0; + foreach (string line in lines) + if (line.Length > 0) + equal += FirstEqualLast(line, punctuation); + return equal; + } + + /** Splits line into words and counts the words having same the first + and the last letters. + @param line – string of data + @param punctuation – punctuation marks to separate words */ + private static int FirstEqualLast (string line, string punctuation) + { + string[] parts = Regex.Split(line, punctuation); + int equal = 0; + foreach (string word in parts) + if(word.Length > 0) // empty words at the end of line + if (word[0] == word[word.Length - 1]) + equal++; + return equal; + } + /** Reads file and finds the number of words having same the first and the last letters. @param fin – name of data file @@ -15,8 +45,8 @@ namespace Lab4.FirstEqualLast string[] lines = File.ReadAllLines(fin, Encoding.UTF8); int equal = 0; foreach (string line in lines) - if (line.Length > 0) - equal += FirstEqualLast(line, punctuation); + if (line.Length > 0) + equal += FirstEqualLast(line, punctuation); return equal; } From eaed3f058fd5b04774fbf81352bceeab2d55403e Mon Sep 17 00:00:00 2001 From: Rokas Puzonas Date: Mon, 22 Nov 2021 01:37:06 +0200 Subject: [PATCH 08/28] feat: handle edge case when last and first have different casing --- Lab4.FirstEqualLast/TaskUtils.cs | 5 ++--- Lab4.RemoveComments/Program.cs | 3 ++- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Lab4.FirstEqualLast/TaskUtils.cs b/Lab4.FirstEqualLast/TaskUtils.cs index af0fe1d..87945c6 100644 --- a/Lab4.FirstEqualLast/TaskUtils.cs +++ b/Lab4.FirstEqualLast/TaskUtils.cs @@ -27,7 +27,7 @@ namespace Lab4.FirstEqualLast @param punctuation – punctuation marks to separate words */ private static int FirstEqualLast (string line, string punctuation) { - string[] parts = Regex.Split(line, punctuation); + string[] parts = Regex.Split(line.ToLower(), punctuation); int equal = 0; foreach (string word in parts) if(word.Length > 0) // empty words at the end of line @@ -56,8 +56,7 @@ namespace Lab4.FirstEqualLast @param punctuation – punctuation marks to separate words */ private static int FirstEqualLast (string line, char[] punctuation) { - string[] parts = line.Split(punctuation, - StringSplitOptions.RemoveEmptyEntries); + string[] parts = line.ToLower().Split(punctuation, StringSplitOptions.RemoveEmptyEntries); int equal = 0; foreach (string word in parts) if (word[0] == word[word.Length - 1]) diff --git a/Lab4.RemoveComments/Program.cs b/Lab4.RemoveComments/Program.cs index 5e8d41e..f789a14 100644 --- a/Lab4.RemoveComments/Program.cs +++ b/Lab4.RemoveComments/Program.cs @@ -1,4 +1,5 @@ -using System; +using System; +using System.Text.RegularExpressions; namespace Lab4.RemoveComments { From c731d76fe03b0d5c61be23a5442fb7115de53aaa Mon Sep 17 00:00:00 2001 From: Rokas Puzonas Date: Mon, 22 Nov 2021 01:52:43 +0200 Subject: [PATCH 09/28] feat: add "Lab4.AddSurname" --- Lab4.AddSurname/Duomenys.txt | 9 +++++ Lab4.AddSurname/Lab4.AddSurname.csproj | 10 +++++ Lab4.AddSurname/Program.cs | 16 ++++++++ Lab4.AddSurname/TaskUtils.cs | 52 ++++++++++++++++++++++++++ Lab4.sln | 6 +++ 5 files changed, 93 insertions(+) create mode 100644 Lab4.AddSurname/Duomenys.txt create mode 100644 Lab4.AddSurname/Lab4.AddSurname.csproj create mode 100644 Lab4.AddSurname/Program.cs create mode 100644 Lab4.AddSurname/TaskUtils.cs diff --git a/Lab4.AddSurname/Duomenys.txt b/Lab4.AddSurname/Duomenys.txt new file mode 100644 index 0000000..796a223 --- /dev/null +++ b/Lab4.AddSurname/Duomenys.txt @@ -0,0 +1,9 @@ +Arvydas (g. 1964 m. gruodžio 19 d. Kaune) – Lietuvos krepÅ¡ininkas, +olimpinis ir pasaulio Äempionas Arvydas, nuo Arvydas +2011 m. spalio 24 d. Lietuvos krepÅ¡inio federacijos prezidentas. +Profesionalaus žaidÄ—jo karjerÄ… Arvydas pradÄ—jo 1981 m. +Kauno krepÅ¡inio klube "Žalgiris". +Arvydas tris sezonus iÅ¡ eilÄ—s (1985–1987 m.). Arvydas +padÄ—jo komandai iÅ¡kovoti SSRS krepÅ¡inio Äempionato aukso medalius. +1982 m. Arvydas SSRS rinktinÄ—s Arvydas sudÄ—tyje Arvydas +dalyvavo pasaulio krepÅ¡inio Äempionate ir laimÄ—jo auksÄ…. diff --git a/Lab4.AddSurname/Lab4.AddSurname.csproj b/Lab4.AddSurname/Lab4.AddSurname.csproj new file mode 100644 index 0000000..74abf5c --- /dev/null +++ b/Lab4.AddSurname/Lab4.AddSurname.csproj @@ -0,0 +1,10 @@ + + + + Exe + net6.0 + enable + enable + + + diff --git a/Lab4.AddSurname/Program.cs b/Lab4.AddSurname/Program.cs new file mode 100644 index 0000000..c554ed4 --- /dev/null +++ b/Lab4.AddSurname/Program.cs @@ -0,0 +1,16 @@ + +namespace Lab4.AddSurname +{ + public class Program + { + public static void Main(string[] args) + { + const string CFd = "Duomenys.txt"; + const string CFr = "Rezultatai.txt"; + string punctuation = " .,!?:;()\t'"; + string name = "Arvydas"; + string surname = "Sabonis"; + TaskUtils.Process(CFd, CFr, punctuation, name, surname); + } + } +} diff --git a/Lab4.AddSurname/TaskUtils.cs b/Lab4.AddSurname/TaskUtils.cs new file mode 100644 index 0000000..ef7d2a9 --- /dev/null +++ b/Lab4.AddSurname/TaskUtils.cs @@ -0,0 +1,52 @@ +using System.Text; +using System.IO; + +namespace Lab4.AddSurname +{ + public class TaskUtils + { + /** Finds name in the line and constructs new line appending given surname. + @param line – string of data + @param punctuation – punctuation marks to separate words + @param name – word to find + @param surname – given word to add + @param newLine – string of result */ + private static void AddSurname(string line, string punctuation, string name, string surname, StringBuilder newLine) + { + string addLine = " " + line + " "; + int init = 1; + int ind = addLine.IndexOf(name); + while (ind != -1) + { + if (punctuation.IndexOf(addLine[ind - 1]) != -1 && punctuation.IndexOf(addLine[ind + name.Length]) != -1) + { + newLine.Append(addLine.Substring(init, ind + name.Length - init)); + newLine.Append(surname); + init = ind + name.Length; + } + ind = addLine.IndexOf(name, ind + 1); + } + newLine.Append(line.Substring(init - 1)); + } + + /** Reads file and adds given surname to the given name. + @param fin – name of data file + @param fout – name of result file + @param punctuation – punctuation marks to separate words + @param name – word to find + @param surname – given word to add */ + public static void Process(string fin, string fout, string punctuation, string name, string surname) + { + string[] lines = File.ReadAllLines(fin, Encoding.UTF8); + using (var writer = File.CreateText(fout)) + { + foreach (string line in lines) + { + StringBuilder newLine = new StringBuilder(); + AddSurname(line, punctuation, name, surname, newLine); + writer.WriteLine(newLine); + } + } + } + } +} diff --git a/Lab4.sln b/Lab4.sln index c41487d..e4a4e10 100644 --- a/Lab4.sln +++ b/Lab4.sln @@ -11,6 +11,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lab4.LetterFrequency", "Lab EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lab4.FirstEqualLast", "Lab4.FirstEqualLast\Lab4.FirstEqualLast.csproj", "{83CB5DEC-25E5-42FF-8601-9BF8DA73E397}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lab4.AddSurname", "Lab4.AddSurname\Lab4.AddSurname.csproj", "{F7EFA186-AD5D-4E5D-B405-9ACBAEDB7BF3}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -37,6 +39,10 @@ Global {83CB5DEC-25E5-42FF-8601-9BF8DA73E397}.Debug|Any CPU.Build.0 = Debug|Any CPU {83CB5DEC-25E5-42FF-8601-9BF8DA73E397}.Release|Any CPU.ActiveCfg = Release|Any CPU {83CB5DEC-25E5-42FF-8601-9BF8DA73E397}.Release|Any CPU.Build.0 = Release|Any CPU + {F7EFA186-AD5D-4E5D-B405-9ACBAEDB7BF3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F7EFA186-AD5D-4E5D-B405-9ACBAEDB7BF3}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F7EFA186-AD5D-4E5D-B405-9ACBAEDB7BF3}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F7EFA186-AD5D-4E5D-B405-9ACBAEDB7BF3}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE From b8778be6ef1b3189fb496762c0a6002e6dd812cb Mon Sep 17 00:00:00 2001 From: Rokas Puzonas Date: Mon, 22 Nov 2021 01:56:25 +0200 Subject: [PATCH 10/28] feat: update "Lab4.AddSurname" --- Lab4.AddSurname/TaskUtils.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Lab4.AddSurname/TaskUtils.cs b/Lab4.AddSurname/TaskUtils.cs index ef7d2a9..6f80c69 100644 --- a/Lab4.AddSurname/TaskUtils.cs +++ b/Lab4.AddSurname/TaskUtils.cs @@ -11,8 +11,9 @@ namespace Lab4.AddSurname @param name – word to find @param surname – given word to add @param newLine – string of result */ - private static void AddSurname(string line, string punctuation, string name, string surname, StringBuilder newLine) + private static string AddSurname(string line, string punctuation, string name, string surname) { + StringBuilder newLine = new StringBuilder(); string addLine = " " + line + " "; int init = 1; int ind = addLine.IndexOf(name); @@ -21,12 +22,15 @@ namespace Lab4.AddSurname if (punctuation.IndexOf(addLine[ind - 1]) != -1 && punctuation.IndexOf(addLine[ind + name.Length]) != -1) { newLine.Append(addLine.Substring(init, ind + name.Length - init)); + newLine.Append(" "); newLine.Append(surname); init = ind + name.Length; } ind = addLine.IndexOf(name, ind + 1); } newLine.Append(line.Substring(init - 1)); + + return newLine.ToString(); } /** Reads file and adds given surname to the given name. @@ -42,8 +46,7 @@ namespace Lab4.AddSurname { foreach (string line in lines) { - StringBuilder newLine = new StringBuilder(); - AddSurname(line, punctuation, name, surname, newLine); + string newLine = AddSurname(line, punctuation, name, surname); writer.WriteLine(newLine); } } From 8a8b98823fb55fb5ca6695e1cabf885ba6e61bfe Mon Sep 17 00:00:00 2001 From: Rokas Puzonas Date: Mon, 22 Nov 2021 02:20:52 +0200 Subject: [PATCH 11/28] feat: complete individual exercise 4 --- Lab4.AddSurname/Program.cs | 3 ++- Lab4.AddSurname/TaskUtils.cs | 24 +++++++++++++++++++++++- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/Lab4.AddSurname/Program.cs b/Lab4.AddSurname/Program.cs index c554ed4..8ef3ff5 100644 --- a/Lab4.AddSurname/Program.cs +++ b/Lab4.AddSurname/Program.cs @@ -10,7 +10,8 @@ namespace Lab4.AddSurname string punctuation = " .,!?:;()\t'"; string name = "Arvydas"; string surname = "Sabonis"; - TaskUtils.Process(CFd, CFr, punctuation, name, surname); + TaskUtils.ProcessAddSurname(CFd, CFr, punctuation, name, surname); + /* TaskUtils.ProcessRemoveWord(CFd, CFr, punctuation, name); */ } } } diff --git a/Lab4.AddSurname/TaskUtils.cs b/Lab4.AddSurname/TaskUtils.cs index 6f80c69..862a624 100644 --- a/Lab4.AddSurname/TaskUtils.cs +++ b/Lab4.AddSurname/TaskUtils.cs @@ -1,4 +1,5 @@ using System.Text; +using System.Text.RegularExpressions; using System.IO; namespace Lab4.AddSurname @@ -39,7 +40,7 @@ namespace Lab4.AddSurname @param punctuation – punctuation marks to separate words @param name – word to find @param surname – given word to add */ - public static void Process(string fin, string fout, string punctuation, string name, string surname) + public static void ProcessAddSurname(string fin, string fout, string punctuation, string name, string surname) { string[] lines = File.ReadAllLines(fin, Encoding.UTF8); using (var writer = File.CreateText(fout)) @@ -51,5 +52,26 @@ namespace Lab4.AddSurname } } } + + public static string RemoveWord(string line, string punctuation, string word) + { + string pattern = String.Format(@"([{0}]*){1}[{0}]*", Regex.Unescape(punctuation), Regex.Unescape(word)); + return Regex.Replace(line, pattern, "$1"); + } + + public static void ProcessRemoveWord(string fin, string fout, string punctuation, string word) + { + using (StreamWriter writer = File.CreateText(fout)) + { + using (StreamReader reader = new StreamReader(fin)) + { + string? line = String.Empty; + while ((line = reader.ReadLine()) != null) + { + writer.WriteLine(RemoveWord(line, punctuation, word)); + } + } + } + } } } From 64a56eca2af0ca37b98fdadf15e5ecb75d5484f0 Mon Sep 17 00:00:00 2001 From: Rokas Puzonas Date: Mon, 22 Nov 2021 02:36:34 +0200 Subject: [PATCH 12/28] feat: add "Lab4.RemoveVowels" --- Lab4.RemoveVowels/Duomenys.txt | 15 +++++ Lab4.RemoveVowels/Lab4.RemoveVowels.csproj | 10 +++ Lab4.RemoveVowels/Program.cs | 18 ++++++ Lab4.RemoveVowels/TaskUtils.cs | 74 ++++++++++++++++++++++ Lab4.sln | 6 ++ 5 files changed, 123 insertions(+) create mode 100644 Lab4.RemoveVowels/Duomenys.txt create mode 100644 Lab4.RemoveVowels/Lab4.RemoveVowels.csproj create mode 100644 Lab4.RemoveVowels/Program.cs create mode 100644 Lab4.RemoveVowels/TaskUtils.cs diff --git a/Lab4.RemoveVowels/Duomenys.txt b/Lab4.RemoveVowels/Duomenys.txt new file mode 100644 index 0000000..4968592 --- /dev/null +++ b/Lab4.RemoveVowels/Duomenys.txt @@ -0,0 +1,15 @@ +KÅ«Äių rytÄ… + + Anksti KÅ«Äių rytÄ… Å¡eimininkÄ— budina savo vyrÄ…: + - Eik greiÄiau, saulei netekÄ—jus, kur dalgÄ—s kabo, iÅ¡tverk dalges. Dalges +padÄ—k po stogu, o dalgiakoÄius sudÄ—k svirnan. + Å eimininkÄ— ieÅ¡ko kubilo lanko, kad bÅ«t visai apskritas, nepertrÅ«kÄ™s niekur. +TÄ… lankÄ… neÅ¡a viÅ¡tų tvartan, vidury tvarto paguldo. O tada Å¡eimininkÄ— skuba +tvartant prie kodžio, kur bÅ«na žirniai supilti. Å eimininkÄ— tuos žirnius semia +negailÄ—dama didžiulį gorÄių, kad visos viÅ¡tos prilestų lig soties. Å eimininkÄ— +pila tuos žirnius tan kubilo lankan, kad nei vienas žirnis nebÅ«t už kubilo +lanko - kad viÅ¡tos visos dÄ—tų kiauÅ¡inius vienan daiktan, nemÄ—tytų kiauÅ¡inių. +Berdama žirnius tan lankan, Å¡eimininkÄ— garsiai sako viÅ¡tom: + - ŽiÅ«rÄ—kite, kad nei vieno kiauÅ¡inio, nei vieno niekur nepamestut, visus +vienon vieton dÄ—kite! +Na ir visos viÅ¡tos Å¡eimininkÄ—s įsakymÄ… vykdo. diff --git a/Lab4.RemoveVowels/Lab4.RemoveVowels.csproj b/Lab4.RemoveVowels/Lab4.RemoveVowels.csproj new file mode 100644 index 0000000..74abf5c --- /dev/null +++ b/Lab4.RemoveVowels/Lab4.RemoveVowels.csproj @@ -0,0 +1,10 @@ + + + + Exe + net6.0 + enable + enable + + + diff --git a/Lab4.RemoveVowels/Program.cs b/Lab4.RemoveVowels/Program.cs new file mode 100644 index 0000000..89b1bda --- /dev/null +++ b/Lab4.RemoveVowels/Program.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; + +namespace Lab4.RemoveVowels +{ + class Program + { + static void Main(string[] args) + { + const string CFd = "Duomenys.txt"; + const string CFr = "Rezultatai.txt"; + const string CFa = "Analize.txt"; + const string vowels = "AEIYOUaeiyouĄąĘęĖėĮįŲųŪū"; + char[] punctuation = {' ', '.', ',', '!', '?', ':', ';', '(', ')', '\t'}; + TaskUtils.Process(CFd, CFr, CFa, punctuation, vowels); + } + } +} diff --git a/Lab4.RemoveVowels/TaskUtils.cs b/Lab4.RemoveVowels/TaskUtils.cs new file mode 100644 index 0000000..0212a92 --- /dev/null +++ b/Lab4.RemoveVowels/TaskUtils.cs @@ -0,0 +1,74 @@ +using System; +using System.Text; +using System.IO; + +namespace Lab4.RemoveVowels +{ + class TaskUtils + { + /** Finds the longest word in the line. + @param line – string of data + @param punctuation – punctuation marks to separate words */ + private static string LongestWord(string line, char[] punctuation) + { + string[] parts = line.Split(punctuation, StringSplitOptions.RemoveEmptyEntries); + string longestWord=""; + foreach (string word in parts) + if (word.Length > longestWord.Length) + longestWord = word; + return longestWord; + } + + /** Removes vowels from the given word. + @param line – word with possible vowels + @param vowels – vowels of the alphabet */ + private static StringBuilder RemoveVowels(string line, string vowels) + { + StringBuilder newLine = new StringBuilder(); + for (int i = 0; i < line.Length; i++) + if (vowels.IndexOf(line[i]) == -1) + newLine.Append(line[i]); + return newLine; + } + + /** Reads file, removes vowels from the longest word, creates files of + results and of information. + @param fin – name of data file + @param fout – name of result file + @param finfo – name of informative file + @param punctuation – punctuation marks to separate words + @param vowels – vowels of the alphabet */ + public static void Process(string fin, string fout, string finfo, char[] punctuation, string vowels) + { + string[] lines = File.ReadAllLines(fin, Encoding.UTF8); + string dashes = new string('-', 38); + using (var writerF = File.CreateText(fout)) + { + using (var writerI = File.CreateText(finfo)) + { + writerI.WriteLine(dashes); + writerI.WriteLine("| Ilgiausias žodis | Pradžia | Ilgis |"); + writerI.WriteLine(dashes); + foreach (string line in lines) + { + if (line.Length > 0) + { + string longestWord = LongestWord(line, punctuation); + string wordNoVowels = RemoveVowels(longestWord, vowels).ToString(); + writerI.WriteLine("| {0,-16} | {1, 7:d} | {2, 5:d} |", + longestWord, line.IndexOf(longestWord), longestWord.Length); + string newLine = line.Replace(longestWord, wordNoVowels); + // The shortest word cannot be replaced this way. + // It can be a part of the other word; solution is 4.5 subsection. + writerF.WriteLine(newLine); + } + else + writerF.WriteLine(line); + } + writerI.WriteLine(dashes); + } + } + } + } +} + diff --git a/Lab4.sln b/Lab4.sln index e4a4e10..70dafb1 100644 --- a/Lab4.sln +++ b/Lab4.sln @@ -13,6 +13,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lab4.FirstEqualLast", "Lab4 EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lab4.AddSurname", "Lab4.AddSurname\Lab4.AddSurname.csproj", "{F7EFA186-AD5D-4E5D-B405-9ACBAEDB7BF3}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lab4.RemoveVowels", "Lab4.RemoveVowels\Lab4.RemoveVowels.csproj", "{5AD87F42-DD6D-4ADF-B1D5-66553BAA4BCC}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -43,6 +45,10 @@ Global {F7EFA186-AD5D-4E5D-B405-9ACBAEDB7BF3}.Debug|Any CPU.Build.0 = Debug|Any CPU {F7EFA186-AD5D-4E5D-B405-9ACBAEDB7BF3}.Release|Any CPU.ActiveCfg = Release|Any CPU {F7EFA186-AD5D-4E5D-B405-9ACBAEDB7BF3}.Release|Any CPU.Build.0 = Release|Any CPU + {5AD87F42-DD6D-4ADF-B1D5-66553BAA4BCC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5AD87F42-DD6D-4ADF-B1D5-66553BAA4BCC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5AD87F42-DD6D-4ADF-B1D5-66553BAA4BCC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {5AD87F42-DD6D-4ADF-B1D5-66553BAA4BCC}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE From d7901266191eb48e3b29ee448cb59b40c4424c18 Mon Sep 17 00:00:00 2001 From: Rokas Puzonas Date: Tue, 23 Nov 2021 11:58:35 +0200 Subject: [PATCH 13/28] fix: handle "Lab4.AddSurname" edge cases when removing words --- Lab4.AddSurname/Duomenys.txt | 6 ++++-- Lab4.AddSurname/Lab4.AddSurname.csproj | 10 +++++++--- Lab4.AddSurname/TaskUtils.cs | 6 +++--- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/Lab4.AddSurname/Duomenys.txt b/Lab4.AddSurname/Duomenys.txt index 796a223..e190be7 100644 --- a/Lab4.AddSurname/Duomenys.txt +++ b/Lab4.AddSurname/Duomenys.txt @@ -2,8 +2,10 @@ Arvydas (g. 1964 m. gruodžio 19 d. Kaune) – Lietuvos krepÅ¡ininkas, olimpinis ir pasaulio Äempionas Arvydas, nuo Arvydas 2011 m. spalio 24 d. Lietuvos krepÅ¡inio federacijos prezidentas. Profesionalaus žaidÄ—jo karjerÄ… Arvydas pradÄ—jo 1981 m. -Kauno krepÅ¡inio klube "Žalgiris". +Kauno krepÅ¡inio klube "Žalgiris". asasd Arvydas tris sezonus iÅ¡ eilÄ—s (1985–1987 m.). Arvydas padÄ—jo komandai iÅ¡kovoti SSRS krepÅ¡inio Äempionato aukso medalius. -1982 m. Arvydas SSRS rinktinÄ—s Arvydas sudÄ—tyje Arvydas +1982 m. Arvydas as SSRS rinktinÄ—s Arvydas sudÄ—tyje Arvydas dalyvavo pasaulio krepÅ¡inio Äempionate ir laimÄ—jo auksÄ…. + +as \ No newline at end of file diff --git a/Lab4.AddSurname/Lab4.AddSurname.csproj b/Lab4.AddSurname/Lab4.AddSurname.csproj index 74abf5c..3a26489 100644 --- a/Lab4.AddSurname/Lab4.AddSurname.csproj +++ b/Lab4.AddSurname/Lab4.AddSurname.csproj @@ -2,9 +2,13 @@ Exe - net6.0 - enable - enable + netcoreapp2.1 + + + PreserveNewest + + + diff --git a/Lab4.AddSurname/TaskUtils.cs b/Lab4.AddSurname/TaskUtils.cs index 862a624..47bb650 100644 --- a/Lab4.AddSurname/TaskUtils.cs +++ b/Lab4.AddSurname/TaskUtils.cs @@ -55,8 +55,8 @@ namespace Lab4.AddSurname public static string RemoveWord(string line, string punctuation, string word) { - string pattern = String.Format(@"([{0}]*){1}[{0}]*", Regex.Unescape(punctuation), Regex.Unescape(word)); - return Regex.Replace(line, pattern, "$1"); + string pattern = string.Format(@"(^|[{0}]+){1}($|[{0}]+)", Regex.Escape(punctuation), Regex.Escape(word)); + return Regex.Replace(line, pattern, "$1"); } public static void ProcessRemoveWord(string fin, string fout, string punctuation, string word) @@ -65,7 +65,7 @@ namespace Lab4.AddSurname { using (StreamReader reader = new StreamReader(fin)) { - string? line = String.Empty; + string line = string.Empty; while ((line = reader.ReadLine()) != null) { writer.WriteLine(RemoveWord(line, punctuation, word)); From fbc22c65df2a6a3218af0e15fc0464d9f1aa9e25 Mon Sep 17 00:00:00 2001 From: Rokas Puzonas Date: Tue, 23 Nov 2021 11:59:22 +0200 Subject: [PATCH 14/28] fix: update file encoding --- Lab4.LetterFrequency/Duomenys.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Lab4.LetterFrequency/Duomenys.txt b/Lab4.LetterFrequency/Duomenys.txt index b0b56c5..289a351 100644 --- a/Lab4.LetterFrequency/Duomenys.txt +++ b/Lab4.LetterFrequency/Duomenys.txt @@ -1,6 +1,6 @@ Draugas draugui sako: -- Kà pasakytum, jei sutiktum moterá, kuri visada bûtø ðvelni ir maloni, - viskà tau atleistø, tave dievintø. -- Tokiø nebûna. -- Bûna. Reiktø pasakyti: +- KÄ… pasakytum, jei sutiktum moterį, kuri visada bÅ«tų Å¡velni ir maloni, + viskÄ… tau atleistų, tave dievintų. +- Tokių nebÅ«na. +- BÅ«na. Reiktų pasakyti: - Labas, mama! \ No newline at end of file From f028cfba89130ab5f880a7d7653dd6c47288e295 Mon Sep 17 00:00:00 2001 From: Rokas Puzonas Date: Thu, 25 Nov 2021 02:42:36 +0200 Subject: [PATCH 15/28] feat: complete first half of "Lab4.ChainedWords" --- Lab4.ChainedWords/Knyga.txt | 7 ++ Lab4.ChainedWords/Lab4.ChainedWords.csproj | 8 ++ Lab4.ChainedWords/Program.cs | 18 +++ Lab4.ChainedWords/TaskUtils.cs | 122 +++++++++++++++++++++ 4 files changed, 155 insertions(+) create mode 100644 Lab4.ChainedWords/Knyga.txt create mode 100644 Lab4.ChainedWords/Lab4.ChainedWords.csproj create mode 100644 Lab4.ChainedWords/Program.cs create mode 100644 Lab4.ChainedWords/TaskUtils.cs diff --git a/Lab4.ChainedWords/Knyga.txt b/Lab4.ChainedWords/Knyga.txt new file mode 100644 index 0000000..e1b448d --- /dev/null +++ b/Lab4.ChainedWords/Knyga.txt @@ -0,0 +1,7 @@ +Vienas QRSs!!?SABC V ABC +. +CEF FEG GOF + +QRS SABC + + diff --git a/Lab4.ChainedWords/Lab4.ChainedWords.csproj b/Lab4.ChainedWords/Lab4.ChainedWords.csproj new file mode 100644 index 0000000..23df604 --- /dev/null +++ b/Lab4.ChainedWords/Lab4.ChainedWords.csproj @@ -0,0 +1,8 @@ + + + + Exe + netcoreapp2.1 + + + diff --git a/Lab4.ChainedWords/Program.cs b/Lab4.ChainedWords/Program.cs new file mode 100644 index 0000000..a66aa2d --- /dev/null +++ b/Lab4.ChainedWords/Program.cs @@ -0,0 +1,18 @@ +using System; + +namespace Lab4.ChainedWords +{ + class Program + { + static void Main(string[] args) + { + string input = "Knyga.txt"; + string output1 = "Rodikliai.txt"; + string output2 = "ManoKnyga.txt"; + string punctuation = " ,.;!?"; + TaskUtils.ProcessChains(input, output1, punctuation); + TaskUtils.ProcessAligned(input, output2, punctuation); + } + } +} + diff --git a/Lab4.ChainedWords/TaskUtils.cs b/Lab4.ChainedWords/TaskUtils.cs new file mode 100644 index 0000000..806765d --- /dev/null +++ b/Lab4.ChainedWords/TaskUtils.cs @@ -0,0 +1,122 @@ +using System; +using System.Text; +using System.Text.RegularExpressions; +using System.Collections.Generic; +using System.IO; +using System.Linq; + +namespace Lab4.ChainedWords +{ + static class TaskUtils + { + private static MatchCollection MatchByWords(string text, string punctuation) + { + string pattern = string.Format(@"[^{0}\n]+", Regex.Escape(punctuation)); + return Regex.Matches(text, pattern, RegexOptions.IgnoreCase); + } + + private static MatchCollection MatchByIntegers(string text) + { + return Regex.Matches(text, @"\d+"); + } + + public static List> FindChains(string text, string punctuation) + { + List> chains = new List>(); + + bool startedChain = false; + int chainStart = 0; + + MatchCollection matches = MatchByWords(text, punctuation); + for (int i = 1; i < matches.Count; i++) + { + Match prevMatch = matches[i-1]; + Match match = matches[i]; + bool matchesCriteria = prevMatch.Value.ToLowerInvariant().Last() == match.Value.ToLowerInvariant().First(); + + if (matchesCriteria && !startedChain) + { + startedChain = true; + chainStart = prevMatch.Index; + } + else if (!matchesCriteria && startedChain) + { + startedChain = false; + int line = text.Substring(0, chainStart).Count(c => c == '\n')+1; + string chain = text.Substring(chainStart, match.Index-chainStart).TrimEnd('\n'); + chains.Add(new Tuple(line, chain)); + } + } + + // Ensure that last chain gets added to list + if (startedChain) + { + int line = text.Substring(0, chainStart).Count(c => c == '\n')+1; + string chain = text.Substring(chainStart).TrimEnd('\n'); + chains.Add(new Tuple(line, chain)); + } + + return chains; + } + + public static List FindIntegers(string text) + { + List integers = new List(); + + MatchCollection matches = MatchByIntegers(text); + foreach (Match match in matches) + { + integers.Add(int.Parse(match.Value)); + } + + return integers; + } + + public static Tuple FindLongestChain(string text, string punctuation) + { + List> chains = FindChains(text, punctuation); + + if (chains.Count == 0) + { + return null; + } + + Tuple longestChain = chains[0]; + foreach (var pair in chains) + { + if (pair.Item2.Length > longestChain.Item2.Length) + { + longestChain = pair; + } + } + + return longestChain; + } + + public static void ProcessChains(string inputFile, string outputFile, string punctuation) + { + string text = File.ReadAllText(inputFile, Encoding.UTF8); + Tuple longestChain = FindLongestChain(text, punctuation); + List integers = FindIntegers(text); + + using (StreamWriter writer = new StreamWriter(outputFile)) + { + if (longestChain != null) + { + writer.WriteLine("Ilgiausia žodžių grandinÄ— {0} eilutÄ—je: {1}", longestChain.Item1, longestChain.Item2); + } + else + { + writer.WriteLine("NÄ—ra žodžių grandinių."); + } + + writer.WriteLine("Yra {0} žodžiai sudaryti iÅ¡ skaitmenų. Jų suma: {1}", integers.Count, integers.Sum()); + } + } + + public static void ProcessAligned(string input, string ouput, string punctuation) + { + } + } +} + From 3a6de12fc02f8aaaf9a55988abb34ca6a322e553 Mon Sep 17 00:00:00 2001 From: Rokas Puzonas Date: Thu, 25 Nov 2021 03:11:02 +0200 Subject: [PATCH 16/28] feat: complete second half of "Lab4.ChainedWords" --- Lab4.ChainedWords/Knyga.txt | 11 +++---- Lab4.ChainedWords/TaskUtils.cs | 55 +++++++++++++++++++++++++++++++++- 2 files changed, 58 insertions(+), 8 deletions(-) diff --git a/Lab4.ChainedWords/Knyga.txt b/Lab4.ChainedWords/Knyga.txt index e1b448d..09c1b75 100644 --- a/Lab4.ChainedWords/Knyga.txt +++ b/Lab4.ChainedWords/Knyga.txt @@ -1,7 +1,4 @@ -Vienas QRSs!!?SABC V ABC -. -CEF FEG GOF - -QRS SABC - - +Reikia teksto žodžius sulygiuoti, kad kiekvienos eilutÄ—s kiekvienas žodis +prasidÄ—tų fiksuotoje toje paÄioje pozicijoje. Galima įterpti tik minimalų +bÅ«tinÄ… tarpų skaiÄių. Reikia Å¡alinti iÅ¡ pradinio teksto kelis iÅ¡ eilÄ—s einanÄius +vienodus skyriklius, paliekant tik vienÄ… jų atstovÄ…. Ä®terpimo taisyklÄ™ taikome, diff --git a/Lab4.ChainedWords/TaskUtils.cs b/Lab4.ChainedWords/TaskUtils.cs index 806765d..120fa75 100644 --- a/Lab4.ChainedWords/TaskUtils.cs +++ b/Lab4.ChainedWords/TaskUtils.cs @@ -114,8 +114,61 @@ namespace Lab4.ChainedWords } } - public static void ProcessAligned(string input, string ouput, string punctuation) + private static IEnumerable ReadByLines(string filename) { + string line; + using (StreamReader reader = new StreamReader(filename)) + { + while((line = reader.ReadLine()) != null) + { + yield return line; + } + } + } + + public static void ProcessAligned(string inputFile, string outputFile, string punctuation) + { + string pattern = string.Format(@"[^{0}]+[{0}]*", Regex.Escape(punctuation)); + string text = File.ReadAllText(inputFile, Encoding.UTF8); + Dictionary columns = new Dictionary(); + List> words = new List>(); + + foreach (string line in ReadByLines(inputFile)) + { + List row = new List(); + words.Add(row); + int column = 0; + foreach (Match match in Regex.Matches(line, pattern)) + { + string word = match.Value.TrimEnd('\n'); + row.Add(word); + if (!columns.ContainsKey(column)) + { + columns.Add(column, 0); + } + columns[column] = Math.Max(columns[column], word.Length); + column++; + } + } + + using (StreamWriter writer = new StreamWriter(outputFile)) + { + foreach (List row in words) + { + int column = 0; + for (int i = 0; i < row.Count; i++) + { + string word = row[i]; + writer.Write(word); + if (i < row.Count-1) + { + writer.Write(new string(' ', columns[column]-word.Length)); + } + column++; + } + writer.Write("\n"); + } + } } } } From 3c08b04264bc168e057c827f60285ede4063c1cc Mon Sep 17 00:00:00 2001 From: Rokas Puzonas Date: Thu, 25 Nov 2021 10:39:27 +0200 Subject: [PATCH 17/28] feat: add editroconfig --- .editorconfig | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..3159b2a --- /dev/null +++ b/.editorconfig @@ -0,0 +1,14 @@ +root=true + +[*] +charset = utf-8 +end_of_line = lf +indent_style = tab +indent_size = 2 +insert_final_newline = true +trim_trailing_whitespace = true + +[*.cs] +indent_style = space +indent_size = 4 + From 27098835b41350afee6312a7448f1e09a4d48770 Mon Sep 17 00:00:00 2001 From: Rokas Puzonas Date: Thu, 25 Nov 2021 16:30:28 +0200 Subject: [PATCH 18/28] feat: complete "Lab2.K2" --- Lab4.K2/Lab4.K2.csproj | 8 ++ Lab4.K2/Program.cs | 165 +++++++++++++++++++++++++++++++++++++++++ Lab4.K2/Tekstas.txt | 5 ++ Lab4.sln | 6 ++ 4 files changed, 184 insertions(+) create mode 100644 Lab4.K2/Lab4.K2.csproj create mode 100644 Lab4.K2/Program.cs create mode 100644 Lab4.K2/Tekstas.txt diff --git a/Lab4.K2/Lab4.K2.csproj b/Lab4.K2/Lab4.K2.csproj new file mode 100644 index 0000000..23df604 --- /dev/null +++ b/Lab4.K2/Lab4.K2.csproj @@ -0,0 +1,8 @@ + + + + Exe + netcoreapp2.1 + + + diff --git a/Lab4.K2/Program.cs b/Lab4.K2/Program.cs new file mode 100644 index 0000000..7667f33 --- /dev/null +++ b/Lab4.K2/Program.cs @@ -0,0 +1,165 @@ +using System.Text; +using System.Text.RegularExpressions; +using System.Collections.Generic; +using System.IO; + +namespace Lab4.K2 +{ + static class TaskUtils + { + public static bool NoDigits(string line) + { + return !Regex.IsMatch(line, @"\d"); + } + + public static int NumberDifferentVowelsInLine(string line) + { + string vowels = "AEIYOUaeiyouĄąĘęĖėĮįŲųŪū"; + string pattern = string.Format(@"[{0}]", Regex.Escape(vowels)); + return Regex.Matches(line, pattern).Count; + } + + // Note: returns words including punctuation after them + public static MatchCollection MatchByWords(string line, string punctuation) + { + string pattern = string.Format(@"[^{0}]+[{0}]*", Regex.Escape(punctuation)); + return Regex.Matches(line, pattern); + } + + public static string FindWord1Line(string line, string punctuation) + { + List wordsWith3Vowels = new List(); + + foreach (Match match in MatchByWords(line, punctuation)) + { + int vowelCount = NumberDifferentVowelsInLine(match.Value); + if (vowelCount == 3) + { + wordsWith3Vowels.Add(match.Value); + } + } + + string longestWord = ""; + foreach (string word in wordsWith3Vowels) + { + if (word.Length > longestWord.Length) + { + longestWord = word; + } + } + + return longestWord; + } + + public static string EditLine(string line, string punctuation, string word) + { + // 1. Find given word in line + MatchCollection words = MatchByWords(line, punctuation); + int wordPosition = -1; + + for (int i = 0; i < words.Count; i++) + { + if (words[i].Value == word) + { + wordPosition = i; + break; + } + } + + if (wordPosition == -1) return line; + + // 2. Move found word to front + StringBuilder builder = new StringBuilder(); + builder.Append(words[wordPosition]); + for (int i = 0; i < words.Count; i++) + { + if (i != wordPosition) + { + builder.Append(words[i]); + } + } + + // 3. Profit + return builder.ToString(); + } + + public static Match MatchLastWord(string line, string punctuation) + { + string pattern = string.Format(@"[^{0}]+[{0}]*$", Regex.Escape(punctuation)); + return Regex.Match(line, pattern); + } + + public static string FindWord2Line(string line, string punctuation) + { + Match lastWord = MatchLastWord(line, punctuation); + if (NoDigits(lastWord.Value)) + { + return lastWord.Value; + } + else + { + return ""; + } + } + + public static IEnumerable ReadByLines(string filename) + { + string line; + using (StreamReader reader = new StreamReader(filename, Encoding.UTF8)) + { + while ((line = reader.ReadLine()) != null) + { + yield return line; + } + } + } + + public static void PerformTask(string fd, string fr) + { + List wordsWithoutDigits = new List(); + string punctuation = null; + using (StreamWriter writer = File.CreateText(fr)) + { + foreach (string line in ReadByLines(fd)) + { + if (punctuation == null) + { + punctuation = line; + continue; + } + + string longestWord = TaskUtils.FindWord1Line(line, punctuation); + if (longestWord != "") + { + writer.WriteLine(TaskUtils.EditLine(line, punctuation, longestWord)); + } + else + { + writer.WriteLine(line); + } + + string wordWithoutDigits = TaskUtils.FindWord2Line(line, punctuation); + if (wordWithoutDigits != "") + { + wordsWithoutDigits.Add(wordWithoutDigits); + } + } + + char[] punctuationChars = punctuation.ToCharArray(); + foreach (string word in wordsWithoutDigits) + { + writer.WriteLine(word.Trim(punctuationChars)); + } + } + } + } + + class Program + { + static void Main(string[] args) + { + TaskUtils.PerformTask("Tekstas.txt", "RedTekstas.txt"); + } + } +} + diff --git a/Lab4.K2/Tekstas.txt b/Lab4.K2/Tekstas.txt new file mode 100644 index 0000000..aa597a6 --- /dev/null +++ b/Lab4.K2/Tekstas.txt @@ -0,0 +1,5 @@ + .!?;:@ +bar fooo,@ !ba1 +bar bAaar baar bAoUr!! +bar foÄ—o@ 1ba +bar? baer boar f!! diff --git a/Lab4.sln b/Lab4.sln index 70dafb1..e68a3ea 100644 --- a/Lab4.sln +++ b/Lab4.sln @@ -15,6 +15,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lab4.AddSurname", "Lab4.Add EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lab4.RemoveVowels", "Lab4.RemoveVowels\Lab4.RemoveVowels.csproj", "{5AD87F42-DD6D-4ADF-B1D5-66553BAA4BCC}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lab4.K2", "Lab4.K2\Lab4.K2.csproj", "{BE0E7198-95F7-4EFA-BFE1-CA5BBE7798D2}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -49,6 +51,10 @@ Global {5AD87F42-DD6D-4ADF-B1D5-66553BAA4BCC}.Debug|Any CPU.Build.0 = Debug|Any CPU {5AD87F42-DD6D-4ADF-B1D5-66553BAA4BCC}.Release|Any CPU.ActiveCfg = Release|Any CPU {5AD87F42-DD6D-4ADF-B1D5-66553BAA4BCC}.Release|Any CPU.Build.0 = Release|Any CPU + {BE0E7198-95F7-4EFA-BFE1-CA5BBE7798D2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {BE0E7198-95F7-4EFA-BFE1-CA5BBE7798D2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {BE0E7198-95F7-4EFA-BFE1-CA5BBE7798D2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {BE0E7198-95F7-4EFA-BFE1-CA5BBE7798D2}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE From 49b85f6cfb8a35967c010c54fafc83cf6e7e3c37 Mon Sep 17 00:00:00 2001 From: Rokas Puzonas Date: Thu, 25 Nov 2021 11:59:38 +0200 Subject: [PATCH 19/28] docs: add comments to "Lab4.ChainedWords" --- Lab4.ChainedWords/InOut.cs | 27 ++++++++++ Lab4.ChainedWords/Lab4.ChainedWords.csproj | 6 +++ Lab4.ChainedWords/TaskUtils.cs | 57 +++++++++++++++++----- 3 files changed, 77 insertions(+), 13 deletions(-) create mode 100644 Lab4.ChainedWords/InOut.cs diff --git a/Lab4.ChainedWords/InOut.cs b/Lab4.ChainedWords/InOut.cs new file mode 100644 index 0000000..84f47ca --- /dev/null +++ b/Lab4.ChainedWords/InOut.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Text; + +namespace Lab4.ChainedWords +{ + static class InOut + { + /// + /// Read a file line-by-line using an enumarable + /// + /// Target file + /// Enumerable + public static IEnumerable ReadByLines(string filename) + { + string line; + using (StreamReader reader = new StreamReader(filename)) + { + while ((line = reader.ReadLine()) != null) + { + yield return line; + } + } + } + } +} diff --git a/Lab4.ChainedWords/Lab4.ChainedWords.csproj b/Lab4.ChainedWords/Lab4.ChainedWords.csproj index 23df604..8a5bcb0 100644 --- a/Lab4.ChainedWords/Lab4.ChainedWords.csproj +++ b/Lab4.ChainedWords/Lab4.ChainedWords.csproj @@ -5,4 +5,10 @@ netcoreapp2.1 + + + Always + + + diff --git a/Lab4.ChainedWords/TaskUtils.cs b/Lab4.ChainedWords/TaskUtils.cs index 120fa75..7cfb8c8 100644 --- a/Lab4.ChainedWords/TaskUtils.cs +++ b/Lab4.ChainedWords/TaskUtils.cs @@ -9,17 +9,35 @@ namespace Lab4.ChainedWords { static class TaskUtils { + /// + /// Return anything that matches a word in given text, depending on punctuation + /// + /// Target text + /// Target punctuation + /// Word matches private static MatchCollection MatchByWords(string text, string punctuation) { string pattern = string.Format(@"[^{0}\n]+", Regex.Escape(punctuation)); return Regex.Matches(text, pattern, RegexOptions.IgnoreCase); } + /// + /// Return anything that matches a positive integer in text + /// + /// Target text + /// Integer matches private static MatchCollection MatchByIntegers(string text) { return Regex.Matches(text, @"\d+"); } + /// + /// Find all chains of words in given text. A chain is a sequence of words where every words + /// last letter matches the next words first letter. And split the text into words using punctuation + /// + /// Target text + /// Target punctuation + /// A list of chains with line number where it was found public static List> FindChains(string text, string punctuation) { List> chains = new List>(); @@ -59,6 +77,11 @@ namespace Lab4.ChainedWords return chains; } + /// + /// Find all positive integers in given text + /// + /// Target text + /// List of positive integers public static List FindIntegers(string text) { List integers = new List(); @@ -72,6 +95,12 @@ namespace Lab4.ChainedWords return integers; } + /// + /// Finds the longest chain in the given text, while using given punctuation to determine words. + /// + /// Target text + /// Target punctuation + /// public static Tuple FindLongestChain(string text, string punctuation) { List> chains = FindChains(text, punctuation); @@ -93,6 +122,14 @@ namespace Lab4.ChainedWords return longestChain; } + /// + /// Ouput to file: + /// * longest chain and where it was found + /// * sum of all positive integers + /// + /// Input file + /// Output file + /// Target punctuation public static void ProcessChains(string inputFile, string outputFile, string punctuation) { string text = File.ReadAllText(inputFile, Encoding.UTF8); @@ -114,18 +151,12 @@ namespace Lab4.ChainedWords } } - private static IEnumerable ReadByLines(string filename) - { - string line; - using (StreamReader reader = new StreamReader(filename)) - { - while((line = reader.ReadLine()) != null) - { - yield return line; - } - } - } - + /// + /// Align every word in a line by columns + /// + /// Input file + /// Output file + /// Target punctuation public static void ProcessAligned(string inputFile, string outputFile, string punctuation) { string pattern = string.Format(@"[^{0}]+[{0}]*", Regex.Escape(punctuation)); @@ -133,7 +164,7 @@ namespace Lab4.ChainedWords Dictionary columns = new Dictionary(); List> words = new List>(); - foreach (string line in ReadByLines(inputFile)) + foreach (string line in InOut.ReadByLines(inputFile)) { List row = new List(); words.Add(row); From 22bac32be693dae34bbd4ad725be94d82ffaab72 Mon Sep 17 00:00:00 2001 From: Rokas Puzonas Date: Thu, 25 Nov 2021 12:00:36 +0200 Subject: [PATCH 20/28] fix: add "Lab4.ChainedWords" to solution --- Lab4.sln | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/Lab4.sln b/Lab4.sln index e68a3ea..2a9e988 100644 --- a/Lab4.sln +++ b/Lab4.sln @@ -3,17 +3,19 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 VisualStudioVersion = 15.0.28307.1525 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lab4.RemoveLines", "Lab4.RemoveLines\Lab4.RemoveLines.csproj", "{5309D21D-2A14-4332-90EC-504AD89CE397}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Lab4.RemoveLines", "Lab4.RemoveLines\Lab4.RemoveLines.csproj", "{5309D21D-2A14-4332-90EC-504AD89CE397}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Lab4.RemoveComments", "Lab4.RemoveComments\Lab4.RemoveComments.csproj", "{4D9B08C9-5735-4C95-8D2A-BDFC888B1E68}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lab4.LetterFrequency", "Lab4.LetterFrequency\Lab4.LetterFrequency.csproj", "{F1797B5C-1541-4821-9485-7C3520C5DD8D}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Lab4.LetterFrequency", "Lab4.LetterFrequency\Lab4.LetterFrequency.csproj", "{F1797B5C-1541-4821-9485-7C3520C5DD8D}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lab4.FirstEqualLast", "Lab4.FirstEqualLast\Lab4.FirstEqualLast.csproj", "{83CB5DEC-25E5-42FF-8601-9BF8DA73E397}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Lab4.FirstEqualLast", "Lab4.FirstEqualLast\Lab4.FirstEqualLast.csproj", "{83CB5DEC-25E5-42FF-8601-9BF8DA73E397}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lab4.AddSurname", "Lab4.AddSurname\Lab4.AddSurname.csproj", "{F7EFA186-AD5D-4E5D-B405-9ACBAEDB7BF3}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Lab4.AddSurname", "Lab4.AddSurname\Lab4.AddSurname.csproj", "{F7EFA186-AD5D-4E5D-B405-9ACBAEDB7BF3}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lab4.RemoveVowels", "Lab4.RemoveVowels\Lab4.RemoveVowels.csproj", "{5AD87F42-DD6D-4ADF-B1D5-66553BAA4BCC}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Lab4.RemoveVowels", "Lab4.RemoveVowels\Lab4.RemoveVowels.csproj", "{5AD87F42-DD6D-4ADF-B1D5-66553BAA4BCC}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Lab4.ChainedWords", "Lab4.ChainedWords\Lab4.ChainedWords.csproj", "{DA96CD19-65AA-4665-831F-8D9B21A6E369}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lab4.K2", "Lab4.K2\Lab4.K2.csproj", "{BE0E7198-95F7-4EFA-BFE1-CA5BBE7798D2}" EndProject @@ -23,10 +25,6 @@ Global Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {1966BAA5-C5E8-4F18-A1CB-69A0B2FFD5CE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {1966BAA5-C5E8-4F18-A1CB-69A0B2FFD5CE}.Debug|Any CPU.Build.0 = Debug|Any CPU - {1966BAA5-C5E8-4F18-A1CB-69A0B2FFD5CE}.Release|Any CPU.ActiveCfg = Release|Any CPU - {1966BAA5-C5E8-4F18-A1CB-69A0B2FFD5CE}.Release|Any CPU.Build.0 = Release|Any CPU {5309D21D-2A14-4332-90EC-504AD89CE397}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {5309D21D-2A14-4332-90EC-504AD89CE397}.Debug|Any CPU.Build.0 = Debug|Any CPU {5309D21D-2A14-4332-90EC-504AD89CE397}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -51,10 +49,10 @@ Global {5AD87F42-DD6D-4ADF-B1D5-66553BAA4BCC}.Debug|Any CPU.Build.0 = Debug|Any CPU {5AD87F42-DD6D-4ADF-B1D5-66553BAA4BCC}.Release|Any CPU.ActiveCfg = Release|Any CPU {5AD87F42-DD6D-4ADF-B1D5-66553BAA4BCC}.Release|Any CPU.Build.0 = Release|Any CPU - {BE0E7198-95F7-4EFA-BFE1-CA5BBE7798D2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {BE0E7198-95F7-4EFA-BFE1-CA5BBE7798D2}.Debug|Any CPU.Build.0 = Debug|Any CPU - {BE0E7198-95F7-4EFA-BFE1-CA5BBE7798D2}.Release|Any CPU.ActiveCfg = Release|Any CPU - {BE0E7198-95F7-4EFA-BFE1-CA5BBE7798D2}.Release|Any CPU.Build.0 = Release|Any CPU + {DA96CD19-65AA-4665-831F-8D9B21A6E369}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {DA96CD19-65AA-4665-831F-8D9B21A6E369}.Debug|Any CPU.Build.0 = Debug|Any CPU + {DA96CD19-65AA-4665-831F-8D9B21A6E369}.Release|Any CPU.ActiveCfg = Release|Any CPU + {DA96CD19-65AA-4665-831F-8D9B21A6E369}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE From 6ed1429304bbacca254c9299164d8ab8f308dffc Mon Sep 17 00:00:00 2001 From: Rokas Puzonas Date: Thu, 25 Nov 2021 16:38:28 +0200 Subject: [PATCH 21/28] fix: add dotnet cli config --- global.json | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 global.json diff --git a/global.json b/global.json new file mode 100644 index 0000000..4aa91ae --- /dev/null +++ b/global.json @@ -0,0 +1,5 @@ +{ + "sdk": { + "version": "3.0.103" + } +} From 691f9153e9698bbc18247b043bb5cad04f52dc20 Mon Sep 17 00:00:00 2001 From: Rokas Puzonas Date: Thu, 25 Nov 2021 22:58:08 +0200 Subject: [PATCH 22/28] fix: bug with "NumberDifferentVowelsInLine" --- Lab4.K2/Program.cs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/Lab4.K2/Program.cs b/Lab4.K2/Program.cs index 7667f33..9fc4fce 100644 --- a/Lab4.K2/Program.cs +++ b/Lab4.K2/Program.cs @@ -14,9 +14,16 @@ namespace Lab4.K2 public static int NumberDifferentVowelsInLine(string line) { - string vowels = "AEIYOUaeiyouĄąĘęĖėĮįŲųŪū"; - string pattern = string.Format(@"[{0}]", Regex.Escape(vowels)); - return Regex.Matches(line, pattern).Count; + string vowels = "aeiyouąęėįųū"; + int count = 0; + + line = line.ToLower(); + foreach (char vowel in vowels) + { + count += line.Contains(vowel) ? 1 : 0; + } + + return count; } // Note: returns words including punctuation after them From d2c1a49ebb1fd8156ddcafa0ad9d3f3175453bbe Mon Sep 17 00:00:00 2001 From: Rokas Puzonas Date: Thu, 25 Nov 2021 23:53:48 +0200 Subject: [PATCH 23/28] fix: bug in "FindWord1Line" --- Lab4.K2/Program.cs | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/Lab4.K2/Program.cs b/Lab4.K2/Program.cs index 9fc4fce..6c41ff2 100644 --- a/Lab4.K2/Program.cs +++ b/Lab4.K2/Program.cs @@ -29,33 +29,40 @@ namespace Lab4.K2 // Note: returns words including punctuation after them public static MatchCollection MatchByWords(string line, string punctuation) { - string pattern = string.Format(@"[^{0}]+[{0}]*", Regex.Escape(punctuation)); + string pattern = string.Format(@"([^{0}]+)[{0}]*", Regex.Escape(punctuation)); return Regex.Matches(line, pattern); } public static string FindWord1Line(string line, string punctuation) { - List wordsWith3Vowels = new List(); + List wordsWith3Vowels = new List(); foreach (Match match in MatchByWords(line, punctuation)) { int vowelCount = NumberDifferentVowelsInLine(match.Value); if (vowelCount == 3) { - wordsWith3Vowels.Add(match.Value); + wordsWith3Vowels.Add(match); } } - string longestWord = ""; - foreach (string word in wordsWith3Vowels) + Match longestWord = null; + foreach (Match word in wordsWith3Vowels) { - if (word.Length > longestWord.Length) + if (word.Groups[1].Length > longestWord.Groups[1].Length) { longestWord = word; } } - return longestWord; + if (longestWord == null) + { + return ""; + } + else + { + return longestWord.Value; + } } public static string EditLine(string line, string punctuation, string word) From 66b05d63c21fc2406c2c9e092b31410446cefd54 Mon Sep 17 00:00:00 2001 From: Rokas Puzonas Date: Thu, 25 Nov 2021 23:57:59 +0200 Subject: [PATCH 24/28] fix: simplify "FindWord1Line" --- Lab4.K2/Program.cs | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/Lab4.K2/Program.cs b/Lab4.K2/Program.cs index 6c41ff2..607ba5b 100644 --- a/Lab4.K2/Program.cs +++ b/Lab4.K2/Program.cs @@ -35,23 +35,13 @@ namespace Lab4.K2 public static string FindWord1Line(string line, string punctuation) { - List wordsWith3Vowels = new List(); - + Match longestWord = null; foreach (Match match in MatchByWords(line, punctuation)) { int vowelCount = NumberDifferentVowelsInLine(match.Value); - if (vowelCount == 3) + if (vowelCount == 3 && (longestWord == null || longestWord.Groups[1].Length < match.Groups[1].Length)) { - wordsWith3Vowels.Add(match); - } - } - - Match longestWord = null; - foreach (Match word in wordsWith3Vowels) - { - if (word.Groups[1].Length > longestWord.Groups[1].Length) - { - longestWord = word; + longestWord = match; } } From eddc67b0cc1ae1a529fcdfe814d34a57fc42bb67 Mon Sep 17 00:00:00 2001 From: Rokas Puzonas Date: Wed, 1 Dec 2021 00:03:42 +0200 Subject: [PATCH 25/28] test: add tests to "Lab4.ChainedWords" --- Lab4.ChainedWords/tests/1/Knyga.txt | 8 ++++++++ Lab4.ChainedWords/tests/2/Knyga.txt | 8 ++++++++ 2 files changed, 16 insertions(+) create mode 100644 Lab4.ChainedWords/tests/1/Knyga.txt create mode 100644 Lab4.ChainedWords/tests/2/Knyga.txt diff --git a/Lab4.ChainedWords/tests/1/Knyga.txt b/Lab4.ChainedWords/tests/1/Knyga.txt new file mode 100644 index 0000000..299975f --- /dev/null +++ b/Lab4.ChainedWords/tests/1/Knyga.txt @@ -0,0 +1,8 @@ +Reikia teksto žodžius sulygiuoti, kad 33 +eilutÄ—s 1 žodis +prasidÄ—tų fiksuotoje toje paÄioje pozicijoje. +Galima įterpti tik minimalų 22 +bÅ«tinÄ… tarpų 111. Reikia Å¡alinti iÅ¡ +pradinio teksto kelis iÅ¡ eilÄ—s einanÄius +vienodus skyriklius, paliekant tik vienÄ… +jų atstovÄ…. Ä®terpimo taisyklÄ™ 44, diff --git a/Lab4.ChainedWords/tests/2/Knyga.txt b/Lab4.ChainedWords/tests/2/Knyga.txt new file mode 100644 index 0000000..ddc1b04 --- /dev/null +++ b/Lab4.ChainedWords/tests/2/Knyga.txt @@ -0,0 +1,8 @@ +Reikia teksto žodžius , kad kiekvienos +eilutÄ—s kiekvienas žodis 100 +prasidÄ—tų fiksuotoje toje paÄioje pozicijoje. +Galima įterpti 12 minimalų +ABC CDEEEEF FG. Reikia Å¡alinti iÅ¡ +pradinio teksto kelis iÅ¡ eilÄ—s einanÄius +vienodus 420, paliekant tik vienÄ… +jų atstovÄ…. FOO OFO OOOOOF From 80635a8ac860a8c1f6b4c85820b16a23aad8c0bc Mon Sep 17 00:00:00 2001 From: Rokas Puzonas Date: Wed, 8 Dec 2021 01:10:36 +0200 Subject: [PATCH 26/28] feat: solve extra problem for "Lab4.ChainedWords" --- Lab4.ChainedWords/Program.cs | 3 +- Lab4.ChainedWords/TaskUtils.cs | 87 +++++++++++++++++++++++++--------- 2 files changed, 67 insertions(+), 23 deletions(-) diff --git a/Lab4.ChainedWords/Program.cs b/Lab4.ChainedWords/Program.cs index a66aa2d..a66e42f 100644 --- a/Lab4.ChainedWords/Program.cs +++ b/Lab4.ChainedWords/Program.cs @@ -11,7 +11,8 @@ namespace Lab4.ChainedWords string output2 = "ManoKnyga.txt"; string punctuation = " ,.;!?"; TaskUtils.ProcessChains(input, output1, punctuation); - TaskUtils.ProcessAligned(input, output2, punctuation); + //TaskUtils.ProcessAligned(input, output2, punctuation); + TaskUtils.ProccessVericallyAligned(input, output2, punctuation); } } } diff --git a/Lab4.ChainedWords/TaskUtils.cs b/Lab4.ChainedWords/TaskUtils.cs index 7cfb8c8..d1dccc7 100644 --- a/Lab4.ChainedWords/TaskUtils.cs +++ b/Lab4.ChainedWords/TaskUtils.cs @@ -151,6 +151,44 @@ namespace Lab4.ChainedWords } } + private static string AlignWordsByColumns(List> words, string punctuation) + { + StringBuilder aligned = new StringBuilder(); + Dictionary columns = new Dictionary(); + + foreach (List row in words) + { + int column = 0; + foreach (string word in row) + { + if (!columns.ContainsKey(column)) + { + columns.Add(column, 0); + } + columns[column] = Math.Max(columns[column], word.Length); + column++; + } + } + + foreach (List row in words) + { + int column = 0; + for (int i = 0; i < row.Count; i++) + { + string word = row[i]; + aligned.Append(word); + if (i < row.Count - 1) + { + aligned.Append(new string(' ', columns[column] - word.Length)); + } + column++; + } + aligned.Append("\n"); + } + + return aligned.ToString(); + } + /// /// Align every word in a line by columns /// @@ -161,45 +199,50 @@ namespace Lab4.ChainedWords { string pattern = string.Format(@"[^{0}]+[{0}]*", Regex.Escape(punctuation)); string text = File.ReadAllText(inputFile, Encoding.UTF8); - Dictionary columns = new Dictionary(); List> words = new List>(); foreach (string line in InOut.ReadByLines(inputFile)) { List row = new List(); words.Add(row); - int column = 0; foreach (Match match in Regex.Matches(line, pattern)) { - string word = match.Value.TrimEnd('\n'); - row.Add(word); - if (!columns.ContainsKey(column)) - { - columns.Add(column, 0); - } - columns[column] = Math.Max(columns[column], word.Length); - column++; + row.Add(match.Value.TrimEnd('\n')); } } - using (StreamWriter writer = new StreamWriter(outputFile)) + File.WriteAllText(outputFile, AlignWordsByColumns(words, punctuation)); + } + + /// + /// Align every line by columns and print words vertically + /// + /// Input file + /// Output file + /// Punctuation + public static void ProccessVericallyAligned(string inputFile, string outputFile, string punctuation) + { + string pattern = string.Format(@"[^{0}]+[{0}]*", Regex.Escape(punctuation)); + string text = File.ReadAllText(inputFile, Encoding.UTF8); + List> words = new List>(); + + foreach (string line in InOut.ReadByLines(inputFile)) { - foreach (List row in words) + int column = 0; + int row = 0; + foreach (Match match in Regex.Matches(line, pattern)) { - int column = 0; - for (int i = 0; i < row.Count; i++) + if (words.Count <= row) { - string word = row[i]; - writer.Write(word); - if (i < row.Count-1) - { - writer.Write(new string(' ', columns[column]-word.Length)); - } - column++; + words.Add(new List()); } - writer.Write("\n"); + words[row].Add(match.Value.TrimEnd('\n')); + row++; } + column++; } + + File.WriteAllText(outputFile, AlignWordsByColumns(words, punctuation)); } } } From 2c08b00837279619b8a66a3c572259a100f72b9c Mon Sep 17 00:00:00 2001 From: Rokas Puzonas Date: Wed, 8 Dec 2021 01:11:06 +0200 Subject: [PATCH 27/28] fix: update Lab4.sln --- Lab4.sln | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Lab4.sln b/Lab4.sln index 2a9e988..ce89cec 100644 --- a/Lab4.sln +++ b/Lab4.sln @@ -17,7 +17,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Lab4.RemoveVowels", "Lab4.R EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Lab4.ChainedWords", "Lab4.ChainedWords\Lab4.ChainedWords.csproj", "{DA96CD19-65AA-4665-831F-8D9B21A6E369}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lab4.K2", "Lab4.K2\Lab4.K2.csproj", "{BE0E7198-95F7-4EFA-BFE1-CA5BBE7798D2}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Lab4.K2", "Lab4.K2\Lab4.K2.csproj", "{BE0E7198-95F7-4EFA-BFE1-CA5BBE7798D2}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -53,6 +53,10 @@ Global {DA96CD19-65AA-4665-831F-8D9B21A6E369}.Debug|Any CPU.Build.0 = Debug|Any CPU {DA96CD19-65AA-4665-831F-8D9B21A6E369}.Release|Any CPU.ActiveCfg = Release|Any CPU {DA96CD19-65AA-4665-831F-8D9B21A6E369}.Release|Any CPU.Build.0 = Release|Any CPU + {BE0E7198-95F7-4EFA-BFE1-CA5BBE7798D2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {BE0E7198-95F7-4EFA-BFE1-CA5BBE7798D2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {BE0E7198-95F7-4EFA-BFE1-CA5BBE7798D2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {BE0E7198-95F7-4EFA-BFE1-CA5BBE7798D2}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE From f94bc038f42d0fe4fdfc3ee7c5026a6a7ab9ddbe Mon Sep 17 00:00:00 2001 From: Rokas Puzonas Date: Wed, 8 Dec 2021 21:09:07 +0200 Subject: [PATCH 28/28] fix: move all files to 'Lab4' --- .editorconfig => Lab4/.editorconfig | 0 .gitignore => Lab4/.gitignore | 0 {Lab4.AddSurname => Lab4/Lab4.AddSurname}/Duomenys.txt | 0 {Lab4.AddSurname => Lab4/Lab4.AddSurname}/Lab4.AddSurname.csproj | 0 {Lab4.AddSurname => Lab4/Lab4.AddSurname}/Program.cs | 0 {Lab4.AddSurname => Lab4/Lab4.AddSurname}/TaskUtils.cs | 0 {Lab4.ChainedWords => Lab4/Lab4.ChainedWords}/InOut.cs | 0 {Lab4.ChainedWords => Lab4/Lab4.ChainedWords}/Knyga.txt | 0 .../Lab4.ChainedWords}/Lab4.ChainedWords.csproj | 0 {Lab4.ChainedWords => Lab4/Lab4.ChainedWords}/Program.cs | 0 {Lab4.ChainedWords => Lab4/Lab4.ChainedWords}/TaskUtils.cs | 0 {Lab4.ChainedWords => Lab4/Lab4.ChainedWords}/tests/1/Knyga.txt | 0 {Lab4.ChainedWords => Lab4/Lab4.ChainedWords}/tests/2/Knyga.txt | 0 {Lab4.FirstEqualLast => Lab4/Lab4.FirstEqualLast}/Duomenys.txt | 0 .../Lab4.FirstEqualLast}/Lab4.FirstEqualLast.csproj | 0 {Lab4.FirstEqualLast => Lab4/Lab4.FirstEqualLast}/Program.cs | 0 {Lab4.FirstEqualLast => Lab4/Lab4.FirstEqualLast}/TaskUtils.cs | 0 {Lab4.K2 => Lab4/Lab4.K2}/Lab4.K2.csproj | 0 {Lab4.K2 => Lab4/Lab4.K2}/Program.cs | 0 {Lab4.K2 => Lab4/Lab4.K2}/Tekstas.txt | 0 {Lab4.LetterFrequency => Lab4/Lab4.LetterFrequency}/Duomenys.txt | 0 {Lab4.LetterFrequency => Lab4/Lab4.LetterFrequency}/InOut.cs | 0 .../Lab4.LetterFrequency}/Lab4.LetterFrequency.csproj | 0 .../Lab4.LetterFrequency}/LettersFrequency.cs | 0 {Lab4.LetterFrequency => Lab4/Lab4.LetterFrequency}/Program.cs | 0 {Lab4.RemoveComments => Lab4/Lab4.RemoveComments}/Duomenys.txt | 0 {Lab4.RemoveComments => Lab4/Lab4.RemoveComments}/InOut.cs | 0 .../Lab4.RemoveComments}/Lab4.RemoveComments.csproj | 0 {Lab4.RemoveComments => Lab4/Lab4.RemoveComments}/Program.cs | 0 {Lab4.RemoveComments => Lab4/Lab4.RemoveComments}/TaskUtils.cs | 0 {Lab4.RemoveLines => Lab4/Lab4.RemoveLines}/Duomenys.txt | 0 {Lab4.RemoveLines => Lab4/Lab4.RemoveLines}/InOut.cs | 0 .../Lab4.RemoveLines}/Lab4.RemoveLines.csproj | 0 {Lab4.RemoveLines => Lab4/Lab4.RemoveLines}/Program.cs | 0 {Lab4.RemoveVowels => Lab4/Lab4.RemoveVowels}/Duomenys.txt | 0 .../Lab4.RemoveVowels}/Lab4.RemoveVowels.csproj | 0 {Lab4.RemoveVowels => Lab4/Lab4.RemoveVowels}/Program.cs | 0 {Lab4.RemoveVowels => Lab4/Lab4.RemoveVowels}/TaskUtils.cs | 0 Lab4.sln => Lab4/Lab4.sln | 0 README.md => Lab4/README.md | 0 global.json => Lab4/global.json | 0 41 files changed, 0 insertions(+), 0 deletions(-) rename .editorconfig => Lab4/.editorconfig (100%) rename .gitignore => Lab4/.gitignore (100%) rename {Lab4.AddSurname => Lab4/Lab4.AddSurname}/Duomenys.txt (100%) rename {Lab4.AddSurname => Lab4/Lab4.AddSurname}/Lab4.AddSurname.csproj (100%) rename {Lab4.AddSurname => Lab4/Lab4.AddSurname}/Program.cs (100%) rename {Lab4.AddSurname => Lab4/Lab4.AddSurname}/TaskUtils.cs (100%) rename {Lab4.ChainedWords => Lab4/Lab4.ChainedWords}/InOut.cs (100%) rename {Lab4.ChainedWords => Lab4/Lab4.ChainedWords}/Knyga.txt (100%) rename {Lab4.ChainedWords => Lab4/Lab4.ChainedWords}/Lab4.ChainedWords.csproj (100%) rename {Lab4.ChainedWords => Lab4/Lab4.ChainedWords}/Program.cs (100%) rename {Lab4.ChainedWords => Lab4/Lab4.ChainedWords}/TaskUtils.cs (100%) rename {Lab4.ChainedWords => Lab4/Lab4.ChainedWords}/tests/1/Knyga.txt (100%) rename {Lab4.ChainedWords => Lab4/Lab4.ChainedWords}/tests/2/Knyga.txt (100%) rename {Lab4.FirstEqualLast => Lab4/Lab4.FirstEqualLast}/Duomenys.txt (100%) rename {Lab4.FirstEqualLast => Lab4/Lab4.FirstEqualLast}/Lab4.FirstEqualLast.csproj (100%) rename {Lab4.FirstEqualLast => Lab4/Lab4.FirstEqualLast}/Program.cs (100%) rename {Lab4.FirstEqualLast => Lab4/Lab4.FirstEqualLast}/TaskUtils.cs (100%) rename {Lab4.K2 => Lab4/Lab4.K2}/Lab4.K2.csproj (100%) rename {Lab4.K2 => Lab4/Lab4.K2}/Program.cs (100%) rename {Lab4.K2 => Lab4/Lab4.K2}/Tekstas.txt (100%) rename {Lab4.LetterFrequency => Lab4/Lab4.LetterFrequency}/Duomenys.txt (100%) rename {Lab4.LetterFrequency => Lab4/Lab4.LetterFrequency}/InOut.cs (100%) rename {Lab4.LetterFrequency => Lab4/Lab4.LetterFrequency}/Lab4.LetterFrequency.csproj (100%) rename {Lab4.LetterFrequency => Lab4/Lab4.LetterFrequency}/LettersFrequency.cs (100%) rename {Lab4.LetterFrequency => Lab4/Lab4.LetterFrequency}/Program.cs (100%) rename {Lab4.RemoveComments => Lab4/Lab4.RemoveComments}/Duomenys.txt (100%) rename {Lab4.RemoveComments => Lab4/Lab4.RemoveComments}/InOut.cs (100%) rename {Lab4.RemoveComments => Lab4/Lab4.RemoveComments}/Lab4.RemoveComments.csproj (100%) rename {Lab4.RemoveComments => Lab4/Lab4.RemoveComments}/Program.cs (100%) rename {Lab4.RemoveComments => Lab4/Lab4.RemoveComments}/TaskUtils.cs (100%) rename {Lab4.RemoveLines => Lab4/Lab4.RemoveLines}/Duomenys.txt (100%) rename {Lab4.RemoveLines => Lab4/Lab4.RemoveLines}/InOut.cs (100%) rename {Lab4.RemoveLines => Lab4/Lab4.RemoveLines}/Lab4.RemoveLines.csproj (100%) rename {Lab4.RemoveLines => Lab4/Lab4.RemoveLines}/Program.cs (100%) rename {Lab4.RemoveVowels => Lab4/Lab4.RemoveVowels}/Duomenys.txt (100%) rename {Lab4.RemoveVowels => Lab4/Lab4.RemoveVowels}/Lab4.RemoveVowels.csproj (100%) rename {Lab4.RemoveVowels => Lab4/Lab4.RemoveVowels}/Program.cs (100%) rename {Lab4.RemoveVowels => Lab4/Lab4.RemoveVowels}/TaskUtils.cs (100%) rename Lab4.sln => Lab4/Lab4.sln (100%) rename README.md => Lab4/README.md (100%) rename global.json => Lab4/global.json (100%) diff --git a/.editorconfig b/Lab4/.editorconfig similarity index 100% rename from .editorconfig rename to Lab4/.editorconfig diff --git a/.gitignore b/Lab4/.gitignore similarity index 100% rename from .gitignore rename to Lab4/.gitignore diff --git a/Lab4.AddSurname/Duomenys.txt b/Lab4/Lab4.AddSurname/Duomenys.txt similarity index 100% rename from Lab4.AddSurname/Duomenys.txt rename to Lab4/Lab4.AddSurname/Duomenys.txt diff --git a/Lab4.AddSurname/Lab4.AddSurname.csproj b/Lab4/Lab4.AddSurname/Lab4.AddSurname.csproj similarity index 100% rename from Lab4.AddSurname/Lab4.AddSurname.csproj rename to Lab4/Lab4.AddSurname/Lab4.AddSurname.csproj diff --git a/Lab4.AddSurname/Program.cs b/Lab4/Lab4.AddSurname/Program.cs similarity index 100% rename from Lab4.AddSurname/Program.cs rename to Lab4/Lab4.AddSurname/Program.cs diff --git a/Lab4.AddSurname/TaskUtils.cs b/Lab4/Lab4.AddSurname/TaskUtils.cs similarity index 100% rename from Lab4.AddSurname/TaskUtils.cs rename to Lab4/Lab4.AddSurname/TaskUtils.cs diff --git a/Lab4.ChainedWords/InOut.cs b/Lab4/Lab4.ChainedWords/InOut.cs similarity index 100% rename from Lab4.ChainedWords/InOut.cs rename to Lab4/Lab4.ChainedWords/InOut.cs diff --git a/Lab4.ChainedWords/Knyga.txt b/Lab4/Lab4.ChainedWords/Knyga.txt similarity index 100% rename from Lab4.ChainedWords/Knyga.txt rename to Lab4/Lab4.ChainedWords/Knyga.txt diff --git a/Lab4.ChainedWords/Lab4.ChainedWords.csproj b/Lab4/Lab4.ChainedWords/Lab4.ChainedWords.csproj similarity index 100% rename from Lab4.ChainedWords/Lab4.ChainedWords.csproj rename to Lab4/Lab4.ChainedWords/Lab4.ChainedWords.csproj diff --git a/Lab4.ChainedWords/Program.cs b/Lab4/Lab4.ChainedWords/Program.cs similarity index 100% rename from Lab4.ChainedWords/Program.cs rename to Lab4/Lab4.ChainedWords/Program.cs diff --git a/Lab4.ChainedWords/TaskUtils.cs b/Lab4/Lab4.ChainedWords/TaskUtils.cs similarity index 100% rename from Lab4.ChainedWords/TaskUtils.cs rename to Lab4/Lab4.ChainedWords/TaskUtils.cs diff --git a/Lab4.ChainedWords/tests/1/Knyga.txt b/Lab4/Lab4.ChainedWords/tests/1/Knyga.txt similarity index 100% rename from Lab4.ChainedWords/tests/1/Knyga.txt rename to Lab4/Lab4.ChainedWords/tests/1/Knyga.txt diff --git a/Lab4.ChainedWords/tests/2/Knyga.txt b/Lab4/Lab4.ChainedWords/tests/2/Knyga.txt similarity index 100% rename from Lab4.ChainedWords/tests/2/Knyga.txt rename to Lab4/Lab4.ChainedWords/tests/2/Knyga.txt diff --git a/Lab4.FirstEqualLast/Duomenys.txt b/Lab4/Lab4.FirstEqualLast/Duomenys.txt similarity index 100% rename from Lab4.FirstEqualLast/Duomenys.txt rename to Lab4/Lab4.FirstEqualLast/Duomenys.txt diff --git a/Lab4.FirstEqualLast/Lab4.FirstEqualLast.csproj b/Lab4/Lab4.FirstEqualLast/Lab4.FirstEqualLast.csproj similarity index 100% rename from Lab4.FirstEqualLast/Lab4.FirstEqualLast.csproj rename to Lab4/Lab4.FirstEqualLast/Lab4.FirstEqualLast.csproj diff --git a/Lab4.FirstEqualLast/Program.cs b/Lab4/Lab4.FirstEqualLast/Program.cs similarity index 100% rename from Lab4.FirstEqualLast/Program.cs rename to Lab4/Lab4.FirstEqualLast/Program.cs diff --git a/Lab4.FirstEqualLast/TaskUtils.cs b/Lab4/Lab4.FirstEqualLast/TaskUtils.cs similarity index 100% rename from Lab4.FirstEqualLast/TaskUtils.cs rename to Lab4/Lab4.FirstEqualLast/TaskUtils.cs diff --git a/Lab4.K2/Lab4.K2.csproj b/Lab4/Lab4.K2/Lab4.K2.csproj similarity index 100% rename from Lab4.K2/Lab4.K2.csproj rename to Lab4/Lab4.K2/Lab4.K2.csproj diff --git a/Lab4.K2/Program.cs b/Lab4/Lab4.K2/Program.cs similarity index 100% rename from Lab4.K2/Program.cs rename to Lab4/Lab4.K2/Program.cs diff --git a/Lab4.K2/Tekstas.txt b/Lab4/Lab4.K2/Tekstas.txt similarity index 100% rename from Lab4.K2/Tekstas.txt rename to Lab4/Lab4.K2/Tekstas.txt diff --git a/Lab4.LetterFrequency/Duomenys.txt b/Lab4/Lab4.LetterFrequency/Duomenys.txt similarity index 100% rename from Lab4.LetterFrequency/Duomenys.txt rename to Lab4/Lab4.LetterFrequency/Duomenys.txt diff --git a/Lab4.LetterFrequency/InOut.cs b/Lab4/Lab4.LetterFrequency/InOut.cs similarity index 100% rename from Lab4.LetterFrequency/InOut.cs rename to Lab4/Lab4.LetterFrequency/InOut.cs diff --git a/Lab4.LetterFrequency/Lab4.LetterFrequency.csproj b/Lab4/Lab4.LetterFrequency/Lab4.LetterFrequency.csproj similarity index 100% rename from Lab4.LetterFrequency/Lab4.LetterFrequency.csproj rename to Lab4/Lab4.LetterFrequency/Lab4.LetterFrequency.csproj diff --git a/Lab4.LetterFrequency/LettersFrequency.cs b/Lab4/Lab4.LetterFrequency/LettersFrequency.cs similarity index 100% rename from Lab4.LetterFrequency/LettersFrequency.cs rename to Lab4/Lab4.LetterFrequency/LettersFrequency.cs diff --git a/Lab4.LetterFrequency/Program.cs b/Lab4/Lab4.LetterFrequency/Program.cs similarity index 100% rename from Lab4.LetterFrequency/Program.cs rename to Lab4/Lab4.LetterFrequency/Program.cs diff --git a/Lab4.RemoveComments/Duomenys.txt b/Lab4/Lab4.RemoveComments/Duomenys.txt similarity index 100% rename from Lab4.RemoveComments/Duomenys.txt rename to Lab4/Lab4.RemoveComments/Duomenys.txt diff --git a/Lab4.RemoveComments/InOut.cs b/Lab4/Lab4.RemoveComments/InOut.cs similarity index 100% rename from Lab4.RemoveComments/InOut.cs rename to Lab4/Lab4.RemoveComments/InOut.cs diff --git a/Lab4.RemoveComments/Lab4.RemoveComments.csproj b/Lab4/Lab4.RemoveComments/Lab4.RemoveComments.csproj similarity index 100% rename from Lab4.RemoveComments/Lab4.RemoveComments.csproj rename to Lab4/Lab4.RemoveComments/Lab4.RemoveComments.csproj diff --git a/Lab4.RemoveComments/Program.cs b/Lab4/Lab4.RemoveComments/Program.cs similarity index 100% rename from Lab4.RemoveComments/Program.cs rename to Lab4/Lab4.RemoveComments/Program.cs diff --git a/Lab4.RemoveComments/TaskUtils.cs b/Lab4/Lab4.RemoveComments/TaskUtils.cs similarity index 100% rename from Lab4.RemoveComments/TaskUtils.cs rename to Lab4/Lab4.RemoveComments/TaskUtils.cs diff --git a/Lab4.RemoveLines/Duomenys.txt b/Lab4/Lab4.RemoveLines/Duomenys.txt similarity index 100% rename from Lab4.RemoveLines/Duomenys.txt rename to Lab4/Lab4.RemoveLines/Duomenys.txt diff --git a/Lab4.RemoveLines/InOut.cs b/Lab4/Lab4.RemoveLines/InOut.cs similarity index 100% rename from Lab4.RemoveLines/InOut.cs rename to Lab4/Lab4.RemoveLines/InOut.cs diff --git a/Lab4.RemoveLines/Lab4.RemoveLines.csproj b/Lab4/Lab4.RemoveLines/Lab4.RemoveLines.csproj similarity index 100% rename from Lab4.RemoveLines/Lab4.RemoveLines.csproj rename to Lab4/Lab4.RemoveLines/Lab4.RemoveLines.csproj diff --git a/Lab4.RemoveLines/Program.cs b/Lab4/Lab4.RemoveLines/Program.cs similarity index 100% rename from Lab4.RemoveLines/Program.cs rename to Lab4/Lab4.RemoveLines/Program.cs diff --git a/Lab4.RemoveVowels/Duomenys.txt b/Lab4/Lab4.RemoveVowels/Duomenys.txt similarity index 100% rename from Lab4.RemoveVowels/Duomenys.txt rename to Lab4/Lab4.RemoveVowels/Duomenys.txt diff --git a/Lab4.RemoveVowels/Lab4.RemoveVowels.csproj b/Lab4/Lab4.RemoveVowels/Lab4.RemoveVowels.csproj similarity index 100% rename from Lab4.RemoveVowels/Lab4.RemoveVowels.csproj rename to Lab4/Lab4.RemoveVowels/Lab4.RemoveVowels.csproj diff --git a/Lab4.RemoveVowels/Program.cs b/Lab4/Lab4.RemoveVowels/Program.cs similarity index 100% rename from Lab4.RemoveVowels/Program.cs rename to Lab4/Lab4.RemoveVowels/Program.cs diff --git a/Lab4.RemoveVowels/TaskUtils.cs b/Lab4/Lab4.RemoveVowels/TaskUtils.cs similarity index 100% rename from Lab4.RemoveVowels/TaskUtils.cs rename to Lab4/Lab4.RemoveVowels/TaskUtils.cs diff --git a/Lab4.sln b/Lab4/Lab4.sln similarity index 100% rename from Lab4.sln rename to Lab4/Lab4.sln diff --git a/README.md b/Lab4/README.md similarity index 100% rename from README.md rename to Lab4/README.md diff --git a/global.json b/Lab4/global.json similarity index 100% rename from global.json rename to Lab4/global.json