Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

Multiple convolution neural networks approach for online handwriting recognition

, 9 Apr 2013
The research focuses on the presentation of word recognition technique for an online handwriting recognition system which uses multiple component neural networks (MCNN) as the exchangeable parts of the classifier.
capital_letter_v2.zip
digit_v2.zip
lower_case_letter_v2.zip
UNIPENviewer_source_code-noexe.zip
UNIPENviewer
DocToolkit
DocToolkit.csproj.user
DocToolkit.snk
obj
Debug
Release
DrawTools
about.bmp
App.ico
bin
Debug
Release
DrawTools.csproj.user
ellipse.bmp
Ellipse.cur
line.bmp
Line.cur
new.bmp
obj
Debug
DrawTools.DrawArea.resources
GenerateResource.read.1.tlog
GenerateResource.write.1.tlog
Release
DrawTools.DrawArea.resources
GenerateResource.read.1.tlog
GenerateResource.write.1.tlog
open.bmp
pencil.bmp
Pencil.cur
pointer.bmp
PolyHandle.cur
rectangle.bmp
Rectangle.cur
save.bmp
NNControl
bin
Debug
Common
NNTesting
NNTraining
obj
Debug
GenerateResource.read.1.tlog
GenerateResource.write.1.tlog
NNControl.Common.UPTemplateControl.resources
NNControl.FlashForm.resources
NNControl.NNTesting.NNTestingControl.resources
NNControl.NNTesting.TextSpellControl.resources
NNControl.NNTraining.ConvolutionForm.resources
NNControl.NNTraining.CreateNetworkForm.resources
NNControl.NNTraining.FullConnectedForm.resources
NNControl.NNTraining.InputLayerForm.resources
NNControl.NNTraining.OutputLayerForm.resources
NNControl.NNTraining.UP_NNTrainingControl.resources
NNControl.Properties.Resources.resources
NNControl.TrainingParametersForm.resources
NNControl.UPViewer.UpImageViewer.resources
UPControl.Common.BaseControl.resources
UPControl.Common.UPTemplateControl.resources
UPControl.FlashForm.resources
UPControl.NNTraining.UP_NNTrainingControl.resources
UPControl.TrainingParametersForm.resources
UPControl.UPViewer.UpImageViewer.resources
UP_NeuralTraining.FlashForm.resources
UP_NeuralTraining.TrainingParametersForm.resources
UP_NeuralTraining.UP_NNTrainingControl.resources
Release
GenerateResource.read.1.tlog
GenerateResource.write.1.tlog
NNControl.Common.UPTemplateControl.resources
NNControl.FlashForm.resources
NNControl.NNTesting.NNTestingControl.resources
NNControl.NNTraining.ConvolutionForm.resources
NNControl.NNTraining.CreateNetworkForm.resources
NNControl.NNTraining.FullConnectedForm.resources
NNControl.NNTraining.InputLayerForm.resources
NNControl.NNTraining.OutputLayerForm.resources
NNControl.NNTraining.UP_NNTrainingControl.resources
NNControl.Properties.Resources.resources
NNControl.TrainingParametersForm.resources
NNControl.UPViewer.UpImageViewer.resources
Properties
Resources
btnBack.png
btnDrag.png
btnFitToScreen.png
btnNext.png
btnOpen.png
btnPreview.png
btnRotate270.png
btnRotate90.png
btnSelect.png
btnZoomIn.png
btnZoomOut.png
circle.png
clear.png
color_line.png
cry.png
document-new.png
Drag.cur
draw_line.png
ellipse.png
export.png
file.png
fingerprint-recognition.png
folder-open.png
folder.png
folders_explorer.png
Grab.cur
home.png
label-link.png
pointer.png
rectangle.png
save_accept.png
script_(stop).gif
smile.png
stock_draw-line.png
Stop sign.png
Upload.png
user-group-new.png
UPViewer
Perceptron
ActivationFunction
ArchiveSerialization
bin
Debug
Common
Connections
Layers
Network
Neurons
obj
Debug
ANN.Perceptron.Common.BaseControl.resources
GenerateResource.read.1.tlog
GenerateResource.write.1.tlog
Neurons.BaseControl.resources
Release
GenerateResource.read.1.tlog
GenerateResource.write.1.tlog
Neurons.BaseControl.resources
Properties
Weights
SpellChecker
bin
Debug
Controls
Dictionary
Affix
Dictionary.bmp
Phonetic
doc
NetSpell.ndoc
Forms
Interactive.bmp
obj
Debug
ResGen.read.1.tlog
ResGen.write.1.tlog
SpellChecker.Dictionary.WordDictionary.resources
SpellChecker.Forms.OptionForm.resources
SpellChecker.MultipleSpelling.resources
SpellChecker.NewSpelling.resources
Spell.snk
Spelling.bmp
UNIPENviewer.suo
UNIPENviewer.v11.suo
UNIPENviewer
bin
Debug
Config
de-DE.dic
en-US.dic
fr-FR.dic
it-IT.dic
UNIPENviewer.vshost.exe.manifest
Release
Config
obj
Debug
GenerateResource.read.1.tlog
GenerateResource.write.1.tlog
UNIPENviewer.MainForm.resources
UNIPENviewer.Properties.Resources.resources
Release
GenerateResource.read.1.tlog
GenerateResource.write.1.tlog
UNIPENviewer.MainForm.resources
UNIPENviewer.Properties.Resources.resources
x86
Debug
GenerateResource.read.1.tlog
GenerateResource.write.1.tlog
UNIPENviewer.Form1.resources
UNIPENviewer.Properties.Resources.resources
Properties
Settings.settings
UPImage
Common
Data
FileFormat
obj
Debug
Release
Properties
UNIPENviewer_source_code.zip
bin
Debug
DocToolkit.dll
Release
DocToolkit.dll
DocToolkit.csproj.user
DocToolkit.snk
DocToolkit.dll
DocToolkit.dll
about.bmp
App.ico
DocToolkit.dll
DrawTools.dll
DocToolkit.dll
DrawTools.dll
DrawTools.csproj.user
ellipse.bmp
Ellipse.cur
line.bmp
Line.cur
new.bmp
DrawTools.dll
DrawTools.DrawArea.resources
GenerateResource.read.1.tlog
GenerateResource.write.1.tlog
DrawTools.dll
DrawTools.DrawArea.resources
GenerateResource.read.1.tlog
GenerateResource.write.1.tlog
open.bmp
pencil.bmp
Pencil.cur
pointer.bmp
PolyHandle.cur
rectangle.bmp
Rectangle.cur
save.bmp
DocToolkit.dll
DrawTools-LinhLam.dll
DrawTools.dll
NNControl-LinhLam.dll
NNControl.dll
Perceptron.dll
SpellChecker.dll
UP-NeuralTraining.dll
UPImage-LinhLam.dll
UpImage.dll
Release
DocToolkit.dll
DrawTools.dll
Neurons.dll
NNControl.dll
UPImage.dll
GenerateResource.read.1.tlog
GenerateResource.write.1.tlog
NNControl-LinhLam.dll
NNControl.Common.UPTemplateControl.resources
NNControl.dll
NNControl.FlashForm.resources
NNControl.NNTesting.NNTestingControl.resources
NNControl.NNTesting.TextSpellControl.resources
NNControl.NNTraining.ConvolutionForm.resources
NNControl.NNTraining.CreateNetworkForm.resources
NNControl.NNTraining.FullConnectedForm.resources
NNControl.NNTraining.InputLayerForm.resources
NNControl.NNTraining.OutputLayerForm.resources
NNControl.NNTraining.UP_NNTrainingControl.resources
NNControl.Properties.Resources.resources
NNControl.TrainingParametersForm.resources
NNControl.UPViewer.UpImageViewer.resources
TempPE
Properties.Resources.Designer.cs.dll
UP-NeuralTraining.dll
UPControl.Common.BaseControl.resources
UPControl.Common.UPTemplateControl.resources
UPControl.FlashForm.resources
UPControl.NNTraining.UP_NNTrainingControl.resources
UPControl.TrainingParametersForm.resources
UPControl.UPViewer.UpImageViewer.resources
UP_NeuralTraining.FlashForm.resources
UP_NeuralTraining.TrainingParametersForm.resources
UP_NeuralTraining.UP_NNTrainingControl.resources
GenerateResource.read.1.tlog
GenerateResource.write.1.tlog
NNControl.Common.UPTemplateControl.resources
NNControl.dll
NNControl.FlashForm.resources
NNControl.NNTesting.NNTestingControl.resources
NNControl.NNTraining.ConvolutionForm.resources
NNControl.NNTraining.CreateNetworkForm.resources
NNControl.NNTraining.FullConnectedForm.resources
NNControl.NNTraining.InputLayerForm.resources
NNControl.NNTraining.OutputLayerForm.resources
NNControl.NNTraining.UP_NNTrainingControl.resources
NNControl.Properties.Resources.resources
NNControl.TrainingParametersForm.resources
NNControl.UPViewer.UpImageViewer.resources
TempPE
Properties.Resources.Designer.cs.dll
btnBack.png
btnDrag.png
btnFitToScreen.png
btnNext.png
btnOpen.png
btnPreview.png
btnRotate270.png
btnRotate90.png
btnSelect.png
btnZoomIn.png
btnZoomOut.png
circle.png
clear.png
color_line.png
cry.png
document-new.png
Drag.cur
draw_line.png
ellipse.png
export.png
file.png
fingerprint-recognition.png
folder-open.png
folder.png
folders_explorer.png
Grab.cur
home.png
label-link.png
pointer.png
rectangle.png
save_accept.png
script_(stop).gif
smile.png
stock_draw-line.png
Stop sign.png
Upload.png
user-group-new.png
AForgeLibrary.dll
NeuralNetworkLibrary.dll
Perceptron.dll
SpellChecker.dll
UpImage.dll
Release
NeuralNetworkLibrary.dll
Neurons.dll
UPImage.dll
ANN.Perceptron.Common.BaseControl.resources
GenerateResource.read.1.tlog
GenerateResource.write.1.tlog
NeuralNetworkLibrary.dll
Neurons.BaseControl.resources
Perceptron.dll
GenerateResource.read.1.tlog
GenerateResource.write.1.tlog
NeuralNetworkLibrary.dll
Neurons.BaseControl.resources
Neurons.dll
SpellChecker.dll
Dictionary.bmp
NetSpell.ndoc
Interactive.bmp
NetSpell.SpellChecker.dll
ResGen.read.1.tlog
ResGen.write.1.tlog
SpellChecker.Dictionary.WordDictionary.resources
SpellChecker.dll
SpellChecker.Forms.OptionForm.resources
SpellChecker.MultipleSpelling.resources
SpellChecker.NewSpelling.resources
Spell.snk
Spelling.bmp
UNIPENviewer.suo
UNIPENviewer.v11.suo
de-DE.dic
DocToolkit.dll
DrawTools-LinhLam.dll
DrawTools.dll
en-US.dic
fr-FR.dic
it-IT.dic
NNControl-LinhLam.dll
NNControl.dll
Perceptron.dll
SpellChecker.dll
UNIPENviewer-LinhLam.exe
UNIPENviewer.exe
UNIPENviewer.vshost.exe
UNIPENviewer.vshost.exe.manifest
UPImage-LinhLam.dll
UpImage.dll
GenerateResource.read.1.tlog
GenerateResource.write.1.tlog
TempPE
Properties.Resources.Designer.cs.dll
UNIPENviewer-LinhLam.exe
UNIPENviewer.exe
UNIPENviewer.MainForm.resources
UNIPENviewer.Properties.Resources.resources
GenerateResource.read.1.tlog
GenerateResource.write.1.tlog
UNIPENviewer.exe
UNIPENviewer.MainForm.resources
UNIPENviewer.Properties.Resources.resources
GenerateResource.read.1.tlog
GenerateResource.write.1.tlog
UNIPENviewer.exe
UNIPENviewer.Form1.resources
UNIPENviewer.Properties.Resources.resources
Settings.settings
bin
Debug
AForgeLibrary.dll
UPDatabase.dll
UpImage-LinhLam.dll
UpImage.dll
UPUnipenLib.dll
Release
UPImage.dll
UPDatabase.dll
UpImage-LinhLam.dll
UpImage.dll
UPUnipenLib.dll
UPImage.dll
Word_samples.zip
Word samples
beach.dtl
Bengal.dtl
best.dtl
Brower.dtl
Buy.dtl
Byte byte.dtl
Change.dtl
Color.dtl
Company.dtl
Complet.dtl
copy.dtl
cup.dtl
draw tool.dtl
Eastern.dtl
Eat.dtl
eldest.dtl
Emergency.dtl
English.dtl
File.dtl
Finist.dtl
found nothing.dtl
France.dtl
Future.dtl
help me now.dtl
Hey hello.dtl
Hobby.dtl
How are you.dtl
Huck.dtl
icon.dtl
inker.dtl
Internet.dtl
Link.dtl
load.dtl
Local.dtl
Lonely.dtl
loosen.dtl
love you.dtl
Madden.dtl
Main gate.dtl
Mercy.dtl
Module.dtl
monday.dtl
Moon.dtl
mouse.dtl
my turn.dtl
net spell.dtl
network.dtl
never.dtl
newest.dtl
noted.dtl
Novel.dtl
oldest.dtl
Option.dtl
Pencil.dtl
petro.dtl
Pink.dtl
quick and slow.dtl
Rock.dtl
save.dtl
Sell.dtl
slam.dtl
smart phone.dtl
Strong.dtl
Strongest.dtl
success.dtl
Summer.dtl
Take.dtl
Text.dtl
Took.dtl
Train.dtl
Tuesday.dtl
Valence.dtl
Victory.dtl
viewer.dtl
vintage.dtl
Volume.dtl
water.dtl
Weak.dtl
Window.dtl
Windy.dtl
word expert.dtl
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Windows.Forms;
using System.Threading;
using System.Threading.Tasks;
namespace UPImage.FileFormat
{

