File Manager

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

#! /usr/bin/crm
window
{
    output /**** Alternating Example SVM 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:] < SVM unigram append> (m_test.css)
		learn [:onep:] < SVM 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:] < SVM unigram append> (a_test.css)
		learn [:twop:] < SVM 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:] <SVM fromstart bychunk> (m_test.css )
    # learn [:_nl:] <SVM fromstart bychunk> (a_test.css)
}

output /\n**** Alternating Example SVM 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 < SVM unigram > ( m_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 < SVM unigram > ( m_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