44 |
*) |
*) |
45 |
|
|
46 |
open Sys |
open Sys |
47 |
|
open Pxp_yacc |
48 |
|
|
49 |
open DefaultVisitor |
open DefaultVisitor |
50 |
open Nn |
open Nn |
63 |
exception FileExists |
exception FileExists |
64 |
|
|
65 |
(** |
(** |
66 |
|
|
67 |
|
*) |
68 |
|
class warner = |
69 |
|
object |
70 |
|
method warn w = |
71 |
|
print_endline ("WARNING: " ^ w) |
72 |
|
end |
73 |
|
|
74 |
|
(** |
75 |
The abstract XML export visitor. |
The abstract XML export visitor. |
76 |
This object exports a neural network as an XML file. |
This object exports a neural network as an XML file. |
77 |
@raise FileExists Thrown if _overwriteFile is false, and someone tries to |
@raise FileExists Thrown if _overwriteFile is false, and someone tries to |
80 |
class virtual ['a] xmlVisitor = |
class virtual ['a] xmlVisitor = |
81 |
object (this) |
object (this) |
82 |
inherit ['a] defaultVisitor |
inherit ['a] defaultVisitor |
83 |
|
|
84 |
(** |
(** |
85 |
The XML file's header. Contains the DTD. |
The XML file's header. Contains the DTD. |
86 |
@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 |
361 |
close_out _outChannel |
close_out _outChannel |
362 |
|
|
363 |
(** |
(** |
364 |
|
Parses an XML file and creates a nn object out of it. |
365 |
|
*) |
366 |
|
method private xmlParse = |
367 |
|
let document2Nn doc = |
368 |
|
((new mlpNN) :> nn) |
369 |
|
in |
370 |
|
try |
371 |
|
let config = |
372 |
|
{ default_config with warner = new warner } |
373 |
|
in |
374 |
|
let d = |
375 |
|
parse_document_entity config (from_file "doc.xml") default_spec |
376 |
|
in |
377 |
|
document2Nn d |
378 |
|
with |
379 |
|
e -> |
380 |
|
print_endline (Pxp_types.string_of_exn e); ((new mlpNN) :> nn) |
381 |
|
|
382 |
|
|
383 |
|
(** |
384 |
The generic visit method. |
The generic visit method. |
385 |
*) |
*) |
386 |
method virtual visit : 'a -> unit |
method virtual visit : 'a -> unit |