Esempio n. 1
0
def retrieveOriginalOrder(starts,rGlob):
    startA=starts[0]
    startB=starts[1]

    a_followers=[]
    # retrieve relation where A starts
    for relation in rGlob:
        if(getSender(relation))==startA:
            neighbour=getReceiver(relation)
            if neighbour==startB:
                return startA,startB
            else:
                a_followers.append(neighbour)
    
    for elem in range(len(rGlob)+1):
        neighbour=retrieveFollower(a_followers[-1],rGlob)
        if neighbour==startB:
            return startA,startB
        else:
            a_followers.append(neighbour)

    # check on the global graph who's first: 
    #whether B is one of the getReceivers of the set of relations where A starts. If not, then it is the other way around
    
    return startB, startA 
Esempio n. 2
0
def filterOnRoles(linkages, projRefs):
    # filter on events
    roleLinkages = []
    for line in linkages:
        if (getSender(line) in projRefs) and (getReceiver(line) in projRefs):
            roleLinkages.append(line)
                
    if len(roleLinkages)==0:
        roleLinkages = ["#--> None Matching - Manual implementation required"]

    return ["\n## Linkages ##"] + roleLinkages #+ ["\n## WrongLinks ##"] + wrongLinks
Esempio n. 3
0
def computeExternalEvents(rExt, eProj):
    eExt=[]
    for r in rExt:
        sender = getSender(r)
        receiver = getReceiver(r)

        if ((sender not in eExt) and (sender not in eProj)):
            eExt.append(sender)

        if ((receiver not in eExt) and (receiver not in eProj)):
            eExt.append(receiver)
    return eExt
Esempio n. 4
0
def retrieveExternalRelations(eProj, rProj, eGlob, rGlob):
    rExt=[]
    for e in eProj:
        for l in rGlob:
            if((l not in rProj) and (e == getReceiver(l))):
                rExt.append(l) # direct relations
                rExt = transitiveIncludeExclude(rExt, e, l, rGlob)
                rExt = transitiveResponse(rExt, e, l, rGlob)

    eExt = computeExternalEvents(rExt, eProj)
    rExt = computeExternalRelations(rExt,eExt,eGlob)

    return eExt, rExt
Esempio n. 5
0
def countChunks(e,r):
    
    events=getRoleList(e)

    #retrieve number of inputs of each elem. If no input, then elem is a chunk start.
    cntInputs=np.zeros(len(events))
    for event in events:
        for relation in r:
            if(getReceiver(relation)==event):
                cntInputs[events.index(event)]=cntInputs[events.index(event)]+1

    # retrieve chunk starts    
    chunkStarts=[]
    ind=0
    for elem in cntInputs:
        if (int(elem)==0):
            chunkStarts.append(events[ind])
        ind=ind+1

    return (cntInputs == 0).sum(), chunkStarts
Esempio n. 6
0
def computeExternalRelations(externalLinkages,externalIds,eGlob):
    _externalLinkages = []
    for link in externalLinkages:
        sender = getSender(link)
        receiver = getReceiver(link)
        arrow_link = getArrowLink(link)

        if sender in externalIds:
            for elem in eGlob:
                toTest = getRole(elem) 
                if toTest in sender:
                    newLink = toTest + ' ' + arrow_link + ' ' + receiver
                    _externalLinkages.append(newLink)
        else: # receiver in externalIds:
            for elem in eGlob:
                toTest = getRole(elem)  
                if toTest in receiver:
                    newLink = sender + ' ' + arrow_link + ' ' + toTest    
                    _externalLinkages.append(newLink.strip())

    return _externalLinkages
Esempio n. 7
0
def retrieveChunkTail(first,events,relations, rGlob):

    events=getRoleList(events)
    neighbours=[]
    # retrieve relation where A starts
    for relation in relations:
        if(getSender(relation)) in first:
            neighbour=getReceiver(relation)
            if (neighbour not in neighbours):
                neighbours.append(neighbour)

    if (len(neighbours)>0):
        #retrieve following chunk elems
        for elem in range(len(relations)+1):
            neighbour=retrieveFollower(neighbours[-1],relations)
            if( (neighbour != '') and (neighbour not in neighbours)):
                neighbours.append(neighbour)
            
        #retrieve additional routes
        for elem in neighbours:
            cntNext=0
            for relation in relations:
                if (getSender(relation)==elem):
                    cntNext=cntNext+1
                    neighbour=getReceiver(relation)
                    if( (neighbour != '') and (neighbour not in neighbours)):
                        neighbours.append(neighbour)

        cntOutputs=np.zeros(len(neighbours))
        for event in neighbours:
            for relation in relations:
                if(getSender(relation)==event):
                    cntOutputs[neighbours.index(event)]=cntOutputs[neighbours.index(event)]+1

        # retrieve chunk starts    
        chunkTails=[]
        ind=0
        for elem in cntOutputs:
            if (int(elem)==0):
                chunkTails.append(neighbours[ind])
            ind=ind+1


        # remove wrong chunks (ie real outputs)
        real_outputs=[]

        outputs=[]
        for elem in rGlob:
            if (getReceiver(elem) not in outputs):
                outputs.append(getReceiver(elem))
        cntOutputsGlob=np.zeros(len(outputs))
        for event in outputs:
            for relation in rGlob:
                if(getSender(relation)==event):
                    cntOutputsGlob[outputs.index(event)]=cntOutputsGlob[outputs.index(event)]+1
        ind=0
        for elem in cntOutputsGlob:
            if (int(elem)==0):
                real_outputs.append(outputs[ind])
            ind=ind+1

        _chunkTails=[]
        for elem in chunkTails:
            if (elem not in real_outputs):
                _chunkTails.append(elem)

        return (cntOutputs == 0).sum(), _chunkTails

    else:
        return 0, [first]
Esempio n. 8
0
def retrieveFollower(elem, r):
    for relation in r:
        if(getSender(relation))==elem:
            return(getReceiver(relation))

    return ''
Esempio n. 9
0
def transitiveResponse(rExt, e, l, rGlob):
    if((e==getSender(l)) and(getType(l)=='milestone')):
        for rel in rGlob:
            if ((getType(rel)=='response') and (getSender(rel)==getReceiver(l))):
                rExt.append(rel)
    return rExt
Esempio n. 10
0
def transitiveIncludeExclude(rExt, e, l, rGlob):
    if((e==getReceiver(l)) and (getType(l) in ['condition', 'milestone'])):
        for rel in rGlob:
            if((getType(rel) in ['include','exclude']) and (getReceiver(rel)==getSender(l))):
                rExt.append(rel)
    return rExt