/** * Reads the binary representation of a learner with this object's run-time type, overwriting * any and all learned or manually specified parameters as well as the label lexicon but without * modifying the feature lexicon. * * @param in The input stream. **/ public void read(ExceptionlessInputStream in) { super.read(in); POSBaselineLearner.read(in, firstCapitalized); POSBaselineLearner.read(in, notFirstCapitalized); }
/** * Returns a new, emtpy learner into which all of the parameters that control the behavior of * the algorithm have been copied. Here, "emtpy" means no learning has taken place. **/ public Learner emptyClone() { return new POSBaselineLearner(); }
/** * Reads the binary representation of a learner with this object's run-time type, overwriting * any and all learned or manually specified parameters as well as the label lexicon but without * modifying the feature lexicon. * * @param in The input stream. **/ public void read(ExceptionlessInputStream in) { super.read(in); forget(); read(in, table); }
/** Clears out the table to start fresh. */ public void forget() { super.forget(); firstCapitalized.clear(); notFirstCapitalized.clear(); }
/** * Returns the value of the discrete prediction that this learner would make, given an example. * * @param example The example object. * @return The discrete value. **/ public String discreteValue(Object example) { return computePrediction(example); }
/** * Returns the set of tags that the given word has been observed with. * * @param form The form of the word. * @return The set of tags observed in association with the given word. **/ public Set<String> allowableTags(String form) { if (!table.containsKey(form)) { HashSet<String> result = new HashSet<>(); if (form.equals(";")) result.add(":"); else if (looksLikeNumber(form)) result.add("CD"); return result; } return table.get(form).keySet(); }
/** * This function makes one or more decisions about a single object, returning those decisions as * <code>Feature</code>s in a vector. * * @param example The object to make decisions about. * @return A vector of <code>Feature</code>s about the input object. **/ public FeatureVector classify(Object example) { return new FeatureVector(featureValue(example)); }
/** * Reads the binary representation of a learner with this object's run-time type, overwriting * any and all learned or manually specified parameters as well as the label lexicon but without * modifying the feature lexicon. * * @param in The input stream. **/ public void read(ExceptionlessInputStream in) { super.read(in); forget(); read(in, table); }
/** Clears out the table to start fresh. */ public void forget() { super.forget(); firstCapitalized.clear(); notFirstCapitalized.clear(); }
/** * Returns the value of the discrete prediction that this learner would make, given an example. * * @param example The example object. * @return The discrete value. **/ public String discreteValue(Object example) { return computePrediction(example); }
/** * Returns the set of tags that the given word has been observed with. * * @param form The form of the word. * @return The set of tags observed in association with the given word. **/ public Set<String> allowableTags(String form) { if (!table.containsKey(form)) { HashSet<String> result = new HashSet<>(); if (form.equals(";")) result.add(":"); else if (looksLikeNumber(form)) result.add("CD"); return result; } return table.get(form).keySet(); }
/** * This function makes one or more decisions about a single object, returning those decisions as * <code>Feature</code>s in a vector. * * @param example The object to make decisions about. * @return A vector of <code>Feature</code>s about the input object. **/ public FeatureVector classify(Object example) { return new FeatureVector(featureValue(example)); }
/** * Writes the algorithm's internal representation as text. * * @param out The output stream. **/ public void write(PrintStream out) { write(out, table); }
/** Clears out the table to start fresh. */ public void forget() { super.forget(); firstCapitalized.clear(); notFirstCapitalized.clear(); }
/** * Reads the binary representation of a learner with this object's run-time type, overwriting * any and all learned or manually specified parameters as well as the label lexicon but without * modifying the feature lexicon. * * @param in The input stream. **/ public void read(ExceptionlessInputStream in) { super.read(in); POSBaselineLearner.read(in, firstCapitalized); POSBaselineLearner.read(in, notFirstCapitalized); }
/** * Returns the classification of the given example object as a single feature instead of a * {@link FeatureVector}. * * @param example The object to classify. * @return The classification of <code>example</code> as a feature. **/ public Feature featureValue(Object example) { return new DiscretePrimitiveStringFeature(containingPackage, name, "", computePrediction(example)); }
if (form.equals(";")) l = ":"; else if (looksLikeNumber(form)) l = "CD"; else
/** * Returns a new, emtpy learner into which all of the parameters that control the behavior of * the algorithm have been copied. Here, "emtpy" means no learning has taken place. **/ public Learner emptyClone() { return new POSBaselineLearner(); }