How to use the orange.StringVariable function in Orange

To help you get started, we’ve selected a few Orange examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github biolab / orange3-network / orangecontrib / network / networks / makeNetworkList.py View on Github external
import os
import os.path
import glob

import orange
import orngNetwork

atts = []
atts.append(orange.StringVariable("Network Name"))
atts.append(orange.StringVariable("Network File"))
atts.append(orange.StringVariable("dir"))
atts.append(orange.StringVariable("Item Set"))
atts.append(orange.StringVariable("Edge Set"))
atts.append(orange.FloatVariable("Vertices"))
atts[-1].numberOfDecimals = 0
atts.append(orange.FloatVariable("Edges"))
atts[-1].numberOfDecimals = 0
atts.append(orange.StringVariable("Date"))
atts.append(orange.StringVariable("Description"))

netlist = orange.ExampleTable(orange.Domain(atts, False))

for netFile in glob.glob(os.path.join(os.getcwd(), '*.net')):
	net = orngNetwork.Network.read(netFile)
	name, ext = os.path.splitext(netFile)
github biolab / orange3-network / orangecontrib / network / networks / makeNetworkList.py View on Github external
import os
import os.path
import glob

import orange
import orngNetwork

atts = []
atts.append(orange.StringVariable("Network Name"))
atts.append(orange.StringVariable("Network File"))
atts.append(orange.StringVariable("dir"))
atts.append(orange.StringVariable("Item Set"))
atts.append(orange.StringVariable("Edge Set"))
atts.append(orange.FloatVariable("Vertices"))
atts[-1].numberOfDecimals = 0
atts.append(orange.FloatVariable("Edges"))
atts[-1].numberOfDecimals = 0
atts.append(orange.StringVariable("Date"))
atts.append(orange.StringVariable("Description"))

netlist = orange.ExampleTable(orange.Domain(atts, False))

for netFile in glob.glob(os.path.join(os.getcwd(), '*.net')):
	net = orngNetwork.Network.read(netFile)
	name, ext = os.path.splitext(netFile)

	itemFile = ""
	if os.path.exists(name + '_items.tab'):
github biolab / orange2 / orange / orngTextCorpus.py View on Github external
def __init__(self, fileName, tags = {}, additionalTags = [], lem = None, doNotParse = [] , wordsPerDocRange = (-1, -1), charsPerDocRange = (-1, -1)):
        if lem:
            self.lem = lem
        else:
            self.lem = lemmatizer.NOPLemmatization()
            
        cat = orange.StringVariable("category")
        meta = orange.StringVariable("meta")
        addCat = [cat, meta]
        if additionalTags:
            addCat.extend([orange.StringVariable(s) for s in additionalTags])
        dom = orange.Domain(addCat, 0)
        self.data = orange.ExampleTable(dom)
    
        f = open(fileName, "r")
        t = DocumentSetRetriever(f, tags = tags, doNotParse = doNotParse, additionalTags = additionalTags)       
        
        while 1:
            # load document
            ex = orange.Example(dom)
            
            doc = t.getNextDocument()
            if not len(doc): break
github biolab / orange2 / Orange / OrangeWidgets / VisualizeQt / OWMDSQt.py View on Github external
def sendList(self, selectedInd):
        if self.data and type(self.data[0]) == str:
            xAttr=orange.FloatVariable("X")
            yAttr=orange.FloatVariable("Y")
            nameAttr=  orange.StringVariable("name")
            if self.selectionOptions == 1:
                domain = orange.Domain([xAttr, yAttr, nameAttr])
                selection = orange.ExampleTable(domain)
                for i in range(len(selectedInd)):
                    selection.append(list(self.mds.points[selectedInd[i]]) + [self.data[i]])
            else:
                domain = orange.Domain([nameAttr])
                if self.selectionOptions:
                    domain.addmeta(orange.newmetaid(), xAttr)
                    domain.addmeta(orange.newmetaid(), yAttr)
                selection = orange.ExampleTable(domain)
                for i in range(len(selectedInd)):
                    selection.append([self.data[i]])
                    if self.selectionOptions:
                        selection[i][xAttr]=self.mds.points[selectedInd[i]][0]
                        selection[i][yAttr]=self.mds.points[selectedInd[i]][1]
github biolab / orange2 / Orange / OrangeWidgets / Unsupervised / OWDistanceFile.py View on Github external
if self.takeAttributeNames:
                domain = self.data.domain
                if matrix.dim == len(domain.attributes):
                    matrix.setattr("items", domain.attributes)
                elif matrix.dim == len(domain.variables):
                    matrix.setattr("items", domain.variables)
                else:
                    self.error("The number of attributes doesn't match the matrix dimension")

            else:
                if matrix.dim == len(self.data):
                    matrix.setattr("items", self.data)
                else:
                    self.error("The number of examples doesn't match the matrix dimension")
        elif matrix and self.labels:
            lbl = orange.StringVariable('label')
            self.data = orange.ExampleTable(orange.Domain([lbl]), 
                                            [[str(l)] for l in self.labels])
            for e, label in zip(self.data, self.labels):
                e.name = label
            matrix.setattr("items", self.data)
        
        if self.data == None and self.labels == None:
            matrix.setattr("items", [str(i) for i in range(matrix.dim)])
        
        self.matrix.matrixType = orange.SymMatrix.Symmetric
        self.send("Distances", self.matrix)
github biolab / orange2 / Orange / orng / orngInteract.py View on Github external
for i in range(len(atts)):
            map[atts[i]] = i
            
            ndx = atts[i]
            t = '%s' % self.names[ndx]
            if pretty_names:
                t = string.replace(t, "ED_", "")
                t = string.replace(t, "D_", "")
                t = string.replace(t, "M_", "")
                t = string.replace(t, " ", "\\n")
                t = string.replace(t, "-", "\\n")
                t = string.replace(t, "_", "\\n")
                r = self.gains[ndx] * 100.0 / self.entropy
                table.append([i + 1, t, r])  
        
        d = orange.Domain([orange.FloatVariable('index'), orange.StringVariable('label'), orange.FloatVariable('norm. gain')])
        data = orange.ExampleTable(d, table)
        graph.items = data
        
        table = []
        for (ig,i,j) in ints:
            j = map[j]
            i = map[i]
            
            perc = int(abs(ig)*100.0/max(max_igain,self.attlist[-1][0])+0.5)
            graph[i, j] = perc / 30 + 1
            
            if self.entropy > 1e-6:
                mc = _nicefloat(100.0*ig/self.entropy,significant_digits)+"%"
            else:
                mc = _nicefloat(0.0,significant_digits)
            if len(self.plist) > 0 and pcutoff < 1:
github biolab / orange2 / orange / orngTextCorpus.py View on Github external
def __init__(self, fileName, tags = {}, additionalTags = [], lem = None, doNotParse = [] , wordsPerDocRange = (-1, -1), charsPerDocRange = (-1, -1)):
        if lem:
            self.lem = lem
        else:
            self.lem = lemmatizer.NOPLemmatization()
            
        cat = orange.StringVariable("category")
        meta = orange.StringVariable("meta")
        addCat = [cat, meta]
        if additionalTags:
            addCat.extend([orange.StringVariable(s) for s in additionalTags])
        dom = orange.Domain(addCat, 0)
        self.data = orange.ExampleTable(dom)
    
        f = open(fileName, "r")
        t = DocumentSetRetriever(f, tags = tags, doNotParse = doNotParse, additionalTags = additionalTags)       
        
        while 1:
            # load document
            ex = orange.Example(dom)
            
            doc = t.getNextDocument()
            if not len(doc): break
                
            if not len(charsPerDocRange) == 2:
                raise Exception('length of charsPerDocRange != 2')                
            if not charsPerDocRange[0] == -1:
github biolab / orange2 / orange / doc / networks / makeNetworkList.py View on Github external
import orange
import orngNetwork

atts = []
atts.append(orange.StringVariable("Network Name"))
atts.append(orange.StringVariable("Network File"))
atts.append(orange.StringVariable("dir"))
atts.append(orange.StringVariable("Item Set"))
atts.append(orange.StringVariable("Edge Set"))
atts.append(orange.FloatVariable("Vertices"))
atts[-1].numberOfDecimals = 0
atts.append(orange.FloatVariable("Edges"))
atts[-1].numberOfDecimals = 0
atts.append(orange.StringVariable("Date"))
atts.append(orange.StringVariable("Description"))

netlist = orange.ExampleTable(orange.Domain(atts, False))

for netFile in glob.glob(os.path.join(os.getcwd(), '*.net')):
	net = orngNetwork.Network.read(netFile)
	name, ext = os.path.splitext(netFile)
	
	itemFile = ""
	if os.path.exists(name + '_items.tab'):
		itemFile = name + '_items.tab'
	elif os.path.exists(name + '.tab'):
		itemFile = name + '.tab'
	
	edgeFile = ""
	if os.path.exists(name + '_edges.tab'):
		edgeFile = name + '_edges.tab'