Access Hunspell from an OOo Extension

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Access Hunspell from an OOo Extension

William Colen
Hello,

Is it possible to access Hunspell analyzer (hunspell -m)  from an OOo
Extension written in Java?
I couldn't find that in any documentation.

Thanks,
William
Reply | Threaded
Open this post in threaded view
|

Re: Access Hunspell from an OOo Extension

William Colen
Let me detail what I need:
I have access to a Hunspell dictionary for pt-PT with morphological
annotation. I'd like to access that morphological data to write a new
Proofreader (grammar checker).
That would be easier if I could access the OOo Hunspell wrapper.
If that is not possible, I'll try to use FSA like LT did.

Thanks,
William


On Fri, Sep 25, 2009 at 11:18 AM, William Colen <[hidden email]>wrote:

> Hello,
>
> Is it possible to access Hunspell analyzer (hunspell -m)  from an OOo
> Extension written in Java?
> I couldn't find that in any documentation.
>
> Thanks,
> William
>
Reply | Threaded
Open this post in threaded view
|

Re: Re: Access Hunspell from an OOo Extension

thomas.lange

Hi,

William Colen wrote:

> Let me detail what I need:
> I have access to a Hunspell dictionary for pt-PT with morphological
> annotation. I'd like to access that morphological data to write a new
> Proofreader (grammar checker).
> That would be easier if I could access the OOo Hunspell wrapper.
> If that is not possible, I'll try to use FSA like LT did.
>
> Thanks,
> William
>  

Can't be done. There is no UNO API for that.

Thomas



---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Re: Access Hunspell from an OOo Extension

thomas.lange
In reply to this post by William Colen

Hi,

> Let me detail what I need:
> I have access to a Hunspell dictionary for pt-PT with morphological
> annotation. I'd like to access that morphological data to write a new
> Proofreader (grammar checker).
> That would be easier if I could access the OOo Hunspell wrapper.
> If that is not possible, I'll try to use FSA like LT did.
>  

On second thought:
If Java has something similar to LoadLibrary
  http://msdn.microsoft.com/en-us/library/ms684175(VS.85).aspx
it might be done.

You'll need functionality that will allow you to load a C/C++ library
and call function in that.
I was told Java might have something like that...
In that case you just need to find the hunspell library in the
installation and make use of it.


Thomas




---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Re: Access Hunspell from an OOo Extension

Németh László-2
In reply to this post by thomas.lange
Hello,

In fact, you can use the XML API of Hunspell over the isValid() and
spell() methods of XSpellChecker UNO interface. It is already used by
the thesaurus component for stemming and morphological generation (see
http://qa.openoffice.org/issues/show_bug.cgi?id=19563).

From the Hunspell manual (hunspell.3):

   XML API
       The  spell()  [isValid() of XSpellChecker] function  returns
non-zero  for  the   "<?xml?>"   input
       indicating the XML API support.

       The  suggest() [spell() of XSpellChecker]  function stems,
analyzes and generates the forms of the
       input word, if it was added by one of the following "SPELLML" syntaxes:

              <?xml?>
              <query type="analyze">
              <word>dogs</word>
              </query>

              <?xml?>
              <query type="stem">
              <word>dogs</word>
              </query>

              <?xml?>
              <query type="generate">
              <word>dog</word>
              <word>cats</word>
              </query>

              <?xml?>
              <query type="generate">
              <word>dog</word>
              <code><a>is:pl</a><a>is:poss</a></code>
              </query>

       The  outputs  of  the type="stem" query and the stem() library function
       are the same. The output  of  the  type="analyze"  query  is  a  string
       contained  a <code><a>result1</a><a>result2</a>...</code> element. This
       element can be used in the second syntax of the type="generate"  query.
.......

Regards,
László



2009/9/25 Thomas Lange - Sun Germany - ham02 - Hamburg <[hidden email]>:

>
> Hi,
>
> William Colen wrote:
>> Let me detail what I need:
>> I have access to a Hunspell dictionary for pt-PT with morphological
>> annotation. I'd like to access that morphological data to write a new
>> Proofreader (grammar checker).
>> That would be easier if I could access the OOo Hunspell wrapper.
>> If that is not possible, I'll try to use FSA like LT did.
>>
>> Thanks,
>> William
>>
>
> Can't be done. There is no UNO API for that.
>
> Thomas
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Re: Access Hunspell from an OOo Extension

William Colen
In reply to this post by thomas.lange
Hi, Thomas,

That is a good solution. There are some Java wrapper to Hunspell, if we can
at least using the Hunspell library distributed by OOo I'll not have to
compile it for all platforms and distribute with my extension.

Thank you!
William


On Fri, Sep 25, 2009 at 11:54 AM, Thomas Lange - Sun Germany - ham02 -
Hamburg <[hidden email]> wrote:

>
> Hi,
>
> > Let me detail what I need:
> > I have access to a Hunspell dictionary for pt-PT with morphological
> > annotation. I'd like to access that morphological data to write a new
> > Proofreader (grammar checker).
> > That would be easier if I could access the OOo Hunspell wrapper.
> > If that is not possible, I'll try to use FSA like LT did.
> >
>
> On second thought:
> If Java has something similar to LoadLibrary
>  http://msdn.microsoft.com/en-us/library/ms684175(VS.85).aspx<http://msdn.microsoft.com/en-us/library/ms684175%28VS.85%29.aspx>
> it might be done.
>
> You'll need functionality that will allow you to load a C/C++ library
> and call function in that.
> I was told Java might have something like that...
> In that case you just need to find the hunspell library in the
> installation and make use of it.
>
>
> Thomas
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
Reply | Threaded
Open this post in threaded view
|

Re: Re: Access Hunspell from an OOo Extension

William Colen
In reply to this post by Németh László-2
Thank you, László

I'll try that! I was wondering how I'll access my dictionary. Maybe I'll
have to add it as a dictionary extension with a special locale (using a
special Variant)?
I'll have to use my own dictionary for now and figure out how to stay
compatible with the official dictionary for that language. Latter I would
try to merge the official dictionary (without morph annotation) with mine.

Thanks,
William


On Fri, Sep 25, 2009 at 12:00 PM, Németh László <[hidden email]>wrote:

> Hello,
>
> In fact, you can use the XML API of Hunspell over the isValid() and
> spell() methods of XSpellChecker UNO interface. It is already used by
> the thesaurus component for stemming and morphological generation (see
> http://qa.openoffice.org/issues/show_bug.cgi?id=19563).
>
> From the Hunspell manual (hunspell.3):
>
>   XML API
>       The  spell()  [isValid() of XSpellChecker] function  returns
> non-zero  for  the   "<?xml?>"   input
>       indicating the XML API support.
>
>       The  suggest() [spell() of XSpellChecker]  function stems,
> analyzes and generates the forms of the
>       input word, if it was added by one of the following "SPELLML"
> syntaxes:
>
>              <?xml?>
>              <query type="analyze">
>              <word>dogs</word>
>              </query>
>
>              <?xml?>
>              <query type="stem">
>              <word>dogs</word>
>              </query>
>
>              <?xml?>
>              <query type="generate">
>              <word>dog</word>
>              <word>cats</word>
>              </query>
>
>              <?xml?>
>              <query type="generate">
>              <word>dog</word>
>              <code><a>is:pl</a><a>is:poss</a></code>
>              </query>
>
>       The  outputs  of  the type="stem" query and the stem() library
> function
>       are the same. The output  of  the  type="analyze"  query  is  a
>  string
>       contained  a <code><a>result1</a><a>result2</a>...</code> element.
> This
>       element can be used in the second syntax of the type="generate"
>  query.
> .......
>
> Regards,
> László
>
>
>
> 2009/9/25 Thomas Lange - Sun Germany - ham02 - Hamburg <
> [hidden email]>:
> >
> > Hi,
> >
> > William Colen wrote:
> >> Let me detail what I need:
> >> I have access to a Hunspell dictionary for pt-PT with morphological
> >> annotation. I'd like to access that morphological data to write a new
> >> Proofreader (grammar checker).
> >> That would be easier if I could access the OOo Hunspell wrapper.
> >> If that is not possible, I'll try to use FSA like LT did.
> >>
> >> Thanks,
> >> William
> >>
> >
> > Can't be done. There is no UNO API for that.
> >
> > Thomas
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [hidden email]
> > For additional commands, e-mail: [hidden email]
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
Reply | Threaded
Open this post in threaded view
|

Re: Re: Access Hunspell from an OOo Extension

Németh László-2
Hi,

Here is a Basic example:

Dim aLocale As New com.sun.star.lang.Locale
Dim emptyArgs(0) As New com.sun.star.beans.PropertyValue
aLocale.Language = "en"
aLocale.Country = "US"
aLocale.Variant = ""
Dim vSpeller As Variant
vSpeller = createUnoService("com.sun.star.linguistic2.SpellChecker")
hasXMLAPI = "<?xml?>"
query = "<?xml?><query type='analyze'><word>mice</word></query>"
if (vSpeller.isValid(hasXMLAPI, aLocale, emptyArgs())) then
        vReturn = vSpeller.spell(query, aLocale, emptyArgs())
        if (not IsNull(vReturn)) then
                if (vReturn.getAlternativesCount() > 0) then
                        s = vReturn.getAlternatives()
                        MsgBox "Result: " & s(0)
                end if
        end if
end if

The result of the analysis of the word "mice" is "<code><a> st:mouse
ts:Ns</a></code>" (stem: mouse, affix:Ns, POS information (po: fields)
is missing from the recent en-US dictionary, but you can add this and
arbitrary fields to the morphological description).

It seems, dictionary variant may be good for the development (adding a
Variant string to the Locale parameter of the isValid/spell,
OpenOffice.org doesn't use the base en-US dictionary).

By the way, next version of the (language-neutral) Lightproof grammar
checker extension will use Hunspell for morphological analysis, too.

Regard,
László

2009/9/25 William Colen <[hidden email]>:

> Thank you, László
>
> I'll try that! I was wondering how I'll access my dictionary. Maybe I'll
> have to add it as a dictionary extension with a special locale (using a
> special Variant)?
> I'll have to use my own dictionary for now and figure out how to stay
> compatible with the official dictionary for that language. Latter I would
> try to merge the official dictionary (without morph annotation) with mine.
>
> Thanks,
> William
>
>
> On Fri, Sep 25, 2009 at 12:00 PM, Németh László <[hidden email]>wrote:
>
>> Hello,
>>
>> In fact, you can use the XML API of Hunspell over the isValid() and
>> spell() methods of XSpellChecker UNO interface. It is already used by
>> the thesaurus component for stemming and morphological generation (see
>> http://qa.openoffice.org/issues/show_bug.cgi?id=19563).
>>
>> From the Hunspell manual (hunspell.3):
>>
>>   XML API
>>       The  spell()  [isValid() of XSpellChecker] function  returns
>> non-zero  for  the   "<?xml?>"   input
>>       indicating the XML API support.
>>
>>       The  suggest() [spell() of XSpellChecker]  function stems,
>> analyzes and generates the forms of the
>>       input word, if it was added by one of the following "SPELLML"
>> syntaxes:
>>
>>              <?xml?>
>>              <query type="analyze">
>>              <word>dogs</word>
>>              </query>
>>
>>              <?xml?>
>>              <query type="stem">
>>              <word>dogs</word>
>>              </query>
>>
>>              <?xml?>
>>              <query type="generate">
>>              <word>dog</word>
>>              <word>cats</word>
>>              </query>
>>
>>              <?xml?>
>>              <query type="generate">
>>              <word>dog</word>
>>              <code><a>is:pl</a><a>is:poss</a></code>
>>              </query>
>>
>>       The  outputs  of  the type="stem" query and the stem() library
>> function
>>       are the same. The output  of  the  type="analyze"  query  is  a
>>  string
>>       contained  a <code><a>result1</a><a>result2</a>...</code> element.
>> This
>>       element can be used in the second syntax of the type="generate"
>>  query.
>> .......
>>
>> Regards,
>> László
>>
>>
>>
>> 2009/9/25 Thomas Lange - Sun Germany - ham02 - Hamburg <
>> [hidden email]>:
>> >
>> > Hi,
>> >
>> > William Colen wrote:
>> >> Let me detail what I need:
>> >> I have access to a Hunspell dictionary for pt-PT with morphological
>> >> annotation. I'd like to access that morphological data to write a new
>> >> Proofreader (grammar checker).
>> >> That would be easier if I could access the OOo Hunspell wrapper.
>> >> If that is not possible, I'll try to use FSA like LT did.
>> >>
>> >> Thanks,
>> >> William
>> >>
>> >
>> > Can't be done. There is no UNO API for that.
>> >
>> > Thomas
>> >
>> >
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: [hidden email]
>> > For additional commands, e-mail: [hidden email]
>> >
>> >
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [hidden email]
>> For additional commands, e-mail: [hidden email]
>>
>>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]