How to know the difference between two words with same pronunciation?


I am new to Japanese and I want to know how to find the differences between
words that are pronounced the exact same way. So let's say there was a word in
Hiragana and a word in Katakana, both pronounced the same way. And I was have
a general conversation with a Japanese person, how would we know the
difference between them?




Context.

For example, きかい can mean either "machine" (機械) or "opportunity" (機会). You can
come up with some sort of sentence that includes one of them, and it may be
ambiguous:

> 自己紹介{じこしょうかい}する **きかい** がなかった。

When spoken (or written in kana), this sentence can mean one of two things:

  * I didn't have a chance to introduce myself.
  * There was no machine that introduces itself.

Hopefully it should be obvious which one it is, especially when given a
context.

