"(A dog) bit (my friend)." "(My friend) bit (a dog)." Both parse as "(compound subject) verb (compound object)." Both "my" and "a" function as adjectives modifying the single noun after them.
The sentences have identical parse trees, even when considering the types of the nodes. They are grammatically identical.
They are not identical. They are similar at this production step:
S -> subj verb obj
verb -> ... -> bit
Other than that, the derivation diverges:
subj -> ... -> a dog
subj -> ... -> my friend
Of course, any two things are the same, if you choose to ignore anything that is different and define "sameness" that way.
This isn't conveniently bending definitions to make myself sound correct. This is the specific technical definition that was worked out by linguists in their empirical examination of language (and later adopted by computer scientists because it happens to work nicely with programming languages too). It might not match with some colloquial uses, but it's a reasonable assumption that an article discussing linguistics would be using the precise linguistic definition.
I get the point of the example, but it seems different at the grammatical level too.
Subject/object should be at a different level above grammar.
There are animals that have demonstrated some "semantics". There are parrots that do better than Koko with spoken language, but still do not produce anything like the grammatical constructs humans do. Everything I've seen out of parrots could be covered by memorizing a handful of grammar constructs in a very brute-force manner, and they have no deliberate ability to combine them.
The core point is that to distinguish '"A dog bit my friend" and "My friend bit a dog."' requires grammar, which so far as I know as one who tends to pay attention to these things, is not a thing that animals have ever demonstrated a deep understanding of (if there are animals that could distinguish that, that is probably their maximum limit) and certainly never demonstrated production of. (Or, at the very least, we've never decoded and proved is speech, if you're thinking of whales and dolphins and such.) If you produce and understand speech as the Koko sentence above, you can't distinguish those two sentences. It's not about whether changing subject and object makes a "different sentence" by some metric, it's about whether the animal in question has a well-defined usage of subject and object as distinct grammatical categories at all.
For example, in my sentence "The cup wants Koko" I used earlier, it is invalid, yet everyone here reading it has at the very least the same understanding of why it is invalid, because what it says and the grammar of why it says that is completely clear to us.
† An operation mapping a set X onto another X' by relating every member of X with some member of X', so that X' has the same number of members as X, but the identity of the members may be different.