/** * Get the index for this label string * * @param str * A label string * @return */ public int getLabelId(String str) { if (!containsLabel((str))) System.out.println("!!!!! " + str); return LabelStr2Id_map.get(str); }
/** * The constructor: Note that the feature indexes need to be greater than * zero. We preview the 0 feature in the constructor to prevent the user * tries to use feature 0 */ public LexManager() { feaStr2Id_map = new ConcurrentHashMap<String, Integer>(); feaId2Str_map = new ConcurrentHashMap<Integer, String>(); // VERY IMPORTANT // In the current of the weight wector, we use zero as the global bias // term // therefore, it is very important to preview the first feature // so no one can take over the zero index! this.previewFeature(bias_str); // zero should always be bias // What happened in Structured case? // The structure case might have their own lex // However, they also need to find a way to keep the zero index for the // bias term // In JLIS-sequence, we use this Lexmanager inside the structural lex // manger // Therefore, the zero index will still be not used by regular features }