    /// <summary>
    /// KEYWORDs in file
    /// </summary>
    public class UPKEYWORD
    {
        public List<String> content_list;
        public String keyName;
        public UPKEYWORD()
        {
            keyName = "";
            content_list = new List<String>();
        }
    };

    /// <summary>
    /// ////---------------------------------------------------------------------------
    /// </summary>
    public class UPRecognizerDocumentation
    {
    }
    public class UPRecognizerDeclarations
    {
    }
    public class UPRecognitionResults
    {
    }

    /// <summary>
    /// --------------------------------------------------------------------------------
    /// </summary>
    public class UPAlphabet
    {
        UPKEYWORD alphabet;
        UPKEYWORD alphabet_freq;
        public UPAlphabet()
        {
            alphabet = new UPKEYWORD();
            alphabet_freq = new UPKEYWORD();

        }
        public void SetAlphabet(UPKEYWORD kw)
        {
            switch (kw.keyName)
            {
                case ".ALPHABET":
                    alphabet = kw;
                    break;
                case ".ALPHABET_FREQ":
                    alphabet_freq = kw;
                    break;
            }
        }
    }
    /// <summary>
    /// ---------  Lexicon  ---------------------------------------------------
    ///
    /// .KEYWORD .LEXICON_SOURCE [S]	       	Name of institution or person where the lexicon came from.
    /// .KEYWORD .LEXICON_ID [S]		Name of the lexicon.
    /// .KEYWORD .LEXICON_CONTACT [F]	        Where to reach the person responsible to answer questions about the lexicon.
    /// .KEYWORD .LEXICON_INFO [F]		Informations about the lexicon.
    /// .KEYWORD .LEXICON [L] [.]		Representative set of class labels found in the database, generally at the word or character segmentation level.
    /// .KEYWORD .LEXICON_FREQ [N] [.]		Frequencies of lexical entries defined by .LEXICON. Lexical frequencies 
    /// characterize the distribution from which data samples were drawn at random. Therefore, the number of
    /// times a lexical entry appears in the database should be approximately proportional to the lexical 
    /// frequencies. Normalizing such that all numbers add-up to one is not necessary.
    /// </summary>
    public class UPLexicon
    {
        public UPKEYWORD lexicon_source;
        public UPKEYWORD lexicon_id;
        public UPKEYWORD lexicon_contact;
        public UPKEYWORD lexicon_info;
        public UPKEYWORD lexicon;
        public UPKEYWORD lexicon_freq;
        public UPLexicon()
        {
        }
        public void SetLexicon(UPKEYWORD kw)
        {
            switch (kw.keyName)
            {
                case ".LEXICON_SOURCE":
                    break;
                case ".LEXICON_ID":
                    break;
                case ".LEXICON_CONTACT":
                    break;
                case ".LEXICON_INFO":
                    break;
                case ".LEXICON":
                    break;
                case ".LEXICON_FREQ":
                    break;
            }
        }
    }
    public class UPUnitSystem
    {
        /*
         * .COMMENT ---------  Unit system   ---------------------------------------------
        .KEYWORD .X_POINTS_PER_INCH [N]	  	x resolution of the data collection device (1 inch ~ 2.5 cm).
        .KEYWORD .Y_POINTS_PER_INCH [N]		y resolution of the data collection device.
        .KEYWORD .Z_POINTS_PER_INCH [N]		z (altitude) resolution of the data collection device.
        .KEYWORD .X_POINTS_PER_MM [N]	  	x resolution of the data collection device (in SI units).
        .KEYWORD .Y_POINTS_PER_MM [N]		y resolution of the data collection device.
        .KEYWORD .Z_POINTS_PER_MM [N]		z (altitude) resolution of the data collection device.
        .KEYWORD .POINTS_PER_GRAM [N]		Pressure resolution of the data collection device.
        .KEYWORD .POINTS_PER_SECOND [N]		Sampling rate, MANDATORY if T not in .COORD.
         * */
        double dpiX;
        double dpiY;
        double dpiZ;

