Changeset bcef5c in git
- Timestamp:
- Sep 16, 2019, 1:05:01 PM (5 years ago)
- Branches:
- (u'fieker-DuVal', '117eb8c30fc9e991c4decca4832b1d19036c4c65')(u'spielwiese', 'b4f17ed1d25f93d46dbe29e4b499baecc2fd51bb')
- Children:
- 50fb15949d9519d601bdaaa9bf8bbb49921c95a7
- Parents:
- f0dcd61d6b40b59408860cf1bdbc88f0d558a871
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/iparith.cc
rf0dcd6 rbcef5c 7802 7802 static BOOLEAN jjPREDHELP0(leftv res, leftv) 7803 7803 { 7804 char buffer[30]; 7804 char *buffer[5]; 7805 int lengths[5]; 7805 7806 char filename[15] = "~/.history"; 7806 7807 int i; 7807 7808 lists L = (lists)omAllocBin(slists_bin); 7808 7809 7809 buffer[0] = '\0'; 7810 buffer[0] = NULL; 7811 buffer[1] = NULL; 7812 buffer[2] = NULL; 7813 buffer[3] = NULL; 7814 buffer[4] = NULL; 7810 7815 7811 7816 if(write_history(NULL)) { … … 7821 7826 } 7822 7827 7823 ml_make_prediction(filename, 30, buffer, &i); 7824 printf("prediction %s\n", buffer); 7825 7826 L->Init(1); 7827 7828 L->m[0].rtyp = STRING_CMD; 7829 L->m[0].data = omStrDup("SomeString"); 7828 ml_make_prediction(filename, buffer, lengths, _omStrDup); 7829 7830 L->Init(5); 7831 7832 for (i = 0; i < 5; i++) { 7833 //printf("prediction %d: %s\n", i, buffer[i]); 7834 L->m[i].rtyp = STRING_CMD; 7835 L->m[i].data = buffer[i]; 7836 } 7830 7837 7831 7838 // pass the resultant list to the res datastructure -
machine_learning/mlpredict.c
rf0dcd6 rbcef5c 212 212 int ml_make_prediction(char *filename, 213 213 char *prediction_buffers[], 214 int *pred_len) 214 int *pred_len, 215 char *(*custom_strdup)(const char *)) 215 216 { 216 217 PyObject *pFName = NULL; … … 261 262 if (PyList_Size(pValue) != 5) { 262 263 printf("List length is supposed to be five, but is %d.\n", 263 PyList_Size(pValue));264 (int)PyList_Size(pValue)); 264 265 Py_DECREF(pValue); 265 266 return 0; … … 268 269 for (i = 0; i < 5; i++) { 269 270 pString = PyObject_Str(PyList_GetItem(pValue, i)); 270 prediction_buffers[i] = strdup(PyString_AsString(pString));271 prediction_buffers[i] = custom_strdup(PyString_AsString(pString)); 271 272 //pTemp = PyUnicode_AsASCIIString(pString); 272 //prediction_buffers[i] = strdup(PyBytes_AsString(pTemp));273 //prediction_buffers[i] = custom_strdup(PyBytes_AsString(pTemp)); 273 274 pred_len[i] = strlen(prediction_buffers[i]); 274 275 Py_DECREF(pString); -
machine_learning/mlpredict.h
rf0dcd6 rbcef5c 61 61 int ml_make_prediction(char *filename, 62 62 char *prediction_buffers[], 63 int *pred_len); 63 int *pred_len, 64 char *(*custom_strdup)(const char *)); 64 65 65 66 #ifdef __cplusplus -
machine_learning/tests/test_bufsize.c
rf0dcd6 rbcef5c 21 21 if (i != 0) return 1; 22 22 23 i = ml_make_prediction("test.txt", buffer, length );23 i = ml_make_prediction("test.txt", buffer, length, strdup); 24 24 printf("Returnvalue for ml_make_prediciton: \t%d\n", i); 25 25 for (k = 0; k < 5; k++) { -
machine_learning/tests/test_init_ml.c
rf0dcd6 rbcef5c 135 135 136 136 i = ml_finalise(); 137 printf("Returnvalue for ml_finalise: \t %d\n", i);137 printf("Returnvalue for ml_finalise: \t\t%d\n", i); 138 138 if (i != 1) return 1; 139 139
Note: See TracChangeset
for help on using the changeset viewer.