You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@opennlp.apache.org by Radu Simionescu <ra...@yahoo.com> on 2011/03/13 00:54:01 UTC

Hybrid POS tagger

Hello

I am making paper a pos tagger for Romanian for my disertation. I want  to be 
able to restrict the outcomes even more than just using a  dictionary. I want to 
use some rules for disambiguation, based on the  context. This would allow me to 
use smaller corpus, and also to fix  consistent output mistakes.

So I want to be able to give the postagger the possible set of outcomes  for 
each word from the input, separately. So, since the training of a  model doesn't 
really use the pos dictionary, I figured I could make this parser by  making 
small modifications to the API, because the dictionary can change from one 
sentence/word to the other. Please let me know if I am wrong.

Thanks
Rad 


      

Re: Hybrid POS tagger

Posted by "william.colen@gmail.com" <wi...@gmail.com>.
Hi Radu,

Did you measure the performance before and after the changes?

Have you tried to create a custom feature generator according to the
language constraints? Maybe it would be more flexible to let the framework
decide the importance of the constraints according to the training corpus,
taking other context information into account.

I am interested on that because I'm working on pos-tagging improvements for
Portuguese, and I was focusing on improving the context generators according
to language particularities.

Regards,
William

On Tue, Mar 15, 2011 at 2:40 PM, Radu Simionescu <ra...@yahoo.com> wrote:

> Yes, something like that
>
>
>
> Pe Mar 15, 2011, la 6:12 PM, Jörn Kottmann <ko...@gmail.com> a scris:
>
> > On 3/15/11 4:49 PM, Radu Simionescu wrote:
> >> I can't wrap everything there. The validSequence method is called for
> each word
> >> in the sentence. But to generate the sequence of sets of possible
> outputs I just
> >> need to loop once through the input sentence, before anything else, and
> store
> >> these in an instance, and then use them. So, this is what I did right
> now, I
> >> implemented the SequenceValidator.
> >
> > That is actually a pattern you can observe in many places of our feature
> generation.
> > Is it this way possible for you to wrap everything?
> >
> >> I am reading the sequence of posibilities
> >> from a static variable in the validSequence method. I am setting the
> static
> >> variable before every tagging call... but this can't really be
> considered
> >> wrapping. This is not healthy coding, in my opinion.
> > This part I do not understand actually. You mean, you pass the possible
> sequences
> > first to the sequence validator and then you call the tag method? I am
> little confused.
> >
> > Jörn
>

Re: Hybrid POS tagger

Posted by Radu Simionescu <ra...@yahoo.com>.
Yes, something like that



Pe Mar 15, 2011, la 6:12 PM, Jörn Kottmann <ko...@gmail.com> a scris:

> On 3/15/11 4:49 PM, Radu Simionescu wrote:
>> I can't wrap everything there. The validSequence method is called for each word
>> in the sentence. But to generate the sequence of sets of possible outputs I just
>> need to loop once through the input sentence, before anything else, and store
>> these in an instance, and then use them. So, this is what I did right now, I
>> implemented the SequenceValidator.
> 
> That is actually a pattern you can observe in many places of our feature generation.
> Is it this way possible for you to wrap everything?
> 
>> I am reading the sequence of posibilities
>> from a static variable in the validSequence method. I am setting the static
>> variable before every tagging call... but this can't really be considered
>> wrapping. This is not healthy coding, in my opinion.
> This part I do not understand actually. You mean, you pass the possible sequences
> first to the sequence validator and then you call the tag method? I am little confused.
> 
> Jörn

Re: Hybrid POS tagger

Posted by Jörn Kottmann <ko...@gmail.com>.
On 3/15/11 4:49 PM, Radu Simionescu wrote:
> I can't wrap everything there. The validSequence method is called for each word
> in the sentence. But to generate the sequence of sets of possible outputs I just
> need to loop once through the input sentence, before anything else, and store
> these in an instance, and then use them. So, this is what I did right now, I
> implemented the SequenceValidator.

That is actually a pattern you can observe in many places of our feature 
generation.
Is it this way possible for you to wrap everything?

> I am reading the sequence of posibilities
> from a static variable in the validSequence method. I am setting the static
> variable before every tagging call... but this can't really be considered
> wrapping. This is not healthy coding, in my opinion.
This part I do not understand actually. You mean, you pass the possible 
sequences
first to the sequence validator and then you call the tag method? I am 
little confused.

Jörn

Re: Hybrid POS tagger

Posted by Radu Simionescu <ra...@yahoo.com>.
I can't wrap everything there. The validSequence method is called for each word 
in the sentence. But to generate the sequence of sets of possible outputs I just 
need to loop once through the input sentence, before anything else, and store 
these in an instance, and then use them. So, this is what I did right now, I 
implemented the SequenceValidator. I am reading the sequence of posibilities 
from a static variable in the validSequence method. I am setting the static 
variable before every tagging call... but this can't really be considered 
wrapping. This is not healthy coding, in my opinion.

But yes, if there was a way to feed in my own sequence validator, I wouldn't 
have had to modify the api. So, your suggestion would work for my case. I was 
just saying that I am not sure if it is the best solution, in terms of code 
organizing.

Radu



________________________________
From: Jörn Kottmann <ko...@gmail.com>
To: opennlp-users@incubator.apache.org
Sent: Tue, March 15, 2011 5:22:24 PM
Subject: Re: Hybrid POS tagger

On 3/15/11 4:01 PM, Radu Simionescu wrote:
> I do not store the sequences of possible sets of outcomes. I generate them at
> runtime based on a dictionary and disambiguation rules(applied on the given
> input sentence). So for my case, I needed a method like tagger.tag(String[]
> sentence, String[][] possible_outcomes_for_each_word). Where
> possible_outcomes_for_each_word is generated by some code which is not related
> to OpenNLP.  where sentence.length() = possible_outcomes_for_each_word.length
>

That is exactly where the sequence validation is for. Couldn't you wrap your
validation mechanism inside a sequene validator? There you get the full
sentence and the current partial sequence.

Jörn



      

Re: Hybrid POS tagger

Posted by Jörn Kottmann <ko...@gmail.com>.
On 3/15/11 4:01 PM, Radu Simionescu wrote:
> I do not store the sequences of possible sets of outcomes. I generate them at
> runtime based on a dictionary and disambiguation rules(applied on the given
> input sentence). So for my case, I needed a method like tagger.tag(String[]
> sentence, String[][] possible_outcomes_for_each_word). Where
> possible_outcomes_for_each_word is generated by some code which is not related
> to OpenNLP.  where sentence.length() = possible_outcomes_for_each_word.length
>

That is exactly where the sequence validation is for. Couldn't you wrap your
validation mechanism inside a sequene validator? There you get the full
sentence and the current partial sequence.

Jörn

Re: Hybrid POS tagger

Posted by Radu Simionescu <ra...@yahoo.com>.
I do not store the sequences of possible sets of outcomes. I generate them at 
runtime based on a dictionary and disambiguation rules(applied on the given 
input sentence). So for my case, I needed a method like tagger.tag(String[] 
sentence, String[][] possible_outcomes_for_each_word). Where 
possible_outcomes_for_each_word is generated by some code which is not related 
to OpenNLP.  where sentence.length() = possible_outcomes_for_each_word.length

Radu



________________________________
From: Jörn Kottmann <ko...@gmail.com>
To: opennlp-users@incubator.apache.org
Sent: Tue, March 15, 2011 4:09:39 PM
Subject: Re: Hybrid POS tagger

On 3/15/11 2:46 PM, Radu Simionescu wrote:
> I don't know how to do that. Anyway, i think it is best to just create another 
>tag method for the POSTaggerME class which would have as parameter a sequence of 
>sets of possible outcomes for the input sentence. And implement such a sequence 
>validator in the api. This might be better cose it exposes less functionality to 
>the end user, keeping things simpler.
>
> If you could do this jira issue it would be great. Otherwise, instruct me 
>please.

Here is the link to the issue:
https://issues.apache.org/jira/browse/OPENNLP-144

We can either extend our current dictionary to look up possible tag 
sequences
for n-grams or make something new like you did.

Which format do you use to store the tag sequences for n-grams?

Jörn



      

Re: Hybrid POS tagger

Posted by Jörn Kottmann <ko...@gmail.com>.
On 3/15/11 2:46 PM, Radu Simionescu wrote:
> I don't know how to do that. Anyway, i think it is best to just create another tag method for the POSTaggerME class which would have as parameter a sequence of sets of possible outcomes for the input sentence. And implement such a sequence validator in the api. This might be better cose it exposes less functionality to the end user, keeping things simpler.
>
> If you could do this jira issue it would be great. Otherwise, instruct me please.

Here is the link to the issue:
https://issues.apache.org/jira/browse/OPENNLP-144

We can either extend our current dictionary to look up possible tag 
sequences
for n-grams or make something new like you did.

Which format do you use to store the tag sequences for n-grams?

Jörn

Re: Hybrid POS tagger

Posted by Radu Simionescu <ra...@yahoo.com>.
I don't know how to do that. Anyway, i think it is best to just create another tag method for the POSTaggerME class which would have as parameter a sequence of sets of possible outcomes for the input sentence. And implement such a sequence validator in the api. This might be better cose it exposes less functionality to the end user, keeping things simpler.

If you could do this jira issue it would be great. Otherwise, instruct me please.

Thank you
Radu



Pe Mar 15, 2011, la 2:52 PM, Jörn Kottmann <ko...@gmail.com> a scris:

> On 3/15/11 12:33 PM, Radu Simionescu wrote:
>> Thanks
>> 
>> Yes, i have done this already. It works great. The power of a hybrid pos tagger is great, because you can control exceptional tagging cases, or correct output mistakes. It would be cool if the api had support for this
>> 
> 
> Adding API support is not a big deal, would you mind to open a jira issue?
> Then I will take care of extending the API for the 1.5.2 release.
> 
> Jörn

Re: Hybrid POS tagger

Posted by Jörn Kottmann <ko...@gmail.com>.
On 3/15/11 12:33 PM, Radu Simionescu wrote:
> Thanks
>
> Yes, i have done this already. It works great. The power of a hybrid pos tagger is great, because you can control exceptional tagging cases, or correct output mistakes. It would be cool if the api had support for this
>

Adding API support is not a big deal, would you mind to open a jira issue?
Then I will take care of extending the API for the 1.5.2 release.

Jörn

Re: Hybrid POS tagger

Posted by Radu Simionescu <ra...@yahoo.com>.
Thanks

Yes, i have done this already. It works great. The power of a hybrid pos tagger is great, because you can control exceptional tagging cases, or correct output mistakes. It would be cool if the api had support for this

Radu



Pe Mar 15, 2011, la 12:44 PM, Jörn Kottmann <ko...@gmail.com> a scris:

> On 3/13/11 12:54 AM, Radu Simionescu wrote:
>> Hello
>> 
>> I am making paper a pos tagger for Romanian for my disertation. I want  to be
>> able to restrict the outcomes even more than just using a  dictionary. I want to
>> use some rules for disambiguation, based on the  context. This would allow me to
>> use smaller corpus, and also to fix  consistent output mistakes.
>> 
>> So I want to be able to give the postagger the possible set of outcomes  for
>> each word from the input, separately. So, since the training of a  model doesn't
>> really use the pos dictionary, I figured I could make this parser by  making
>> small modifications to the API, because the dictionary can change from one
>> sentence/word to the other. Please let me know if I am wrong.
>> 
> 
> There is no out-of-the-box support for this, but I believe it should be easy to implement,
> all you need to do is to write a custom sequence validator which does what you described
> above.
> 
> Just have a look at the POSTaggerME class, you need to modify the constructor to give it
> a custom fetaure generator. We should open a jira issue and extend our API to pass-in
> a sequence validator object.
> 
> Jörn

Re: Hybrid POS tagger

Posted by Jörn Kottmann <ko...@gmail.com>.
On 3/13/11 12:54 AM, Radu Simionescu wrote:
> Hello
>
> I am making paper a pos tagger for Romanian for my disertation. I want  to be
> able to restrict the outcomes even more than just using a  dictionary. I want to
> use some rules for disambiguation, based on the  context. This would allow me to
> use smaller corpus, and also to fix  consistent output mistakes.
>
> So I want to be able to give the postagger the possible set of outcomes  for
> each word from the input, separately. So, since the training of a  model doesn't
> really use the pos dictionary, I figured I could make this parser by  making
> small modifications to the API, because the dictionary can change from one
> sentence/word to the other. Please let me know if I am wrong.
>

There is no out-of-the-box support for this, but I believe it should be 
easy to implement,
all you need to do is to write a custom sequence validator which does 
what you described
above.

Just have a look at the POSTaggerME class, you need to modify the 
constructor to give it
a custom fetaure generator. We should open a jira issue and extend our 
API to pass-in
a sequence validator object.

Jörn