David Campbell avatar David Campbell committed aad6ffd

Ceri committing on David's machine

Comments (0)

Files changed (1)

svmlight/svmlight.py

 
 
 class SVECTOR(Structure):
-	_fields_ = [("words",       POINTER(WORD)),
-                ("twonorm_sq",  c_double),
-                ("userdefined", POINTER(c_char)),
-                ("kernel_id",   c_long),
-                ("next",        POINTER(SVECTOR),
-                ("factor",      c_double)]
+    pass
+
+SVECTOR._fields_ = [("words",       POINTER(WORD)),
+                    ("twonorm_sq",  c_double),
+                    ("userdefined", POINTER(c_char)),
+                    ("kernel_id",   c_long),
+                    ("next",        POINTER(SVECTOR)),
+                    ("factor",      c_double)]
 
 
 class DOC(Structure):
                 ("compute_loo",           c_long),
                 ("rho",                   c_double),
                 ("xa_depth",              c_long),
-                ("predfile",              (c_char * 200)()),
-                ("alphafile",             (c_char * 200)()),
+                ("predfile",              (c_char * 200)),
+                ("alphafile",             (c_char * 200)),
                 ("epsilon_const",         c_double),
                 ("epsilon_a",             c_double),
                 ("opt_precision",         c_double),
                 ("rbf_gamma",       c_double),
                 ("coef_lin",        c_double),
                 ("coef_const",      c_double),
-                ("custom",          (c_char * 50)())]
+                ("custom",          (c_char * 50))]
 
 class MODEL(Structure):
     _fields_ = [("sv_num",          c_long),
                 ("last_lin",        POINTER(c_double))]
 
 
-if __name__ == "__main__":
-	svec = SVECTOR()
-	for i, word in enumerate(svec.words):
-		word.wnum = i
-
-	print svec.words
-
-	resize(svec.words, 64)
-
-	for word in svec.words:
-		print word.wnum
-
 def svm_learn2(*args, **kwds):
-    docs = POINTER(POINTER(DOC()))
+    docs = POINTER(POINTER(DOC))
     target = POINTER(c_double)
     totwords = c_int
-	totdoc = c_int
+    totdoc = c_int
     kernel_cache = POINTER(KERNEL_CACHE)
     learn_parm = LEARN_PARM
     kernel_parm = KERNEL_PARM
     verbosity = c_long
     #doclist = POINTER(PyObject) #FIXME
     model = POINTER(MODEL)
-    result = POINTER(MODEL_AND_DOCS)
+    # result = POINTER(MODEL_AND_DOCS)
 	# DO THIS ONE!
 
-	# NULL: alpha in
-    if learn_parm.type == CLASSIFICATION {
+    # NULL: alpha in
+    if learn_parm.type == CLASSIFICATION:
         svm.svm_learn_classification(docs, target, totdoc, totwords,
-			addressof(learn_parm), addressof(kernel_parm), kernel_cache,
-			model, None)
-    }
+            addressof(learn_parm), addressof(kernel_parm), kernel_cache,
+            model, None)
+    return model
+
+if __name__ == "__main__":
+	svm_learn2()
 
 
 '''
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.