Chào mọi người,
Mọi người xem giúp mình sửa lỗi “Multiple entries with same key”
Cám ơn mọi người nhiều !!!
public class Ex {
private static final Log LOG = AutoLog.getLog();
static Ex ex = new Ex();
public static void main(String[] args) throws IOException, TException, UnknownWordException {
System.out.println("Test Word2Vec: ");
ex.loadModel();
}
public void interact(Searcher searcher) throws IOException, UnknownWordException {
try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
while (true) {
System.out.print("Enter word or sentence (EXIT to break): ");
String word = br.readLine();
if (word.equals("EXIT")) {
break;
}
List<Match> matches = searcher.getMatches(word, 20);
System.out.println(Strings.joinObjects("\n", matches));
}
}
}
public void loadModel() throws IOException, TException, UnknownWordException {
Word2VecModel model;
try (ProfilingTimer timer = ProfilingTimer.create(LOG, "Loading model")) {
String json = Common.readFileToString(new File("D:\\DT\\aaa.model"));
model = Word2VecModel.fromThrift(ThriftUtils.deserializeJson(new Word2VecModelThrift(), json));
}
ex.interact(model.forSearch());
}
}
Run -> Lỗi
Exception in thread “main” java.lang.IllegalArgumentException: Multiple entries with same key: ??=3000 and ??=2000
at com.google.common.collect.ImmutableMap.checkNoConflict(ImmutableMap.java:136)
at com.google.common.collect.RegularImmutableMap.checkNoConflictInKeyBucket(RegularImmutableMap.java:98)
at com.google.common.collect.RegularImmutableMap.fromEntryArray(RegularImmutableMap.java:84)
at com.google.common.collect.ImmutableMap$Builder.build(ImmutableMap.java:295)
at com.medallia.word2vec.SearcherImpl.(SearcherImpl.java:27)
at com.medallia.word2vec.SearcherImpl.(SearcherImpl.java:31)
at com.medallia.word2vec.Word2VecModel.forSearch(Word2VecModel.java:62)
at com.medallia.word2vec.Ex.loadModel(Ex.java:55)
at com.medallia.word2vec.Ex.main(Ex.java:31)

83% thành viên diễn đàn không hỏi bài tập, còn bạn thì sao?