Skip to main content
Kofax

Mark a Document for Online Learning in Script

17796

QAID # 17796 Published * INTERNAL ONLY * 

QAID # 17796 Published * INTERNAL ONLY *

Please do NOT provide the article number (QAID) and/or URL of this Knowledgebase article or its contents to external customers, as it is NOT Published and/or * INTERNAL ONLY *.

Question / Problem:

Mark a Document for Online Learning in Script

Answer / Solution:

Specific Online Learning was introduced in KTM 3.5. The user has to manually press a button to mark a document for Specific Online Learning. The following script allows it to perform this step automatically. Please note that the script code does not check if it really makes sense to train the current document.

To mark a document for either Generic or Specific Online Learning, a text file needs to be created with the same name as the XDocument, but with the extension ".oll". The content of the OLL file controls the detailed action for this document in the Knowledge Base Learning Server. To mark a document for Specific Online Learning, the Specific option needs to be set to 1.

Add Microsoft Scripting Runtime to the reference list first. The script event below runs in server, but it is also possible to move the script code to a different event, e.g., Document_Validated.

Private Sub Document_AfterProcess(pXDoc As CASCADELib.CscXDocument)
   '* Reference - Microsoft Scripting Runtime (1.0)
   '* Create an online learning (OL)  file To go With the XDoc

   Dim XDocFilename As String
   Dim OllFilename As String
   Dim FDS As New FileSystemObject
   Dim TS As TextStream

XDocFilename = pXDoc.FileName

OllFilename = Left(XDocFilename, Len(XDocFilename) - 3) + "oll"

   Set TS = FDS.CreateTextFile(OllFilename, True, False)
   TS.WriteLine("NTUser=script")
   TS.WriteLine("NTStation=script")
   TS.WriteLine("Classification=0")
   TS.WriteLine("Extraction=0")
   TS.WriteLine("Specific=1")

   TS.WriteLine("Comment=")

   TS.Close
End Sub

An alternative script in pure WinWrap Basic without external references:

Sub TrainforOnlineLearning(pXDoc As CASCADELib.CscXDocument,comment As String, _
                           classification As Boolean, extraction As Boolean, specific As Boolean)

   Dim OllFilename As String
   OllFilename = Left(pXDoc.FileName, Len(pXDoc.FileName) - 3) + "oll"
   Open  OllFilename For Output As #1
   Print #1, "NTUser=" & Environ("USERNAME")
   Print #1, "NTStation=" & Environ("COMPUTERNAME")
   Print #1, "Classification=" & Bool2String(classification)
   Print #1, "Extraction=" & Bool2String(extraction)
   Print #1, "Specific=" & Bool2String(specific)

Print #1, "Comment=" & comment

   Close #1
End Sub

Private Function Bool2String(a As Boolean) As String
   Bool2String = "0"
   If a Then Bool2String = "1"

End Function

Applies To: 

Product Version Category
AXPRO 3.5 Script
  • Was this article helpful?