        //
        double dpMX;
        double dpMY;
        double dpMZ;
        //
        double dpGram;
        double dpSecond;
        //
        public double DpiX
        {
            get
            {
                return dpiX;
            }
            set
            {
                if (dpiX == value)
                    return;
                dpiX = value;
            }
        }
        public double DpiY
        {
            get
            {
                return dpiY;
            }
            set
            {
                if (dpiY == value)
                    return;
                dpiY = value;
            }
        }
        public double DpiZ
        {
            get
            {
                return dpiZ;
            }
            set
            {
                if (dpiZ == value)
                    return;
                dpiZ = value;
            }
        }
        public double DpSecond
        {
            get
            {
                return dpSecond;
            }
            set
            {
                if (dpSecond == value)
                    return;
                dpSecond = value;
            }
        }
        //
        public UPUnitSystem()
        {
            dpiX = 0;
            dpiY = 0;
            dpiZ = 0;
            dpMX = 0;
            dpMY = 0;
            dpMZ = 0;
            dpGram = 0;
            dpSecond = 0;
        }
        public void SetUPUnitSystem(UPKEYWORD kw)
        {
            switch (kw.keyName)
            {
                case ".X_POINTS_PER_INCH":

                    foreach (var s in kw.content_list)
                    {
                        //get Y_DIM number
                        if (UPImage.Common.UpCommonLib.SubStringSearch(null, s, ".X_POINTS_PER_INCH"))
                        {
                            String tempSt = s.Substring(s.IndexOf(" ")).Trim();
                            dpiX = Convert.ToDouble(tempSt);
                            break;
                        }
                    }
                    break;
                case ".Y_POINTS_PER_INCH":
                    foreach (var s in kw.content_list)
                    {
                        //get Y_DIM number
                        if (UPImage.Common.UpCommonLib.SubStringSearch(null, s, ".Y_POINTS_PER_INCH"))
                        {
                            String tempSt = s.Substring(s.IndexOf(" ")).Trim();
                            dpiY = Convert.ToDouble(tempSt);
                            break;
                        }
                    }
                    break;
                case ".Z_POINTS_PER_INCH":
                    foreach (var s in kw.content_list)
                    {
                        //get Y_DIM number
                        if (UPImage.Common.UpCommonLib.SubStringSearch(null, s, ".Z_POINTS_PER_INCH"))
                        {
                            String tempSt = s.Substring(s.IndexOf(" ")).Trim();
                            dpiZ = Convert.ToDouble(tempSt);
                            break;
                        }
                    }
                    break;
                case ".X_POINTS_PER_MM":
                    foreach (var s in kw.content_list)
                    {
                        //get Y_DIM number
                        if (UPImage.Common.UpCommonLib.SubStringSearch(null, s, ".X_POINTS_PER_MM"))
                        {
                            String tempSt = s.Substring(s.IndexOf(" ")).Trim();
                            dpMX = Convert.ToDouble(tempSt);
                            break;
                        }
                    }
                    break;
                case ".Y_POINTS_PER_MM":
                    foreach (var s in kw.content_list)
                    {
                        //get Y_DIM number
                        if (UPImage.Common.UpCommonLib.SubStringSearch(null, s, ".Y_POINTS_PER_MM"))
                        {
                            String tempSt = s.Substring(s.IndexOf(" ")).Trim();
                            dpMY = Convert.ToDouble(tempSt);
                            break;
                        }
                    }
                    break;
                case ".Z_POINTS_PER_MM":
                    foreach (var s in kw.content_list)
                    {
                        //get Y_DIM number
                        if (UPImage.Common.UpCommonLib.SubStringSearch(null, s, ".Z_POINTS_PER_MM"))
                        {
                            String tempSt = s.Substring(s.IndexOf(" ")).Trim();
                            dpMZ = Convert.ToDouble(tempSt);
                            break;
                        }
                    }
                    break;
                case ".POINTS_PER_GRAM":
                    foreach (var s in kw.content_list)
                    {
                        //get Y_DIM number
                        if (UPImage.Common.UpCommonLib.SubStringSearch(null, s, ".POINTS_PER_GRAM"))
                        {
                            String tempSt = s.Substring(s.IndexOf(" ")).Trim();
                            dpGram = Convert.ToDouble(tempSt);
                            break;
                        }
                    }
                    break;
                case ".POINTS_PER_SECOND":
                    foreach (var s in kw.content_list)
                    {
                        //get Y_DIM number
                        if (UPImage.Common.UpCommonLib.SubStringSearch(null, s, ".POINTS_PER_SECOND"))
                        {
                            String tempSt = s.Substring(s.IndexOf(" ")).Trim();
                            dpSecond = Convert.ToDouble(tempSt);
                            break;
                        }
                    }
                    break;
            }
        }
    }
    public class UPDataSet : UPDataAnnotations
    {
        String stName; //name of UPDataSet
        UPAlphabet alphabet;
        UPLexicon lexicon;
        UPUnitSystem unitsystem;
        //list of data layouts
        List<UPDataLayout> datalayouts;
        UPDataLayout curr_datalayout;
        //
        /* allocated filecontents, for the Unipenfile and each included file */
        String initialDirectory;
        String filename;
        String currentopenfile;
        List<String> upIncludeFiles;
        UPKEYWORD keyword;
        int CompID;
        private int _maxDegreeOfParallelism = Environment.ProcessorCount;
    

