Difference between revisions of "Documentation/DevGuide/OfficeDev/Using Thesaurus"

From Apache OpenOffice Wiki
Jump to: navigation, search
m (Robot: Changing Category:Documentation/Developers Guide/Office Development)
m (FINAL VERSION FOR L10N)
Line 6: Line 6:
 
|NextPage=Documentation/DevGuide/OfficeDev/Events
 
|NextPage=Documentation/DevGuide/OfficeDev/Events
 
}}
 
}}
{{DISPLAYTITLE:Using Thesaurus}}
+
{{Documentation/DevGuideLanguages|Documentation/DevGuide/OfficeDev/{{SUBPAGENAME}}}}
 +
{{DISPLAYTITLE:Using Thesaurus}}
 
The interface used for the thesaurus is <idl>com.sun.star.linguistic2.XThesaurus</idl>. Accessing the thesaurus through the <code>LinguServiceManager</code> and initializing the mxThes object is done by:  
 
The interface used for the thesaurus is <idl>com.sun.star.linguistic2.XThesaurus</idl>. Accessing the thesaurus through the <code>LinguServiceManager</code> and initializing the mxThes object is done by:  
 
<!--[SOURCE:OfficeDev/Linguistic/LinguisticExamples.java]-->
 
<!--[SOURCE:OfficeDev/Linguistic/LinguisticExamples.java]-->

Revision as of 11:18, 13 May 2009



The interface used for the thesaurus is com.sun.star.linguistic2.XThesaurus. Accessing the thesaurus through the LinguServiceManager and initializing the mxThes object is done by:

  /** Get the Thesaurus to be used.
   */
  public boolean GetThes()
      throws com.sun.star.uno.Exception,
      com.sun.star.uno.RuntimeException
  {
      if (mxLinguSvcMgr != null)
          mxThes = mxLinguSvcMgr.getThesaurus();
      return mxThes != null;
  }

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

Thesaurus related Properties of com.sun.star.linguistic2.LinguProperties
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." );
  else
  {
      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