public void testCreationWithDetokenizer() { var detokenizer = DictionaryDetokenizerTest.CreateLatinDetokenizer(); var tokens = new[] { "start", "(", // move right ")", // move left "end", ".", // move left "hyphen", "-", // move both "string", "." }; var a = new TokenSample(detokenizer, tokens); Assert.AreEqual("start () end. hyphen-string.", a.Text); // 0123456789012345678901234567 Assert.AreEqual("start (" + TokenSample.DefaultSeparator + ") end" + TokenSample.DefaultSeparator + "." + " hyphen" + TokenSample.DefaultSeparator + "-" + TokenSample.DefaultSeparator + "string" + TokenSample.DefaultSeparator + ".", a.ToString()); Assert.AreEqual(9, a.TokenSpans.Length); Assert.AreEqual(new Span(0, 5), a.TokenSpans[0]); Assert.AreEqual(new Span(6, 7), a.TokenSpans[1]); Assert.AreEqual(new Span(7, 8), a.TokenSpans[2]); Assert.AreEqual(new Span(9, 12), a.TokenSpans[3]); Assert.AreEqual(new Span(12, 13), a.TokenSpans[4]); Assert.AreEqual(new Span(14, 20), a.TokenSpans[5]); Assert.AreEqual(new Span(20, 21), a.TokenSpans[6]); Assert.AreEqual(new Span(21, 27), a.TokenSpans[7]); Assert.AreEqual(new Span(27, 28), a.TokenSpans[8]); }
/// <summary> /// Equalses the specified other. /// </summary> /// <param name="other">The other.</param> /// <returns><c>true</c> if if the specified object is equal to the current object<c>false</c> otherwise.</returns> protected bool Equals(TokenSample other) { return(Text == other.Text && TokenSpans.SequenceEqual(other.TokenSpans)); }
public void testRetrievingContent() { const string sentence = "A test"; var sample = new TokenSample(sentence, new[] {new Span(0, 1), new Span(2, 6)}); Assert.AreEqual("A test", sample.Text); Assert.AreEqual(new Span(0, 1), sample.TokenSpans[0]); Assert.AreEqual(new Span(2, 6), sample.TokenSpans[1]); }
/// <summary> /// Equalses the specified other. /// </summary> /// <param name="other">The other.</param> /// <returns><c>true</c> if if the specified object is equal to the current object<c>false</c> otherwise.</returns> protected bool Equals(TokenSample other) { return Text == other.Text && TokenSpans.SequenceEqual(other.TokenSpans); }