File Manager

Current Path : /usr/share/doc/crm114/examples/
Upload File :
Current File : //usr/share/doc/crm114/examples/alternating_example_neural.crm

#! /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/ }
}

File Manager Version 1.0, Coded By Lucas
Email: hehe@yahoo.com