Semantic analysis

The semantic analysis of a message is the phase of its analysis which establishes its meaning by using the meaning of the elements ( words ) of the text, as opposed to the lexical or grammatical analyzes that break down the message using a lexicon or a grammar.

Linguistics

In the context of semantic analysis, the fact that two words are written in the same way does not necessarily mean that they have the same meaning: homonyms are polysemic .

For example, from a morpho-syntactic point of view, the word “vienna” can take on a different meaning in sentences such as “come here” (in this case, the verb “to come”) and in others like “going on vacation to Vienna” (here it is a proper name). From the semantic point of view, the same word “vienna” may correspond to the city of “Vienna”, which exists in Austria and France, as well as to the department of Vienne (in Vienna) etc . There is a multitude of ambiguous words in all languages 1, which can create misunderstandings. It is estimated that one word two, deprived of context is ambiguous in Indo-European languages 2 .
But from the perspective of interpretative semantics, these examples pose false problems because, in a situation of real communication, any competent speaker in French will know how to make a difference in the context between the words “Vienne” and “vienne”. In addition to the capital V in written form, contextual instructions make it clear that these are not the same words. In the two examples given above, the only grammatical logic makes it possible to understand that “vienne” is a verb, while “Vienne” is a toponym. This is why the question of meaning, and thus the semantic description, can arise across the word, but only at the level of a sequence, often several phrases, called “period” 3 .

It is therefore fundamental to analyze the meaning of words in order to understand what is said (or what others say). It is a human operation that we do every day, without necessarily being aware of it, which poses many problems for automatic analysis on computers. Especially in search engines , translation software and spell checkers, the results contain many errors.

Computers

In compilation , semantic analysis is the phase after the syntactic analysis and before the code generation . It carries out the checks necessary for the semantics of the considered programming language , adds information to the abstract syntax tree and constructs the symbol table . The checks carried out by this analysis are:

  • The resolution of names. The compiler constructs the symbol table by associating the labels (labels) found with the identifiers of variables, functions , types , and reports an error in cases where this is not possible. For example, for two variables with the same name and located in the same block, there is ambiguity, and therefore a programming error;
  • Type checking . The compiler checks the compatibility of the types in the statements and expressions. For example, if a function is initialized with 2 integer parameters, an error occurs if an attempt is made to pass a different number of parameters or if the passed parameters are not integers. During an assignment, the analyzer checks the compatibility between the two types, as well as the possible implicit conversion necessary;
  • The final assignment , requiring local variables to be initialized before being used. Some languages ​​consider that this initial non-assignment is a compilation error ( Java ), while the others do not specify anything or generate a warning (like gccfor the C ).

Be the first to comment

Leave a Reply

Your email address will not be published.


*