The sword knows. Notice how despite requesting a woman, not only did the sword not complain but it was even elated by seeing the new companion flustered after the night. IIRC There were some hints in the last chapter too about the sword realizing the roommate was a woman, but it's been awhile.