Skip to content

Commit

Permalink
修复月份识别异常问题
Browse files Browse the repository at this point in the history
修复月份识别异常问题
  • Loading branch information
shinyke committed May 31, 2016
1 parent d2dc32e commit 7551e84
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 6 deletions.
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
*.classpath
.project
*.prefs
.svn/entries
.svn/format
*.svn-base
.svn/wc.db
Binary file modified resources/TimeExp.m
Binary file not shown.
19 changes: 13 additions & 6 deletions src/com/time/nlp/TimeUnit.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import java.util.regex.Pattern;

import com.time.enums.RangeTimeEnum;
import com.time.util.DateUtil;

/**
* <p>
Expand Down Expand Up @@ -218,7 +219,7 @@ public void norm_sethour()
isAllDayTime = false;
}

rule = "";
rule = "早上|早晨|早间|晨间|今早|明早";
pattern = Pattern.compile(rule);
match = pattern.matcher(Time_Expression);
if(match.find()){
Expand Down Expand Up @@ -266,7 +267,7 @@ public void norm_sethour()
isAllDayTime = false;
}

rule = "";
rule = "晚上|夜间|夜里|今晚|明晚";
pattern = Pattern.compile(rule);
match = pattern.matcher(Time_Expression);
if(match.find()){
Expand Down Expand Up @@ -974,9 +975,11 @@ private void preferFuture(int checkTimeIndex){
Calendar c = Calendar.getInstance();
if (this.normalizer.getTimeBase() != null) {
String[] ini = this.normalizer.getTimeBase().split("-");
c.set(Integer.valueOf(ini[0]).intValue(), Integer.valueOf(ini[1]).intValue(), Integer.valueOf(ini[2]).intValue()
c.set(Integer.valueOf(ini[0]).intValue(), Integer.valueOf(ini[1]).intValue()-1, Integer.valueOf(ini[2]).intValue()
, Integer.valueOf(ini[3]).intValue(), Integer.valueOf(ini[4]).intValue(), Integer.valueOf(ini[5]).intValue());
System.out.println(DateUtil.formatDateDefault(c.getTime()));
}

int curTime = c.get(TUNIT_MAP.get(checkTimeIndex));
if(curTime < _tp.tunit[checkTimeIndex]){
return;
Expand All @@ -985,10 +988,14 @@ private void preferFuture(int checkTimeIndex){
int addTimeUnit = TUNIT_MAP.get(checkTimeIndex-1);
c.add(addTimeUnit, 1);

_tp.tunit[checkTimeIndex - 1] = c.get(TUNIT_MAP.get(checkTimeIndex - 1));
if(TUNIT_MAP.get(checkTimeIndex - 1) == Calendar.MONTH){
++_tp.tunit[checkTimeIndex - 1];
// _tp.tunit[checkTimeIndex - 1] = c.get(TUNIT_MAP.get(checkTimeIndex - 1));
for(int i = 0; i < checkTimeIndex; i++){
_tp.tunit[i] = c.get(TUNIT_MAP.get(i));
if(TUNIT_MAP.get(i) == Calendar.MONTH){
++_tp.tunit[i];
}
}

}

/**
Expand Down
Binary file removed target/Time-NLP-1.0.0.jar
Binary file not shown.
Binary file modified target/classes/TimeExp.m
Binary file not shown.
Binary file modified target/classes/com/shinyke/TimeAnalyseTest.class
Binary file not shown.
Binary file modified target/classes/com/time/nlp/TimeUnit.class
Binary file not shown.

0 comments on commit 7551e84

Please sign in to comment.