1.
1
public void Parse() | ||
{ | ||
using (FileStream stream = new FileStream(_filePath, FileMode.Open, FileAccess.Read)) | ||
{ | ||
StreamReader reader = new StreamReader(stream); | ||
while (!reader.EndOfStream) | ||
{ | ||
string line = reader.ReadLine().ToLower(); | ||
int openBracket; | ||
string initialForm = ""; | ||
try | ||
{ | ||
openBracket = line.IndexOf('('); | ||
if (openBracket == -1) | ||
throw new DictionaryException(_dictionaryType, | ||
DictionaryExceptionReason. ); | ||
initialForm = string.Concat(line.Where((c, i) => i < openBracket)).Trim().ToUpper(); | ||
} | ||
catch | ||
{ | ||
throw new DictionaryException(_dictionaryType, | ||
DictionaryExceptionReason. ); | ||
} | ||
Dictionary[initialForm] = new List<string>() {initialForm}; | ||
Dictionary[initialForm].AddRange(line.Substring(openBracket + 1) | ||
.Split(new string[] {",", ")"}, | ||
StringSplitOptions. RemoveEmptyEntries) | ||
.Select(s => s.Trim().ToUpper()) | ||
.ToList()); | ||
} | ||
reader.Close(); | ||
} | ||
} |
- ( 3).
3. - DictionaryParser.Parse
. Dictionary .
(. 4).
4. DictionaryParser.Parse
, . :
1) V(G) = = 4
2) V(G) = + 2 = 15 13 + 2 = 4
3) V(G) = +1 = 3 + 1 = 4
, 4 , .
, . .
:
1) 1-12-13
2) 1-2-3-12-13
3) 1-2-3-4-5-6-8-10-11-3-12-13
4) 1-2-3-4-5-6-7-9-10-11-3-12-13
|
|
( 3-4--11 )
. (), (. .) , (. .), 5. .
5.
. . | ||
.txt | FileNotFoundException, Program.Main. | |
.txt | DictionaryParser.Dictionary . | |
.txt : (, , , ) (, , , ) | DictionaryParser.Dictionary : -> [0]: "" [1]: "" [2]: "" [3]: "" [4]: "" -> [0]: "" [1]: "" [2]: "" [3]: "" [4]: "" | |
.txt : , , , ) : ( | DictionaryException, Program.Main. |