commit f3419dd0f8614bc81c2a3e6ff28a852aadb9d1d1 Author: Guntram Blohm Date: Tue May 7 15:34:34 2019 +0200 first version diff --git a/abr_wb_meawblom.csv b/abr_wb_meawblom.csv new file mode 100644 index 0000000..c7cc119 --- /dev/null +++ b/abr_wb_meawblom.csv @@ -0,0 +1,91 @@ +#Description Index Start End peakPos PeakFactor IsRefOffset RefIndex AnaFixed Info +wire break 0 337146 337212 337194 5.17 0 -1 0 0.144818 > 0.084059 +wire break 1 339240 339308 339295 3.68 0 -1 0 0.103132 > 0.084059 +wire break 2 342952 343050 343030 4.13 0 -1 0 0.115647 > 0.084059 +wire break 3 351989 352113 352097 5.74 0 -1 0 0.160835 > 0.084059 +splice begin 4 2944476 2944676 2944476 50.00 1 0 1 +wire break 5 2944543 2944775 2944699 4.94 0 -1 0 0.138428 > 0.084059 +wire break 6 2947377 2947544 2947476 3.77 0 -1 0 0.105598 > 0.084059 +wire break 7 2950395 2950522 2950492 6.31 0 -1 0 0.176837 > 0.084059 +splice mid 8 2950535 2950885 2950535 50.00 0 1 1 +wire break 9 2950908 2951015 2950950 3.06 0 -1 0 0.085753 > 0.084059 +wire break 10 2953757 2953895 2953865 5.25 0 -1 0 0.146987 > 0.084059 +wire break 11 2953911 2953962 2953941 3.08 0 -1 0 0.086209 > 0.084059 +wire break 12 2954032 2954212 2954168 3.35 0 -1 0 0.093795 > 0.084059 +wire break 13 2956905 2957045 2956950 4.49 0 -1 0 0.125914 > 0.084059 +splice mid 14 2957048 2957384 2957048 50.00 0 2 1 +wire break 15 2957396 2957544 2957430 4.66 0 -1 0 0.130665 > 0.084059 +wire break 16 2960222 2960397 2960336 4.59 0 -1 0 0.128513 > 0.084059 +wire break 17 2960535 2960700 2960634 3.21 0 -1 0 0.089898 > 0.084059 +wire break 18 2963464 2963569 2963492 5.57 0 -1 0 0.156008 > 0.084059 +splice mid 19 2963569 2963757 2963569 50.00 0 3 1 +splice mid 20 2990720 2990912 2990720 50.00 0 4 1 +wire break 21 2990924 2991056 2990974 4.69 0 -1 0 0.131496 > 0.084059 +wire break 22 2993617 2993761 2993748 4.13 0 -1 0 0.115844 > 0.084059 +wire break 23 2996605 2996795 2996753 3.15 0 -1 0 0.088161 > 0.084059 +splice mid 24 2996795 2997153 2996795 50.00 0 5 1 +wire break 25 2997175 2997352 2997224 4.04 0 -1 0 0.113268 > 0.084059 +wire break 26 2997642 2997728 2997661 3.32 0 -1 0 0.093049 > 0.084059 +wire break 27 3000056 3000215 3000113 3.62 0 -1 0 0.101334 > 0.084059 +wire break 28 3000215 3000308 3000286 3.11 0 -1 0 0.087027 > 0.084059 +wire break 29 3000308 3000437 3000414 3.12 0 -1 0 0.087503 > 0.084059 +wire break 30 3003094 3003260 3003236 5.42 0 -1 0 0.151840 > 0.084059 +splice mid 31 3003260 3003655 3003260 50.00 0 6 1 +wire break 32 3006497 3006607 3006554 3.61 0 -1 0 0.101281 > 0.084059 +wire break 33 3006607 3006653 3006638 4.30 0 -1 0 0.120536 > 0.084059 +wire break 34 3006771 3006882 3006839 3.85 0 -1 0 0.107807 > 0.084059 +wire break 35 3009581 3009773 3009728 3.94 0 -1 0 0.110324 > 0.084059 +splice end 36 3009773 3010025 3009773 50.00 0 7 1 +wire break 37 3047508 3047577 3047564 10.29 0 -1 0 0.288310 > 0.084059 +wire break 38 3221630 3221694 3221680 6.87 0 -1 0 0.192431 > 0.084059 +wire break 39 3318948 3319044 3319024 6.32 0 -1 0 0.177116 > 0.084059 +wire break 40 4005982 4006044 4006030 6.79 0 -1 0 0.190170 > 0.084059 +wire break 41 4008073 4008147 4008133 4.70 0 -1 0 0.131652 > 0.084059 +wire break 42 4011783 4011881 4011864 3.89 0 -1 0 0.108914 > 0.084059 +wire break 43 4020894 4020959 4020941 6.54 0 -1 0 0.183381 > 0.084059 +wire break 44 4027847 4027922 4027907 4.22 0 -1 0 0.118148 > 0.084059 +wire break 45 4492399 4492474 4492452 2.82 0 -1 0 -0.048169 < -0.028020 | 0.079128 > 0.075653 | -0.044806 < -0.028020 +wire break 46 4774637 4774710 4774689 2.79 0 -1 0 -0.043771 < -0.028020 | 0.078122 > 0.075653 | -0.040041 < -0.028020 +splice begin 47 6613226 6613453 6613226 50.00 1 0 1 +wire break 48 6613321 6613543 6613321 4.94 0 -1 0 0.138335 > 0.084059 +wire break 49 6616083 6616163 6616137 2.85 0 -1 0 -0.084632 < -0.028020 | 0.079826 > 0.075653 | -0.039096 < -0.028020 +wire break 50 6616271 6616324 6616311 3.31 0 -1 0 0.092847 > 0.084059 +wire break 51 6616383 6616458 6616432 4.78 0 -1 0 0.133957 > 0.084059 +wire break 52 6619136 6619280 6619248 5.95 0 -1 0 0.166664 > 0.084059 +splice mid 53 6619280 6619678 6619280 50.00 0 1 1 +wire break 54 6622503 6622746 6622650 4.61 0 -1 0 0.129135 > 0.084059 +wire break 55 6625546 6625841 6625799 5.22 0 -1 0 0.146226 > 0.084059 +splice mid 56 6625876 6626192 6625876 50.00 0 2 1 +wire break 57 6626200 6626284 6626255 4.15 0 -1 0 0.116143 > 0.084059 +wire break 58 6629036 6629239 6629152 3.73 0 -1 0 0.104596 > 0.084059 +wire break 59 6629326 6629534 6629454 3.83 0 -1 0 0.107185 > 0.084059 +wire break 60 6631862 6631903 6631879 3.28 0 -1 0 0.091988 > 0.084059 +wire break 61 6632229 6632379 6632308 7.23 0 -1 0 0.202643 > 0.084059 +splice mid 62 6632379 6632579 6632379 50.00 0 3 1 +splice mid 63 6659508 6659693 6659508 50.00 0 4 1 +wire break 64 6659586 6659836 6659759 4.43 0 -1 0 0.124117 > 0.084059 +wire break 65 6662383 6662502 6662475 3.70 0 -1 0 0.103576 > 0.084059 +wire break 66 6662574 6662642 6662625 3.15 0 -1 0 0.088252 > 0.084059 +wire break 67 6662710 6662801 6662745 4.03 0 -1 0 0.112897 > 0.084059 +splice mid 68 6665573 6665917 6665573 50.00 0 5 1 +wire break 69 6668914 6668984 6668971 3.34 0 -1 0 0.093484 > 0.084059 +wire break 70 6669066 6669198 6669119 2.75 0 -1 0 -0.133300 < -0.028020 | 0.076941 > 0.075653 | -0.052040 < -0.028020 +wire break 71 6671922 6672031 6672010 4.81 0 -1 0 0.134888 > 0.084059 +splice mid 72 6672076 6672426 6672076 50.00 0 6 1 +wire break 73 6672522 6672592 6672557 3.01 0 -1 0 0.084474 > 0.084059 +wire break 74 6675307 6675413 6675361 3.97 0 -1 0 0.111309 > 0.084059 +wire break 75 6675413 6675466 6675447 3.67 0 -1 0 0.102964 > 0.084059 +wire break 76 6678393 6678596 6678532 3.96 0 -1 0 0.110872 > 0.084059 +splice end 77 6678596 6678804 6678596 50.00 0 7 1 +wire break 78 6716304 6716382 6716367 7.39 0 -1 0 0.207110 > 0.084059 +wire break 79 6740824 6740894 6740875 2.72 0 -1 0 -0.046936 < -0.028020 | 0.076094 > 0.075653 | -0.041233 < -0.028020 +wire break 80 6890448 6890517 6890504 8.03 0 -1 0 0.225115 > 0.084059 +wire break 81 6987812 6987895 6987880 9.23 0 -1 0 0.258559 > 0.084059 +wire break 82 7506065 7506141 7506119 2.95 0 -1 0 -0.032500 < -0.028020 | 0.082549 > 0.075653 | -0.041575 < -0.028020 +wire break 83 7674857 7674940 7674927 6.38 0 -1 0 0.178858 > 0.084059 +wire break 84 7676993 7677045 7677029 5.17 0 -1 0 0.144773 > 0.084059 +wire break 85 7680703 7680762 7680750 6.68 0 -1 0 0.187274 > 0.084059 +wire break 86 7689731 7689799 7689784 10.46 0 -1 0 0.293208 > 0.084059 +wire break 87 7696702 7696775 7696763 5.14 0 -1 0 0.143918 > 0.084059 +wire break 88 7897772 7897845 7897825 2.79 0 -1 0 -0.040019 < -0.028020 | 0.078246 > 0.075653 | -0.041862 < -0.028020 +wire break 89 8189462 8189528 8189508 2.74 0 -1 0 -0.036704 < -0.028020 | 0.076669 > 0.075653 | -0.043269 < -0.028020 diff --git a/abr_wb_refwblom.csv b/abr_wb_refwblom.csv new file mode 100644 index 0000000..74b39aa --- /dev/null +++ b/abr_wb_refwblom.csv @@ -0,0 +1,29 @@ +#Description Index Start End peakPos PeakFactor IsRefOffset RefIndex AnaFixed Info +splice begin 0 243 297 243 50.00 1 0 1 +splice mid 1 6475 6604 6475 50.00 0 1 1 +splice mid 2 13013 13143 13013 50.00 0 2 1 +splice mid 3 19399 19489 19399 50.00 0 3 1 +splice mid 4 46487 46543 46487 50.00 0 4 1 +splice mid 5 52738 52866 52738 50.00 0 5 1 +splice mid 6 59187 59315 59187 50.00 0 6 1 +splice end 7 65604 65683 65604 50.00 0 7 1 +wire break 8 103258 103276 103267 0.00 0 8 0 +wire break 9 277427 277441 277434 0.00 0 9 0 +wire break 10 374789 374803 374796 0.00 0 10 0 +wire break 11 1062129 1062133 1062131 0.00 0 11 0 +wire break 12 1067961 1067975 1067968 0.00 0 12 0 +wire break 13 1077046 1077063 1077054 0.00 0 13 0 +splice begin 14 3668243 3668297 3668243 50.00 1 0 1 +splice mid 15 3674475 3674604 3674475 50.00 0 1 1 +splice mid 16 3681013 3681143 3681013 50.00 0 2 1 +splice mid 17 3687399 3687489 3687399 50.00 0 3 1 +splice mid 18 3714487 3714543 3714487 50.00 0 4 1 +splice mid 19 3720738 3720866 3720738 50.00 0 5 1 +splice mid 20 3727187 3727315 3727187 50.00 0 6 1 +splice end 21 3733604 3733683 3733604 50.00 0 7 1 +wire break 22 3771258 3771276 3771267 0.00 0 8 0 +wire break 23 3945427 3945441 3945434 0.00 0 9 0 +wire break 24 4042789 4042803 4042796 0.00 0 10 0 +wire break 25 4730129 4730133 4730131 0.00 0 11 0 +wire break 26 4735961 4735975 4735968 0.00 0 12 0 +wire break 27 4745046 4745063 4745054 0.00 0 13 0 diff --git a/build.xml b/build.xml new file mode 100644 index 0000000..2110a62 --- /dev/null +++ b/build.xml @@ -0,0 +1,73 @@ + + + + + + + + + + + Builds, tests, and runs the project MentionMatch. + + + diff --git a/nbproject/build-impl.xml b/nbproject/build-impl.xml new file mode 100644 index 0000000..e385a53 --- /dev/null +++ b/nbproject/build-impl.xml @@ -0,0 +1,1420 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set src.dir + Must set test.src.dir + Must set build.dir + Must set dist.dir + Must set build.classes.dir + Must set dist.javadoc.dir + Must set build.test.classes.dir + Must set build.test.results.dir + Must set build.classes.excludes + Must set dist.jar + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + No tests executed. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set JVM to use for profiling in profiler.info.jvm + Must set profiler agent JVM arguments in profiler.info.jvmargs.agent + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + To run this application from the command line without Ant, try: + + java -jar "${dist.jar.resolved}" + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set run.class + + + + Must select one file in the IDE or set run.class + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set debug.class + + + + + Must select one file in the IDE or set debug.class + + + + + Must set fix.includes + + + + + + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + Must select one file in the IDE or set profile.class + This target only works when run from inside the NetBeans IDE. + + + + + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set run.class + + + + + + Must select some files in the IDE or set test.includes + + + + + Must select one file in the IDE or set run.class + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + + + + + Some tests failed; see details above. + + + + + + + + + Must select some files in the IDE or set test.includes + + + + Some tests failed; see details above. + + + + Must select some files in the IDE or set test.class + Must select some method in the IDE or set test.method + + + + Some tests failed; see details above. + + + + + Must select one file in the IDE or set test.class + + + + Must select one file in the IDE or set test.class + Must select some method in the IDE or set test.method + + + + + + + + + + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/nbproject/genfiles.properties b/nbproject/genfiles.properties new file mode 100644 index 0000000..3e27af8 --- /dev/null +++ b/nbproject/genfiles.properties @@ -0,0 +1,8 @@ +build.xml.data.CRC32=85458ccf +build.xml.script.CRC32=34900e25 +build.xml.stylesheet.CRC32=8064a381@1.80.1.48 +# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. +# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. +nbproject/build-impl.xml.data.CRC32=85458ccf +nbproject/build-impl.xml.script.CRC32=4e970dde +nbproject/build-impl.xml.stylesheet.CRC32=830a3534@1.80.1.48 diff --git a/nbproject/project.properties b/nbproject/project.properties new file mode 100644 index 0000000..0ee3a94 --- /dev/null +++ b/nbproject/project.properties @@ -0,0 +1,76 @@ +annotation.processing.enabled=true +annotation.processing.enabled.in.editor=false +annotation.processing.processors.list= +annotation.processing.run.all.processors=true +annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output +application.title=MentionMatch +application.vendor=gbl +build.classes.dir=${build.dir}/classes +build.classes.excludes=**/*.java,**/*.form +# This directory is removed when the project is cleaned: +build.dir=build +build.generated.dir=${build.dir}/generated +build.generated.sources.dir=${build.dir}/generated-sources +# Only compile against the classpath explicitly listed here: +build.sysclasspath=ignore +build.test.classes.dir=${build.dir}/test/classes +build.test.results.dir=${build.dir}/test/results +# Uncomment to specify the preferred debugger connection transport: +#debug.transport=dt_socket +debug.classpath=\ + ${run.classpath} +debug.test.classpath=\ + ${run.test.classpath} +# Files in build.classes.dir which should be excluded from distribution jar +dist.archive.excludes= +# This directory is removed when the project is cleaned: +dist.dir=dist +dist.jar=${dist.dir}/MentionMatch.jar +dist.javadoc.dir=${dist.dir}/javadoc +endorsed.classpath= +excludes= +includes=** +jar.compress=false +javac.classpath= +# Space-separated list of extra javac options +javac.compilerargs= +javac.deprecation=false +javac.external.vm=true +javac.processorpath=\ + ${javac.classpath} +javac.source=1.8 +javac.target=1.8 +javac.test.classpath=\ + ${javac.classpath}:\ + ${build.classes.dir} +javac.test.processorpath=\ + ${javac.test.classpath} +javadoc.additionalparam= +javadoc.author=false +javadoc.encoding=${source.encoding} +javadoc.noindex=false +javadoc.nonavbar=false +javadoc.notree=false +javadoc.private=false +javadoc.splitindex=true +javadoc.use=true +javadoc.version=false +javadoc.windowtitle= +main.class=mentionmatch.MentionMatch +manifest.file=manifest.mf +meta.inf.dir=${src.dir}/META-INF +mkdist.disabled=false +platform.active=default_platform +run.classpath=\ + ${javac.classpath}:\ + ${build.classes.dir} +# Space-separated list of JVM arguments used when running the project. +# You may also define separate properties like run-sys-prop.name=value instead of -Dname=value. +# To set system properties for unit tests define test-sys-prop.name=value: +run.jvmargs= +run.test.classpath=\ + ${javac.test.classpath}:\ + ${build.test.classes.dir} +source.encoding=ISO-8859-1 +src.dir=src +test.src.dir=test diff --git a/nbproject/project.xml b/nbproject/project.xml new file mode 100644 index 0000000..0111b6e --- /dev/null +++ b/nbproject/project.xml @@ -0,0 +1,15 @@ + + + org.netbeans.modules.java.j2seproject + + + MentionMatch + + + + + + + + + diff --git a/src/mentionmatch/Comparison.java b/src/mentionmatch/Comparison.java new file mode 100644 index 0000000..bdf894e --- /dev/null +++ b/src/mentionmatch/Comparison.java @@ -0,0 +1,115 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package mentionmatch; + +import java.io.PrintStream; +import java.util.ArrayList; +import java.util.List; + +/** + * + * @author gbl + */ +class Comparison { + + List parts; + + Comparison(ListOfMentions measure, ListOfMentions reference) { + parts=new ArrayList<>(); + + // Get the first and second mentions that have refOffset set + // (i.e. splice begins) from both mention lists + Mention measureFirst = measure.getMentions().get(measure.firstRefOffset); + Mention refFirst = reference.getMentions().get(reference.firstRefOffset); + + Mention measureLast = measure.getMentions().get(measure.secondRefOffset); + Mention refLast = reference.getMentions().get(reference.secondRefOffset); + + // and do some sanity checks + + if (measureFirst.refIndex != 0 || refFirst.refIndex != 0 + || measureLast.refIndex != 0 || refLast.refIndex != 0 + || measureFirst.anaFixed != 1 || refFirst.anaFixed != 1 + || measureLast.anaFixed != 1 || refLast.anaFixed != 1) { + System.err.println("Splice references don't match up"); + System.exit(1); + } + + // Divide the whole list into parts that have matching first and last + // fixed points (anaFixed equal). For example, this list + // + // A 0 P 0 + // B 1 Q -1 + // C 3 R -1 + // D 0 S 1 + // T -1 + // U 2 + // V -1 + // W 3 + // X 0 + // will have [AB] compared to [PS], [BC] to [SW] and [CD] to [WX]. + // Note the missing anaFixed==2 in the left table which means we + // need to skip U on the right. + + int measureStart=measure.firstRefOffset; // 'A' in comment + int referenceStart=reference.firstRefOffset; // 'P' in comment + int measureEnd, referenceEnd; + for (;;) { + measureEnd=findNextFixedPoint(measure, measureStart); // find 'B' from 'A' + referenceEnd=findNextFixedPoint(reference, referenceStart); // find 'S' from 'P' + + // Handle the "missing" case from the example; the 'End's are at + // C/U here. The one that has the lower anaFixed (but not 0) needs + // advance to the next fixed point. + + while (measure.getMentionAt(measureEnd).refIndex != reference.getMentionAt(referenceEnd).refIndex) { + if (measure.getMentionAt(measureEnd).refIndex > 0 && + measure.getMentionAt(measureEnd).refIndex < reference.getMentionAt(referenceEnd).refIndex) + measureEnd=findNextFixedPoint(measure, measureEnd); + else if (reference.getMentionAt(referenceEnd).refIndex > 0 && + measure.getMentionAt(measureEnd).refIndex > reference.getMentionAt(referenceEnd).refIndex) + referenceEnd=findNextFixedPoint(reference, referenceEnd); + else { + System.err.println("This should not happen; bug when finding next matching references"); + System.err.printf("starts = %d <> %d, ends = %d <> %d\n", measureStart, referenceStart, measureEnd, referenceEnd); + System.exit(1); + } + } + + parts.add(new MatrixComparison(measure, measureStart, measureEnd, reference, referenceStart, referenceEnd)); + if (measure.getMentionAt(measureEnd).refIndex == 0 && reference.getMentionAt(referenceEnd).refIndex == 0) + break; + measureStart=measureEnd; + referenceStart=referenceEnd; + } + } + + /** + * Find the next point, in a mentions list, that has anaFixed set, beginning from startIndex. + * @param list the list of mentions to be searched + * @param startIndex starting point + * @return the first index > startIndex that has a mention with anaFixed != 0 + */ + private int findNextFixedPoint(ListOfMentions list, int startIndex) { + int endIndex=startIndex+1; + while (list.getMentionAt(endIndex).anaFixed == 0) { + endIndex++; + } + return endIndex; + } + + void process() { + for (MatrixComparison part: parts) { + part.process(); + } + } + + void print(PrintStream out) { + for (MatrixComparison part: parts) { + part.print(out); + } + } +} diff --git a/src/mentionmatch/ListOfMentions.java b/src/mentionmatch/ListOfMentions.java new file mode 100644 index 0000000..5208789 --- /dev/null +++ b/src/mentionmatch/ListOfMentions.java @@ -0,0 +1,47 @@ +package mentionmatch; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileReader; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +class ListOfMentions { + + List mentions; + int firstRefOffset, secondRefOffset; + + ListOfMentions(File file) throws IOException { + mentions=new ArrayList<>(); + + BufferedReader reader=new BufferedReader(new FileReader(file)); + String line; + while ((line=reader.readLine())!=null) { + if (line.startsWith("#")) + continue; + mentions.add(new Mention(line)); + } + + int i=0; + while (i getMentions() { + return mentions; + } + + Mention getMentionAt(int i) { + return mentions.get(i); + } +} diff --git a/src/mentionmatch/MatrixComparison.java b/src/mentionmatch/MatrixComparison.java new file mode 100644 index 0000000..58f7f6b --- /dev/null +++ b/src/mentionmatch/MatrixComparison.java @@ -0,0 +1,306 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package mentionmatch; + +import java.io.PrintStream; +import java.util.Arrays; + +/** + * + * @author gbl + */ + +class MatrixComparison { + + private class Coord implements Comparable { + + int x; int y; + private Coord(int bestX, int bestY) { + x=bestX; + y=bestY; + } + + @Override + public int compareTo(Object o2) { + if (o2 instanceof Coord) { + return (this).x - ((Coord)o2).x; + } + throw new IllegalArgumentException("Coords can only be compared to coords"); + } + } + + ListOfMentions measure, reference; + int meaStart, meaEnd, refStart, refEnd; + float xAxisVal[], yAxisVal[]; + float[][] matrix; + Coord[] matches; + + MatrixComparison(ListOfMentions measure, int measureStart, int measureEnd, ListOfMentions reference, int referenceStart, int referenceEnd) { + this.measure=measure; + this.meaStart=measureStart; + this.meaEnd=measureEnd; + + this.reference=reference; + this.refStart=referenceStart; + this.refEnd=referenceEnd; + + matrix=new float[meaEnd-meaStart+1][]; + for (int i=0; i matches[i+1].y) { // i=B, i+1=C in above case + // find the last pair that has decrementing Y (DP) + int decrementingLength=1; + int minInvolvedY=matches[i+1].y; + while (i+decrementingLength < matches.length-1 + && matches[i].y > matches[i+decrementingLength+1].y) { + if (minInvolvedY > matches[i+decrementingLength+1].y) { + minInvolvedY = matches[i+decrementingLength+1].y; + } + decrementingLength++; + } + // here, i should index B, and decrementingLength should be 2 so i+DL indexes D + // next, count how many elements we need to go back from S to find P. As matches + // is sorted by X, and we don't have a sorted array of Y's, count how many + // Ys that are actually referenced are in [P, S] - here, 4. + int matchingYs=0; + for (int j=0; j= minInvolvedY + && matches[j].y <= matches[i].y) { + matchingYs++; + } + } + int lastChainX=i+decrementingLength; // find D + int firstChainX=i+decrementingLength+1-matchingYs; // find A + if (ratio(xAxisVal[matches[firstChainX].x]-0.0f, yAxisVal[matches[lastChainX].y]-0.0f) < maxAllowedStretch // compare MA to MP + && ratio(xAxisVal[matches[lastChainX].x]-xAxisVal[matches[firstChainX].x], yAxisVal[matches[i].y]-yAxisVal[matches[lastChainX].y]) < maxAllowedStretch // compare AD to PS + && ratio(1.0f-xAxisVal[matches[lastChainX].x], 1.0f-yAxisVal[matches[i].y]) < maxAllowedStretch) { + System.out.printf("I should switch between %d and %d but don't know how yet\n", firstChainX, lastChainX); + int[] resorted = new int[lastChainX-firstChainX+1]; + // switch: AR BS CQ DP to AP BQ CR DS + } else { + // remove match CQ, DP + for (int j=1; j<=decrementingLength; j++) { + matches[i+j].x=matches[i+j].y=-1; + } + } + i+=decrementingLength; // so it starts after current stretch on next iteration + } + } +*/ + + Arrays.sort(matches); + for (int i=0; i matches[i+1].y) { + // we have a backwards match; eliminate the worse one of the both + // by copying the following elements back and replacing the + // last one with invalid (-1,-1) + float myDistance=matrix[matches[i].x][matches[i].y]; + float nextDistance=matrix[matches[i+1].x][matches[i+1].y]; + + for (int j=(myDistance > nextDistance ? i : i+1); j b ? a / b : b / a ); + System.out.printf("rrrrrr ratio of %6.2f and %6.2f is %6.2f\n", a, b, x); + return x; + } + + private void dumpMatrix(String header) { + System.out.println("============ "+header+" ================"); + System.out.printf("%8s", ""); + for (int x=0; x= 1) { + workDirectory=args[0]; + } else { + workDirectory="."; + } + + try { + measure=new ListOfMentions(new File(workDirectory, "abr_wb_meawblom.csv")); + reference=new ListOfMentions(new File(workDirectory, "abr_wb_refwblom.csv")); + } catch (IOException ex) { + ex.printStackTrace(); + System.exit(1); + return; + } + + Comparison result=new Comparison(measure, reference); + result.process(); + result.print(System.out); + } +} diff --git a/testcase_1/README b/testcase_1/README new file mode 100644 index 0000000..34025a6 --- /dev/null +++ b/testcase_1/README @@ -0,0 +1 @@ +Measurement and Reference identical. diff --git a/testcase_1/abr_wb_meawblom.csv b/testcase_1/abr_wb_meawblom.csv new file mode 100644 index 0000000..4e8da22 --- /dev/null +++ b/testcase_1/abr_wb_meawblom.csv @@ -0,0 +1,5 @@ +splice begin 0 100 100 100 50 1 0 1 +wire break 1 200 200 200 50 0 -1 0 +wire break 2 300 300 300 50 0 -1 0 +splice end 3 500 500 500 50 0 -1 0 +splice begin 4 1000 1000 1000 50 1 0 1 diff --git a/testcase_1/abr_wb_refwblom.csv b/testcase_1/abr_wb_refwblom.csv new file mode 100644 index 0000000..4e8da22 --- /dev/null +++ b/testcase_1/abr_wb_refwblom.csv @@ -0,0 +1,5 @@ +splice begin 0 100 100 100 50 1 0 1 +wire break 1 200 200 200 50 0 -1 0 +wire break 2 300 300 300 50 0 -1 0 +splice end 3 500 500 500 50 0 -1 0 +splice begin 4 1000 1000 1000 50 1 0 1 diff --git a/testcase_2/README b/testcase_2/README new file mode 100644 index 0000000..f415ea5 --- /dev/null +++ b/testcase_2/README @@ -0,0 +1 @@ +One wirebreak missing in measurement diff --git a/testcase_2/abr_wb_meawblom.csv b/testcase_2/abr_wb_meawblom.csv new file mode 100644 index 0000000..0f87f17 --- /dev/null +++ b/testcase_2/abr_wb_meawblom.csv @@ -0,0 +1,4 @@ +splice begin 0 100 100 100 50 1 0 1 +wire break 1 200 200 200 50 0 -1 0 +splice end 2 500 500 500 50 0 1 0 +splice begin 3 1000 1000 1000 50 1 0 1 diff --git a/testcase_2/abr_wb_refwblom.csv b/testcase_2/abr_wb_refwblom.csv new file mode 100644 index 0000000..b18c1e1 --- /dev/null +++ b/testcase_2/abr_wb_refwblom.csv @@ -0,0 +1,5 @@ +splice begin 0 100 100 100 50 1 0 1 +wire break 1 200 200 200 50 0 -1 0 +wire break 2 300 300 300 50 0 -1 0 +splice end 3 500 500 500 50 0 1 0 +splice begin 4 1000 1000 1000 50 1 0 1 diff --git a/testcase_3/README b/testcase_3/README new file mode 100644 index 0000000..818f0bb --- /dev/null +++ b/testcase_3/README @@ -0,0 +1 @@ +one new wirebreak in measurement diff --git a/testcase_3/abr_wb_meawblom.csv b/testcase_3/abr_wb_meawblom.csv new file mode 100644 index 0000000..4e8da22 --- /dev/null +++ b/testcase_3/abr_wb_meawblom.csv @@ -0,0 +1,5 @@ +splice begin 0 100 100 100 50 1 0 1 +wire break 1 200 200 200 50 0 -1 0 +wire break 2 300 300 300 50 0 -1 0 +splice end 3 500 500 500 50 0 -1 0 +splice begin 4 1000 1000 1000 50 1 0 1 diff --git a/testcase_3/abr_wb_refwblom.csv b/testcase_3/abr_wb_refwblom.csv new file mode 100644 index 0000000..7d524a7 --- /dev/null +++ b/testcase_3/abr_wb_refwblom.csv @@ -0,0 +1,4 @@ +splice begin 0 100 100 100 50 1 0 1 +wire break 1 200 200 200 50 0 -1 0 +splice end 2 500 500 500 50 0 -1 0 +splice begin 3 1000 1000 1000 50 1 0 1 diff --git a/testcase_4/README b/testcase_4/README new file mode 100644 index 0000000..797dbd7 --- /dev/null +++ b/testcase_4/README @@ -0,0 +1 @@ +both wirebreak shifted slightly diff --git a/testcase_4/abr_wb_meawblom.csv b/testcase_4/abr_wb_meawblom.csv new file mode 100644 index 0000000..56be7c8 --- /dev/null +++ b/testcase_4/abr_wb_meawblom.csv @@ -0,0 +1,5 @@ +splice begin 0 100 100 100 50 1 0 1 +wire break 1 195 195 195 50 0 -1 0 +wire break 2 305 305 305 50 0 -1 0 +splice end 3 500 500 500 50 0 -1 0 +splice begin 4 1000 1000 1000 50 1 0 1 diff --git a/testcase_4/abr_wb_refwblom.csv b/testcase_4/abr_wb_refwblom.csv new file mode 100644 index 0000000..4e8da22 --- /dev/null +++ b/testcase_4/abr_wb_refwblom.csv @@ -0,0 +1,5 @@ +splice begin 0 100 100 100 50 1 0 1 +wire break 1 200 200 200 50 0 -1 0 +wire break 2 300 300 300 50 0 -1 0 +splice end 3 500 500 500 50 0 -1 0 +splice begin 4 1000 1000 1000 50 1 0 1 diff --git a/testcase_5/README b/testcase_5/README new file mode 100644 index 0000000..fe960b8 --- /dev/null +++ b/testcase_5/README @@ -0,0 +1 @@ +measurement rope 10% longer than reference rope diff --git a/testcase_5/abr_wb_meawblom.csv b/testcase_5/abr_wb_meawblom.csv new file mode 100644 index 0000000..6646137 --- /dev/null +++ b/testcase_5/abr_wb_meawblom.csv @@ -0,0 +1,5 @@ +splice begin 0 110 110 110 50 1 0 1 +wire break 1 220 220 220 50 0 -1 0 +wire break 2 330 330 330 50 0 -1 0 +splice end 3 550 550 550 50 0 -1 0 +splice begin 4 1100 1100 1100 50 1 0 1 diff --git a/testcase_5/abr_wb_refwblom.csv b/testcase_5/abr_wb_refwblom.csv new file mode 100644 index 0000000..4e8da22 --- /dev/null +++ b/testcase_5/abr_wb_refwblom.csv @@ -0,0 +1,5 @@ +splice begin 0 100 100 100 50 1 0 1 +wire break 1 200 200 200 50 0 -1 0 +wire break 2 300 300 300 50 0 -1 0 +splice end 3 500 500 500 50 0 -1 0 +splice begin 4 1000 1000 1000 50 1 0 1 diff --git a/testcase_6/README b/testcase_6/README new file mode 100644 index 0000000..4784198 --- /dev/null +++ b/testcase_6/README @@ -0,0 +1 @@ +wirebreak moved from 200 to 400 diff --git a/testcase_6/abr_wb_meawblom.csv b/testcase_6/abr_wb_meawblom.csv new file mode 100644 index 0000000..4ac8d08 --- /dev/null +++ b/testcase_6/abr_wb_meawblom.csv @@ -0,0 +1,5 @@ +splice begin 0 100 100 100 50 1 0 1 +wire break 1 300 300 300 50 0 -1 0 +wire break 2 400 400 400 50 0 -1 0 +splice end 3 500 500 500 50 0 -1 0 +splice begin 4 1000 1000 1000 50 1 0 1 diff --git a/testcase_6/abr_wb_refwblom.csv b/testcase_6/abr_wb_refwblom.csv new file mode 100644 index 0000000..4e8da22 --- /dev/null +++ b/testcase_6/abr_wb_refwblom.csv @@ -0,0 +1,5 @@ +splice begin 0 100 100 100 50 1 0 1 +wire break 1 200 200 200 50 0 -1 0 +wire break 2 300 300 300 50 0 -1 0 +splice end 3 500 500 500 50 0 -1 0 +splice begin 4 1000 1000 1000 50 1 0 1 diff --git a/testcase_7/README b/testcase_7/README new file mode 100644 index 0000000..f2efec6 --- /dev/null +++ b/testcase_7/README @@ -0,0 +1 @@ +series of wirebreaks shifted a bit diff --git a/testcase_7/abr_wb_meawblom.csv b/testcase_7/abr_wb_meawblom.csv new file mode 100644 index 0000000..7c64907 --- /dev/null +++ b/testcase_7/abr_wb_meawblom.csv @@ -0,0 +1,8 @@ +splice begin 0 100 100 100 50 1 0 1 +wire break 1 200 200 200 50 0 -1 0 +wire break 2 210 210 210 50 0 -1 0 +wire break 3 220 220 220 50 0 -1 0 +wire break 4 230 230 230 50 0 -1 0 +wire break 5 300 300 300 50 0 -1 0 +splice end 6 500 500 500 50 0 -1 0 +splice begin 7 1000 1000 1000 50 1 0 1 diff --git a/testcase_7/abr_wb_refwblom.csv b/testcase_7/abr_wb_refwblom.csv new file mode 100644 index 0000000..357636a --- /dev/null +++ b/testcase_7/abr_wb_refwblom.csv @@ -0,0 +1,8 @@ +splice begin 0 100 100 100 50 1 0 1 +wire break 1 210 210 210 50 0 -1 0 +wire break 2 220 220 220 50 0 -1 0 +wire break 3 230 230 230 50 0 -1 0 +wire break 4 240 240 240 50 0 -1 0 +wire break 5 300 300 300 50 0 -1 0 +splice end 6 500 500 500 50 0 -1 0 +splice begin 7 1000 1000 1000 50 1 0 1 diff --git a/testcase_8/README b/testcase_8/README new file mode 100644 index 0000000..f2efec6 --- /dev/null +++ b/testcase_8/README @@ -0,0 +1 @@ +series of wirebreaks shifted a bit diff --git a/testcase_8/abr_wb_meawblom.csv b/testcase_8/abr_wb_meawblom.csv new file mode 100644 index 0000000..7c64907 --- /dev/null +++ b/testcase_8/abr_wb_meawblom.csv @@ -0,0 +1,8 @@ +splice begin 0 100 100 100 50 1 0 1 +wire break 1 200 200 200 50 0 -1 0 +wire break 2 210 210 210 50 0 -1 0 +wire break 3 220 220 220 50 0 -1 0 +wire break 4 230 230 230 50 0 -1 0 +wire break 5 300 300 300 50 0 -1 0 +splice end 6 500 500 500 50 0 -1 0 +splice begin 7 1000 1000 1000 50 1 0 1 diff --git a/testcase_8/abr_wb_refwblom.csv b/testcase_8/abr_wb_refwblom.csv new file mode 100644 index 0000000..2dc5e96 --- /dev/null +++ b/testcase_8/abr_wb_refwblom.csv @@ -0,0 +1,8 @@ +splice begin 0 100 100 100 50 1 0 1 +wire break 1 190 190 190 50 0 -1 0 +wire break 2 200 200 200 50 0 -1 0 +wire break 3 210 210 210 50 0 -1 0 +wire break 4 220 220 220 50 0 -1 0 +wire break 5 300 300 300 50 0 -1 0 +splice end 6 500 500 500 50 0 -1 0 +splice begin 7 1000 1000 1000 50 1 0 1