- Timestamp:
- Jan 21, 2020, 1:08:05 PM (4 years ago)
- Branches:
- (u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
- Children:
- c4ae15496628debfb40fd913b30f80d190ebd49a
- Parents:
- c3239f94e91d849c92850b63ee75974ac46a405b
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/dyn_modules/machinelearning/machinelearning.cc
rc3239f9 r1c9d98 10 10 static BOOLEAN predictHelp(leftv result, leftv arg) 11 11 { 12 char *buffer[5]; 13 int lengths[5]; 14 char filename[15] = "~/.history"; 15 int i; 16 lists L = (lists)omAllocBin(slists_bin); 12 char *buffer[5]; 13 int lengths[5]; 14 char *filename = getenv("SINGULARHIST"); 15 if (filename==NULL) filename=(char*)"~/.history"; 16 int i; 17 lists L = (lists)omAllocBin(slists_bin); 17 18 18 19 20 21 22 19 buffer[0] = NULL; 20 buffer[1] = NULL; 21 buffer[2] = NULL; 22 buffer[3] = NULL; 23 buffer[4] = NULL; 23 24 24 if (write_history(NULL)) { 25 printf("Failed to write history\n"); 26 return TRUE; 27 } 25 if (write_history(filename)) 26 { 27 printf("Failed to write history\n"); 28 return TRUE; 29 } 28 30 29 if (!ml_initialise()) { 30 Print("Initialise of ml failed."); 31 PrintLn();32 33 34 31 if (!ml_initialise()) 32 { 33 WerrorS("Initialise of ml failed."); 34 /* Notify singular that an error occured */ 35 return TRUE; 36 } 35 37 36 38 ml_make_prediction(filename, buffer, lengths, _omStrDup); 37 39 38 40 L->Init(5); 39 41 40 41 42 43 44 42 for (i = 0; i < 5; i++) { 43 //printf("prediction %d: %s\n", i, buffer[i]); 44 L->m[i].rtyp = STRING_CMD; 45 L->m[i].data = buffer[i]; 46 } 45 47 46 47 48 48 // pass the resultant list to the res datastructure 49 result->rtyp=LIST_CMD; 50 result->data=(void *)L; 49 51 50 51 52 ml_finalise(); 53 return FALSE; 52 54 53 55 //result->rtyp=NONE; // set the result type 54 56 } 55 57 … … 57 59 extern "C" int SI_MOD_INIT(machinelearning)(SModulFunctions* psModulFunctions) 58 60 { 59 // this is the initialization routine of the module 60 // adding the routine predictHelp: 61 psModulFunctions->iiAddCproc( 62 (currPack->libname? currPack->libname: ""), 63 "predictHelp",// for the singular interpreter 64 FALSE, // should enter the global name space 65 predictHelp); // the C/C++ routine 66 return MAX_TOK; 61 char *filename = getenv("SINGULARHIST"); 62 if (filename==NULL) 63 { 64 WarnS("SINGULARHIST is not set - no history available, using ~/.history"); 65 } 66 // this is the initialization routine of the module 67 // adding the routine predictHelp: 68 psModulFunctions->iiAddCproc( 69 (currPack->libname? currPack->libname: ""), 70 "predictHelp",// for the singular interpreter 71 FALSE, // should enter the global name space 72 predictHelp); // the C/C++ routine 73 return MAX_TOK; 67 74 }
Note: See TracChangeset
for help on using the changeset viewer.