/[marvin]/marvin/src/libnn/xml/xmlVisitor.ml
ViewVC logotype

Diff of /marvin/src/libnn/xml/xmlVisitor.ml

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.5 by srv89, Mon Sep 1 20:43:52 2003 UTC revision 1.6 by srv89, Sun Sep 7 19:13:12 2003 UTC
# Line 50  open Nn Line 50  open Nn
50  open Pattern  open Pattern
51  open Env  open Env
52  open Corpus  open Corpus
53    open XmlMlpnnVisitor
54    open XmlTdnnVisitor
55    open MlpNN
56    open TdNN
57    
58  (**  (**
59    Thrown if _overwriteFile is false, and someone tries to overwrite an    Raised if _overwriteFile is false, and someone tries to overwrite an
60    existing  file.    existing  file.
61  *)  *)
62  exception FileExists  exception FileExists
63      
64  (**  (**
65    The abstract XML export visitor.    The abstract XML export visitor.
66    This object exports a neural network as an XML file.    This object exports a neural network as an XML file.
67    @raise FileExists Thrown if _overwriteFile is false, and someone tries to    @raise FileExists Thrown if _overwriteFile is false, and someone tries to
68    overwrite an existing  file.    overwrite an existing  file.
69    @see 'nn.dtd' The DTD to which the generated XML files are supposed to   *)
   be conform to.  
 *)  
70  class virtual ['a] xmlVisitor =  class virtual ['a] xmlVisitor =
71  object (this)  object (this)
72    inherit ['a] defaultVisitor    inherit ['a] defaultVisitor
73    
74      constraint 'a = nn
75    
76    (**    (**
77      The XML file's header. Contains the DTD.      The XML file's header. Contains the DTD.
78      @see <http://www.w3schools.com/dtd/dtd_intro.asp> How to get a DTD      @see <http://www.w3schools.com/dtd/dtd_intro.asp> How to get a DTD
# Line 159  tdnn_time_nb,tdnn_field_size)> Line 163  tdnn_time_nb,tdnn_field_size)>
163    val mutable _fileName = "neural_network_dump.xml"    val mutable _fileName = "neural_network_dump.xml"
164    
165    (**    (**
     A get*.  
     @return the name of the .xml file which is to be generated.  
   *)  
   method getFileName =  
     _fileName  
   
   (**  
     Sets the name of the .xml file which is to be generated.  
   *)  
    method setFileName newval =  
     _fileName <- newval  
   
   (**  
166      If true, then if _fileName already exists on the disk, it is overwritten      If true, then if _fileName already exists on the disk, it is overwritten
167      during the dump. Otherwise the `FileExists' exception is thrown during      during the dump. Otherwise the `FileExists' exception is thrown during
168      the dump.      the dump.
# Line 179  tdnn_time_nb,tdnn_field_size)> Line 170  tdnn_time_nb,tdnn_field_size)>
170    val mutable _overwriteFile = false    val mutable _overwriteFile = false
171    
172    (**    (**
     A get*.  
     @return True if the `overwrite' mode is set. Otherwise, false.  
   *)  
   method getOverwriteFile =  
     _overwriteFile  
   
   (**  
     Enables to choose whether LibNN is supposed to overwrite files during  
     XML dumps or not.  
   *)  
   method setOverwriteFile newval =  
     _overwriteFile <- newval  
         
   (**  
173      The out_channel used to dump the neural network. stdout is actually      The out_channel used to dump the neural network. stdout is actually
174       never used (since there is a default value for _fileName), but OCaml       never used (since there is a default value for _fileName), but OCaml
175      needs an initial value...      needs an initial value...
# Line 301  tdnn_time_nb,tdnn_field_size)> Line 278  tdnn_time_nb,tdnn_field_size)>
278      stuffs which are inherited from the `nn' class.      stuffs which are inherited from the `nn' class.
279      @param network The neural network which is to be dumped.      @param network The neural network which is to be dumped.
280    *)    *)
281    method beginDump (network : nn) =    method private beginDump (network : 'a) =
282      (**      (**
283        Dumps a pattern.        Dumps a pattern.
284      *)      *)
# Line 348  tdnn_time_nb,tdnn_field_size)> Line 325  tdnn_time_nb,tdnn_field_size)>
325          this#closeTag "env";          this#closeTag "env";
326      in      in
327                
328        if (Sys.file_exists _fileName & not _overwriteFile) then        if (Sys.file_exists _fileName & not _overwriteFile & _fileName <> "") then
329          raise FileExists;          raise FileExists;
330        _outChannel <- open_out _fileName;        if (_fileName <> "") then
331            _outChannel <- open_out _fileName
332          else
333          _outChannel <- stdout;
334        this#write _header;        this#write _header;
335        (**        (**
336          Dump stuffs inherited from the `nn' class.          Dump stuffs inherited from the `nn' class.
# Line 367  tdnn_time_nb,tdnn_field_size)> Line 347  tdnn_time_nb,tdnn_field_size)>
347      Closes tags which were opened by beginDump, and close the file.      Closes tags which were opened by beginDump, and close the file.
348      @param network The neural network which is to be dumped.      @param network The neural network which is to be dumped.
349    *)    *)
350    method endDump (network : nn) =    method private endDump (network : 'a) =
351      this#write _footer;      this#write _footer;
352      close_out _outChannel      close_out _outChannel
353          
354      (**
355        The generic visit method.
356      *)
357      method virtual visit : 'a -> unit
358    
359  end  end
360        

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.6

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26