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

From Apache OpenOffice Wiki
Jump to: navigation, search
(Initial author Sun Microsystems, Inc.)
 
m
 
(6 intermediate revisions by 4 users not shown)
Line 6: Line 6:
 
|NextPage=Documentation/DevGuide/OfficeDev/Events
 
|NextPage=Documentation/DevGuide/OfficeDev/Events
 
}}
 
}}
{{DISPLAYTITLE:Using Thesaurus}}
+
{{Documentation/DevGuideLanguages|Documentation/DevGuide/OfficeDev/{{SUBPAGENAME}}}}
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:  
+
{{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 <code>mxThes</code> object is done by:  
 
<!--[SOURCE:OfficeDev/Linguistic/LinguisticExamples.java]-->
 
<!--[SOURCE:OfficeDev/Linguistic/LinguisticExamples.java]-->
 
+
<syntaxhighlight lang="java">
 
   /** Get the Thesaurus to be used.
 
   /** Get the Thesaurus to be used.
 
   */
 
   */
Line 20: Line 21:
 
       return mxThes != null;
 
       return mxThes != null;
 
   }
 
   }
 
+
</syntaxhighlight>
 
The properties of the <code>LinguProperties</code> service evaluated by the thesaurus are:
 
The properties of the <code>LinguProperties</code> service evaluated by the thesaurus are:
  
Line 36: Line 37:
 
Changing the values of these properties in the <code>LinguProperties</code> affect all subsequent calls to the thesaurus. The following example about retrieving synonyms shows this:  
 
Changing the values of these properties in the <code>LinguProperties</code> affect all subsequent calls to the thesaurus. The following example about retrieving synonyms shows this:  
 
<!--[SOURCE:OfficeDev/Linguistic/LinguisticExamples.java]-->
 
<!--[SOURCE:OfficeDev/Linguistic/LinguisticExamples.java]-->
 
+
<syntaxhighlight lang="java">
 
   XMeaning[] xMeanings = mxThes.queryMeanings( "house", aLocale, aEmptyProps );
 
   XMeaning[] xMeanings = mxThes.queryMeanings( "house", aLocale, aEmptyProps );
 
   if (xMeanings == null)
 
   if (xMeanings == null)
Line 50: Line 51:
 
       }
 
       }
 
   }
 
   }
 
+
</syntaxhighlight>
 
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 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 aboce 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.
+
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.
  
 
{{PDL1}}
 
{{PDL1}}
[[Category: Office Development]]
+
 
 +
[[Category:Documentation/Developer's Guide/Office Development]]

Latest revision as of 14:18, 9 August 2021



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