public void RecogniseAZero_GivenSingleToken_Recognises() { var ocr = new Ocr(new []{new ZeroRecogniser(), }); var token = new Token { Raw = new List<string> { {" _ "}, {"| |"}, {"|_|"} } }; var digits = ocr.Recognise(token); Assert.That(digits[0], Is.EqualTo(0)); }
public void TryMatch_GivenZero_Matches() { var token = new Token { Raw = new List<string> { {" _ "}, {"| |"}, {"|_|"} } }; var zr = new ZeroRecogniser(); var result = zr.TryMatch(token); Assert.That(result.Item1, Is.True); }
public List<Token> TokeniseLine(string input) { var tokens = new List<Token>(); var lines = input.Split(new[] {Environment.NewLine}, StringSplitOptions.RemoveEmptyEntries); for (var startIndex = 0; startIndex < lines[0].Length; startIndex = startIndex+3) { var token = new Token(); token.Raw.Add(lines[0].Substring(startIndex, 3)); token.Raw.Add(lines[1].Substring(startIndex, 3)); token.Raw.Add(lines[2].Substring(startIndex, 3)); tokens.Add(token); } return tokens; }
public Tuple<bool, string> TryMatch(Token token) { var matches = string.Concat(_pattern) == string.Concat(token.Raw); return new Tuple<bool, string>(matches, "0"); }