@@ -0,0 +1,3565 @@
+package org.wikidata.analyzer.Processor;%0A%0Aimport org.json.simple.JSONObject;%0Aimport org.wikidata.wdtk.datamodel.interfaces.*;%0A%0Aimport java.io.*;%0Aimport java.util.*;%0A%0A/**%0A * ExactValueQuantityProcessor for wikidata-analysis%0A *%0A * @author Addshore%0A */%0Apublic class ExactValueQuantityProcessor extends WikidataAnalyzerProcessor %7B%0A%0A    private Map%3CString, Double%3E counters = new HashMap%3C%3E();%0A%0A    public ExactValueQuantityProcessor() %7B%0A        super();%0A    %7D%0A%0A    private void increment(String counter) %7B%0A        this.increment(counter, 1);%0A    %7D%0A%0A    private void increment(String counter, double quantity) %7B%0A        this.initiateCounterIfNotReady(counter);%0A        this.counters.put(counter, this.counters.get(counter) + quantity);%0A    %7D%0A%0A    private void initiateCounterIfNotReady(String counter) %7B%0A        if (!this.counters.containsKey(counter)) %7B%0A            this.counters.put(counter, (double) 0);%0A        %7D%0A    %7D%0A%0A    public boolean tearDown() %7B%0A        try %7B%0A            File metricsJsonFile = new File(outputDir.getAbsolutePath() + File.separator + %22exactValueQuantityMetrics.json%22);%0A            BufferedWriter metricsJsonWriter = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(metricsJsonFile)));%0A            new JSONObject(this.counters).writeJSONString(metricsJsonWriter);%0A            metricsJsonWriter.close();%0A        %7D catch (IOException e) %7B%0A            e.printStackTrace();%0A            return false;%0A        %7D%0A        return true;%0A    %7D%0A%0A    @Override%0A    public void processItemDocument(ItemDocument item) %7B%0A        for (Iterator%3CStatement%3E statements = item.getAllStatements(); statements.hasNext(); ) %7B%0A            Statement statement = statements.next();%0A%0A            this.processSnak(statement.getClaim().getMainSnak(), %22main%22);%0A%0A%0A            for (Iterator%3CSnak%3E qualifiers = statement.getClaim().getAllQualifiers(); qualifiers.hasNext(); ) %7B%0A                this.processSnak(qualifiers.next(), %22qualifier%22);%0A            %7D%0A%0A            for (Reference reference : statement.getReferences()) %7B%0A                for (Iterator%3CSnak%3E referenceSnaks = reference.getAllSnaks(); referenceSnaks.hasNext(); ) %7B%0A                    this.processSnak(referenceSnaks.next(), %22reference%22);%0A                %7D%0A            %7D%0A        %7D%0A    %7D%0A%0A    private void processSnak(Snak snak, String type) %7B%0A        if (snak instanceof ValueSnak) %7B%0A            Value value = snak.getValue();%0A            if (value instanceof QuantityValue) %7B%0A                QuantityValue quantityValue = (QuantityValue) value;%0A%0A                this.increment(%22property.%22 + snak.getPropertyId().toString());%0A                this.increment(%22type.%22 + type + %22.%22 + snak.getPropertyId().toString());%0A%0A                // number of values with +/-0 bounds (upper bound == lower bound)%0A                if (Objects.equals(quantityValue.getUpperBound(), quantityValue.getLowerBound())) %7B%0A                    this.increment(%22counters.noBound%22);%0A                %7D%0A%0A                // number of values with no unit (unit is %221%22 or Q199)%0A                if (quantityValue.getUnit().equals(%221%22) %7C%7C quantityValue.getUnit().equals(%22http://www.wikidata.org/entity/Q199%22)) %7B%0A                    this.increment(%22counters.noUnit%22);%0A                %7D%0A%0A                // number of values with no decimal point (i.e. whole numbers)%0A                if (quantityValue.getNumericValue().scale() %3C= 0) %7B%0A                    this.increment(%22counters.noDecimal%22);%0A                %7D%0A%0A            %7D%0A        %7D%0A    %7D%0A%0A    @Override%0A    public void processPropertyDocument(PropertyDocument property) %7B%0A    %7D%0A%0A%7D

Add ExactValueQuantityProcessor