I'm just wondering, why whould you translit by words? Is it faster?
and there are also some rules that should be applied for some letter, and then there are some exception words that I need to check with database...
That's why I choosed first to check for certain letters, then for exception words, and then translit the rest of the document letter by letter.
Skydiver, on 13 January 2013 - 10:55 AM, said:
If I had to tackle this project the way I would go about it is I would have a single interface for getting words and putting back words, and multiple classes for reading and writing. Something like:
interface IFileReaderWriter : IDisposable
{
bool MoveNext();
string Current { get; set; }
}
void TranslitFile(string fileName)
{
using (IFileReaderWriter readerWriter = CreateReaderWriter(fileName))
{
while (readerWriter.MoveNext())
{
string word = TranslitWord(readerWriter.Current));
readerWriter.Current = word;
}
}
}
string TranslitWord(string word)
{
// returns a translit version of the incoming word
}
IFileReaderWriter CreateReaderWriter(string fileName)
{
if (Word97ReaderWriter.IsValid(fileName))
return new Word97ReaderWriter(fileName);
if (Word2007ReaderWriter.IsValid(fileName))
return new Word2007ReaderWriter(fileName);
if (PdfReaderWriter.IsValid(fileName))
return new PdfReaderWriter(fileName);
:
}
class Word2007ReaderWriter : IFileReaderWriter
{
public static IsValid(string fileName)
{
// return true if file is a Word2007 file
}
public Word2007ReaderWriter(string fileName)
{
// open the file
}
public override bool MoveNext()
{
// write Current word to the file
// read the next word into Current
// return false if end of file
}
public override string Current { get; set; }
public override void Dispose()
{
// flush all changes to the file
// close the file
}
}

New Topic/Question
Reply





MultiQuote



|