Java 类org.apache.commons.collections.bidimap.TreeBidiMap 实例源码

项目:mule-intellij-plugins    文件:MuleSchemaProvider.java   
private Map<String, String> parseSpringSchemas(String springSchemasContent) {
    BidiMap schemaUrlsAndFileNames = new TreeBidiMap();
    for (String line : springSchemasContent.split("\n")) {
        if (line != null && !line.startsWith("#") && line.contains("=")) {
            String url = line.substring(0, line.indexOf("=")).replaceAll("\\\\", "");
            String fileName = line.substring(line.indexOf("=") + 1);

            if (schemaUrlsAndFileNames.containsValue(fileName)) {
                if (url.contains("current")) { //Avoid duplicates and prefer URL with "current"
                    schemaUrlsAndFileNames.removeValue(fileName);
                    schemaUrlsAndFileNames.put(url, fileName);
                }
            } else {
                schemaUrlsAndFileNames.put(url, fileName);
            }
        }
    }
    return schemaUrlsAndFileNames;
}
项目:argument-reasoning-comprehension-task    文件:AnnotationSpans.java   
public static AnnotationSpans extractAnnotationSpans(JCas jCas)
{
    BidiMap sentenceBeginIndexToCharacterIndex = new TreeBidiMap();
    BidiMap sentenceEndIndexToCharacterIndex = new TreeBidiMap();

    List<Sentence> sentences = new ArrayList<>(JCasUtil.select(jCas, Sentence.class));
    for (int i = 0; i < sentences.size(); i++) {
        Sentence sentence = sentences.get(i);

        sentenceBeginIndexToCharacterIndex.put(i, sentence.getBegin());
        sentenceEndIndexToCharacterIndex.put(i, sentence.getEnd());
    }

    //        System.out.println(sentenceBeginIndexToCharacterIndex);
    //        System.out.println(sentenceEndIndexToCharacterIndex);

    AnnotationSpans annotationSpans = new AnnotationSpans(
            sentenceBeginIndexToCharacterIndex.size());

    Collection<ArgumentComponent> components = JCasUtil.select(jCas, ArgumentComponent.class);

    for (ArgumentComponent component : components) {
        if (!ArgumentUnitUtils.isImplicit(component)) {
            //            System.out.println("=====");
            //            System.out.println(component.getCoveredText());
            int relativeOffset = (int) sentenceBeginIndexToCharacterIndex
                    .getKey(component.getBegin());

            int endingSentenceIndex = (int) sentenceEndIndexToCharacterIndex
                    .getKey(component.getEnd());

            int length = endingSentenceIndex - relativeOffset + 1;

            String type = component.getType().getShortName();

            SingleAnnotationSpan singleAnnotationSpan = new SingleAnnotationSpan(type,
                    relativeOffset, length);

            annotationSpans.getAnnotationSpans().add(singleAnnotationSpan);
        }
    }

    return annotationSpans;
}