Commit a91ee00f authored by jayd1860's avatar jayd1860
Browse files

v1.18

-- Add functionality to fix obsolete processing stream function calls which do not exist in registry by finding in the registry similar entries and replacing the obsolete function call in the processing stream.
-- Add FindClosestMatch methods to registry classes.
-- Add Compare methods to FuncCallClass classes
parent d735fe16
Loading
Loading
Loading
Loading
+36 −1
Original line number Diff line number Diff line
@@ -27,5 +27,40 @@ classdef ArgClass < matlab.mixin.Copyable
            str = obj.str;
        end

        
        % ----------------------------------------------------------------------------------
        function scorefinal = Compare(obj, obj2)
            v1 = obj.Extract();
            v2 = obj2.Extract();
            
            score = zeros(1, max([length(v1), length(v2)]));
            
            for ii = 1:length(v1)
                for jj = 1:length(v2)
                    if strcmp(v1{ii}, v2{jj})
                        if ii==jj
                            score(ii) = 1.00; 
                        else
                            score(ii) = 0.50;
                        end
                    end
                end
            end
            scorefinal = mean(score);
        end
 
        
        % ----------------------------------------------------------------------------------
        function args = Extract(obj)
            args = str2cell(obj.str,',');
            if args{1}(1)=='[' || args{1}(1)=='('
                args{1}(1) = '';
            end
            if args{end}(end)==']'
                args{end}(end) = '';
            end
        end        
        
    end
end
+46 −2
Original line number Diff line number Diff line
@@ -374,6 +374,14 @@ classdef FuncCallClass < handle
            fcallStrEncoded = obj.encodedStr;
        end
        
    end
    
    
    
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    % Comparison methods and overriden operators
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    methods
        
        % ----------------------------------------------------------------------------------
        % Override == operator: 
@@ -456,6 +464,42 @@ classdef FuncCallClass < handle
        end
        
        
        % ----------------------------------------------------------------------------------
        function scorefinal = Compare(obj, obj2)           
            score = [];
            if ~strcmp(obj.name, obj2.name)
                score(end+1) = 0;
            else
                score(end+1) = 0.50;
            end
            score(end+1) = 0.16 * obj.argOut.Compare(obj2.argOut);
            score(end+1) = 0.16 * obj.argIn.Compare(obj2.argIn);
            
            % For parameters first get separate score then add to total 
            scoreParams = zeros(1,max([length(obj.paramIn), length(obj2.paramIn)]));
            
            for ii = 1:length(obj.paramIn)
                for jj = 1:length(obj2.paramIn)
                    if strcmp(obj.paramIn(ii).GetName(), obj2.paramIn(jj).GetName())
                        scoreParams(ii) = obj.paramIn(ii).Compare(obj2.paramIn(jj));
                        if ii ~= jj
                            scoreParams(ii) = .75 * scoreParams(ii);
                        end
                    end
                end
            end
            
            % Tally up final results
            score = [score(:)', 0.18 * mean(scoreParams(:))']; 
            scorefinal = 100*sum(score);
        end
        
    end
    
    
    
    methods
        
        % ----------------------------------------------------------------------------------
        function val = GetErr(obj)
            val = obj.err;
+24 −1
Original line number Diff line number Diff line
@@ -112,6 +112,29 @@ classdef ParamClass < matlab.mixin.Copyable
            str = sprintf('%s %s %s', obj.name, formatstr, valuestr);
        end
        
        
        % ----------------------------------------------------------------------------------
        function scorefinal = Compare(obj, obj2)
            score = [];
            if ~strcmp(obj.name, obj2.name)
                scorefinal = 0;
                return
            else
                score(end+1) = 0.50;
            end
            if ~strcmp(obj.format, obj2.format)
                score(end+1) = 0;
            else
                score(end+1) = 0.20;
            end
            if ~all(obj.value == obj2.value)
                score(end+1) = 0;
            else
                score(end+1) = 0.30;
            end
            scorefinal = sum(score);
        end
                
    end
end
+31 −23
Original line number Diff line number Diff line
@@ -346,34 +346,18 @@ classdef ProcStreamClass < handle
    methods
        
        % ----------------------------------------------------------------------------------
        function [args, type] = GetInputArgs(obj, iFcall)
        function args = GetInputArgs(obj, iFcall)
            args={};
            type={};
            if isempty(obj.fcalls)
                return;
            end
            if ~exist('iFcall', 'var') || isempty(iFcall)
                iFcall = obj.GetFcallsIdxs();
            end
            nFcall = length(obj.fcalls);

            kk=1;
            for jj=1:length(iFcall)
                if iFcall(jj)>nFcall
                    continue;
                end
                if obj.fcalls(iFcall(jj)).argIn.str(1) ~= '('
                    continue;
                args{jj} = obj.fcalls(iFcall(jj)).argIn.Extract();
            end
                j=2;
                k = [strfind(obj.fcalls(iFcall(jj)).argIn.str,',') length(obj.fcalls(iFcall(jj)).argIn.str)+1];
                for ii=1:length(k)
                    args{kk} = obj.fcalls(iFcall(jj)).argIn.str(j:k(ii)-1);
                    j = k(ii)+1;
                    kk=kk+1;
                end
            end
            args = unique(args, 'stable');
            args = unique(args(:)', 'stable');
        end
        
        
@@ -932,6 +916,17 @@ classdef ProcStreamClass < handle
            err=0;
        end
                   
    end

       
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    % Methods for decoding encoded function calls and substituting fixing error 
    % if the encoded call does not exists or has changed in registry. If the 
    % function call doen not exist but another call with the same function name 
    % exists then these methods look for the most similar entry to substitute 
    % for the non-existent call. 
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    methods
                
        % ----------------------------------------------------------------------------------
        function Decode(obj, section)
@@ -1003,14 +998,27 @@ classdef ProcStreamClass < handle
                        obj.fcalls(kk) = FuncCallClass(temp, obj.reg);
                        kk=kk+1;
                    else
                        fprintf('Entry not found in registry: "%s"\n', section{ii})
                        fprintf('Entry \"%s\" not found in registry ...\n', section{ii})
                        fprintf('  Searching registry for equivalent or similar entry\n')
                        temp = obj.reg.FindClosestMatch(temp);
                        if ~isempty(temp)
                            fprintf('  Found similar entry: %s\n', temp.encodedStr);
                            obj.fcalls(kk) = FuncCallClass(temp, obj.reg);
                            kk=kk+1;
                        else
                            fprintf('  Found no similar entries. Discarding %s\n', section{ii})
                        end
                    end
                end
            end            
        end
        
    end
    
    
    
    methods
        
        % ----------------------------------------------------------------------------------
        function Add(obj, new)
            idx = length(obj.fcalls)+1;
+3 −0
Original line number Diff line number Diff line
@@ -239,6 +239,9 @@ classdef FuncHelpClass < matlab.mixin.Copyable
            if isempty(subsections)
                return;
            end
            if param > length(subsections)
                return;
            end
            
            % if the input is a number index into the inputs arrays, then we
            % don't need to seach for the param name
Loading