I am developing a classifier for text classification using VIKA Java libraries. I have removed several attributes using Stanford Core NLP package, which includes a dependency pars of text, which gives a string "(rel, head, mod)".
I wanted to use dependency three as the backbone for the classification, but I did not know how to properly represent them in the ARFF file. Actually, I'm stumped; For each example, Dependency is an arbitrary number of three, so I can not clearly define those attributes, for example:
@attribute entityCount numeric content @ depTriple_1 string @ Attribute depTriple_2 string . @ Distribution Dipthale_N string
Is there any special way to go about this? I have spent a good part of the day of search and have not found anything yet.
Thanks a lot for reading.
Execution was removed from the wiki:
import weka.core. Attribute; Import weka.core.FastVector; Import weka.core.Instance; Import weka.core.Instances; / ** * Generates small ARF file with a different attribute type * * @ Author Frakpate * / Public class SO_Test {Public static zero major (string [] args) Exception {Fast vector ets; FastVector ATTRL; Fastwaker Atwal; Fastwaker etwelsarl; Instance data; Instance Detarrell; Double [] vals; Double [] valsRel; Int i; // 1. Set Up Atsis = New FastVector (); // - Numerical atts.addElement (new feature ("AT1")); // - Nominal Atvilles = New FastVector (); For (i = 0; i <5; i ++) atolls.adlimment ("val" + (i + 1)); Atts.addElement (new feature ("AT2", ATVL)); // - string atts.addElement (new feature ("et3", (fast vector)); // - date atts.addElement (new feature ("AT4", "YYA-MM-DD")); // - relational attsRel = new fastweak (); // - Numerical attsRel.addElement (new attribute ("att5.1")); // - nominal attValsRel = new fastweak (); For (i = 0; i <5; i ++) attValsRel.addElement ("val5." + (I + 1)); AttsRel.addElement (new feature ("att5.2", etwilsarl)); DataRel = New instance ("att5", attsRel, 0); Atts.addElement (new feature ("att5", datreel, 0)); // 2. Instance object data = new instance ("Myralea", ATT, 0); // 3. Fill the data with // first example vals = new double [data.numAttributes ()]; // - Numerical Walls [0] = Math PI; // - nominal vals [1] = attVals.indexOf ("val3"); // - string vals [2] = data. Dividivate (2) .addStringValue ("This is a string!"); // - Date Wall [3] = Data. DataId (3). Paracetate ("2001-11-09"); // - Relational Datellel = new instance (data. Audit (4) .relation (), 0); // - The first example is valsRel = new double [2]; ValsRel [0] = Math PI + 1; ValsRel [1] = attValsRel.indexOf ("val5.3"); DataRel.add (new example (1.0, valsRel)); // - Second example valsRel = new double [2]; ValsRel [0] = Math PI + 2; ValsRel [1] = attValsRel.indexOf ("val5.2"); DataRel.add (new example (1.0, valsRel)); Vals [4] = data. Datyte (4) .addRelation (dataRel); // add data.add (new example (1.0, wal)); // second example vals = new double [data.numAttributes ()]; // Important: New Array is Needed! // - Numerical Walls [0] = Math.e; // - nominal vals [1] = attVals.indexOf ("val1"); // - string vals [2] = data. Databook (2) .addStringValue ("and second one!"); // - Date Wall [3] = Data. DataId (3). Paracetate ("2000-12-01"); // - Relational Datellel = new instance (data. Audit (4) .relation (), 0); // - The first example is valsRel = new double [2]; ValsRel [0] = Math.E + 1; ValsRel [1] = attValsRel.indexOf ("val5.4"); DataRel.add (new example (1.0, valsRel)); // - Second example valsRel = new double [2]; ValsRel [0] = Math.E + 2; ValsRel [1] = attValsRel.indexOf ("val5.1"); DataRel.add (new example (1.0, valsRel)); Vals [4] = data. Datyte (4) .addRelation (dataRel); // add data.add (new example (1.0, wal)); // 4. Output data system.out.println (data); }}
Your problem is especially a "relational" attribute. This code segment has worked with such a relational attribute.
No comments:
Post a Comment