Using Thesaurus

From Apache OpenOffice Wiki
Jump to: navigation, search

The interface used for the thesaurus is Accessing the thesaurus through the LinguServiceManager and initializing the mxThes object is done by:

  /** Get the Thesaurus to be used.
  public boolean GetThes()
      if (mxLinguSvcMgr != null)
          mxThes = mxLinguSvcMgr.getThesaurus();
      return mxThes != null;

The properties of the LinguProperties service evaluated by the thesaurus are:

Thesaurus related Properties of
IsIgnoreControlCharacters Defines if control characters should be ignored or not.
IsGermanPreReform Defines if the new German spelling rules should be used for German language text or not.

Changing the values of these properties in the LinguProperties affect all subsequent calls to the thesaurus. The following example about retrieving synonyms shows this:

  XMeaning[] xMeanings = mxThes.queryMeanings( "house", aLocale, aEmptyProps );
  if (xMeanings == null)
      System.out.println( "nothing found." );
      for (int i = 0; i < xMeanings.length; ++i)
          System.out.println( "Meaning: " + xMeanings[i].getMeaning() );
          String[] aSynonyms = xMeanings[i].querySynonyms();
          for (int k = 0; k < aSynonyms.length; ++k)
              System.out.println( " Synonym: " + aSynonyms[k] );

The reason to subdivide synonyms into different meanings is because there are different synonyms for some words that are not even closely related. For example, the word 'house' has the synonyms 'home', 'place', 'dwelling', 'family', 'clan', 'kindred', 'room', 'board', and 'put up'.

The first three in the above list have the meaning of 'building where one lives' where the next three mean that of 'a group of people sharing common ancestry' and the last three means that of 'to provide with lodging'. Thus, having meanings is a way to group large sets of synonyms into smaller ones with approximately the same definition.

Content on this page is licensed under the Public Documentation License (PDL).
Personal tools
In other languages