File: alternating_example_neural.crm

package info (click to toggle)
crm114 20100106-3
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 3,120 kB
  • sloc: ansic: 34,361; sh: 617; makefile: 584; lisp: 208
file content (84 lines) | stat: -rwxr-xr-x 2,258 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#! /usr/bin/crm
#
#	alternating_example_neural.crm - Alternating Example Neural
#					 Network Classifier training test

# Copyright 2009 William S. Yerazunis.
# This file is under GPLv3, as described in COPYING.

window
{
	output /**** Alternating Example Neural Network Classifier TRAINING\n/
#   load the files in
	isolate (:Macbeth: :Alice:)
	input (:Macbeth:) [ Macbeth_Act_IV.txt 0 16000]
	input (:Alice:) [ Alice_In_Wonderland_Chap_1_And_2.txt 0 16000]

#    Now loop.
     isolate (:loopcontrol:) //
     isolate (:loopcounter:) /0/
     {
        eval (:loopcounter:) / :@: :*:loopcounter: + 1 : /
        #        output /Top of loop at :*:loopcounter: \n/
	match [:loopcontrol:] <absent> /./
	{
		{
		#         Grab a good chunk of Macbeth...
			match <fromend> (:onep:) /(....){255}.*?\n/ [:Macbeth:]
			match [:onep:] /.../
			learn [:onep:] < neural unigram append> (m_test.css)
			learn [:onep:] < neural unigram refute append> (a_test.css)
		}
		alius  #  Set done mark
		{
			alter (:loopcontrol:) /X/
		}
	}
	{
		{
			#         Grab a good chunk of Alice...
			match <fromend> (:twop:) /(....){255}.*?\n/ [:Alice:]
			match [:twop:] /.../
			learn [:twop:] < neural unigram append> (a_test.css)
			learn [:twop:] < neural unigram refute append> (m_test.css)
		}
		alius     #  reset to start of Macbeth file.
		{
			alter (:loopcontrol:) /X/
		}
	}
	liaf
     }
     #   Now run one fromstart loop on each of the files
     learn [:_nl:] <neural fromstart bychunk> (m_test.css)
     learn [:_nl:] <neural fromstart bychunk> (a_test.css)
}

output /\n**** Alternating Example Neural Network Classifier RUNNING TEST\n/

isolate (:s:)
isolate (:filetxt:) //

{
  input (:filetxt:) [ Alice_In_Wonderland_Chap_1_And_2.txt 16000 4096 ]
  match (:t1:) [:filetxt:] /(....){255}.*?\n\n/
  {
    classify < neural unigram> ( m_test.css | a_test.css ) (:s:)/[[:graph:]]+/ [:t1:]
    output / type M \n:*:s:\n/
  }
  alius
  { output / type A \n:*:s:\n/ }
}

{
  isolate (:t2:) //
  input (:filetxt:) [ Macbeth_Act_IV.txt 16000 4096 ]
  match (:t2:) [:filetxt:] /(....){255}.*?\n/

  {
    classify < neural unigram > ( m_test.css | a_test.css ) (:s:) /[[:graph:]]+/ [:t2:]
    output / type M \n:*:s:\n/
  }
  alius
  { output / type A \n:*:s:\n/ }
}