Browse Source

Initial commit

Piotr Czajkowski 3 years ago
commit
d2bd33c7dc

+ 352 - 0
.gitignore

@@ -0,0 +1,352 @@
+## 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/
+[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/
+
+# 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
+*.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
+
+# 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
+
+# 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/
+
+.idea/

+ 11 - 0
LICENSE.md

@@ -0,0 +1,11 @@
+Copyright 2020- Piotr Czajkowski
+
+Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
+
+1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
+
+2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
+
+3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

+ 2 - 0
README.md

@@ -0,0 +1,2 @@
+# memoQAnalysis
+Reading CSV files with analysis produced by memoQ isn't easy as they're designed to be human rather than machine readable. I've created this library to make it smoother.

+ 31 - 0
memoQAnalysis.sln

@@ -0,0 +1,31 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 16
+VisualStudioVersion = 16.0.30114.105
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "memoQAnalysis", "memoQAnalysis\memoQAnalysis.csproj", "{BF7DEBB1-7B29-46A8-9D7B-A3E75921CAC5}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "memoQAnalysisTests", "memoQAnalysisTests\memoQAnalysisTests.csproj", "{BE5BB184-C3EC-47DA-9CCC-73897B347BE6}"
+EndProject
+Global
+	GlobalSection(SolutionConfigurationPlatforms) = preSolution
+		Debug|Any CPU = Debug|Any CPU
+		Release|Any CPU = Release|Any CPU
+	EndGlobalSection
+	GlobalSection(ProjectConfigurationPlatforms) = postSolution
+		{BF7DEBB1-7B29-46A8-9D7B-A3E75921CAC5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{BF7DEBB1-7B29-46A8-9D7B-A3E75921CAC5}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{BF7DEBB1-7B29-46A8-9D7B-A3E75921CAC5}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{BF7DEBB1-7B29-46A8-9D7B-A3E75921CAC5}.Release|Any CPU.Build.0 = Release|Any CPU
+		{BE5BB184-C3EC-47DA-9CCC-73897B347BE6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{BE5BB184-C3EC-47DA-9CCC-73897B347BE6}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{BE5BB184-C3EC-47DA-9CCC-73897B347BE6}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{BE5BB184-C3EC-47DA-9CCC-73897B347BE6}.Release|Any CPU.Build.0 = Release|Any CPU
+	EndGlobalSection
+	GlobalSection(SolutionProperties) = preSolution
+		HideSolutionNode = FALSE
+	EndGlobalSection
+	GlobalSection(ExtensibilityGlobals) = postSolution
+		SolutionGuid = {C9C155C1-A958-4459-BF88-BE0037EBD1A5}
+	EndGlobalSection
+EndGlobal

+ 93 - 0
memoQAnalysis/Analysis.cs

@@ -0,0 +1,93 @@
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.IO;
+using System.Linq;
+using CsvHelper;
+using CsvHelper.Configuration;
+
+namespace memoQAnalysis
+{
+    public class Analysis
+    {
+        public List<MemoQAnalysis> Data { get; }
+
+        private readonly string _delimiter;
+
+        public Analysis(string path, string delimiter = ",")
+        {
+            _delimiter = delimiter;
+            Data = ReadFromFile(path);
+        }
+
+        public Analysis(byte[] data, string delimiter = ";")
+        {
+            _delimiter = delimiter;
+            Data = ReadData(data);
+        }
+
+        private List<MemoQAnalysis> ReadFromFile(string path)
+        {
+            using (var sr = new StreamReader(path))
+            {
+                return ReadData(sr);
+            }
+        }
+
+        private List<MemoQAnalysis> ReadData(StreamReader streamReader)
+        {
+            var configuration = new CsvConfiguration(CultureInfo.InvariantCulture)
+            {
+                Delimiter = _delimiter
+            };
+
+            using (var csv = new CsvReader(streamReader, configuration))
+            {
+                var firstLine = streamReader.ReadLine();
+                if (!string.IsNullOrWhiteSpace(firstLine) && firstLine.StartsWith("file", StringComparison.InvariantCultureIgnoreCase))
+                {
+                    streamReader.BaseStream.Position = 0;
+                    streamReader.DiscardBufferedData();
+                }
+
+                var result = csv.GetRecords<MemoQAnalysis>().ToList();
+                return result;
+            }
+        }
+
+        private List<MemoQAnalysis> ReadData(byte[] data)
+        {
+            using (var ms = new MemoryStream(data))
+            using (var sr = new StreamReader(ms))
+            {
+                return ReadData(sr);
+            }
+        }
+
+        public int WordsToTranslateWithoutRepetitions()
+        {
+            var total = 0;
+            foreach (var file in Data)
+            {
+                total += file.NinentyFiveNineWords;
+                total += file.EightyFiveNinentyFourWords;
+                total += file.SeventyFiveEightyFourWords;
+                total += file.FiftySeventyFourWords;
+                total += file.NoMatchWords;
+            }
+
+            return total;
+        }
+
+        public int WordsToTranslateWithRepetitions()
+        {
+            var total = WordsToTranslateWithoutRepetitions();
+            foreach (var file in Data)
+            {
+                total += file.RepetitionsWords;
+            }
+
+            return total;
+        }
+    }
+}

+ 277 - 0
memoQAnalysis/MemoQAnalysis.cs

@@ -0,0 +1,277 @@
+using CsvHelper.Configuration.Attributes;
+
+namespace memoQAnalysis
+{
+    public class MemoQAnalysis
+    {
+        [Index(0)]
+        public string File { get; set; }
+
+        [Index(1)]
+        public double CharWord { get; set; }
+
+        [Index(2)]
+        public int XtranslatedSegments { get; set; }
+
+        [Index(3)]
+        public int XtranslatedWords { get; set; }
+
+        [Index(4)]
+        public int XtranslatedCharacters { get; set; }
+
+        [Index(5)]
+        public int XtranslatedAsianCharacters { get; set; }
+
+        [Index(6)]
+        public int XtranslatedTags { get; set; }
+
+        [Index(7)]
+        public int XtranslatedReserved1 { get; set; }
+
+        [Index(8)]
+        public int XtranslatedReserved2 { get; set; }
+
+        [Index(9)]
+        public int XtranslatedReserved3 { get; set; }
+
+        [Index(10)]
+        public int HundredOneSegments { get; set; }
+
+        [Index(11)]
+        public int HundredOneWords { get; set; }
+
+        [Index(12)]
+        public int HundredOneCharacters { get; set; }
+
+        [Index(13)]
+        public int HundredOneAsianCharacters { get; set; }
+
+        [Index(14)]
+        public int HundredOneTags { get; set; }
+
+        [Index(15)]
+        public int HundredOneReserved1 { get; set; }
+
+        [Index(16)]
+        public int HundredOneReserved2 { get; set; }
+
+        [Index(17)]
+        public int HundredOneReserved3 { get; set; }
+
+        [Index(18)]
+        public int RepetitionsSegments { get; set; }
+
+        [Index(19)]
+        public int RepetitionsWords { get; set; }
+
+        [Index(20)]
+        public int RepetitionsCharacters { get; set; }
+
+        [Index(21)]
+        public int RepetitionsAsianCharacters { get; set; }
+
+        [Index(22)]
+        public int RepetitionsTags { get; set; }
+
+        [Index(23)]
+        public int RepetitionsReserved1 { get; set; }
+
+        [Index(24)]
+        public int RepetitionsReserved2 { get; set; }
+
+        [Index(25)]
+        public int RepetitionsReserved3 { get; set; }
+
+        [Index(26)]
+        public int HundredSegments { get; set; }
+
+        [Index(27)]
+        public int HundredWords { get; set; }
+
+        [Index(28)]
+        public int HundredCharacters { get; set; }
+
+        [Index(29)]
+        public int HundredAsianCharacters { get; set; }
+
+        [Index(30)]
+        public int HundredTags { get; set; }
+
+        [Index(31)]
+        public int HundredReserved1 { get; set; }
+
+        [Index(32)]
+        public int HundredReserved2 { get; set; }
+
+        [Index(33)]
+        public int HundredReserved3 { get; set; }
+
+        [Index(34)]
+        public int NinentyFiveNineSegments { get; set; }
+
+        [Index(35)]
+        public int NinentyFiveNineWords { get; set; }
+
+        [Index(36)]
+        public int NinentyFiveNineCharacters { get; set; }
+
+        [Index(37)]
+        public int NinentyFiveNineAsianCharacters { get; set; }
+
+        [Index(38)]
+        public int NinentyFiveNineTags { get; set; }
+
+        [Index(39)]
+        public int NinentyFiveNineReserved1 { get; set; }
+
+        [Index(40)]
+        public int NinentyFiveNineReserved2 { get; set; }
+
+        [Index(41)]
+        public int NinentyFiveNineReserved3 { get; set; }
+
+        [Index(42)]
+        public int EightyFiveNinentyFourSegments { get; set; }
+
+        [Index(43)]
+        public int EightyFiveNinentyFourWords { get; set; }
+
+        [Index(44)]
+        public int EightyFiveNinentyFourCharacters { get; set; }
+
+        [Index(45)]
+        public int EightyFiveNinentyFourAsianCharacters { get; set; }
+
+        [Index(46)]
+        public int EightyFiveNinentyFourTags { get; set; }
+
+        [Index(47)]
+        public int EightyFiveNinentyFourReserved1 { get; set; }
+
+        [Index(48)]
+        public int EightyFiveNinentyFourReserved2 { get; set; }
+
+        [Index(49)]
+        public int EightyFiveNinentyFourReserved3 { get; set; }
+
+        [Index(50)]
+        public int SeventyFiveEightyFourSegments { get; set; }
+
+        [Index(51)]
+        public int SeventyFiveEightyFourWords { get; set; }
+
+        [Index(52)]
+        public int SeventyFiveEightyFourCharacters { get; set; }
+
+        [Index(53)]
+        public int SeventyFiveEightyFourAsianCharacters { get; set; }
+
+        [Index(54)]
+        public int SeventyFiveEightyFourTags { get; set; }
+
+        [Index(55)]
+        public int SeventyFiveEightyFourReserved1 { get; set; }
+
+        [Index(56)]
+        public int SeventyFiveEightyFourReserved2 { get; set; }
+
+        [Index(57)]
+        public int SeventyFiveEightyFourReserved3 { get; set; }
+
+        [Index(58)]
+        public int FiftySeventyFourSegments { get; set; }
+
+        [Index(59)]
+        public int FiftySeventyFourWords { get; set; }
+
+        [Index(60)]
+        public int FiftySeventyFourCharacters { get; set; }
+
+        [Index(61)]
+        public int FiftySeventyFourAsianCharacters { get; set; }
+
+        [Index(62)]
+        public int FiftySeventyFourTags { get; set; }
+
+        [Index(63)]
+        public int FiftySeventyFourReserved1 { get; set; }
+
+        [Index(64)]
+        public int FiftySeventyFourReserved2 { get; set; }
+
+        [Index(65)]
+        public int FiftySeventyFourReserved3 { get; set; }
+
+        [Index(66)]
+        public int NoMatchSegments { get; set; }
+
+        [Index(67)]
+        public int NoMatchWords { get; set; }
+
+        [Index(68)]
+        public int NoMatchCharacters { get; set; }
+
+        [Index(69)]
+        public int NoMatchAsianCharacters { get; set; }
+
+        [Index(70)]
+        public int NoMatchTags { get; set; }
+
+        [Index(71)]
+        public int NoMatchReserved1 { get; set; }
+
+        [Index(72)]
+        public int NoMatchReserved2 { get; set; }
+
+        [Index(73)]
+        public int NoMatchReserved3 { get; set; }
+
+        [Index(74)]
+        public int FragmentsSegments { get; set; }
+
+        [Index(75)]
+        public int FragmentsWords { get; set; }
+
+        [Index(76)]
+        public int FragmentsCharacters { get; set; }
+
+        [Index(77)]
+        public int FragmentsAsianCharacters { get; set; }
+
+        [Index(78)]
+        public int FragmentsTags { get; set; }
+
+        [Index(79)]
+        public int FragmentsReserved1 { get; set; }
+
+        [Index(80)]
+        public int FragmentsReserved2 { get; set; }
+
+        [Index(81)]
+        public int FragmentsReserved3 { get; set; }
+
+        [Index(82)]
+        public int TotalSegments { get; set; }
+
+        [Index(83)]
+        public int TotalWords { get; set; }
+
+        [Index(84)]
+        public int TotalCharacters { get; set; }
+
+        [Index(85)]
+        public int TotalAsianCharacters { get; set; }
+
+        [Index(86)]
+        public int TotalTags { get; set; }
+
+        [Index(87)]
+        public int TotalReserved1 { get; set; }
+
+        [Index(88)]
+        public int TotalReserved2 { get; set; }
+
+        [Index(89)]
+        public int TotalReserved3 { get; set; }
+    }
+}

+ 11 - 0
memoQAnalysis/memoQAnalysis.csproj

@@ -0,0 +1,11 @@
+<Project Sdk="Microsoft.NET.Sdk">
+  <PropertyGroup>
+    <TargetFrameworks>netcoreapp3.1;net472</TargetFrameworks>
+  </PropertyGroup>
+  <ItemGroup>
+    <PackageReference Include="CsvHelper" Version="15.0.5" />
+  </ItemGroup>
+  <ItemGroup>
+    <Folder Include="Properties\" />
+  </ItemGroup>
+</Project>

+ 8 - 0
memoQAnalysis/packages.config

@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="utf-8"?>
+<packages>
+  <package id="CsvHelper" version="15.0.5" targetFramework="net472" />
+  <package id="Microsoft.Bcl.AsyncInterfaces" version="1.1.0" targetFramework="net472" />
+  <package id="Microsoft.CSharp" version="4.5.0" targetFramework="net472" />
+  <package id="System.Runtime.CompilerServices.Unsafe" version="4.5.2" targetFramework="net472" />
+  <package id="System.Threading.Tasks.Extensions" version="4.5.2" targetFramework="net472" />
+</packages>

+ 56 - 0
memoQAnalysisTests/AnalysisTests.cs

@@ -0,0 +1,56 @@
+using System.IO;
+using memoQAnalysis;
+using Xunit;
+
+namespace memoQAnalysisTests
+{
+    public class AnalysisTests
+    {
+        private const string MainTestFile = "./testFiles/utf8.csv";
+        private const string UTF16TestFile = "./testFiles/utf16.csv";
+        private const string UTF16NoHeaderTestFile = "./testFiles/utf16NoHeader.csv";
+
+        [Fact]
+        public void ReadAnalysisUTF8Comma()
+        {
+            var test = new Analysis(MainTestFile);
+            Assert.Equal(3, test.Data.Count);
+        }
+
+        [Fact]
+        public void ReadAnalysisUTF16Semicolon()
+        {
+            var test = new Analysis(UTF16TestFile, ";");
+            Assert.Equal(3, test.Data.Count);
+        }
+
+        [Fact]
+        public void ReadAnalysisUTF16SemicolonNoHeader()
+        {
+            var test = new Analysis(UTF16NoHeaderTestFile, ";");
+            Assert.Equal(3, test.Data.Count);
+        }
+
+        [Fact]
+        public void WordsToTranslateWithoutRepetitions()
+        {
+            var test = new Analysis(MainTestFile);
+            Assert.Equal(0, test.WordsToTranslateWithoutRepetitions());
+        }
+
+        [Fact]
+        public void WordsToTranslateWithRepetitions()
+        {
+            var test = new Analysis(MainTestFile);
+            Assert.Equal(601, test.WordsToTranslateWithRepetitions());
+        }
+        
+        [Fact]
+        public void ReadAnalysisFromBytes()
+        {
+            var data = File.ReadAllBytes(UTF16TestFile);
+            var test = new Analysis(data);
+            Assert.Equal(3, test.Data.Count);
+        }
+    }
+}

+ 30 - 0
memoQAnalysisTests/memoQAnalysisTests.csproj

@@ -0,0 +1,30 @@
+<Project Sdk="Microsoft.NET.Sdk">
+  <PropertyGroup>
+    <TargetFramework>netcoreapp3.1</TargetFramework>
+    <IsPackable>false</IsPackable>
+  </PropertyGroup>
+  <ItemGroup>
+    <PackageReference Include="xunit" Version="2.4.1" />
+    <PackageReference Include="xunit.runner.visualstudio" Version="2.4.1">
+      <PrivateAssets>all</PrivateAssets>
+      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
+    </PackageReference>
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="..\memoQAnalysis\memoQAnalysis.csproj" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Update="testFiles\utf16.csv">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </None>
+    <None Update="testFiles\utf16NoHeader.csv">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </None>
+    <None Update="testFiles\utf8.csv">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </None>
+  </ItemGroup>
+  <ItemGroup>
+    <Folder Include="Properties\" />
+  </ItemGroup>
+</Project>

+ 13 - 0
memoQAnalysisTests/packages.config

@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="utf-8"?>
+<packages>
+  <package id="MSTest.TestAdapter" version="2.1.1" targetFramework="net472" />
+  <package id="MSTest.TestFramework" version="2.1.1" targetFramework="net472" />
+  <package id="xunit" version="2.4.1" targetFramework="net472" />
+  <package id="xunit.abstractions" version="2.0.3" targetFramework="net472" />
+  <package id="xunit.analyzers" version="0.10.0" targetFramework="net472" />
+  <package id="xunit.assert" version="2.4.1" targetFramework="net472" />
+  <package id="xunit.core" version="2.4.1" targetFramework="net472" />
+  <package id="xunit.extensibility.core" version="2.4.1" targetFramework="net472" />
+  <package id="xunit.extensibility.execution" version="2.4.1" targetFramework="net472" />
+  <package id="xunit.runner.visualstudio" version="2.4.1" targetFramework="net472" developmentDependency="true" />
+</packages>

BIN
memoQAnalysisTests/testFiles/utf16.csv


BIN
memoQAnalysisTests/testFiles/utf16NoHeader.csv


+ 5 - 0
memoQAnalysisTests/testFiles/utf8.csv

@@ -0,0 +1,5 @@
+,,X-translated,,,,,,,,101%,,,,,,,,Repetitions,,,,,,,,100%,,,,,,,,95% - 99%,,,,,,,,85% - 94%,,,,,,,,75% - 84%,,,,,,,,50% - 74%,,,,,,,,No match,,,,,,,,Fragments,,,,,,,,Total,,,,,,,,
+File,Char/Word,Segments,Words,Characters,Asian characters,Tags,Reserved1,Reserved2,Reserved3,Segments,Words,Characters,Asian characters,Tags,Reserved1,Reserved2,Reserved3,Segments,Words,Characters,Asian characters,Tags,Reserved1,Reserved2,Reserved3,Segments,Words,Characters,Asian characters,Tags,Reserved1,Reserved2,Reserved3,Segments,Words,Characters,Asian characters,Tags,Reserved1,Reserved2,Reserved3,Segments,Words,Characters,Asian characters,Tags,Reserved1,Reserved2,Reserved3,Segments,Words,Characters,Asian characters,Tags,Reserved1,Reserved2,Reserved3,Segments,Words,Characters,Asian characters,Tags,Reserved1,Reserved2,Reserved3,Segments,Words,Characters,Asian characters,Tags,Reserved1,Reserved2,Reserved3,Segments,Words,Characters,Asian characters,Tags,Reserved1,Reserved2,Reserved3,Segments,Words,Characters,Asian characters,Tags,Reserved1,Reserved2,Reserved3,
+"[fre-CA] \!_In\source\en\778453.xml",5.51,0,0,0,0,0,0,0,0,116,1295,6932,0,17,0,0,0,48,57,344,0,56,0,0,0,205,895,5108,0,418,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,369,2247,12384,0,491,0,0,0,
+"[fre-CA] \!_In\source\en\778457.xml",5.55,0,0,0,0,0,0,0,0,196,1804,9839,0,175,0,0,0,39,227,1431,0,14,0,0,0,55,210,1163,0,240,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,290,2241,12433,0,429,0,0,0,
+"[fre-CA] \!_In\source\en\778463.xml",5.56,0,0,0,0,0,0,0,0,194,1891,10423,0,67,0,0,0,84,317,1766,0,51,0,0,0,104,227,1338,0,328,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,382,2435,13527,0,446,0,0,0,