Created
March 21, 2019 05:57
-
-
Save allanj/a4aa3c97cb679af09a9a621693dcd932 to your computer and use it in GitHub Desktop.
Print the feature string in the StatNLP Java framework (Put to main file)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//main.java | |
//First of all, after create `GlobalNetworkParam` object. | |
// run the following code: | |
GlobalNetworkParam gnp = new GlobalNetworkParam(optimizer, gnnp); | |
gnp.setStoreFeatureReps(); | |
/************************ | |
After the model has been trained. | |
model.train(...) | |
The following code is used to print the features | |
******************/ | |
GlobalNetworkParam gnp = model.getFeatureManager().getParam_G(); | |
StringIndex strIdx = gnp.getStringIndex(); | |
strIdx.buildReverseIndex(); | |
gnp.setStoreFeatureReps(); | |
for (int i = 0; i < gnp.size(); i++) { //size is the number of all features | |
int[] fs = gnp.getFeatureRep(i); | |
String type = strIdx.get(fs[0]); | |
String output = strIdx.get(fs[1]); | |
String input = strIdx.get(fs[2]); | |
System.out.println(type + " " + output + input) ; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment