Révision 2676
tmp/org.txm.annotation.kr.core/src/org/txm/annotation/kr/core/AnnotationInjector.java (revision 2676) | ||
---|---|---|
40 | 40 |
|
41 | 41 |
List<Annotation> currentEndAnnotations; |
42 | 42 |
|
43 |
LinkedHashMap<String, Annotation> currentTokenAnnotations = new LinkedHashMap<String, Annotation>();
|
|
43 |
LinkedHashMap<String, Annotation> currentTokenAnnotations = new LinkedHashMap<>(); |
|
44 | 44 |
|
45 | 45 |
int n = 0; |
46 | 46 |
|
... | ... | |
60 | 60 |
|
61 | 61 |
String closeNext = null; // the next close tag to delete |
62 | 62 |
|
63 |
ArrayList<String> openedElements = new ArrayList<String>(); // to ensure to
|
|
63 |
ArrayList<String> openedElements = new ArrayList<>(); // to ensure to |
|
64 | 64 |
// delete the |
65 | 65 |
// right element |
66 | 66 |
|
... | ... | |
95 | 95 |
factory = XMLInputFactory.newInstance(); |
96 | 96 |
|
97 | 97 |
// preparing annotations to being written in the right inclusion order |
98 |
annotationsToAddByStartPos = new HashMap<Integer, List<Annotation>>();
|
|
99 |
annotationsToAddByEndPos = new HashMap<Integer, List<Annotation>>();
|
|
98 |
annotationsToAddByStartPos = new HashMap<>(); |
|
99 |
annotationsToAddByEndPos = new HashMap<>(); |
|
100 | 100 |
|
101 | 101 |
for (Annotation a : segmentAnnotations) { |
102 | 102 |
if (!annotationsToAddByStartPos.containsKey(a.getStart())) |
... | ... | |
163 | 163 |
|
164 | 164 |
private boolean mustChangeWordValue; |
165 | 165 |
|
166 |
@Override |
|
166 | 167 |
protected void processStartElement() throws XMLStreamException, IOException { |
167 | 168 |
|
168 | 169 |
currentStartAnnotations = annotationsToAddByStartPos.get(position_counter); |
... | ... | |
399 | 400 |
} |
400 | 401 |
} |
401 | 402 |
|
403 |
@Override |
|
402 | 404 |
protected void processEndElement() throws XMLStreamException { |
403 | 405 |
// currentEndAnnotations = |
404 | 406 |
// annotationsToAddByEndPos.get(position_counter); // annotation to end |
... | ... | |
537 | 539 |
public static ArrayList<Annotation> testAdding() { |
538 | 540 |
|
539 | 541 |
Annotation a1 = new Annotation("Actr", "Actr100", 15, 16); |
540 |
ArrayList<Annotation> annotations = new ArrayList<Annotation>();
|
|
542 |
ArrayList<Annotation> annotations = new ArrayList<>(); |
|
541 | 543 |
annotations.add(a1); |
542 | 544 |
return annotations; |
543 | 545 |
} |
... | ... | |
545 | 547 |
public static ArrayList<Annotation> testAddingInclusive() { |
546 | 548 |
|
547 | 549 |
Annotation a1 = new Annotation("CoAc", "CoAc2093", 15, 19); |
548 |
ArrayList<Annotation> annotations = new ArrayList<Annotation>();
|
|
550 |
ArrayList<Annotation> annotations = new ArrayList<>(); |
|
549 | 551 |
annotations.add(a1); |
550 | 552 |
return annotations; |
551 | 553 |
} |
... | ... | |
553 | 555 |
public static ArrayList<Annotation> testAddingInclusive2() { |
554 | 556 |
|
555 | 557 |
Annotation a1 = new Annotation("Actr", "Actr100", 15, 16); |
556 |
ArrayList<Annotation> annotations = new ArrayList<Annotation>();
|
|
558 |
ArrayList<Annotation> annotations = new ArrayList<>(); |
|
557 | 559 |
annotations.add(a1); |
558 | 560 |
return annotations; |
559 | 561 |
} |
... | ... | |
561 | 563 |
public static ArrayList<Annotation> testUpdating() { |
562 | 564 |
|
563 | 565 |
Annotation a1 = new Annotation("Actr", "Actr200", 15, 16); |
564 |
ArrayList<Annotation> annotations = new ArrayList<Annotation>();
|
|
566 |
ArrayList<Annotation> annotations = new ArrayList<>(); |
|
565 | 567 |
annotations.add(a1); |
566 | 568 |
return annotations; |
567 | 569 |
} |
... | ... | |
569 | 571 |
public static ArrayList<Annotation> testUpdatingDeleting() { |
570 | 572 |
Annotation a1 = new Annotation("Actr", "Actr200", 15, 16); |
571 | 573 |
Annotation a2 = new Annotation("CoAc", "#del", 15, 19); |
572 |
ArrayList<Annotation> annotations = new ArrayList<Annotation>();
|
|
574 |
ArrayList<Annotation> annotations = new ArrayList<>(); |
|
573 | 575 |
annotations.add(a1); |
574 | 576 |
annotations.add(a2); |
575 | 577 |
return annotations; |
... | ... | |
578 | 580 |
public static ArrayList<Annotation> testAddDeleting2() { |
579 | 581 |
Annotation a1 = new Annotation("Actr", "#del", 15, 16); // DELETE |
580 | 582 |
Annotation a2 = new Annotation("NaPl", "NaPl14554", 15, 19); // ADD |
581 |
ArrayList<Annotation> annotations = new ArrayList<Annotation>();
|
|
583 |
ArrayList<Annotation> annotations = new ArrayList<>(); |
|
582 | 584 |
annotations.add(a1); |
583 | 585 |
annotations.add(a2); |
584 | 586 |
return annotations; |
... | ... | |
588 | 590 |
Annotation a1 = new Annotation("Actr", "Actr200", 15, 16); // UPDATE |
589 | 591 |
Annotation a2 = new Annotation("NaPl", "NaPl14554", 15, 19); // ADD |
590 | 592 |
Annotation a3 = new Annotation("CoAc", "#del", 15, 19); // DELETE |
591 |
ArrayList<Annotation> annotations = new ArrayList<Annotation>();
|
|
593 |
ArrayList<Annotation> annotations = new ArrayList<>(); |
|
592 | 594 |
annotations.add(a1); |
593 | 595 |
annotations.add(a2); |
594 | 596 |
annotations.add(a3); |
... | ... | |
599 | 601 |
Annotation a1 = new Annotation("Actr", "#del", 15, 16); // DELETE |
600 | 602 |
Annotation a2 = new Annotation("NaPl", "NaPl14554", 15, 19); // ADD same place as CoAc |
601 | 603 |
Annotation a3 = new Annotation("CoAc", "CoAc2091", 15, 19); // UPDATE |
602 |
ArrayList<Annotation> annotations = new ArrayList<Annotation>();
|
|
604 |
ArrayList<Annotation> annotations = new ArrayList<>(); |
|
603 | 605 |
annotations.add(a1); |
604 | 606 |
annotations.add(a2); |
605 | 607 |
annotations.add(a3); |
... | ... | |
610 | 612 |
Annotation a1 = new Annotation("Actr", "#del", 15, 16); // DELETE |
611 | 613 |
Annotation a2 = new Annotation("NaPl", "NaPl14554", 15, 16); // ADD same place as Actr |
612 | 614 |
Annotation a3 = new Annotation("CoAc", "CoAc2091", 15, 19); // UPDATE |
613 |
ArrayList<Annotation> annotations = new ArrayList<Annotation>();
|
|
615 |
ArrayList<Annotation> annotations = new ArrayList<>(); |
|
614 | 616 |
annotations.add(a1); |
615 | 617 |
annotations.add(a2); |
616 | 618 |
annotations.add(a3); |
... | ... | |
621 | 623 |
Annotation a1 = new Annotation("Actr", "#del", 15, 16); // DELETE |
622 | 624 |
Annotation a2 = new Annotation("NaPl", "NaPl14554", 13, 20); // ADD Outside Actr and CoAc |
623 | 625 |
Annotation a3 = new Annotation("CoAc", "CoAc2091", 15, 19); // UPDATE |
624 |
ArrayList<Annotation> annotations = new ArrayList<Annotation>();
|
|
626 |
ArrayList<Annotation> annotations = new ArrayList<>(); |
|
625 | 627 |
annotations.add(a1); |
626 | 628 |
annotations.add(a2); |
627 | 629 |
annotations.add(a3); |
... | ... | |
632 | 634 |
Annotation a1 = new Annotation("Actr", "#del", 15, 16); // DELETE |
633 | 635 |
Annotation a2 = new Annotation("NaPl", "NaPl14554", 15, 16); // ADD |
634 | 636 |
Annotation a3 = new Annotation("CoAc", "#del", 15, 19); // DELETE |
635 |
ArrayList<Annotation> annotations = new ArrayList<Annotation>();
|
|
637 |
ArrayList<Annotation> annotations = new ArrayList<>(); |
|
636 | 638 |
annotations.add(a1); |
637 | 639 |
annotations.add(a2); |
638 | 640 |
annotations.add(a3); |
... | ... | |
644 | 646 |
Annotation a2 = new Annotation("NaPl", "NaPl14554", 15, 16); // ADD |
645 | 647 |
Annotation a3 = new Annotation("CoAc", "#del", 15, 19); // DELETE |
646 | 648 |
Annotation a4 = new Annotation("CoAc", "CoAc1", 15, 18); // DELETE |
647 |
ArrayList<Annotation> annotations = new ArrayList<Annotation>();
|
|
649 |
ArrayList<Annotation> annotations = new ArrayList<>(); |
|
648 | 650 |
annotations.add(a1); |
649 | 651 |
annotations.add(a2); |
650 | 652 |
annotations.add(a3); |
... | ... | |
655 | 657 |
public static ArrayList<Annotation> testUpdatingInclusive() { |
656 | 658 |
Annotation a1 = new Annotation("Actr", "Actr200", 15, 16); |
657 | 659 |
Annotation a2 = new Annotation("CoAc", "CoAc321", 15, 19); |
658 |
ArrayList<Annotation> annotations = new ArrayList<Annotation>();
|
|
660 |
ArrayList<Annotation> annotations = new ArrayList<>(); |
|
659 | 661 |
annotations.add(a1); |
660 | 662 |
annotations.add(a2); |
661 | 663 |
return annotations; |
... | ... | |
664 | 666 |
public static ArrayList<Annotation> testDeleting() { |
665 | 667 |
|
666 | 668 |
Annotation a1 = new Annotation("Actr", "#del", 15, 16); |
667 |
ArrayList<Annotation> annotations = new ArrayList<Annotation>();
|
|
669 |
ArrayList<Annotation> annotations = new ArrayList<>(); |
|
668 | 670 |
annotations.add(a1); |
669 | 671 |
return annotations; |
670 | 672 |
} |
... | ... | |
673 | 675 |
|
674 | 676 |
Annotation a1 = new Annotation("Actr", "#del", 15, 16); |
675 | 677 |
Annotation a2 = new Annotation("CoAc", "#del", 15, 16); |
676 |
ArrayList<Annotation> annotations = new ArrayList<Annotation>();
|
|
678 |
ArrayList<Annotation> annotations = new ArrayList<>(); |
|
677 | 679 |
annotations.add(a1); |
678 | 680 |
annotations.add(a2); |
679 | 681 |
return annotations; |
... | ... | |
833 | 835 |
|
834 | 836 |
public static void main(String[] args) { |
835 | 837 |
try { |
836 |
File xmlFile = new File("/home/mdecorde/TXM-0.8.0-dev/corpora/XMLLINEBREAK/txm/XMLLINEBREAK/test.xml");
|
|
837 |
File outfile = new File("/home/mdecorde/TXM-0.8.0-dev/corpora/XMLLINEBREAK/txm/XMLLINEBREAK/test-out.xml");
|
|
838 |
File xmlFile = new File(System.getProperty("user.home"), "TXM-0.8.0-dev/corpora/XMLLINEBREAK/txm/XMLLINEBREAK/test.xml");
|
|
839 |
File outfile = new File(System.getProperty("user.home"), "TXM-0.8.0-dev/corpora/XMLLINEBREAK/txm/XMLLINEBREAK/test-out.xml");
|
|
838 | 840 |
|
839 |
ArrayList<Annotation> segmentAnnotations = new ArrayList<Annotation>();
|
|
841 |
ArrayList<Annotation> segmentAnnotations = new ArrayList<>(); |
|
840 | 842 |
// int starts[] = { 3, 6 }; |
841 | 843 |
// int ends[] = { 5, 8 }; |
842 | 844 |
// for (int i = 0; i < starts.length; i++) { |
... | ... | |
844 | 846 |
// segmentAnnotations.add(new Annotation("DEUX", "deux", starts[i], ends[i])); |
845 | 847 |
// } |
846 | 848 |
|
847 |
ArrayList<Annotation> tokenAnnotations = new ArrayList<Annotation>();
|
|
849 |
ArrayList<Annotation> tokenAnnotations = new ArrayList<>(); |
|
848 | 850 |
int positions[] = { 1, 2 }; |
849 | 851 |
int n = 1; |
850 | 852 |
for (int p : positions) { |
Formats disponibles : Unified diff