-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfileDealer.java
60 lines (46 loc) · 1.71 KB
/
fileDealer.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package com.ming.crf;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import com.ming.time.TimeFetcher;
public class fileDealer {
public static void replaceSlots(String in,String out) throws IOException{
LocationFetcher lcf = new LocationFetcher();
FileWriter writer = new FileWriter(out, true);
File file = new File(in);
BufferedReader reader = null;
reader = new BufferedReader(new FileReader(file));
String tempString = null;
// 一次读入一行,直到读入null为文件结束
while ((tempString = reader.readLine()) != null) {
System.out.println(tempString);
Location lc = lcf.fetchLoc(tempString);
ArrayList<String> locs = lc.getValues();
for(String s: locs){
tempString = tempString.replaceFirst(s, "地点");
}
TimePeriodFetcher tpf = new TimePeriodFetcher();
TimePeriod tp = tpf.fetchTimePeriod(tempString);
ArrayList<String> tps = tp.getValues();
for(String s:tps){
tempString = tempString.replace(s, "时段");
}
TimeFetcher tfc = new TimeFetcher("", "");
List<String> ts = tfc.fetchTime(tempString).getValues();
for(String s : ts){
tempString = tempString.replace(s,"时间");
}
writer.write(tempString);
}
reader.close();
writer.close();
reader.close();
}
public static void main(String[] args) throws IOException{
fileDealer.replaceSlots("dataPh", "dataSlots");
}
}