        //
        /// <summary>
        ///
        /// </summary>
        /// 
        public int MaxDegreeOfParallelism
        {
            get
            {
                return _maxDegreeOfParallelism;
            }

            set
            {
                if (value == _maxDegreeOfParallelism)
                    return;

                if ((value == 0) || (value > Environment.ProcessorCount))
                    _maxDegreeOfParallelism = -1;
                else
                    _maxDegreeOfParallelism = value;

                ParallelOption.MaxDegreeOfParallelism = _maxDegreeOfParallelism;
            }
        }
        public ParallelOptions ParallelOption { get; private set; }
        public String Filename
        {
            get
            {
                return filename;
            }
            set
            {
                if (filename == value)
                    return;
                filename = value;
            }
        }
        public String InitialDirectory
        {
            get
            {
                return initialDirectory;
            }
            set
            {
                initialDirectory = value;
            }
        }
        public List<UPDataLayout> Datalayouts
        {
            get
            {
                return datalayouts;
            }
        }
        public UPUnitSystem Unitsystem
        {
            get
            {
                return unitsystem;
            }
            set
            {
                if (unitsystem == value)
                    return;
                unitsystem = value;
            }
        }
        //----------------------------------------------------------------------------------------------------------------------//
        public UPDataSet()
        {
            stName = "";
            alphabet = new UPAlphabet();
            lexicon = new UPLexicon();
            unitsystem = new UPUnitSystem();
            datalayouts = new List<UPDataLayout>();
            curr_datalayout = null;
            initialDirectory = "";
            upIncludeFiles = new List<string>();
            keyword = null;
            CompID = -1;
            ParallelOption = new ParallelOptions();
            ParallelOption.TaskScheduler = null;
            _maxDegreeOfParallelism = Environment.ProcessorCount;
            ParallelOption.MaxDegreeOfParallelism = _maxDegreeOfParallelism;
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="fname"> file name included full path</param>
        /// <param name="directory">safe file name (without path)</param>
        public bool FillDataSetFromFile(string fname)
        {
            try
            {
                // Create an instance of StreamReader to read from a file.
                // The using statement also closes the StreamReader.
                stName = fname;
                filename = fname;
                currentopenfile = filename;
                
                    using (StreamReader sr = new StreamReader(filename))
                    {
                        string line;
                        // Read and display lines from the file until the end of 
                        // the file is reached.
                        while ((line = sr.ReadLine()) != null)
                        {
                            line = line.Trim();
                            if (UPImage.Common.UpCommonLib.SubStringSearch(null, line, "."))
                            {
                                line = UPImage.Common.UpCommonLib.ReplaceSubString(line, "\t", " ").Trim();
                                String str = "";
                                if (line.Trim().IndexOf(" ") > 0)
                                {
                                    str = line.Substring(0, line.IndexOf(" ")).Trim();
                                }
                                else
                                {
                                    str = line.Trim();
                                }
                                Parallel.ForEach(UPImage.Common.UpCommonLib.keyworkNames, ParallelOption, (st, loopState) =>
                                {
                                    if (str.CompareTo(st) == 0)
                                    {
                                        if ((keyword != null) && (keyword.keyName != ""))
                                        {
                                            SetParameterFromKeyword(keyword);
                                        }
                                        //Create new KEYWORD
                                        keyword = new UPKEYWORD();
                                        keyword.keyName = str;
                                        loopState.Stop();
                                    }
                                });
                            }
                            //add Content to content list
                            if ((keyword != null) && (keyword.keyName != ""))
                            {
                                if (!String.IsNullOrWhiteSpace(line))
                                {
                                    line = line.Trim();
                                    keyword.content_list.Add(line);
                                }
                            }
                        }
                    }
                  
                //read KEYWORDS in included files
                while (upIncludeFiles.Count>0)
                {
                    String[] ls = new String[upIncludeFiles.Count];
                    upIncludeFiles.CopyTo(ls);
                    upIncludeFiles.Clear();
                    foreach (var item in ls)
                    {

                        // Create an instance of StreamReader to read from a file.
                        // The using statement also closes the StreamReader.
                        currentopenfile = item;
                        FileInfo finfo = new FileInfo(currentopenfile);
                        if (finfo.Exists)
                        {
                            using (StreamReader sr = new StreamReader(item))
                            {
                                string line;
                                // Read and display lines from the file until the end of 
                                // the file is reached.
                                while ((line = sr.ReadLine()) != null)
                                {
                                    line = UPImage.Common.UpCommonLib.ReplaceSubString(line, "\t", " ").Trim();
                                    if (UPImage.Common.UpCommonLib.SubStringSearch(null, line, "."))
                                    {
                                        String str = "";
                                        if (line.IndexOf(" ") > 0)
                                        {
                                            str = line.Substring(0, line.IndexOf(" ")).Trim();
                                        }
                                        else
                                        {
                                            str = line.Trim();
                                        }
                                        Parallel.ForEach(UPImage.Common.UpCommonLib.keyworkNames, ParallelOption, (st, loopState) =>
                                        {
                                            if (str.CompareTo(st) == 0)
                                            {
                                                if ((keyword != null) && (keyword.keyName != ""))
                                                {
                                                    //get data from current keyword
                                                    SetParameterFromKeyword(keyword);
                                                }
                                                //Create new KEYWORD
                                                keyword = new UPKEYWORD();
                                                keyword.keyName = str;
                                                loopState.Stop();
                                            }
                                        });
                                    }
                                    if ((keyword != null) && (keyword.keyName != ""))
                                    {
                                        line = line.Trim();
                                        if (!String.IsNullOrWhiteSpace(line))
                                        {
                                            keyword.content_list.Add(line);
                                        }
                                    }
                                }
                               
                            }
                        }
                        else
                        {
                            MessageBox.Show(String.Format("the:{0} is not exits!",currentopenfile));
                            return false;
                        }
                       
                    }
                    
                }
                return true;
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString());
                return false;
            }
            
            
        }
        /// <summary>
        /// GetDataFromKeyword
        /// </summary>
        /// <param name="kw"></param>
        private void SetParameterFromKeyword(UPKEYWORD kw)
        {
            //Category data for last keyword
            //get data from current keyword
            switch (kw.keyName)
            {
                case ".INCLUDE":
                    GetIncludeFileNames(keyword);
                    break;
                case ".X_DIM":
                    //create new DataLayout
                    curr_datalayout = new UPDataLayout();
                    //add datalayout to list
                    datalayouts.Add(curr_datalayout);
                    curr_datalayout.SetDataLayoutParameter(kw);
                    break;
                case ".PEN_DOWN":
                    //check if pen trajectory is not empty
                    
                    if (kw.content_list.Count > 1)
                    {
                        if (kw.content_list.First().Trim().Length == Common.UpCommonLib.keyPenDown.Length)
                        {
                            CompID++;
                            if (curr_datalayout == null)
                            {
                                //create new DataLayout
                                curr_datalayout = new UPDataLayout();
                                //add datalayout to list
                                datalayouts.Add(curr_datalayout);
                            }
                            curr_datalayout.SetUPUnipen(kw, segments, CompID);
                        }
                    }
                    break;
                case ".PEN_UP":
                    //check if pen trajectory is not empty
                    if (kw.content_list.Count > 1)
                    {
                        if (kw.content_list.First().Trim().Length == Common.UpCommonLib.keyPenUp.Length)
                        {
                            CompID++;
                            if (curr_datalayout == null)
                            {
                                //create new DataLayout
                                curr_datalayout = new UPDataLayout();
                                //add datalayout to list
                                datalayouts.Add(curr_datalayout);
                            }
                            curr_datalayout.SetUPUnipen(kw, segments, CompID);
                        }
                    }
                    break;
                case ".DT":
                    //do some thing??
                    break;
                case ".START_SET":
                    //Set name of UPDataSet (future update)
                    break;
                default:
                    //set Mandatory parameters to UPDataSet
                    SetMandatoryDeclarations(kw);
                    //set Document parameters to UPDataSet
                    SetDataDocument(kw);
                    //set Annotation parameters to UPDataSet
                    SetDataAnnotations(kw);
                    //set alphabet parameters
                    alphabet.SetAlphabet(kw);
                    //Set lexicon parameters
                    lexicon.SetLexicon(kw);
                    //Set Unit System parameters
                    unitsystem.SetUPUnitSystem(kw);
                    //add other prameterts to current datalayout
                    if (curr_datalayout != null)
                    {
                        curr_datalayout.SetDataLayoutParameter(kw);
                    }
                    break;
            }
        }
        /// <summary>
        /// GetIncludeFileNames
        /// </summary>
        /// <param name="kw"></param>
        private void GetIncludeFileNames(UPKEYWORD kw)
        {
            if (kw.keyName == ".INCLUDE")
            {
                //get include paths
                foreach (var s in kw.content_list)
                {
                    String sTemp = "";

                    if (UPImage.Common.UpCommonLib.SubStringSearch(null, s, UPImage.Common.UpCommonLib.keyInclude))
                    {
                        sTemp = s.Substring(s.IndexOf(UPImage.Common.UpCommonLib.keyInclude) + UPImage.Common.UpCommonLib.keyInclude.Length).Trim();
                    }
                    else
                    {
                        sTemp = s.Trim();
                    }
                    //add included file name to list
                    FileInfo fInfo = new FileInfo(currentopenfile);
                    DirectoryInfo directory = fInfo.Directory;
                    String includePath="";
                    if (initialDirectory == "")
                    {
                        initialDirectory = "UnipenData";
                    }
                   // check if sTemp has "../".  Get included files inside a included file
                    try
                    {
                        String dataFolder = String.Format("{0}\\{1}",initialDirectory, "data");
                        //try to get default UNIPEN folder
                        if (currentopenfile.Contains(dataFolder))
                        {
                            includePath = String.Format("{0}\\{1}", currentopenfile.Substring(0,currentopenfile.IndexOf(dataFolder)), "UnipenData\\include");
                            //get included files from data file
                            sTemp = sTemp.Replace("/", "\\");
                            String Includedfilename = String.Format("{0}\\{1}", includePath, sTemp);
                            Includedfilename=Includedfilename.Replace("\\\\", "\\");
                            upIncludeFiles.Add(Includedfilename);
                        }
                        else 
                        {
                            includePath = directory.FullName;
                            if (sTemp.Contains("../"))
                            {
                                while (sTemp.Contains("../"))
                                {
                                    directory = directory.Parent;
                                    includePath = directory.FullName;
                                    sTemp = sTemp.Remove(sTemp.IndexOf("../"), 3);
                                }
                                sTemp = sTemp.Replace("/", "\\");
                                String Includedfilename = String.Format("{0}\\{1}", includePath, sTemp);
                                Includedfilename=Includedfilename.Replace("\\\\", "\\");
                                upIncludeFiles.Add(Includedfilename);
                            }
                            else
                            {
                               
                                if (sTemp.Substring(0) == "/")
                                {
                                    sTemp.Remove(0, 1);
                                }
                                String dic = "";
                                if (sTemp.Contains("/"))
                                {
                                    dic = sTemp.Substring(0, sTemp.IndexOf("/"));
                                }
                                if (dic != "")
                                {
                                    if (includePath.Contains(dic))
                                    {
                                        dic = includePath.Substring(0, includePath.IndexOf(dic));
                                        sTemp = sTemp.Replace("/", "\\");
                                        String Includedfilename = String.Format("{0}\\{1}", dic, sTemp);
                                        Includedfilename=Includedfilename.Replace("\\\\", "\\");
                                        upIncludeFiles.Add(Includedfilename);
                                    }
                                    else
                                    {
                                        sTemp = sTemp.Replace("/", "\\");
                                        sTemp=sTemp.Replace("\\\\", "\\");
                                        upIncludeFiles.Add(sTemp);
                                    }
                                }
                                else
                                {
                                    String Includedfilename = String.Format("{0}\\{1}", includePath, sTemp);
                                    Includedfilename=Includedfilename.Replace("\\\\", "\\");
                                    upIncludeFiles.Add(Includedfilename);
                                }
                               
                               
                            }
                            
                        }

                        
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.ToString());
                    }
                   
                }
            }
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Vietdungiitb
Vietnam Maritime University
Vietnam Vietnam
No Biography provided

| Advertise | Privacy | Mobile
Web04 | 2.8.140718.1 | Last Updated 10 Apr 2013
Article Copyright 2013 by Vietdungiitb
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid