Using Jahmm for strings

107 views
Skip to first unread message

Majid

unread,
Apr 29, 2012, 4:29:53 PM4/29/12
to Jahmm HMM library
Hi all,

I have extracted a list of sentences from articles.
My question is, can I use Jahmm for string inputs?
How can I train a Hmm model with these sentences?

If it is possible please let me know how the corpus format should be.
If it is not possible, please let me know if you know anther library
for doing this.

Thanks,
Majid

Philipp Gerling

unread,
Aug 20, 2016, 1:00:39 PM8/20/16
to Jahmm HMM library
Hi Majid, 
recently I encountered the same problem you had literally years ago. Since Jahmm uses enums to represent the alphabet used by the HMM (V according ro Rabiner's notation), you gotta create an enum containing all distinct strings you want to use.
Doing so can cause a lot of work, but I figured out a shorter approach:

Using the library ByteBuddy, you can create an enum on the fly:

Class<? extends Enum<?>> generatedEnum = null;

public Class<? extends Enum<?>> createEnum(String name, List<String> entries) {

   
generatedEnum =  new ByteBuddy()
           
.makeEnumeration(entries)
           
.name(name)
           
.make()
           
.load(getClass().getClassLoader(), ClassLoadingStrategy.Default.WRAPPER)
           
.getLoaded();
   
return generatedEnum;
}

Using ByteBuddy, you can generate the enum used for Jahmm from a List of Strings.

I hope this approach may save some other people time ;-)
Philipp
Reply all
Reply to author
Forward
0 new messages