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

relative Paths addes

parent 32fcb4b0
No related branches found
No related tags found
No related merge requests found
...@@ -8,12 +8,16 @@ namespace Levenshtein ...@@ -8,12 +8,16 @@ namespace Levenshtein
{ {
public class CardMechanic public class CardMechanic
{ {
const string pathScrambled = "../../../Textfiles/scrambled.txt";
const string pathReference = "../../../Textfiles/reference.txt";
const string pathFixed = "../../../Textfiles/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)))
{ {
card.Name = reference;
System.Console.WriteLine(card.Name); System.Console.WriteLine(card.Name);
System.Console.WriteLine(reference); System.Console.WriteLine(reference);
counter++;
} }
} }
} }
System.Console.WriteLine(counter);
CardsToFile();
} }
} }
......
...@@ -10,13 +10,11 @@ namespace Levenshtein ...@@ -10,13 +10,11 @@ namespace Levenshtein
{ {
private static void Main(string[] args) private static void Main(string[] args)
{ {
Levenshtein test = new Levenshtein("industry", "interests");
test.LevenshteinDistance();
CardMechanic test1 = new CardMechanic(); CardMechanic test1 = new CardMechanic();
test1.ReadFromScrambled(); test1.ReadFromScrambled();
test1.ReadFromReference(); test1.ReadFromReference();
//test1.RestoreCards(); test1.RestoreCards();
......
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
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