/** * Returns a new CoreLabel instance based on the contents of the given * CoreMap. It copies the contents of the other CoreMap. * * @param label The CoreMap to copy */ @SuppressWarnings({"unchecked"}) public CoreLabel(CoreMap label) { super(label.size()); Consumer<Class<? extends Key<?>>> savedListener = ArrayCoreMap.listener; // don't listen to the clone operation ArrayCoreMap.listener = null; for (Class key : label.keySet()) { set(key, label.get(key)); } ArrayCoreMap.listener = savedListener; }
private static void findQuotationSpeaker(Document doc, int utterNum, List<CoreMap> sentences, IntPair beginQuotation, IntPair endQuotation, Dictionaries dict) { if(findSpeaker(doc, utterNum, beginQuotation.get(0), sentences, 0, beginQuotation.get(1), dict)) return ; if(findSpeaker(doc, utterNum, endQuotation.get(0), sentences, endQuotation.get(1), sentences.get(endQuotation.get(0)).get(CoreAnnotations.TokensAnnotation.class).size(), dict)) return; if(beginQuotation.get(1) <= 1 && beginQuotation.get(0) > 0) { if(findSpeaker(doc, utterNum, beginQuotation.get(0)-1, sentences, 0, sentences.get(beginQuotation.get(0)-1).get(CoreAnnotations.TokensAnnotation.class).size(), dict)) return; } if(endQuotation.get(1) >= sentences.get(endQuotation.get(0)).size()-2 && sentences.size() > endQuotation.get(0)+1) { if(findSpeaker(doc, utterNum, endQuotation.get(0)+1, sentences, 0, sentences.get(endQuotation.get(0)+1).get(CoreAnnotations.TokensAnnotation.class).size(), dict)) return; } }
private void findQuotationSpeaker(int utterNum, List<CoreMap> sentences, Pair<Integer, Integer> beginQuotation, Pair<Integer, Integer> endQuotation, Dictionaries dict) { if(findSpeaker(utterNum, beginQuotation.first(), sentences, 0, beginQuotation.second(), dict)) return ; if(findSpeaker(utterNum, endQuotation.first(), sentences, endQuotation.second(), sentences.get(endQuotation.first()).get(CoreAnnotations.TokensAnnotation.class).size(), dict)) return; if(beginQuotation.second() <= 1 && beginQuotation.first() > 0) { if(findSpeaker(utterNum, beginQuotation.first()-1, sentences, 0, sentences.get(beginQuotation.first()-1).get(CoreAnnotations.TokensAnnotation.class).size(), dict)) return; } if(endQuotation.second() == sentences.get(endQuotation.first()).size()-1 && sentences.size() > endQuotation.first()+1) { if(findSpeaker(utterNum, endQuotation.first()+1, sentences, 0, sentences.get(endQuotation.first()+1).get(CoreAnnotations.TokensAnnotation.class).size(), dict)) return; } }
/** * Merge one CoreMap into another -- that is, overwrite and add any keys in * the base CoreMap with those in the one to be merged. * This method is functional -- neither of the argument CoreMaps are changed. * @param base The CoreMap to serve as the base (keys in this are lower priority) * @param toBeMerged The CoreMap to merge in (keys in this are higher priority) * @return A new CoreMap representing the merge of the two inputs */ public static CoreMap merge(CoreMap base, CoreMap toBeMerged){ //(variables) CoreMap rtn = new ArrayCoreMap(base.size()); //(copy base) for(Class key : base.keySet()){ rtn.set(key, base.get(key)); } //(merge) for(Class key : toBeMerged.keySet()){ rtn.set(key,toBeMerged.get(key)); } //(return) return rtn; }
/** * Returns a new CoreLabel instance based on the contents of the given * CoreMap. It copies the contents of the other CoreMap. * * @param label The CoreMap to copy */ @SuppressWarnings({"unchecked"}) public CoreLabel(CoreMap label) { super(label.size()); for (Class key : label.keySet()) { set(key, label.get(key)); } }
/** * Returns a new CoreLabel instance based on the contents of the given * CoreMap. It copies the contents of the other CoreMap. * * @param label The CoreMap to copy */ @SuppressWarnings({"unchecked"}) public CoreLabel(CoreMap label) { super(label.size()); Set<Class<?>> otherKeys = label.keySet(); for (Class key : otherKeys) { set(key, label.get(key)); } }
/** * Returns a new CoreLabel instance based on the contents of the given * CoreMap. It copies the contents of the other CoreMap. * * @param label The CoreMap to copy */ @SuppressWarnings({"unchecked"}) public CoreLabel(CoreMap label) { super(label.size()); Consumer<Class<? extends Key<?>>> savedListener = ArrayCoreMap.listener; // don't listen to the clone operation ArrayCoreMap.listener = null; for (Class key : label.keySet()) { set(key, label.get(key)); } ArrayCoreMap.listener = savedListener; }
/** * Returns a new CoreLabel instance based on the contents of the given * CoreMap. It copies the contents of the other CoreMap. * * @param label The CoreMap to copy */ @SuppressWarnings({"unchecked"}) public CoreLabel(CoreMap label) { super(label.size()); Consumer<Class<? extends Key<?>>> savedListener = ArrayCoreMap.listener; // don't listen to the clone operation ArrayCoreMap.listener = null; for (Class key : label.keySet()) { set(key, label.get(key)); } ArrayCoreMap.listener = savedListener; }
private void findQuotationSpeaker(int utterNum, List<CoreMap> sentences, Pair<Integer, Integer> beginQuotation, Pair<Integer, Integer> endQuotation, Dictionaries dict) { if(findSpeaker(utterNum, beginQuotation.first(), sentences, 0, beginQuotation.second(), dict)) return ; if(findSpeaker(utterNum, endQuotation.first(), sentences, endQuotation.second(), sentences.get(endQuotation.first()).get(CoreAnnotations.TokensAnnotation.class).size(), dict)) return; if(beginQuotation.second() <= 1 && beginQuotation.first() > 0) { if(findSpeaker(utterNum, beginQuotation.first()-1, sentences, 0, sentences.get(beginQuotation.first()-1).get(CoreAnnotations.TokensAnnotation.class).size(), dict)) return; } if(endQuotation.second() == sentences.get(endQuotation.first()).size()-1 && sentences.size() > endQuotation.first()+1) { if(findSpeaker(utterNum, endQuotation.first()+1, sentences, 0, sentences.get(endQuotation.first()+1).get(CoreAnnotations.TokensAnnotation.class).size(), dict)) return; } }
private void findQuotationSpeaker(int utterNum, List<CoreMap> sentences, Pair<Integer, Integer> beginQuotation, Pair<Integer, Integer> endQuotation, Dictionaries dict) { if(findSpeaker(utterNum, beginQuotation.first(), sentences, 0, beginQuotation.second(), dict)) return ; if(findSpeaker(utterNum, endQuotation.first(), sentences, endQuotation.second(), sentences.get(endQuotation.first()).get(TokensAnnotation.class).size(), dict)) return; if(beginQuotation.second() <= 1) { if(findSpeaker(utterNum, beginQuotation.first()-1, sentences, 0, sentences.get(beginQuotation.first()-1).get(TokensAnnotation.class).size(), dict)) return ; } if(endQuotation.second() == sentences.get(endQuotation.first()).size()-1 && sentences.size() > endQuotation.first()+1) { if(findSpeaker(utterNum, endQuotation.first()+1, sentences, 0, sentences.get(endQuotation.first()+1).get(TokensAnnotation.class).size(), dict)) return ; } }
private void findQuotationSpeaker(int utterNum, List<CoreMap> sentences, Pair<Integer, Integer> beginQuotation, Pair<Integer, Integer> endQuotation, Dictionaries dict) { if(findSpeaker(utterNum, beginQuotation.first(), sentences, 0, beginQuotation.second(), dict)) return ; if(findSpeaker(utterNum, endQuotation.first(), sentences, endQuotation.second(), sentences.get(endQuotation.first()).get(CoreAnnotations.TokensAnnotation.class).size(), dict)) return; if(beginQuotation.second() <= 1 && beginQuotation.first() > 0) { if(findSpeaker(utterNum, beginQuotation.first()-1, sentences, 0, sentences.get(beginQuotation.first()-1).get(CoreAnnotations.TokensAnnotation.class).size(), dict)) return; } if(endQuotation.second() == sentences.get(endQuotation.first()).size()-1 && sentences.size() > endQuotation.first()+1) { if(findSpeaker(utterNum, endQuotation.first()+1, sentences, 0, sentences.get(endQuotation.first()+1).get(CoreAnnotations.TokensAnnotation.class).size(), dict)) return; } }
private static void findQuotationSpeaker(Document doc, int utterNum, List<CoreMap> sentences, IntPair beginQuotation, IntPair endQuotation, Dictionaries dict) { if(findSpeaker(doc, utterNum, beginQuotation.get(0), sentences, 0, beginQuotation.get(1), dict)) return ; if(findSpeaker(doc, utterNum, endQuotation.get(0), sentences, endQuotation.get(1), sentences.get(endQuotation.get(0)).get(CoreAnnotations.TokensAnnotation.class).size(), dict)) return; if(beginQuotation.get(1) <= 1 && beginQuotation.get(0) > 0) { if(findSpeaker(doc, utterNum, beginQuotation.get(0)-1, sentences, 0, sentences.get(beginQuotation.get(0)-1).get(CoreAnnotations.TokensAnnotation.class).size(), dict)) return; } if(endQuotation.get(1) >= sentences.get(endQuotation.get(0)).size()-2 && sentences.size() > endQuotation.get(0)+1) { if(findSpeaker(doc, utterNum, endQuotation.get(0)+1, sentences, 0, sentences.get(endQuotation.get(0)+1).get(CoreAnnotations.TokensAnnotation.class).size(), dict)) return; } }
boolean runtimeExceptionWasThrown = false; CoreMap sentence = sentences.get(sentenceId); if (maxParseSentenceLength > 0 && sentence.size() > maxParseSentenceLength) { logger.warn(HandlerUtils.getSentenceLengthError(textAnnotation.getId(), sentence.toString(), maxParseSentenceLength));
boolean runtimeExceptionWasThrown = false; CoreMap sentence = sentences.get(sentenceId); if (maxParseSentenceLength > 0 && sentence.size() > maxParseSentenceLength) { logger.warn(HandlerUtils.getSentenceLengthError(textAnnotation.getId(), sentence.toString(), maxParseSentenceLength));
CoreMap sentence = sentences.get(sentenceId); if (maxParseSentenceLength > 0 && sentence.size() > maxParseSentenceLength) {
CoreMap sentence = sentences.get(sentenceId); if (maxParseSentenceLength > 0 && sentence.size() > maxParseSentenceLength) {
/** * Returns a new CoreLabel instance based on the contents of the given * label. Warning: The behavior of this method is a bit disjunctive! * If label is a CoreMap (including CoreLabel), then its entire * contents is copied into this label. But, otherwise, just the * value() and word iff it implements HasWord is copied. * * @param label Basis for this label */ @SuppressWarnings("unchecked") public CoreLabel(Label label) { super(0); if (label instanceof CoreMap) { CoreMap cl = (CoreMap) label; setCapacity(cl.size()); for (Class key : cl.keySet()) { set(key, cl.get(key)); } } else { if (label instanceof HasWord) { setWord(((HasWord)label).word()); } setValue(label.value()); } }