Harium / suneidesis

A project to represent knowledge
MIT License
2 stars 1 forks source link

[Math] Add unit conversion #80

Closed yuripourre closed 3 years ago

yuripourre commented 3 years ago

It can be made with a parser and a set of converters.

Converter should be an interface with a method that receives value+unit and the output unit and converts to value

package com.harium.suneidesis.math;

public class Converter {
    String convert(String amount, String unit, String outputUnit);
}

The parser reads the input and then define what converter should be used.

E.g:

"Tea spoon" -> "g" kcal -> cal cm -> inches "yesterday" -> date

yuripourre commented 3 years ago

We should update Measure: instead having a String, unit should be a concept itself because it has a name and a symbol.

We could also add new modifiers like (many, few, more than, less than,...)

Since convertrs only need amount and unit name, we can have helpers methods (or a helper class) to convert from Measure to Measure).

Remember that unit has a name and a symbol because the symbol can have different meanings depending on the context.

Time Unit should be changed to just Unit.