本文整理汇总了Java中edu.stanford.nlp.util.CollectionUtils.asList方法的典型用法代码示例。如果您正苦于以下问题:Java CollectionUtils.asList方法的具体用法?Java CollectionUtils.asList怎么用?Java CollectionUtils.asList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类edu.stanford.nlp.util.CollectionUtils
的用法示例。
在下文中一共展示了CollectionUtils.asList方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getMergedList
import edu.stanford.nlp.util.CollectionUtils; //导入方法依赖的package包/类
public List<CoreMap> getMergedList(int... groups)
{
List<CoreMap> res = new ArrayList<CoreMap>();
int last = 0;
List<Integer> orderedGroups = CollectionUtils.asList(groups);
Collections.sort(orderedGroups);
for (int group:orderedGroups) {
int groupStart = start(group);
if (groupStart >= last) {
res.addAll(elements.subList(last,groupStart));
int groupEnd = end(group);
if (groupEnd - groupStart >= 1) {
CoreMap merged = createMergedChunk(groupStart, groupEnd);
res.add(merged);
last = groupEnd;
}
}
}
res.addAll(elements.subList(last, elements.size()));
return res;
}
示例2: apply
import edu.stanford.nlp.util.CollectionUtils; //导入方法依赖的package包/类
public SequenceMatchResult<CoreMap> apply(SequenceMatchResult<CoreMap> matchResult, int... groups)
{
BasicSequenceMatchResult<CoreMap> res = matchResult.toBasicSequenceMatchResult();
List<? extends CoreMap> elements = matchResult.elements();
List<CoreMap> mergedElements = new ArrayList<CoreMap>();
res.elements = mergedElements;
int last = 0;
int mergedGroup = 0;
int offset = 0;
List<Integer> orderedGroups = CollectionUtils.asList(groups);
Collections.sort(orderedGroups);
for (int group:orderedGroups) {
int groupStart = matchResult.start(group);
if (groupStart >= last) {
// Add elements from last to start of group to merged elements
mergedElements.addAll(elements.subList(last,groupStart));
// Fiddle with matched group indices
for (; mergedGroup < group; mergedGroup++) {
if (res.matchedGroups[mergedGroup] != null) {
res.matchedGroups[mergedGroup].matchBegin -= offset;
res.matchedGroups[mergedGroup].matchEnd -= offset;
}
}
// Get merged element
int groupEnd = matchResult.end(group);
if (groupEnd - groupStart >= 1) {
CoreMap merged = aggregator.merge(elements, groupStart, groupEnd);
mergedElements.add(merged);
last = groupEnd;
// Fiddle with matched group indices
res.matchedGroups[mergedGroup].matchBegin = mergedElements.size()-1;
res.matchedGroups[mergedGroup].matchEnd = mergedElements.size();
mergedGroup++;
while (mergedGroup < res.matchedGroups.length) {
if (res.matchedGroups[mergedGroup] != null) {
if (res.matchedGroups[mergedGroup].matchBegin == matchResult.start(group) &&
res.matchedGroups[mergedGroup].matchEnd == matchResult.end(group)) {
res.matchedGroups[mergedGroup].matchBegin = res.matchedGroups[group].matchBegin;
res.matchedGroups[mergedGroup].matchEnd = res.matchedGroups[group].matchEnd;
} else if (res.matchedGroups[mergedGroup].matchEnd <= matchResult.end(group)) {
res.matchedGroups[mergedGroup] = null;
} else {
break;
}
}
mergedGroup++;
}
offset = matchResult.end(group) - res.matchedGroups[group].matchEnd;
}
}
}
// Add rest of elements
mergedElements.addAll(elements.subList(last, elements.size()));
// Fiddle with matched group indices
for (; mergedGroup < res.matchedGroups.length; mergedGroup++) {
if (res.matchedGroups[mergedGroup] != null) {
res.matchedGroups[mergedGroup].matchBegin -= offset;
res.matchedGroups[mergedGroup].matchEnd -= offset;
}
}
return res;
}