Information retrieval (IR) based bug location technology is a relatively recognized lightweight bug location method at present. Most IR bug location methods solve the problem of semantic difference between natural language and code language in the bug report based on code semantic intelligibility, and use semantic similarity to construct IR model to locate source code errors through bug report. However, most IR localization studies take error report description as the guidance for code semantic generation, ignoring the difference between error report and error semantics. Due to the irregular submission of error reports and the ambiguity of error descriptions, this kind of research faces the problem of low location accuracy. We found that the code data is the data written in the specification and verified by the program compilation. Compared with the bug data submitted by the tester, the semantic ambiguity is relatively weaker. Therefore, we use code data as the semantic generation of teacher network training bug data to form SGBL method. In addition, based on the bug data set composed by Jena and other projects, we evaluated the effectiveness of our method and explained the relationship between the semantic extraction method and the bug location accuracy. The experimental results show the effectiveness of the proposed method.