in libraries/bot-dialogs/src/main/java/com/microsoft/recognizers/text/datetime/parsers/BaseDateTimeAltParser.java [141:249]
private void getResolution(ExtractResult er, DateTimeParseResult pr, DateTimeResolutionResult ret) {
String parentText = ((Map<String, Object>)er.getData()).get(ExtendedModelResult.ParentTextKey).toString();
String type = pr.getType();
boolean isPeriod = false;
boolean isSinglePoint = false;
String singlePointResolution = "";
String pastStartPointResolution = "";
String pastEndPointResolution = "";
String futureStartPointResolution = "";
String futureEndPointResolution = "";
String singlePointType = "";
String startPointType = "";
String endPointType = "";
if (type.equals(Constants.SYS_DATETIME_DATEPERIOD) || type.equalsIgnoreCase(Constants.SYS_DATETIME_TIMEPERIOD) ||
type.equals(Constants.SYS_DATETIME_DATETIMEPERIOD)) {
isPeriod = true;
switch (type) {
case Constants.SYS_DATETIME_DATEPERIOD:
startPointType = TimeTypeConstants.START_DATE;
endPointType = TimeTypeConstants.END_DATE;
pastStartPointResolution = DateTimeFormatUtil.formatDate(((Pair<LocalDateTime, LocalDateTime>)ret.getPastValue()).getValue0());
pastEndPointResolution = DateTimeFormatUtil.formatDate(((Pair<LocalDateTime, LocalDateTime>)ret.getPastValue()).getValue1());
futureStartPointResolution = DateTimeFormatUtil.formatDate(((Pair<LocalDateTime, LocalDateTime>)ret.getFutureValue()).getValue0());
futureEndPointResolution = DateTimeFormatUtil.formatDate(((Pair<LocalDateTime, LocalDateTime>)ret.getFutureValue()).getValue1());
break;
case Constants.SYS_DATETIME_DATETIMEPERIOD:
startPointType = TimeTypeConstants.START_DATETIME;
endPointType = TimeTypeConstants.END_DATETIME;
if (ret.getPastValue() instanceof Pair<?, ?>) {
pastStartPointResolution = DateTimeFormatUtil.formatDateTime(((Pair<LocalDateTime, LocalDateTime>)ret.getPastValue()).getValue0());
pastEndPointResolution = DateTimeFormatUtil.formatDateTime(((Pair<LocalDateTime, LocalDateTime>)ret.getPastValue()).getValue1());
futureStartPointResolution = DateTimeFormatUtil.formatDateTime(((Pair<LocalDateTime, LocalDateTime>)ret.getFutureValue()).getValue0());
futureEndPointResolution = DateTimeFormatUtil.formatDateTime(((Pair<LocalDateTime, LocalDateTime>)ret.getFutureValue()).getValue1());
} else if (ret.getPastValue() instanceof LocalDateTime) {
pastStartPointResolution = DateTimeFormatUtil.formatDateTime((LocalDateTime)ret.getPastValue());
futureStartPointResolution = DateTimeFormatUtil.formatDateTime((LocalDateTime)ret.getFutureValue());
}
break;
case Constants.SYS_DATETIME_TIMEPERIOD:
startPointType = TimeTypeConstants.START_TIME;
endPointType = TimeTypeConstants.END_TIME;
pastStartPointResolution = DateTimeFormatUtil.formatTime(((Pair<LocalDateTime, LocalDateTime>)ret.getPastValue()).getValue0());
pastEndPointResolution = DateTimeFormatUtil.formatTime(((Pair<LocalDateTime, LocalDateTime>)ret.getPastValue()).getValue1());
futureStartPointResolution = DateTimeFormatUtil.formatTime(((Pair<LocalDateTime, LocalDateTime>)ret.getFutureValue()).getValue0());
futureEndPointResolution = DateTimeFormatUtil.formatTime(((Pair<LocalDateTime, LocalDateTime>)ret.getFutureValue()).getValue1());
break;
default:
break;
}
} else {
isSinglePoint = true;
switch (type) {
case Constants.SYS_DATETIME_DATE:
singlePointType = TimeTypeConstants.DATE;
singlePointResolution = DateTimeFormatUtil.formatDate((LocalDateTime)ret.getFutureValue());
break;
case Constants.SYS_DATETIME_DATETIME:
singlePointType = TimeTypeConstants.DATETIME;
singlePointResolution = DateTimeFormatUtil.formatDateTime((LocalDateTime)ret.getFutureValue());
break;
case Constants.SYS_DATETIME_TIME:
singlePointType = TimeTypeConstants.TIME;
singlePointResolution = DateTimeFormatUtil.formatTime((LocalDateTime)ret.getFutureValue());
break;
default:
break;
}
}
if (isPeriod) {
ret.setFutureResolution(ImmutableMap.<String, String>builder()
.put(startPointType, futureStartPointResolution)
.put(endPointType, futureEndPointResolution)
.put(ExtendedModelResult.ParentTextKey, parentText)
.build());
ret.setPastResolution(ImmutableMap.<String, String>builder()
.put(startPointType, pastStartPointResolution)
.put(endPointType, pastEndPointResolution)
.put(ExtendedModelResult.ParentTextKey, parentText)
.build());
} else if (isSinglePoint) {
ret.setFutureResolution(ImmutableMap.<String, String>builder()
.put(singlePointType, singlePointResolution)
.put(ExtendedModelResult.ParentTextKey, parentText)
.build());
ret.setPastResolution(ImmutableMap.<String, String>builder()
.put(singlePointType, singlePointResolution)
.put(ExtendedModelResult.ParentTextKey, parentText)
.build());
}
if (((DateTimeResolutionResult)pr.getValue()).getMod() != null) {
ret.setMod(((DateTimeResolutionResult)pr.getValue()).getMod());
}
if (((DateTimeResolutionResult)pr.getValue()).getTimeZoneResolution() != null) {
ret.setTimeZoneResolution(((DateTimeResolutionResult)pr.getValue()).getTimeZoneResolution());
}
}