Skip to content
Snippets Groups Projects
Commit 481b846d authored by Sebastian Schwarz's avatar Sebastian Schwarz
Browse files

fixed textdocs

parent cd45ac86
No related branches found
No related tags found
No related merge requests found
No preview for this file type
...@@ -8,12 +8,16 @@ namespace Levenshtein ...@@ -8,12 +8,16 @@ namespace Levenshtein
{ {
public class CardMechanic public class CardMechanic
{ {
const string pathScrambled = "../../../textdocs/scrambled.txt";
const string pathReference = "../../../textdocs/reference.txt";
const string pathFixed = "../../../textdocs/fixed.txt";
private List<Cards> _cards = new List<Cards>(); private List<Cards> _cards = new List<Cards>();
private List<string> _references = new List<string>(); private List<string> _references = new List<string>();
public void ReadFromScrambled() public void ReadFromScrambled()
{ {
var read = System.IO.File.ReadLines(@"E:\Downloads\scrambled.txt"); var read = System.IO.File.ReadLines(pathScrambled);
foreach (string line in read) foreach (string line in read)
{ {
...@@ -35,7 +39,7 @@ namespace Levenshtein ...@@ -35,7 +39,7 @@ namespace Levenshtein
public void CardsToFile() public void CardsToFile()
{ {
using (StreamWriter writer = new StreamWriter(@"E:\Downloads\test.txt")) using (StreamWriter writer = new StreamWriter(pathFixed))
{ {
foreach (Cards card in _cards) foreach (Cards card in _cards)
{ {
...@@ -46,29 +50,33 @@ namespace Levenshtein ...@@ -46,29 +50,33 @@ namespace Levenshtein
public void ReadFromReference() public void ReadFromReference()
{ {
var read = System.IO.File.ReadLines(@"E:\Downloads\reference.txt"); var read = System.IO.File.ReadLines(pathReference);
foreach (string line in read) foreach (string line in read)
{ {
_references.Add(line); _references.Add(line);
System.Console.WriteLine(line.Length);
} }
} }
public void RestoreCards() public void RestoreCards()
{ {
//int counter = 0;
foreach (Cards card in _cards) foreach (Cards card in _cards)
{ {
foreach (string reference in _references) foreach (string reference in _references)
{ {
Levenshtein l = new Levenshtein(card.Name, reference); Levenshtein l = new Levenshtein(card.Name, reference);
if ((l.LevenshteinDistance() / (reference.Length)) < 0.275) if ((l.LevenshteinDistance() < (reference.Length * 0.2675)))
{ {
System.Console.WriteLine(card.Name); card.Name = reference;
System.Console.WriteLine(reference); //System.Console.WriteLine(card.Name);
//System.Console.WriteLine(reference);
//counter++;
} }
} }
} }
//System.Console.WriteLine(counter);
CardsToFile();
} }
} }
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment