sed, 367 (source code bytes) + 532 (amount of matchsticks for the source code) = 899
s/[^0-9a-jln-suxyz]//Ig;/^$/{s/.*/0/;b};s/.+/&; %1ir %%7lnu %%%4cfhjoy %%%%235bdegpqsxz %%%%%069a %%%%%%8/;:1;s/([^% ])(.+ (%+)[^ ]*\1)/%\3 \2/I;/ ;/!b1;s/;.+//;s/^/,;/;:2;s/(;[^%]*)(%+)/\2\1/;:3;s/,%{10}/%,/;s/^%/,&/;/%{10}/b3;/;.*%/b2;:4;s/,[;,]/,0,/;/,[;,]/b4;s/%{9}/9/g;s/%{8}/8/g;s/%{7}/7/g;s/%{6}/6/g;s/%{5}/5/g;s/%%%%/4/g;s/%%%/3/g;s/%%/2/g;s/%/1/g;s/[^0-9]//g
Try it Online
Multi-line version:
s/[^0-9a-jln-suxyz]//Ig
/^$/{s/.*/0/;b}
s/.+/&; %1ir %%7lnu %%%4cfhjoy %%%%235bdegpqsxz %%%%%069a %%%%%%8/
:1
s/([^% ])(.+ (%+)[^ ]*\1)/%\3 \2/I
/ ;/!b1
s/;.+//
s/^/,;/
:2
s/(;[^%]*)(%+)/\2\1/
:3
s/,%{10}/%,/
s/^%/,&/
/%{10}/b3
/;.*%/b2
:4
s/,[;,]/,0,/
/,[;,]/b4
s/%{9}/9/g
s/%{8}/8/g
s/%{7}/7/g
s/%{6}/6/g
s/%{5}/5/g
s/%%%%/4/g
s/%%%/3/g
s/%%/2/g
s/%/1/g
s/[^0-9]//g
Explanation:
The above script reads standard input line by line (into the pattern space -- the usual "sed way") and, for each line, it outputs the amount of matchsticks necessary to represent all the matchstick-representable characters in that line. The computations for each line of input happen as follows:
s/[^0-9a-jln-suxyz]//Ig
First, we remove every character for which we don't have a corresponding matchstick representation (as given on the question) from the pattern space. That is, we remove every character which isn't either a numeral from "0" to "9", a letter from "a" to "j", "n" to "s", "l", "u", "x", "y" or "z". Uppercase and lowercase letters are treated the same.
/^$/{s/.*/0/;b}
If we end up with an empty pattern space, we print 0 (automatically followed by a newline, like sed always does unless you pass a special flag to it), skip all posterior lines of the script and proceed into next "sed cycle" (i.e., read the next line of input and repeat processing all over again from the first command until there are no more lines of input to be processed).
s/.+/&; %1ir %%7lnu %%%4cfhjoy %%%%235bdegpqsxz %%%%%069a %%%%%%8/
Otherwise, if the pattern space is not empty, we now divide it into two "sub-spaces" separated by a semicolon: first comes the input space, which is initially formed by all characters which weren't removed from the pattern space after the execution of line 1; next comes the semicolon, and after it the map space.
The map space tells us how many matchsticks beside 1 are needed to represent each relevant alphanumeric character. If we want to know how many matchsticks are necessary to represent any alphanumeric character in the map space, we look for the first sequence of contiguous %'s on the left of that character, and the answer will be the number of %'s in that sequence plus 1. So, for example, the number of matchsticks necessary to represent a "b" is 4 + 1 = 5; to represent a "4", 3 + 1 = 4, to represent a "y", 3 + 1 = 4; and so on.
:1
s/([^% ])(.+ (%+)[^ ]*\1)/%\3 \2/I
/ ;/!b1
This is a loop. Now we will replace every character in the input space by the (complete) sequence of %'s whose number indicates the necessary amount of matchsticks to represent that character, and follow that sequence by a white space character (again, uppercase and lowercase letters are given the same treatment). The criterion to determine whether the loop should end is to check whether there's a white space character on the immediate left of the semicolon in the pattern space: if that condition holds, we terminate the loop and continue into the next line.
s/;.+//
s/^/,;/
Those two lines remove the semicolon and everything after it from the pattern space and then insert a comma and a semicolon into the beginning of the pattern space. We now have the pattern space divided once again into two new sub-spaces: the analog result space before the semicolon, and the analog input space after it.
The analog input space is just what we have previously called the "input space", but in a different form: it now contains sequences of %'s separated by white space. The total number of such %'s in the analog input space is the same number of matchsticks necessary to represent the initial input character string, i.e., that number is the result. But we must print that result in decimal notation, not as a sequence of percent signs. The purpose of the analog result space is to hold an analog representation of each digit of the result while we compute that result by summing each contiguous sequence of %'s in the analog input space one by one. The next loop performs that sum:
:2
s/(;[^%]*)(%+)/\2\1/
:3
s/,%{10}/%,/
s/^%/,&/
/%{10}/b3
/;.*%/b2
First, after label 2, we move the next contiguous sequence of %'s after the semicolon from the analog input space into the immediate left of the semicolon, in the analog result space;
Next, we step into a sub-loop (label 3) which performs the following computations:
If there's a contiguous sequence of ten %'s after a comma in the analog result space, we remove those %'s and put a single % immediately at the left of the comma. To put it simply, this indicates that one of the decimal places in the result has acquired more than 9 units, so we take 10 units away from that decimal place and add 1 unit to the next larger decimal place;
If a "%" is the first character in the pattern space, we insert a new comma immediately before it. This indicates that the sum has reached a value whose decimal representation has one more decimal place on the left than the previous value;
If there are still any contiguous sequence of ten %'s in the analog result space, we go back to label 3 and repeat this process. Otherwise, we exit this sub-loop and step into the next line.
Now, if there is still any "%" in the analog input space (i.e., after the semicolon), it means that there is still some number of matchsticks to be added to the total sum -- so we go back to label 2.
Once the sum is complete, we step into the final loop of the code:
:4
s/,[;,]/,0,/
/,[;,]/b4
Here, we check every pair of characters formed by a comma on the left and either a semicolon or a comma on the right. We replace all such pairs of characters by a "0" inside two commas.
s/%{9}/9/g
s/%{8}/8/g
s/%{7}/7/g
s/%{6}/6/g
s/%{5}/5/g
s/%%%%/4/g
s/%%%/3/g
s/%%/2/g
s/%/1/g
The above piece of code is quite simple: we replace each contiguous sequence of %'s in the analog result space by a decimal digit character which corresponds to the number of %'s in each particular sequence.
s/[^0-9]//g
Finally, we remove every non-numeral character from the pattern space and what remains is the final result in the familiar decimal notation. That value is printed on standard output and the next sed cycle begins, if there are any more input lines to be processed.
|_\n|_
(lowercaset
) \$\endgroup\$[0-9a-z]
, should we count 0 matchsticks? That's what I understand from Your score is your source code run through this algorithm, plus the length of your source code in bytes. \$\endgroup\$