-
Notifications
You must be signed in to change notification settings - Fork 0
/
SyllabicWord.cs
79 lines (65 loc) · 1.63 KB
/
SyllabicWord.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Grammophone.GenericContentModel;
namespace Grammophone.LanguageModel
{
/// <summary>
/// A word represented with syllables.
/// </summary>
/// <remarks>
/// Supports fast equality checks and it is suitable for hashtables.
/// </remarks>
[System.Diagnostics.DebuggerDisplay("{ToString()}")]
[Serializable]
public class SyllabicWord : EquatableReadOnlySequence<string>
{
#region Construction
/// <summary>
/// Create.
/// </summary>
/// <param name="syllables">The syllables of the word.</param>
public SyllabicWord(string[] syllables)
: base(syllables)
{
}
/// <summary>
/// Create.
/// </summary>
/// <param name="syllables">The syllables of the word.</param>
public SyllabicWord(ICollection<string> syllables)
: base(syllables)
{
}
/// <summary>
/// Create.
/// </summary>
/// <param name="syllables">The syllables of the word.</param>
public SyllabicWord(IEnumerable<string> syllables)
: base(syllables)
{
}
#endregion
#region Public methods
/// <summary>
/// Returns a representation of the syllables, in reverse order.
/// </summary>
/// <remarks>
/// Reversed syllable order is more common among language providers,
/// because most languages have heavier inflection towards the suffix.
/// </remarks>
public override string ToString()
{
var builder = new StringBuilder();
for (int i = this.Count - 1; i >= 0; i--)
{
var syllable = this[i];
builder.Append(syllable);
builder.Append(' ');
}
return builder.ToString();
}
#endregion
}
}