annotate Implab/Parsing/IAlphabet.cs @ 107:f5220e5472ef v2

minor fixes and optimizations
author cin
date Tue, 11 Nov 2014 04:14:21 +0300
parents c0bf853aa04f
children 130781364799
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
55
c0bf853aa04f Added initial JSON support
cin
parents:
diff changeset
1 using System;
c0bf853aa04f Added initial JSON support
cin
parents:
diff changeset
2 using System.Collections.Generic;
c0bf853aa04f Added initial JSON support
cin
parents:
diff changeset
3 using System.Linq;
c0bf853aa04f Added initial JSON support
cin
parents:
diff changeset
4 using System.Text;
c0bf853aa04f Added initial JSON support
cin
parents:
diff changeset
5 using System.Threading.Tasks;
c0bf853aa04f Added initial JSON support
cin
parents:
diff changeset
6
c0bf853aa04f Added initial JSON support
cin
parents:
diff changeset
7 namespace Implab.Parsing {
c0bf853aa04f Added initial JSON support
cin
parents:
diff changeset
8 /// <summary>
c0bf853aa04f Added initial JSON support
cin
parents:
diff changeset
9 /// Алфавит. Множество символов, которые разбиты на классы, при этом классы имеют непрерывную нумерацию,
c0bf853aa04f Added initial JSON support
cin
parents:
diff changeset
10 /// что позволяет использовать их в качестве индексов массивов.
c0bf853aa04f Added initial JSON support
cin
parents:
diff changeset
11 /// </summary>
c0bf853aa04f Added initial JSON support
cin
parents:
diff changeset
12 /// <remarks>Далее вимволами алфавита будем называть классы исходных символов.</remarks>
c0bf853aa04f Added initial JSON support
cin
parents:
diff changeset
13 /// <typeparam name="TSymbol">Тип символов.</typeparam>
c0bf853aa04f Added initial JSON support
cin
parents:
diff changeset
14 public interface IAlphabet<TSymbol> {
c0bf853aa04f Added initial JSON support
cin
parents:
diff changeset
15 /// <summary>
c0bf853aa04f Added initial JSON support
cin
parents:
diff changeset
16 /// Количество символов в алфавите.
c0bf853aa04f Added initial JSON support
cin
parents:
diff changeset
17 /// </summary>
c0bf853aa04f Added initial JSON support
cin
parents:
diff changeset
18 int Count { get; }
c0bf853aa04f Added initial JSON support
cin
parents:
diff changeset
19 /// <summary>
c0bf853aa04f Added initial JSON support
cin
parents:
diff changeset
20 /// Добавляет новый символ в алфавит, если символ уже был добавлен, то
c0bf853aa04f Added initial JSON support
cin
parents:
diff changeset
21 /// возвращается ранее сопоставленный с символом класс.
c0bf853aa04f Added initial JSON support
cin
parents:
diff changeset
22 /// </summary>
c0bf853aa04f Added initial JSON support
cin
parents:
diff changeset
23 /// <param name="symbol">Символ для добавления.</param>
c0bf853aa04f Added initial JSON support
cin
parents:
diff changeset
24 /// <returns>Индекс класса, который попоставлен с символом.</returns>
c0bf853aa04f Added initial JSON support
cin
parents:
diff changeset
25 int DefineSymbol(TSymbol symbol);
c0bf853aa04f Added initial JSON support
cin
parents:
diff changeset
26 /// <summary>
c0bf853aa04f Added initial JSON support
cin
parents:
diff changeset
27 /// Доабвляем класс символов. Множеству указанных исходных символов
c0bf853aa04f Added initial JSON support
cin
parents:
diff changeset
28 /// будет сопоставлен символ в алфавите.
c0bf853aa04f Added initial JSON support
cin
parents:
diff changeset
29 /// </summary>
c0bf853aa04f Added initial JSON support
cin
parents:
diff changeset
30 /// <param name="symbols">Множестов исходных символов</param>
c0bf853aa04f Added initial JSON support
cin
parents:
diff changeset
31 /// <returns>Идентификатор символа алфавита.</returns>
c0bf853aa04f Added initial JSON support
cin
parents:
diff changeset
32 int DefineClass(IEnumerable<TSymbol> symbols);
c0bf853aa04f Added initial JSON support
cin
parents:
diff changeset
33 /// <summary>
c0bf853aa04f Added initial JSON support
cin
parents:
diff changeset
34 /// Создает карту обратного сопоставления символа алфавита и сопоставленным
c0bf853aa04f Added initial JSON support
cin
parents:
diff changeset
35 /// ему исходным символам.
c0bf853aa04f Added initial JSON support
cin
parents:
diff changeset
36 /// </summary>
c0bf853aa04f Added initial JSON support
cin
parents:
diff changeset
37 /// <returns></returns>
c0bf853aa04f Added initial JSON support
cin
parents:
diff changeset
38 List<TSymbol>[] CreateReverseMap();
c0bf853aa04f Added initial JSON support
cin
parents:
diff changeset
39 /// <summary>
c0bf853aa04f Added initial JSON support
cin
parents:
diff changeset
40 /// Создает новый алфавит на основе текущего, горппируя его сиволы в более
c0bf853aa04f Added initial JSON support
cin
parents:
diff changeset
41 /// крупные непересекающиеся классы символов.
c0bf853aa04f Added initial JSON support
cin
parents:
diff changeset
42 /// </summary>
c0bf853aa04f Added initial JSON support
cin
parents:
diff changeset
43 /// <param name="newAlphabet">Новый, пустой алфавит, в котором быдут определены классы.</param>
c0bf853aa04f Added initial JSON support
cin
parents:
diff changeset
44 /// <param name="classes">Множество классов символов текущего алфавита.</param>
c0bf853aa04f Added initial JSON support
cin
parents:
diff changeset
45 /// <returns>Карта для перехода символов текущего
c0bf853aa04f Added initial JSON support
cin
parents:
diff changeset
46 /// алфавита к символам нового.</returns>
c0bf853aa04f Added initial JSON support
cin
parents:
diff changeset
47 int[] Reclassify(IAlphabet<TSymbol> newAlphabet, IEnumerable<ICollection<int>> classes);
c0bf853aa04f Added initial JSON support
cin
parents:
diff changeset
48
c0bf853aa04f Added initial JSON support
cin
parents:
diff changeset
49 /// <summary>
c0bf853aa04f Added initial JSON support
cin
parents:
diff changeset
50 /// Преобразует входной символ в индекс символа из алфавита.
c0bf853aa04f Added initial JSON support
cin
parents:
diff changeset
51 /// </summary>
c0bf853aa04f Added initial JSON support
cin
parents:
diff changeset
52 /// <param name="symobl">Исходный символ</param>
c0bf853aa04f Added initial JSON support
cin
parents:
diff changeset
53 /// <returns>Индекс в алфавите</returns>
c0bf853aa04f Added initial JSON support
cin
parents:
diff changeset
54 int Translate(TSymbol symobl);
c0bf853aa04f Added initial JSON support
cin
parents:
diff changeset
55 }
c0bf853aa04f Added initial JSON support
cin
parents:
diff changeset
56 }