I am sorry if my question is too simple.

Is every semigroup associated to a group? If no, what conditions should be satisfied for a semigroup to have an associated group? If yes, how can I find the group?

I thought of the universal property. Let $X$ be a semigroup, define $G$ to be the group with a morphism of semigroups $\tau: X \rightarrow G$, such that if $H$ is any group having similar morphism $\phi: X \rightarrow H$, there is a group homomorphism $\psi: G \rightarrow H$, such that $\phi = \psi \circ \tau$.

Uniqueness is obtained from the universal property. But existence needs construction. When there is no element $x$ in $X$ such that for any $a \in X$, $xa = ax = a$, i.e., $X$ doesn't contain an identity element, I define $G = \{ 1 \} \cup \{ x\_1^{k\_1} \cdots x\_n^{k\_n} | x\_i \in X, k\_i \in \{ \pm 1 \}, i = 1, \cdots, n; k\_jk\_{j+1} = -1, 1 \leq j <n \}$ with equivalence relations: $x^{k}x^{-k} \equiv 1$, $x\_1^{k\_1} \cdots x\_{i-1}^{k\_{i-1}}x\_i^kx\_i^{-k}x\_{i+2}^{k\_{i+2}} \cdots x\_n^{k\_n} \equiv x\_1^{k\_1} \cdots x\_{i-1}^{k\_{i-1}}x\_{i+2}^{k\_{i+2}} \cdots x\_n^{k\_n}$ and group operations

Multiplication: 
$\begin{cases}
 1 \cdot x\_1^{k\_1} \cdots x\_n^{k\_n} = x\_1^{k\_1} \cdots x\_n^{k\_n} \cdot 1 =x\_1^{k\_1} \cdots x\_n^{k\_n}, \\ 
 x\_1^{k\_1} \cdots x\_n^{k\_n} \cdot y\_1^{l\_1} \cdots y\_m^{l\_m}= \begin{cases}
 x\_1^{k\_1} \cdots x\_n^{k\_n}y\_1^{l\_1} \cdots y\_m^{l\_m} & \text{ if } k\_nl\_1=-1, \\ 
 x\_1^{k\_1} \cdots (x\_ny\_1)^{l\_1} \cdots y\_m^{l\_m}& \text{ if } k\_nl\_1=1; 
\end{cases}
\end{cases}$

Inverse: $1^{-1} =1$, $(x\_1^{k\_1} \cdots x\_n^{k\_n})^{-1} = x\_n^{-k\_n} \cdots x\_1^{-k\_1}$.

Then clearly, the morphism $\tau: X \rightarrow G$ can be defined to send every $x \in X$ to $x \in G$.

Beside possible leaks, this construction is not precise, and doesn't work in case when $G$ already has an identity, or even is a group.

So, when are semigroups associated with a group, and how can I construct a group from a semigroup?

Thanks in advance.