Changeset 9488:b806d4249e12 in orange


Ignore:
Timestamp:
08/22/11 04:49:00 (3 years ago)
Author:
wencanluo <wencanluo@…>
Branch:
default
Convert:
e6736dc46588d23c70cbd19625ea825fbb1cec5e
Message:

Add support for mulan data file on the OWFile widget

Location:
orange
Files:
4 added
4 edited

Legend:

Unmodified
Added
Removed
  • orange/Orange/__init__.py

    r9483 r9488  
    6767_import("multilabel.mlknn") 
    6868_import("multilabel.brknn") 
     69_import("multilabel.mulan") 
    6970 
    7071_import("associate") 
  • orange/Orange/data/io.py

    r9483 r9488  
    88     C45ExampleGenerator, TabDelimExampleGenerator, registerFileType 
    99 
    10  
    1110def loadARFF(filename, create_on_new = Orange.data.variable.Variable.MakeStatus.Incompatible, **kwargs): 
     11    if filename[-5:] == ".arff": 
     12        filename = filename[:-5] 
     13    if os.path.exists(filename + ".xml") and os.path.exists(filename + ".arff"): 
     14        xml_name = filename + ".xml"  
     15        arff_name = filename + ".arff"  
     16        return Orange.multilabel.mulan.trans_mulan_data(xml_name,arff_name) 
     17    else: 
     18        return loadARFF_Weka(filename, create_on_new) 
     19         
     20def loadARFF_Weka(filename, create_on_new = Orange.data.variable.Variable.MakeStatus.Incompatible, **kwargs): 
    1221    """Return class:`Orange.data.Table` containing data from file in Weka ARFF format""" 
    1322    if not os.path.exists(filename) and os.path.exists(filename + ".arff"): 
     
    151160        f.write('%s\n'%x[-1]) 
    152161 
     162def loadMULAN(filename, create_on_new = Orange.data.variable.Variable.MakeStatus.Incompatible, **kwargs): 
     163    """Return class:`Orange.data.Table` containing data from file in Mulan ARFF and XML format""" 
     164    if filename[-4:] == ".xml": 
     165        filename = filename[:-4] 
     166    if os.path.exists(filename + ".xml") and os.path.exists(filename + ".arff"): 
     167        xml_name = filename + ".xml"  
     168        arff_name = filename + ".arff"  
     169        return Orange.multilabel.mulan.trans_mulan_data(xml_name,arff_name) 
     170    else: 
     171        return None 
     172loadARFF = Orange.misc.deprecated_keywords( 
     173{"createOnNew": "create_on_new"} 
     174)(loadARFF) 
     175 
    153176def toC50(filename,table): 
    154177    """Save class:`Orange.data.Table` to file in C50 format""" 
     
    289312registerFileType("R", None, toR, ".R") 
    290313registerFileType("Weka", loadARFF, toARFF, ".arff") 
     314registerFileType("Mulan", loadMULAN, None, ".xml") 
    291315registerFileType("C50", None, toC50, [".names", ".data", ".test"]) 
    292316registerFileType("libSVM", loadLibSVM, toLibSVM, ".svm") 
  • orange/Orange/multilabel/mulan.py

    r9477 r9488  
    2424         
    2525    #load ARFF file 
    26     arff_table = Orange.data.Table(arff_name) 
     26    arff_table = Orange.data.io.loadARFF_Weka(arff_name) 
    2727    domain = arff_table.domain 
    2828     
  • orange/OrangeWidgets/Data/OWFile.py

    r9487 r9488  
    304304                continue 
    305305            attrs = [attr.name for attr, stat in zip(data.domain, data.attributeLoadStatus) if stat == status] \ 
    306                   + [attr.name for id, attr in metas.items() if data.metaAttributeLoadStatus.get(id, -99) == status] 
     306            #      + [attr.name for id, attr in metas.items() if data.metaAttributeLoadStatus.get(id, -99) == status] 
    307307            if attrs: 
    308308                jattrs = ", ".join(attrs) 
Note: See TracChangeset for help on using the changeset viewer.