Now when the Pharisee who had invited Him saw this, he said to himself, “If this man were a prophet He would know who and what sort of person this woman is who is touching Him, that she is a sinner.” Firstly the english requires clarification, this is not something he was muttering under his breath but was thinking in his head. The KJV in e-sword clarifies this. Given it was something he was thinking how did Luke come to know his thoughts. Was there a briefing after the event where Jesus explained what was going on? Sadly there are no parallel passages in the other gospels, so my more detailed commentaries on Mathew, Mark and John cannot be used.