new Equivalent("$","$s","dollar","dollars","usd"),\r
new Equivalent("\u20ac","\u20acs","eur","euro","euros","e","ecu"),\r
new Equivalent("£","£s","pound","pounds","gbp"),\r
- new Equivalent("Unit","Units"),\r
- new Equivalent("Person","People","Persons"),\r
+ new Equivalent("unit","units"),\r
+ new Equivalent("person","people","persons"),\r
new Equivalent("second","seconds","sec","s"),\r
new Equivalent("minute","minutes","min"),\r
new Equivalent("hour","hours","h","hr"),\r
\r
ArrayList<String> copyDividers1 = new ArrayList<String>(dividers);\r
ArrayList<String> copyDividents1 = new ArrayList<String>(dividents);\r
- reduceUnitLists(dividents, copyDividents1, copyDividers1);\r
+ reduceUnitLists(dividents, copyDividents1, copyDividers1, allowEquivalents);\r
\r
StringBuilder sb = new StringBuilder();\r
Iterator<String> iterator = copyDividents1.iterator();\r
\r
ArrayList<String> copyDividers1 = new ArrayList<String>(dividers);\r
ArrayList<String> copyDividents1 = new ArrayList<String>(dividents);\r
- reduceUnitLists(dividents, copyDividents1, copyDividers1);\r
+ reduceUnitLists(dividents, copyDividents1, copyDividers1, allowEquivalents);\r
\r
ArrayList<String> copyDividers2 = new ArrayList<String>(other.dividers);\r
ArrayList<String> copyDividents2 = new ArrayList<String>(other.dividents); \r
- reduceUnitLists(other.dividents, copyDividents2, copyDividers2);\r
+ reduceUnitLists(other.dividents, copyDividents2, copyDividers2, allowEquivalents);\r
\r
if(copyDividents1.size() != copyDividents2.size())\r
return false;\r
return unit;\r
}\r
\r
- public void reduceUnitLists(ArrayList<String> originalDividents, ArrayList<String> copyDividents, ArrayList<String> copyDividers) {\r
+ public void reduceUnitLists(\r
+ ArrayList<String> originalDividents, \r
+ ArrayList<String> copyDividents,\r
+ ArrayList<String> copyDividers,\r
+ boolean allowEquivalents) {\r
+ if (allowEquivalents) {\r
+ // Replace equivalents\r
+ for(int i = 0; i < originalDividents.size(); i++) {\r
+ copyDividents.set(i, getDefaultForm(copyDividents.get(i)));\r
+ }\r
+ for(int i = 0; i < copyDividers.size(); i++) {\r
+ copyDividers.set(i, getDefaultForm(copyDividers.get(i)));\r
+ }\r
+ }\r
+ \r
for(String s : originalDividents) {\r
- if(copyDividers.contains(s)) {\r
- copyDividers.remove(s);\r
- copyDividents.remove(s);\r
+ String equiv = allowEquivalents ? getDefaultForm(s) : s;\r
+ if(copyDividers.contains(equiv)) {\r
+ copyDividers.remove(equiv);\r
+ copyDividents.remove(equiv);\r
}\r
}\r
\r