edu.stanford.nlp.ie.qe.Unit Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of stanford-corenlp Show documentation
Show all versions of stanford-corenlp Show documentation
Stanford CoreNLP provides a set of natural language analysis tools which can take raw English language text input and give the base forms of words, their parts of speech, whether they are names of companies, people, etc., normalize dates, times, and numeric quantities, mark up the structure of sentences in terms of phrases and word dependencies, and indicate which noun phrases refer to the same entities. It provides the foundational building blocks for higher level text understanding applications.
package edu.stanford.nlp.ie.qe;
/**
* Quantifiable entity unit
*
* @author Angel Chang
*/
public class Unit {
protected String name;
protected String symbol;
protected String type;
protected String system;
protected String prefixSystem;
// What unit should be used to express this unit
protected Unit defaultUnit;
protected double defaultUnitScale = 1.0;
public Unit(String name, String symbol, String type) {
this.name = name;
this.symbol = symbol;
this.type = type;
}
public Unit(String name, String symbol, String type, Unit defaultUnit, double defaultUnitScale) {
this.name = name;
this.symbol = symbol;
this.type = type;
this.defaultUnit = defaultUnit;
this.defaultUnitScale = defaultUnitScale;
}
// TODO: unit specific formatting
public String format(double amount) {
return String.valueOf(amount) + symbol;
}
public String formatInDefaultUnit(double amount) {
if (defaultUnit != null && defaultUnit != this) {
return defaultUnit.formatInDefaultUnit(amount*defaultUnitScale);
} else {
return format(amount);
}
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getSymbol() {
return symbol;
}
public void setSymbol(String symbol) {
this.symbol = symbol;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public Unit getDefaultUnit() {
return defaultUnit;
}
public void setDefaultUnit(Unit defaultUnit) {
this.defaultUnit = defaultUnit;
}
public double getDefaultUnitScale() {
return defaultUnitScale;
}
public void setDefaultUnitScale(double defaultUnitScale) {
this.defaultUnitScale = defaultUnitScale;
}
}