The following document contains the results of PMD's CPD 5.3.2.

Duplications

File Project Line
eu/fbk/dkm/pikes/resources/ecb/ECBPlusEvaluator.java pikes-resources 25
eu/fbk/dkm/pikes/resources/ecb/ECBPlusEvaluatorLemma.java pikes-resources 25
    private static final Logger LOGGER = LoggerFactory.getLogger(ECBPlusEvaluator.class);
    private static final Pattern tokenPattern = Pattern.compile(".*/([0-9]+)_([0-9]+ecb[a-z]*)\\.xml#char=([0-9]+).*");
    private static final Pattern fileNamePattern = Pattern.compile("[0-9]+/([0-9]+)_([0-9a-zA-Z]+)");

    //    private static final Boolean removeAloneClusters = false;
//    private static final Pattern chainPattern = Pattern.compile("CHAIN=\"([0-9]+)\"");
    private static Integer FOLDER = null;

    public static void printToken(Appendable writer, Term token, int i, String last) throws IOException {
        writer.append(String.format("%d", i)).append("\t");
        writer.append(token.getForm()).append("\t");
        writer.append("_").append("\t");
        writer.append(token.getForm()).append("\t");
        writer.append("_").append("\t");
        writer.append(token.getMorphofeat()).append("\t");
        writer.append("_").append("\t");
        writer.append("_").append("\t");
        writer.append("_").append("\t");
        writer.append("_").append("\t");
        writer.append("_").append("\t");
        writer.append("_").append("\t");
        writer.append("_").append("\t");
        writer.append("_").append("\t");
        writer.append("_").append("\t");
        writer.append("_").append("\t");
        writer.append(last);
        writer.append("\n");

    }

    public static void main(String[] args) {
        try {

            final CommandLine cmd = CommandLine
                    .parser()
                    .withName("./ecb-evaluator")
                    .withHeader("Evaluator event extractor")
                    .withOption("n", "input-naf", "Input NAF folder", "FOLDER",
                            CommandLine.Type.DIRECTORY_EXISTING, true, false, true)
                    .withOption("i", "input-csv", "Input CSV file", "FILE",
                            CommandLine.Type.FILE_EXISTING, true, false, true)
                    .withOption("g", "output-gold", "Output gold file", "FILE",
                            CommandLine.Type.FILE, true, false, true)
                    .withOption("b", "output-baseline", "Output baseline file", "FILE",
                            CommandLine.Type.FILE, true, false, true)
                    .withOption("o", "output", "Output file", "FILE",
                            CommandLine.Type.FILE, true, false, true)
                    .withOption("l", "input-lemmas", "Lemmas CSV file", "FILE",
                            CommandLine.Type.FILE_EXISTING, true, false, false)
                    .withOption("a", "input-all-lemmas", "Lemmas CSV file", "FILE",
                            CommandLine.Type.FILE_EXISTING, true, false, false)
//                    .withOption("r", "remove-alone", "Remove alone clusters")
                    .withOption("c", "check-gold", "Use only events annotated in gold standard")
                    .withOption("s", "add-single", "Add single clusters")
                    .withLogger(LoggerFactory.getLogger("eu.fbk")).parse(args);

            File inputCsv = cmd.getOptionValue("input-csv", File.class);
            File inputNaf = cmd.getOptionValue("input-naf", File.class);
            File inputLemmas = cmd.getOptionValue("input-lemmas", File.class);
            File inputAllLemmas = cmd.getOptionValue("input-all-lemmas", File.class);

            File outputGold = cmd.getOptionValue("output-gold", File.class);
            File outputBaseline = cmd.getOptionValue("output-baseline", File.class);
            File output = cmd.getOptionValue("output", File.class);

//            Boolean removeAloneClusters = cmd.hasOption("remove-alone");
            Boolean checkGold = cmd.hasOption("check-gold");
            Boolean addSingleClusters = cmd.hasOption("add-single");

            Reader in;
            Iterable<CSVRecord> records;

            HashMap<String, Integer> lemmas = null;
            HashMap<String, Integer> allLemmas = null;

            int lemmaIndex = 0;
            if (inputLemmas != null) {
                lemmas = new HashMap<>();
                in = new FileReader(inputLemmas);
                records = CSVFormat.EXCEL.withHeader().parse(in);
                for (CSVRecord record : records) {
                    String lemma = record.get(1);
                    lemma = lemma.replaceAll("\"", "").trim();
                    if (lemma.length() > 0) {
                        lemmas.put(lemma, ++lemmaIndex);
                    }
                }
            }
            lemmaIndex = 0;
            if (inputAllLemmas != null) {
                allLemmas = new HashMap<>();
                in = new FileReader(inputAllLemmas);
                records = CSVFormat.EXCEL.withHeader().parse(in);
                for (CSVRecord record : records) {
                    String lemma = record.get(1);
                    lemma = lemma.replaceAll("\"", "").trim();
                    if (lemma.length() > 0) {
                        allLemmas.put(lemma, ++lemmaIndex);
                    }
                }
            }

            if (lemmas != null) {
                LOGGER.info("Lemmas: {}", lemmas.size());
            }
            if (allLemmas != null) {
                LOGGER.info("All-lemmas: {}", allLemmas.size());
            }

            BufferedWriter goldWriter = new BufferedWriter(new FileWriter(outputGold));
            BufferedWriter baselineWriter = new BufferedWriter(new FileWriter(outputBaseline));
            BufferedWriter writer = new BufferedWriter(new FileWriter(output));

            HashMultimap<String, String> goldTmpClusters = HashMultimap.create();
            HashMap<String, String> goldClusters = new HashMap<>();
            Set<String> okEvents = new HashSet<>();

            Map<String, String> theBaseline = new HashMap<>();

            for (final File file : Files.fileTreeTraverser().preOrderTraversal(inputNaf)) {
                if (!file.isFile()) {
                    continue;
                }
                if (file.getName().startsWith(".")) {
                    continue;
                }

                String path = file.getParentFile().toString();
                String relativeFilePath = file.getAbsolutePath()
                        .substring(inputNaf.getAbsolutePath().length());

                Matcher matcher = fileNamePattern.matcher(relativeFilePath);
                Integer folder = null;
                String fileNum = null;
                if (matcher.find()) {
                    folder = Integer.parseInt(matcher.group(1));
                    fileNum = matcher.group(2);

                } else {
                    LOGGER.error("Error in file name: {}", relativeFilePath);
                    System.exit(1);
                }

                if (FOLDER != null && !folder.equals(FOLDER)) {
                    continue;
                }

                LOGGER.debug(file.getAbsolutePath());
                KAFDocument document = KAFDocument.createFromFile(file);

                for (Coref coref : document.getCorefs()) {
                    if (coref.getType() == null) {
                        continue;
                    }
                    if (!coref.getType().equals("event-gold")) {
                        continue;
                    }

                    Integer cluster = Integer.parseInt(coref.getCluster());
                    String idCluster = String.valueOf(1000 * folder + cluster);

                    for (Span<Term> termSpan : coref.getSpans()) {
                        Term term = termSpan.getTargets().get(0);
                        String lemma = term.getLemma();

                        boolean add = false;
                        if (allLemmas != null && allLemmas.containsKey(lemma)) {
                            add = true;
                        }
                        if (lemmas == null || lemmas.containsKey(lemma)) {
                            add = true;
                        }

                        if (add) {
                            String text = folder + "_" + fileNum + "_" + term.getOffset();
                            goldTmpClusters.put(idCluster, text);
                            goldClusters.put(text, idCluster);
                            okEvents.add(text);
                        }
                    }
                }

                goldWriter.append(String.format("#begin document %d_%s", folder, fileNum)).append("\n");
                baselineWriter.append(String.format("#begin document %d_%s", folder, fileNum)).append("\n");

                Integer numSentences = document.getNumSentences();
                for (int i = 1; i <= numSentences; i++) {

                    boolean useThis = false;
                    StringBuilder goldBuilder = new StringBuilder();
                    StringBuilder baselineBuilder = new StringBuilder();

                    List<Term> sentenceTerms = document.getSentenceTerms(i);
                    int n = 0;
                    for (Term token : sentenceTerms) {
                        String id = String.format("%d_%s_%d", folder, fileNum, token.getOffset());
                        String last;
                        n++;

                        last = "_";
                        if (goldClusters.containsKey(id)) {
                            last = String.format("(%s)", goldClusters.get(id));
                            useThis = true;
                        }
                        printToken(goldBuilder, token, n, last);

                        last = "_";
                        String lemma = token.getLemma();
                        if (lemmas != null) {
                            if (goldClusters.containsKey(id) && lemmas.containsKey(lemma)) {
                                last = String.format("(%d)", lemmas.get(lemma));
                            }
                        }
                        if (allLemmas != null) {
                            if (goldClusters.containsKey(id) && allLemmas.containsKey(lemma)) {
                                last = String.format("(%d)", allLemmas.get(lemma));
                            }
                        }
                        if (!last.equals("_")) {
                            theBaseline.put(id, last);
                        }
                        printToken(baselineBuilder, token, n, last);
                    }

                    goldBuilder.append("\n");
                    baselineBuilder.append("\n");

                    if (useThis) {
                        goldWriter.append(goldBuilder.toString());
                        baselineWriter.append(baselineBuilder.toString());
                    }
                }
//                break;
            }

            goldWriter.close();
            baselineWriter.close();

//            Set<Set> goldClusters = new HashSet<>();
//            for (String key : goldTmpClusters.keySet()) {
//                Set<String> cluster = goldTmpClusters.get(key);
//                if (cluster.size() > 1 || !removeAloneClusters) {
//                    goldClusters.add(cluster);
//                }
//            }

//            LOGGER.info("Gold clusters: {}", goldClusters.size());

            in = new FileReader(inputCsv);
            records = CSVFormat.EXCEL.withHeader().parse(in);

            // Size must be always 4!
            int clusterID = 0;
            HashMap<String, Integer> clusterIndexes = new HashMap<>();
            HashMultimap<Integer, String> theClusters = HashMultimap.create();
            for (CSVRecord record : records) {
                Matcher matcher;

                String id1 = null;
                String id2 = null;
                matcher = tokenPattern.matcher(record.get(1));
                if (matcher.find()) {
                    id1 = matcher.group(1) + "_" + matcher.group(2) + "_" + matcher.group(3);
                }
                matcher = tokenPattern.matcher(record.get(3));
                if (matcher.find()) {
                    id2 = matcher.group(1) + "_" + matcher.group(2) + "_" + matcher.group(3);
                }

//                System.out.println(id1);
//                System.out.println(id2);

                Integer index1 = clusterIndexes.get(id1);
                Integer index2 = clusterIndexes.get(id2);

//                System.out.println(index1);
//                System.out.println(index2);

                if (index1 == null && index2 == null) {
                    clusterID++;
                    if (!checkGold || okEvents.contains(id2)) {
                        if (id2 != null) {
                            theClusters.put(clusterID, id2);
                            clusterIndexes.put(id2, clusterID);
                        }
                    }
                    if (!checkGold || okEvents.contains(id1)) {
                        if (id1 != null) {
                            theClusters.put(clusterID, id1);
                            clusterIndexes.put(id1, clusterID);
                        }
                    }
                }
                if (index1 == null && index2 != null) {
                    if (!checkGold || okEvents.contains(id1)) {
                        if (id1 != null) {
                            theClusters.put(index2, id1);
                            clusterIndexes.put(id1, index2);
                        }
                    }
                }
                if (index2 == null && index1 != null) {
                    if (!checkGold || okEvents.contains(id2)) {
                        if (id2 != null) {
                            theClusters.put(index1, id2);
                            clusterIndexes.put(id2, index1);
                        }
                    }
                }
                if (index2 != null && index1 != null) {
                    if (!index1.equals(index2)) {
                        if (id2 != null) {
                            clusterIndexes.put(id2, index1);
                            theClusters.putAll(index1, theClusters.get(index2));
                            theClusters.removeAll(index2);
                        }
                    }
                }
            }

//            System.out.println(theClusters);
//            System.out.println(theBaseline);

            int otherClusterID = 100000;
            for (final File file : Files.fileTreeTraverser().preOrderTraversal(inputNaf)) {
                if (!file.isFile()) {
                    continue;
                }
                if (file.getName().startsWith(".")) {
                    continue;
                }

//                String path = file.getParentFile().toString();
                String relativeFilePath = file.getAbsolutePath()
                        .substring(inputNaf.getAbsolutePath().length());

                Matcher matcher = fileNamePattern.matcher(relativeFilePath);
                Integer folder = null;
                String fileNum = null;
                if (matcher.find()) {
                    folder = Integer.parseInt(matcher.group(1));
                    fileNum = matcher.group(2);

                } else {
                    LOGGER.error("Error in file name: {}", relativeFilePath);
                    System.exit(1);
                }
//                Integer folder = Integer.parseInt(path.substring(path.lastIndexOf("/")).substring(1));
//                Integer fileNum = Integer.parseInt(file.getName().substring(0, file.getName().length() - 4));

                LOGGER.debug(file.getAbsolutePath());
                KAFDocument document = KAFDocument.createFromFile(file);

                if (FOLDER != null && !folder.equals(FOLDER)) {
                    continue;
                }

                writer.append(String.format("#begin document %d_%s", folder, fileNum)).append("\n");
                Integer numSentences = document.getNumSentences();
                for (int i = 1; i <= numSentences; i++) {

                    boolean useThis = false;
                    StringBuilder outBuilder = new StringBuilder();

                    List<Term> sentenceTerms = document.getSentenceTerms(i);
                    int n = 0;
                    for (Term token : sentenceTerms) {
                        String id = String.format("%d_%s_%d", folder, fileNum, token.getOffset());
                        if (okEvents.contains(id)) {
                            useThis = true;
                        }
                        String last = theBaseline.getOrDefault(id, "_");
                        if (clusterIndexes.containsKey(id)) {
                            last = String.format("(%d)", clusterIndexes.get(id) + 1000000);
                        }
                        if (last.equals("_")) {
                            if (okEvents.contains(id) && addSingleClusters) {
                                last = String.format("(%d)", ++otherClusterID);
                            }
                        }
                        printToken(outBuilder, token, ++n, last);
                    }

                    outBuilder.append("\n");

                    if (useThis) {
                        writer.append(outBuilder.toString());
                    }
                }

            }
            writer.close();

        } catch (Exception e) {
            CommandLine.fail(e);

        }
    }

}
File Project Line
eu/fbk/dkm/pikes/raid/mdfsa/APIManager.java pikes-raid 61
eu/fbk/dkm/pikes/raid/mdfsa/APIManager.java pikes-raid 294
    HashMap<String, Integer> sentenceTokens = new HashMap<String, Integer>();
    HashMap<String, Integer> stemmedTokens = new HashMap<String, Integer>();

    FuzzyMembership eT = new FuzzyMembership(1.0, 1.0, -1.0, -1.0);
    String[] tokens = text.split(" ");
    for(int i = 0; i < tokens.length; i++) {
      if(tokens[i].compareTo("") != 0) {
        String lexToken = this.wnlex.getWordLexicalizationByType(tokens[i].toLowerCase(), "MIX");
        //System.out.print(" " + lexToken + " ");
        if(lexToken != null) {
          tokens[i] = lexToken;
        }
        sentenceTokens.put(tokens[i], new Integer(i));

        porterStemmer stemmer = new porterStemmer();
        stemmer.setCurrent(tokens[i].toLowerCase());
        String stemLink = tokens[i].toLowerCase();
        if(stemmer.stem()) {
          stemLink = stemmer.getCurrent();
          //System.out.print(stemLink + " ");
        }
        stemmedTokens.put(stemLink, new Integer(i));
      }
    }
    Iterator<String> it = this.labels.keySet().iterator();
    while(it.hasNext()) {
      String currentConcept = it.next();
      String[] cts = currentConcept.split("_");
      int higherIdx = 0;
      int lowerIdx = tokens.length;
      int foundCT = 0;
      int flagNegation = 1;
      for(String ct: cts) {
        
        /*
        if(ct.compareTo("regret") == 0) {
          int A = 1;
        }
        */

        Integer tempIdx = sentenceTokens.get(ct);
        if(tempIdx == null) {
          tempIdx = stemmedTokens.get(ct);
        }
        if(tempIdx != null) {
          if(tempIdx < lowerIdx) lowerIdx = tempIdx;
          if(tempIdx > higherIdx) higherIdx = tempIdx;
          foundCT++;
        }
      }
      Integer notToken = sentenceTokens.get("not");
      if(notToken == null) {
        //notToken = sentenceTokens.get("no");
      }

      if(notToken != null &&
        (
         (notToken >= (lowerIdx - 2)) ||
         (
          (notToken > lowerIdx) && (notToken < higherIdx)
         )
        )
        ) {
        flagNegation = -1;
      }
      /*
      if(notToken != null && notToken == lowerIdx - 1) {
        flagNegation = -1;
      }
      */
      if(higherIdx >= 0 && foundCT == cts.length && (higherIdx - lowerIdx) < (cts.length + 2)) {

        Long feature = this.labels.get(currentConcept);
        //Long feature = labels.get(stemLink);
        
        /*
        double ratioFactor = 1.0 / (sentenceTokens.size() - lowerIdx);
        if(ratioFactor == Double.NaN || ratioFactor == 0.0) {
          ratioFactor = 1.0;
        }
        */
        double ratioFactor = 1.0;

        FuzzyMembership fm = this.polarities.get(feature);
        double a = 0.0;
        try {
          a = fm.getA() * ratioFactor * flagNegation;
        } catch (Exception e) {
          System.out.println("Error on getting fuzzy shape: " + currentConcept);
          //System.exit(0);
          return -2.0;
        }

        double b = fm.getB() * ratioFactor * flagNegation;
        double c = fm.getC() * ratioFactor * flagNegation;
        double d = fm.getD() * ratioFactor * flagNegation;

        if(flagNegation == -1) {
          double t = a;
          a = d;
          d = t;

          t = b;
          b = c;
          c = t;
        }

        double eA = eT.getA();
        double eB = eT.getB();
        double eC = eT.getC();
        double eD = eT.getD();

        if(a < eA) eA = a;
        if(b < eB) eB = b;
        if(c > eC) eC = c;
        if(d > eD) eD = d;

        eT.setA(eA);
        eT.setB(eB);
        eT.setC(eC);
        eT.setD(eD);

        fuzzyShapeFound += 1.0;
        tempPolarity += fm.getCentroidXAxis();
      }
    }

    if(eT.getA() != 1.0) {
      //textPolarity = eT.getCentroid();
      textPolarity = eT.getCentroidXAxis();
      if(Double.isNaN(textPolarity)) {
        return -2.0;
      }
      //textPolarity = tempPolarity / fuzzyShapeFound;
    }

    return textPolarity;
  }
File Project Line
eu/fbk/dkm/pikes/raid/pipeline/PipelineTrainer.java pikes-raid 152
eu/fbk/dkm/pikes/raid/sbrs/SBRSTrainer.java pikes-raid 76
    }

    private void addArguments(final KAFDocument document, final int sentence,
            final Opinion[] opinions) {

        // Index holder and target spans by expression head, keeping track of all exp. heads
        final Set<Term> expressionHeads = Sets.newHashSet();
        final Multimap<Term, Span<Term>> holderSpans = HashMultimap.create();
        final Multimap<Term, Span<Term>> targetSpans = HashMultimap.create();
        for (final Opinion opinion : opinions) {
            final Set<Term> heads = Opinions.heads(document,
                    NAFUtils.normalizeSpan(document, opinion.getExpressionSpan()),
                    Component.EXPRESSION);
            if (!heads.isEmpty()) {
                final Term head = Ordering.from(Term.OFFSET_COMPARATOR).max(heads);
                expressionHeads.add(head);
                final Span<Term> holderSpan = opinion.getHolderSpan();
                final Span<Term> targetSpan = opinion.getTargetSpan();
                if (holderSpan != null) {
                    holderSpans.putAll(head, NAFUtils.splitSpan(document, holderSpan, //
                            Opinions.heads(document, holderSpan, Component.HOLDER)));
                }
                if (targetSpan != null) {
                    targetSpans.putAll(head, NAFUtils.splitSpan(document, targetSpan, //
                            Opinions.heads(document, targetSpan, Component.TARGET)));
                }
            }
        }

        // Add training samples for holder and target extraction, separately (if enabled)
        for (final Term expressionHead : expressionHeads) {
            if (components().contains(Component.HOLDER)) {
                addArguments(document, sentence, expressionHead, holderSpans.get(expressionHead),
                        this.holderLinkTrainer, this.holderSpanTrainer);
            }
            if (components().contains(Component.TARGET)) {
                addArguments(document, sentence, expressionHead, targetSpans.get(expressionHead),
                        this.targetLinkTrainer, this.targetSpanTrainer);
            }
        }
    }

    private void addArguments(final KAFDocument document, final int sentence,
            final Term expressionHead, final Iterable<Span<Term>> argSpans,
            final LinkLabeller.Trainer linkTrainer, final SpanLabeller.Trainer spanTrainer) {

        // Extract heads and spans of the arguments (only where defined)
        final List<Term> heads = Lists.newArrayList();
        final List<Span<Term>> spans = Lists.newArrayList();
        for (final Span<Term> span : argSpans) {
            final Term head = NAFUtils.extractHead(document, span);
            if (head != null) {
                heads.add(head);
                spans.add(span);
            }
        }

        // Add a sample for node labelling
        linkTrainer.add(document, expressionHead, heads);

        // Add samples for span labelling (one for each argument)
        for (int i = 0; i < heads.size(); ++i) {
            final List<Term> excludedTerms = Lists.newArrayList(heads);
            excludedTerms.remove(heads.get(i));
            spanTrainer.add(document, heads.get(i), excludedTerms, spans.get(i));
        }
    }

}
File Project Line
eu/fbk/dkm/pikes/resources/trec/CR.java pikes-resources 45
eu/fbk/dkm/pikes/resources/trec/LATIMES.java pikes-resources 49
                    .withHeader("Extract CR documents from TREC dataset and save them in NAF format")
                    .withOption("i", "input", "Input folder", "FOLDER", CommandLine.Type.DIRECTORY_EXISTING, true,
                            false, true)
                    .withOption("o", "output", "Output folder", "FOLDER", CommandLine.Type.DIRECTORY, true, false, true)
                    .withOption("u", "url-template", "URL template (with %d for the ID)", "URL",
                            CommandLine.Type.STRING, true, false, false)
                    .withLogger(LoggerFactory.getLogger("eu.fbk")) //
                    .parse(args);

            File inputDir = cmd.getOptionValue("input", File.class);

            String urlTemplate = DEFAULT_URL;
            if (cmd.hasOption("url-template")) {
                urlTemplate = cmd.getOptionValue("url-template", String.class);
            }

            File outputDir = cmd.getOptionValue("output", File.class);
            if (!outputDir.exists()) {
                outputDir.mkdirs();
            }

            for (final File file : Files.fileTreeTraverser().preOrderTraversal(inputDir)) {
                if (!file.isFile()) {
                    continue;
                }
                if (file.getName().startsWith(".")) {
                    continue;
                }

                String outputTemplate = outputDir.getAbsolutePath() + File.separator + file.getName();
                File newFolder = new File(outputTemplate);
                newFolder.mkdirs();

                outputTemplate += File.separator + "NAF";
                saveFile(file, outputTemplate, urlTemplate);
            }
        } catch (Exception e) {
            CommandLine.fail(e);
        }
    }

    private static void saveFile(File inputFile, String outputFilePattern, String urlTemplate)
            throws IOException, SAXException, ParserConfigurationException {

        LOGGER.info("Input file: {}", inputFile);

        StringBuffer stringBuffer = new StringBuffer();
        stringBuffer.append("<ROOT>\n");
        stringBuffer.append(Files.toString(inputFile, Charsets.UTF_8));
        stringBuffer.append("\n</ROOT>\n");

        InputStream is = new ByteArrayInputStream(stringBuffer.toString().getBytes());
        DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
        DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
        Document doc = dBuilder.parse(is);

        doc.getDocumentElement().normalize();

        int i = 0;
        for (Element element : JOOX.$(doc).find("DOC")) {
            Element docnoElement = JOOX.$(element).find("DOCNO").get(0);
            Element dateElement = JOOX.$(element).find("DATE").get(0);
            Element headlineElement = JOOX.$(element).find("TTL").get(0);
File Project Line
eu/fbk/dkm/pikes/resources/ecb/ECBPlusEvaluator.java pikes-resources 27
eu/fbk/dkm/pikes/resources/ecb/ECBPlusEvaluatorLemma.java pikes-resources 27
eu/fbk/dkm/pikes/resources/ecb/ECBevaluator.java pikes-resources 29
    private static final Pattern fileNamePattern = Pattern.compile("[0-9]+/([0-9]+)_([0-9a-zA-Z]+)");

    //    private static final Boolean removeAloneClusters = false;
//    private static final Pattern chainPattern = Pattern.compile("CHAIN=\"([0-9]+)\"");
    private static Integer FOLDER = null;

    public static void printToken(Appendable writer, Term token, int i, String last) throws IOException {
        writer.append(String.format("%d", i)).append("\t");
        writer.append(token.getForm()).append("\t");
        writer.append("_").append("\t");
        writer.append(token.getForm()).append("\t");
        writer.append("_").append("\t");
        writer.append(token.getMorphofeat()).append("\t");
        writer.append("_").append("\t");
        writer.append("_").append("\t");
        writer.append("_").append("\t");
        writer.append("_").append("\t");
        writer.append("_").append("\t");
        writer.append("_").append("\t");
        writer.append("_").append("\t");
        writer.append("_").append("\t");
        writer.append("_").append("\t");
        writer.append("_").append("\t");
        writer.append(last);
        writer.append("\n");

    }

    public static void main(String[] args) {
        try {

            final CommandLine cmd = CommandLine
                    .parser()
                    .withName("./ecb-evaluator")
                    .withHeader("Evaluator event extractor")
                    .withOption("n", "input-naf", "Input NAF folder", "FOLDER",
                            CommandLine.Type.DIRECTORY_EXISTING, true, false, true)
                    .withOption("i", "input-csv", "Input CSV file", "FILE",
                            CommandLine.Type.FILE_EXISTING, true, false, true)
                    .withOption("g", "output-gold", "Output gold file", "FILE",
                            CommandLine.Type.FILE, true, false, true)
                    .withOption("b", "output-baseline", "Output baseline file", "FILE",
                            CommandLine.Type.FILE, true, false, true)
                    .withOption("o", "output", "Output file", "FILE",
                            CommandLine.Type.FILE, true, false, true)
                    .withOption("l", "input-lemmas", "Lemmas CSV file", "FILE",
                            CommandLine.Type.FILE_EXISTING, true, false, false)
                    .withOption("a", "input-all-lemmas", "Lemmas CSV file", "FILE",
File Project Line
eu/fbk/dkm/pikes/tintopclient/TintopOrchestrator.java pikes-tintop-client 169
eu/fbk/dkm/pikes/tintop/FolderOrchestrator.java pikes-tintop 151
    }

    synchronized public String getNextFile(TintopSession session) {

        fIter:
        while (fileCache != null || session.getFileIterator().hasNext()) {

            File file;
            if (fileCache != null) {
                file = new File(fileCache);
                fileCache = null;
            } else {
                file = session.getFileIterator().next();
            }

            File outputFile = getOutputFile(file, session);

            // todo: use parameters
            outputFile = new File(outputFile.getAbsolutePath() + ".gz");

            logger.debug("Output file: " + outputFile);

            if (outputFile.exists()) {
                logger.debug("Skipping file (it exists): " + file);
                continue fIter;
            }

            for (String p : session.getSkipPatterns()) {
                if (file.toString().contains(p)) {
                    logger.debug("Skipping file (skip pattern): " + file);
                    continue fIter;
                }
            }

            if (maxSize > 0 && file.length() > maxSize) {
                logger.debug("Skipping file (too big, " + file.length() + "): " + file);
                skipped++;
                continue fIter;
            }

            // File is empty
            if (file.length() < 1000) {
                try {
                    KAFDocument document = KAFDocument.createFromFile(file);
                    if (document.getRawText() == null || document.getRawText().trim().length() == 0) {
                        logger.info("File is empty: " + file);
                        logger.info("Writing empty file " + outputFile);
                        Files.createParentDirs(outputFile);
                        try (Writer w = IO.utf8Writer(IO.buffer(IO.write(outputFile.getAbsolutePath())))) {
                            w.write(document.toString());
                        }
                        continue fIter;
                    }
                } catch (IOException e) {
                    e.printStackTrace();
                    skipped++;
                    continue fIter;
                } catch (JDOMException e) {
                    e.printStackTrace();
                    skipped++;
                    continue fIter;
                }
            }

            return file.getAbsolutePath();
        }

        return null;
    }

    public void run(TintopSession session) {
File Project Line
eu/fbk/dkm/pikes/resources/ontonotes/senses/Sense.java pikes-resources 19
eu/fbk/dkm/pikes/resources/util/onsenses/Sense.java pikes-resources 24
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
    "commentary",
    "examples",
    "mappings",
    "sensemeta"
})
@XmlRootElement(name = "sense")
public class Sense {

    @XmlAttribute(name = "n", required = true)
    @XmlJavaTypeAdapter(NormalizedStringAdapter.class)
    protected String n;
    @XmlAttribute(name = "type")
    @XmlJavaTypeAdapter(NormalizedStringAdapter.class)
    protected String type;
    @XmlAttribute(name = "name", required = true)
    @XmlJavaTypeAdapter(NormalizedStringAdapter.class)
    protected String name;
    @XmlAttribute(name = "group", required = true)
    @XmlJavaTypeAdapter(NormalizedStringAdapter.class)
    protected String group;
    protected String commentary;
    @XmlElement(required = true)
    protected String examples;
    @XmlElement(required = true)
    protected Mappings mappings;
    @XmlElement(name = "SENSE_META", required = true)
    protected SENSEMETA sensemeta;

    /**
     * Recupera il valore della proprietà n.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getN() {
        return n;
    }

    /**
     * Imposta il valore della proprietà n.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setN(String value) {
        this.n = value;
    }

    /**
     * Recupera il valore della proprietà type.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getType() {
        return type;
    }

    /**
     * Imposta il valore della proprietà type.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setType(String value) {
        this.type = value;
    }

    /**
     * Recupera il valore della proprietà name.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getName() {
        return name;
    }

    /**
     * Imposta il valore della proprietà name.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setName(String value) {
        this.name = value;
    }

    /**
     * Recupera il valore della proprietà group.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getGroup() {
        return group;
    }

    /**
     * Imposta il valore della proprietà group.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setGroup(String value) {
        this.group = value;
    }

    /**
     * Recupera il valore della proprietà commentary.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getCommentary() {
        return commentary;
    }

    /**
     * Imposta il valore della proprietà commentary.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setCommentary(String value) {
        this.commentary = value;
    }

    /**
     * Recupera il valore della proprietà examples.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getExamples() {
        return examples;
    }

    /**
     * Imposta il valore della proprietà examples.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setExamples(String value) {
        this.examples = value;
    }

    /**
     * Recupera il valore della proprietà mappings.
     * 
     * @return
     *     possible object is
     *     {@link Mappings }
     *     
     */
    public Mappings getMappings() {
        return mappings;
    }

    /**
     * Imposta il valore della proprietà mappings.
     * 
     * @param value
     *     allowed object is
     *     {@link Mappings }
     *     
     */
    public void setMappings(Mappings value) {
        this.mappings = value;
    }

    /**
     * Recupera il valore della proprietà sensemeta.
     * 
     * @return
     *     possible object is
     *     {@link SENSEMETA }
     *     
     */
    public SENSEMETA getSENSEMETA() {
        return sensemeta;
    }

    /**
     * Imposta il valore della proprietà sensemeta.
     * 
     * @param value
     *     allowed object is
     *     {@link SENSEMETA }
     *     
     */
    public void setSENSEMETA(SENSEMETA value) {
        this.sensemeta = value;
    }

}
File Project Line
eu/fbk/dkm/pikes/rdf/Renderer.java pikes-rdf 480
eu/fbk/dkm/pikes/rdf/naf/NAFRenderer.java pikes-rdf 421
                final URI mentionURI = (URI) stmt.getObject();
                final String name = mentionURI.getLocalName();
                if (name.indexOf(';') < 0) {
                    final int index = name.indexOf(',');
                    final int start = Integer.parseInt(name.substring(5, index));
                    final int end = Integer.parseInt(name.substring(index + 1));
                    final int s = Arrays.binarySearch(offsets, start);
                    if (s >= 0) {
                        int e = s;
                        while (e < offsets.length && offsets[e] < end) {
                            ++e;
                        }
                        markables.add(new Markable(ImmutableList.copyOf(terms.subList(s, e)),
                                color));
                    }
                }
            }
        }

        return markables;
    }

    private static String select(final Map<Object, String> map,
            final Iterable<? extends Value> keys, final String defaultColor) {
        String color = null;
        for (final Value key : keys) {
            if (key instanceof URI) {
                final String mappedColor = map.get(key);
                if (mappedColor != null) {
                    if (color == null) {
                        color = mappedColor;
                    } else {
                        break;
                    }
                }
            }
        }
        return color != null ? color : defaultColor;
    }

    private static String escape(final String string) {
        return HtmlEscapers.htmlEscaper().escape(string);
    }

    @Nullable
    private static String shorten(@Nullable final URI uri) {
        if (uri == null) {
            return null;
        }
        final String prefix = Namespaces.DEFAULT.prefixFor(uri.getNamespace());
        if (prefix != null) {
            return prefix + ':' + uri.getLocalName();
        }
        return "&lt;../" + uri.getLocalName() + "&gt;";
    }
File Project Line
eu/fbk/dkm/pikes/resources/ontonotes/frames/Roleset.java pikes-resources 22
eu/fbk/dkm/pikes/resources/util/propbank/Roleset.java pikes-resources 20
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
    "noteOrRolesOrExample"
})
@XmlRootElement(name = "roleset")
public class Roleset {

    @XmlAttribute(name = "id", required = true)
    @XmlJavaTypeAdapter(CollapsedStringAdapter.class)
    @XmlID
    protected String id;
    @XmlAttribute(name = "name")
    @XmlJavaTypeAdapter(NormalizedStringAdapter.class)
    protected String name;
    @XmlAttribute(name = "vncls")
    @XmlJavaTypeAdapter(NormalizedStringAdapter.class)
    protected String vncls;
    @XmlAttribute(name = "framnet")
    @XmlJavaTypeAdapter(NormalizedStringAdapter.class)
    protected String framnet;
    @XmlAttribute(name = "source")
    @XmlJavaTypeAdapter(NormalizedStringAdapter.class)
    protected String source;
    @XmlElements({
        @XmlElement(name = "note", type = Note.class),
        @XmlElement(name = "roles", type = Roles.class),
        @XmlElement(name = "example", type = Example.class)
    })
    protected List<Object> noteOrRolesOrExample;

    /**
     * Recupera il valore della proprietà id.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getId() {
        return id;
    }

    /**
     * Imposta il valore della proprietà id.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setId(String value) {
        this.id = value;
    }

    /**
     * Recupera il valore della proprietà name.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getName() {
        return name;
    }

    /**
     * Imposta il valore della proprietà name.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setName(String value) {
        this.name = value;
    }

    /**
     * Recupera il valore della proprietà vncls.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getVncls() {
        return vncls;
    }

    /**
     * Imposta il valore della proprietà vncls.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setVncls(String value) {
        this.vncls = value;
    }

    /**
     * Recupera il valore della proprietà framnet.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getFramnet() {
        return framnet;
    }

    /**
     * Imposta il valore della proprietà framnet.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setFramnet(String value) {
        this.framnet = value;
    }

    /**
     * Recupera il valore della proprietà source.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getSource() {
        return source;
    }

    /**
     * Imposta il valore della proprietà source.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setSource(String value) {
        this.source = value;
    }

    /**
     * Gets the value of the noteOrRolesOrExample property.
     * 
     * <p>
     * This accessor method returns a reference to the live list,
     * not a snapshot. Therefore any modification you make to the
     * returned list will be present inside the JAXB object.
     * This is why there is not a <CODE>set</CODE> method for the noteOrRolesOrExample property.
     * 
     * <p>
     * For example, to add a new item, do as follows:
     * <pre>
     *    getNoteOrRolesOrExample().add(newItem);
     * </pre>
     * 
     * 
     * <p>
     * Objects of the following type(s) are allowed in the list
     * {@link Note }
     * {@link Roles }
     * {@link Example }
     * 
     * 
     */
    public List<Object> getNoteOrRolesOrExample() {
        if (noteOrRolesOrExample == null) {
            noteOrRolesOrExample = new ArrayList<Object>();
        }
        return this.noteOrRolesOrExample;
    }

}
File Project Line
eu/fbk/dkm/pikes/resources/trec/FBIS.java pikes-resources 50
eu/fbk/dkm/pikes/resources/trec/FR94.java pikes-resources 47
                    .withHeader("Extract FBIS documents from TREC dataset and save them in NAF format")
                    .withOption("i", "input", "Input folder", "FOLDER", CommandLine.Type.DIRECTORY_EXISTING, true,
                            false, true)
                    .withOption("o", "output", "Output folder", "FOLDER", CommandLine.Type.DIRECTORY, true, false, true)
                    .withOption("u", "url-template", "URL template (with %d for the ID)", "URL",
                            CommandLine.Type.STRING, true, false, false)
                    .withLogger(LoggerFactory.getLogger("eu.fbk")) //
                    .parse(args);

            File inputDir = cmd.getOptionValue("input", File.class);

            String urlTemplate = DEFAULT_URL;
            if (cmd.hasOption("url-template")) {
                urlTemplate = cmd.getOptionValue("url-template", String.class);
            }

            File outputDir = cmd.getOptionValue("output", File.class);
            if (!outputDir.exists()) {
                outputDir.mkdirs();
            }

            for (final File file : Files.fileTreeTraverser().preOrderTraversal(inputDir)) {
                if (!file.isFile()) {
                    continue;
                }
                if (file.getName().startsWith(".")) {
                    continue;
                }

                String outputTemplate = outputDir.getAbsolutePath() + File.separator + file.getName();
                File newFolder = new File(outputTemplate);
                newFolder.mkdirs();

                outputTemplate += File.separator + "NAF";
                saveFile(file, outputTemplate, urlTemplate);
            }
        } catch (Exception e) {
            CommandLine.fail(e);
        }
    }

    private static void saveFile(File inputFile, String outputFilePattern, String urlTemplate)
            throws IOException, SAXException, ParserConfigurationException {

        LOGGER.info("Input file: {}", inputFile);

        StringBuffer stringBuffer = new StringBuffer();
        stringBuffer.append("<?xml version=\"1.0\"?>\n"
                + "<!DOCTYPE tutorials [\n");
        stringBuffer.append("<!ENTITY amp \" \">\n");
File Project Line
eu/fbk/dkm/pikes/resources/trec/CR.java pikes-resources 45
eu/fbk/dkm/pikes/resources/trec/FBIS.java pikes-resources 50
eu/fbk/dkm/pikes/resources/trec/FR94.java pikes-resources 47
eu/fbk/dkm/pikes/resources/trec/LATIMES.java pikes-resources 49
                    .withHeader("Extract CR documents from TREC dataset and save them in NAF format")
                    .withOption("i", "input", "Input folder", "FOLDER", CommandLine.Type.DIRECTORY_EXISTING, true,
                            false, true)
                    .withOption("o", "output", "Output folder", "FOLDER", CommandLine.Type.DIRECTORY, true, false, true)
                    .withOption("u", "url-template", "URL template (with %d for the ID)", "URL",
                            CommandLine.Type.STRING, true, false, false)
                    .withLogger(LoggerFactory.getLogger("eu.fbk")) //
                    .parse(args);

            File inputDir = cmd.getOptionValue("input", File.class);

            String urlTemplate = DEFAULT_URL;
            if (cmd.hasOption("url-template")) {
                urlTemplate = cmd.getOptionValue("url-template", String.class);
            }

            File outputDir = cmd.getOptionValue("output", File.class);
            if (!outputDir.exists()) {
                outputDir.mkdirs();
            }

            for (final File file : Files.fileTreeTraverser().preOrderTraversal(inputDir)) {
                if (!file.isFile()) {
                    continue;
                }
                if (file.getName().startsWith(".")) {
                    continue;
                }

                String outputTemplate = outputDir.getAbsolutePath() + File.separator + file.getName();
                File newFolder = new File(outputTemplate);
                newFolder.mkdirs();

                outputTemplate += File.separator + "NAF";
                saveFile(file, outputTemplate, urlTemplate);
            }
        } catch (Exception e) {
            CommandLine.fail(e);
        }
    }

    private static void saveFile(File inputFile, String outputFilePattern, String urlTemplate)
            throws IOException, SAXException, ParserConfigurationException {

        LOGGER.info("Input file: {}", inputFile);

        StringBuffer stringBuffer = new StringBuffer();
        stringBuffer.append("<ROOT>\n");
File Project Line
eu/fbk/dkm/pikes/rdf/Renderer.java pikes-rdf 287
eu/fbk/dkm/pikes/rdf/naf/NAFRenderer.java pikes-rdf 220
    private void renderPropertiesHelper(final Appendable out, final Model model,
            final Resource node, final boolean emitID, final Set<Resource> seen,
            final Set<URI> excludedProperties) throws IOException {

        // Open properties table
        out.append("<table class=\"properties table table-condensed\">\n<tbody>\n");

        // Emit a raw for the node ID, if requested
        if (emitID) {
            out.append("<tr><td><a>ID</a>:</td><td>");
            renderObject(out, node, model);
            out.append("</td></tr>\n");
        }

        // Emit other properties
        for (final URI pred : this.valueComparator.sortedCopy(model.filter(node, null, null)
                .predicates())) {
            if (excludedProperties.contains(pred)) {
                continue;
            }
            out.append("<tr><td>");
            renderObject(out, pred, model);
            out.append(":</td><td>");
            final List<Resource> nested = Lists.newArrayList();
            String separator = "";
            for (final Value obj : this.valueComparator.sortedCopy(model.filter(node, pred, null)
                    .objects())) {
                if (obj instanceof Literal || model.filter((Resource) obj, null, null).isEmpty()) {
                    out.append(separator);
                    renderObject(out, obj, model);
                    separator = ", ";
                } else {
                    nested.add((Resource) obj);
                }
            }
            out.append("".equals(separator) ? "" : "<br/>");
            for (final Resource obj : nested) {
                out.append(separator);
                if (seen.add(obj)) {
                    renderPropertiesHelper(out, model, obj, true, seen, excludedProperties);
                } else {
                    renderObject(out, obj, model);
                }
            }
            out.append("</td></tr>\n");
        }

        // Close properties table
        out.append("</tbody>\n</table>\n");
File Project Line
eu/fbk/dkm/pikes/resources/ontonotes/frames/Inflection.java pikes-resources 19
eu/fbk/dkm/pikes/resources/util/propbank/Inflection.java pikes-resources 17
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "")
@XmlRootElement(name = "inflection")
public class Inflection {

    @XmlAttribute(name = "person")
    @XmlJavaTypeAdapter(CollapsedStringAdapter.class)
    protected String person;
    @XmlAttribute(name = "tense")
    @XmlJavaTypeAdapter(CollapsedStringAdapter.class)
    protected String tense;
    @XmlAttribute(name = "aspect")
    @XmlJavaTypeAdapter(CollapsedStringAdapter.class)
    protected String aspect;
    @XmlAttribute(name = "voice")
    @XmlJavaTypeAdapter(CollapsedStringAdapter.class)
    protected String voice;
    @XmlAttribute(name = "form")
    @XmlJavaTypeAdapter(CollapsedStringAdapter.class)
    protected String form;

    /**
     * Recupera il valore della proprietà person.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getPerson() {
        if (person == null) {
            return "ns";
        } else {
            return person;
        }
    }

    /**
     * Imposta il valore della proprietà person.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setPerson(String value) {
        this.person = value;
    }

    /**
     * Recupera il valore della proprietà tense.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getTense() {
        if (tense == null) {
            return "ns";
        } else {
            return tense;
        }
    }

    /**
     * Imposta il valore della proprietà tense.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setTense(String value) {
        this.tense = value;
    }

    /**
     * Recupera il valore della proprietà aspect.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getAspect() {
        if (aspect == null) {
            return "ns";
        } else {
            return aspect;
        }
    }

    /**
     * Imposta il valore della proprietà aspect.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setAspect(String value) {
        this.aspect = value;
    }

    /**
     * Recupera il valore della proprietà voice.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getVoice() {
        if (voice == null) {
            return "ns";
        } else {
            return voice;
        }
    }

    /**
     * Imposta il valore della proprietà voice.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setVoice(String value) {
        this.voice = value;
    }

    /**
     * Recupera il valore della proprietà form.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getForm() {
        if (form == null) {
            return "ns";
        } else {
            return form;
        }
    }

    /**
     * Imposta il valore della proprietà form.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setForm(String value) {
        this.form = value;
    }

}
File Project Line
ixa/kaflib/Opinion.java pikes-naflib 78
ixa/kaflib/Opinion.java pikes-naflib 195
            for (final ExternalRef externalRef : oh.getExternalRefs()) {
                this.externalReferences.add(new ExternalRef(externalRef));
            }
        }

        public boolean hasType() {
            return this.type != null;
        }

        public String getType() {
            return this.type;
        }

        public void setType(final String type) {
            this.type = type;
        }

        public List<Term> getTerms() {
            return this.span.getTargets();
        }

        public void addTerm(final Term term) {
            this.span.addTarget(term);
        }

        public void addTerm(final Term term, final boolean isHead) {
            this.span.addTarget(term, isHead);
        }

        public Span<Term> getSpan() {
            return this.span;
        }

        public void setSpan(final Span<Term> span) {
            this.span = span;
        }

        public ExternalRef getExternalRef(final String resource) {
            for (final ExternalRef ref : this.externalReferences) {
                if (ref.getResource().equalsIgnoreCase(resource)) {
                    return ref;
                }
            }
            return null;
        }

        public List<ExternalRef> getExternalRefs() {
            return this.externalReferences;
        }

        public void addExternalRef(final ExternalRef externalRef) {
            this.externalReferences.add(externalRef);
        }

        public void addExternalRefs(final List<ExternalRef> externalRefs) {
            this.externalReferences.addAll(externalRefs);
        }

        @Override
        public boolean equals(final Object object) {
            if (object == this) {
                return true;
            }
            if (!(object instanceof OpinionTarget)) {
                return false;
            }
            final OpinionHolder other = (OpinionHolder) object;
File Project Line
eu/fbk/dkm/pikes/rdf/Renderer.java pikes-rdf 554
eu/fbk/dkm/pikes/rdf/naf/NAFRenderer.java pikes-rdf 527
        @Nullable
        private Map<Object, String> colorMap;

        @Nullable
        private Map<Object, String> styleMap;

        @Nullable
        private Mustache template;

        private final Map<String, Object> templateParameters;

        Builder() {
            this.templateParameters = Maps.newHashMap();
        }

        public Builder withProperties(final Map<?, ?> properties, @Nullable final String prefix) {
            final String p = prefix == null ? "" : prefix.endsWith(".") ? prefix : prefix + ".";
            for (final Map.Entry<?, ?> entry : properties.entrySet()) {
                if (entry.getKey() != null && entry.getValue() != null
                        && entry.getKey().toString().startsWith(p)) {
                    final String name = entry.getKey().toString().substring(p.length());
                    final String value = Strings.emptyToNull(entry.getValue().toString());
                    if ("template".equals(name)) {
                        withTemplate(value);
                    } else if (name.startsWith("template.")) {
                        withTemplateParameter(name.substring("template.".length()), value);
                    }
                }
            }
            return this;
        }

        public Builder withNodeTypes(@Nullable final Iterable<? extends URI> nodeTypes) {
            this.nodeTypes = nodeTypes;
            return this;
        }

        public Builder withNodeNamespaces(@Nullable final Iterable<? extends String> nodeNamespaces) {
File Project Line
eu/fbk/dkm/pikes/resources/ontonotes/frames/Example.java pikes-resources 21
eu/fbk/dkm/pikes/resources/util/propbank/Example.java pikes-resources 19
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
    "inflectionOrNoteOrTextOrArgOrRel"
})
@XmlRootElement(name = "example")
public class Example {

    @XmlAttribute(name = "name")
    @XmlJavaTypeAdapter(NormalizedStringAdapter.class)
    protected String name;
    @XmlAttribute(name = "type")
    @XmlJavaTypeAdapter(NormalizedStringAdapter.class)
    protected String type;
    @XmlAttribute(name = "src")
    @XmlJavaTypeAdapter(NormalizedStringAdapter.class)
    protected String src;
    @XmlElements({
        @XmlElement(name = "inflection", type = Inflection.class),
        @XmlElement(name = "note", type = Note.class),
        @XmlElement(name = "text", type = Text.class),
        @XmlElement(name = "arg", type = Arg.class),
        @XmlElement(name = "rel", type = Rel.class)
    })
    protected List<Object> inflectionOrNoteOrTextOrArgOrRel;

    /**
     * Recupera il valore della proprietà name.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getName() {
        return name;
    }

    /**
     * Imposta il valore della proprietà name.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setName(String value) {
        this.name = value;
    }

    /**
     * Recupera il valore della proprietà type.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getType() {
        return type;
    }

    /**
     * Imposta il valore della proprietà type.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setType(String value) {
        this.type = value;
    }

    /**
     * Recupera il valore della proprietà src.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getSrc() {
        return src;
    }

    /**
     * Imposta il valore della proprietà src.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setSrc(String value) {
        this.src = value;
    }

    /**
     * Gets the value of the inflectionOrNoteOrTextOrArgOrRel property.
     * 
     * <p>
     * This accessor method returns a reference to the live list,
     * not a snapshot. Therefore any modification you make to the
     * returned list will be present inside the JAXB object.
     * This is why there is not a <CODE>set</CODE> method for the inflectionOrNoteOrTextOrArgOrRel property.
     * 
     * <p>
     * For example, to add a new item, do as follows:
     * <pre>
     *    getInflectionOrNoteOrTextOrArgOrRel().add(newItem);
     * </pre>
     * 
     * 
     * <p>
     * Objects of the following type(s) are allowed in the list
     * {@link Inflection }
     * {@link Note }
     * {@link Text }
     * {@link Arg }
     * {@link Rel }
     * 
     * 
     */
    public List<Object> getInflectionOrNoteOrTextOrArgOrRel() {
        if (inflectionOrNoteOrTextOrArgOrRel == null) {
            inflectionOrNoteOrTextOrArgOrRel = new ArrayList<Object>();
        }
        return this.inflectionOrNoteOrTextOrArgOrRel;
    }

}
File Project Line
eu/fbk/dkm/pikes/resources/tempeval/TMLtoNAF.java pikes-resources 26
eu/fbk/dkm/pikes/resources/treccani/TAOL.java pikes-resources 26
    public static void main(String[] args) {
        try {
            final CommandLine cmd = CommandLine
                    .parser()
                    .withName("./taol-extractor")
                    .withHeader("Convert file from Treccani XML to NAF")
                    .withOption("i", "input", "Input folder", "FOLDER",
                            CommandLine.Type.DIRECTORY_EXISTING, true, false, true)
                    .withOption("o", "output", "Output folder", "FOLDER",
                            CommandLine.Type.DIRECTORY, true, false, true)
                    .withOption("p", "prefix", String.format("Prefix (default %s)", DEFAULT_PREFIX), "PREFIX",
                            CommandLine.Type.STRING, true, false, false)
                    .withLogger(LoggerFactory.getLogger("eu.fbk")).parse(args);

            File inputFolder = cmd.getOptionValue("input", File.class);
            File outputFolder = cmd.getOptionValue("output", File.class);
            String prefix = cmd.getOptionValue("prefix", String.class, DEFAULT_PREFIX);

            if (!outputFolder.exists()) {
                outputFolder.mkdirs();
            }

            DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
            DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();

            int i = 0;
            for (final File file : Files.fileTreeTraverser().preOrderTraversal(inputFolder)) {
                if (!file.isFile()) {
                    continue;
                }
                if (file.getName().startsWith(".")) {
                    continue;
                }

                Document doc = dBuilder.parse(file);
                doc.getDocumentElement().normalize();
File Project Line
eu/fbk/dkm/pikes/resources/trec/CR.java pikes-resources 70
eu/fbk/dkm/pikes/resources/trec/FT.java pikes-resources 67
                if (file.getName().startsWith(".")) {
                    continue;
                }

                String outputTemplate = outputDir.getAbsolutePath() + File.separator + file.getName();
                File newFolder = new File(outputTemplate);
                newFolder.mkdirs();

                outputTemplate += File.separator + "NAF";
                saveFile(file, outputTemplate, urlTemplate);
            }
        } catch (Exception e) {
            CommandLine.fail(e);
        }
    }

    private static void saveFile(File inputFile, String outputFilePattern, String urlTemplate)
            throws IOException, SAXException, ParserConfigurationException {

        LOGGER.info("Input file: {}", inputFile);

        StringBuffer stringBuffer = new StringBuffer();
        stringBuffer.append("<ROOT>\n");
        stringBuffer.append(Files.toString(inputFile, Charsets.UTF_8));
        stringBuffer.append("\n</ROOT>\n");

        InputStream is = new ByteArrayInputStream(stringBuffer.toString().getBytes());
        DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
        DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
        Document doc = dBuilder.parse(is);

        doc.getDocumentElement().normalize();

        int i = 0;
        for (Element element : JOOX.$(doc).find("DOC")) {
            Element docnoElement = JOOX.$(element).find("DOCNO").get(0);
            Element dateElement = JOOX.$(element).find("DATE").get(0);
            Element headlineElement = JOOX.$(element).find("TTL").get(0);
File Project Line
eu/fbk/dkm/pikes/rdf/Renderer.java pikes-rdf 432
eu/fbk/dkm/pikes/rdf/naf/NAFRenderer.java pikes-rdf 373
    public void renderObject(final Appendable out, final Object object, @Nullable final Model model)
            throws IOException {

        if (object instanceof URI) {
            final URI uri = (URI) object;
            out.append("<a>").append(shorten(uri)).append("</a>");

        } else if (object instanceof Literal) {
            final Literal literal = (Literal) object;
            out.append("<span");
            if (literal.getLanguage() != null) {
                out.append(" title=\"@").append(literal.getLanguage()).append("\"");
            } else if (literal.getDatatype() != null) {
                out.append(" title=\"").append(shorten(literal.getDatatype())).append("\"");
            }
            out.append(">").append(literal.stringValue()).append("</span>");

        } else if (object instanceof BNode) {
            final BNode bnode = (BNode) object;
            out.append("_:").append(bnode.getID());

        } else if (object instanceof Iterable<?>) {
            String separator = "";
            for (final Object element : (Iterable<?>) object) {
                out.append(separator);
                renderObject(out, element, model);
                separator = "<br/>";
            }

        } else if (object != null) {
            out.append(object.toString());
        }
File Project Line
eu/fbk/dkm/pikes/resources/trec/FT.java pikes-resources 67
eu/fbk/dkm/pikes/resources/trec/LATIMES.java pikes-resources 74
                if (!file.isFile()) {
                    continue;
                }

                String outputTemplate = outputDir.getAbsolutePath() + File.separator + file.getName();
                File newFolder = new File(outputTemplate);
                newFolder.mkdirs();

                outputTemplate += File.separator + "NAF";
                saveFile(file, outputTemplate, urlTemplate);
            }
        } catch (Exception e) {
            CommandLine.fail(e);
        }
    }

    private static void saveFile(File inputFile, String outputFilePattern, String urlTemplate)
            throws IOException, SAXException, ParserConfigurationException {

        LOGGER.info("Input file: {}", inputFile);

        StringBuffer stringBuffer = new StringBuffer();
        stringBuffer.append("<ROOT>\n");
        stringBuffer.append(Files.toString(inputFile, Charsets.UTF_8));
        stringBuffer.append("\n</ROOT>\n");

        InputStream is = new ByteArrayInputStream(stringBuffer.toString().getBytes());
        DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
        DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
        Document doc = dBuilder.parse(is);

        doc.getDocumentElement().normalize();

        int i = 0;
        for (Element element : JOOX.$(doc).find("DOC")) {
            Element docnoElement = JOOX.$(element).find("DOCNO").get(0);
            Element dateElement = JOOX.$(element).find("DATE").get(0);
            Element headlineElement = JOOX.$(element).find("HEADLINE").get(0);
File Project Line
eu/fbk/dkm/pikes/resources/ontonotes/frames/Role.java pikes-resources 21
eu/fbk/dkm/pikes/resources/util/propbank/Role.java pikes-resources 19
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
    "vnrole"
})
@XmlRootElement(name = "role")
public class Role {

    @XmlAttribute(name = "n", required = true)
    @XmlJavaTypeAdapter(NormalizedStringAdapter.class)
    protected String n;
    @XmlAttribute(name = "f")
    @XmlJavaTypeAdapter(NormalizedStringAdapter.class)
    protected String f;
    @XmlAttribute(name = "descr", required = true)
    @XmlJavaTypeAdapter(NormalizedStringAdapter.class)
    protected String descr;
    @XmlAttribute(name = "source")
    @XmlJavaTypeAdapter(NormalizedStringAdapter.class)
    protected String source;
    protected List<Vnrole> vnrole;

    /**
     * Recupera il valore della proprietà n.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getN() {
        return n;
    }

    /**
     * Imposta il valore della proprietà n.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setN(String value) {
        this.n = value;
    }

    /**
     * Recupera il valore della proprietà f.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getF() {
        return f;
    }

    /**
     * Imposta il valore della proprietà f.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setF(String value) {
        this.f = value;
    }

    /**
     * Recupera il valore della proprietà descr.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getDescr() {
        return descr;
    }

    /**
     * Imposta il valore della proprietà descr.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setDescr(String value) {
        this.descr = value;
    }

    /**
     * Recupera il valore della proprietà source.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getSource() {
        return source;
    }

    /**
     * Imposta il valore della proprietà source.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setSource(String value) {
        this.source = value;
    }

    /**
     * Gets the value of the vnrole property.
     * 
     * <p>
     * This accessor method returns a reference to the live list,
     * not a snapshot. Therefore any modification you make to the
     * returned list will be present inside the JAXB object.
     * This is why there is not a <CODE>set</CODE> method for the vnrole property.
     * 
     * <p>
     * For example, to add a new item, do as follows:
     * <pre>
     *    getVnrole().add(newItem);
     * </pre>
     * 
     * 
     * <p>
     * Objects of the following type(s) are allowed in the list
     * {@link Vnrole }
     * 
     * 
     */
    public List<Vnrole> getVnrole() {
        if (vnrole == null) {
            vnrole = new ArrayList<Vnrole>();
        }
        return this.vnrole;
    }

}
File Project Line
eu/fbk/dkm/pikes/resources/ontonotes/senses/Mappings.java pikes-resources 19
eu/fbk/dkm/pikes/resources/util/onsenses/Mappings.java pikes-resources 23
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
    "grSense",
    "wn",
    "omega",
    "pb",
    "vn",
    "fn"
})
@XmlRootElement(name = "mappings")
public class Mappings {

    @XmlElement(name = "gr_sense")
    protected String grSense;
    @XmlElement(required = true)
    protected List<Wn> wn;
    @XmlElement(required = true)
    protected String omega;
    @XmlElement(required = true)
    protected String pb;
    protected String vn;
    protected String fn;

    /**
     * Recupera il valore della proprietà grSense.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getGrSense() {
        return grSense;
    }

    /**
     * Imposta il valore della proprietà grSense.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setGrSense(String value) {
        this.grSense = value;
    }

    /**
     * Gets the value of the wn property.
     * 
     * <p>
     * This accessor method returns a reference to the live list,
     * not a snapshot. Therefore any modification you make to the
     * returned list will be present inside the JAXB object.
     * This is why there is not a <CODE>set</CODE> method for the wn property.
     * 
     * <p>
     * For example, to add a new item, do as follows:
     * <pre>
     *    getWn().add(newItem);
     * </pre>
     * 
     * 
     * <p>
     * Objects of the following type(s) are allowed in the list
     * {@link Wn }
     * 
     * 
     */
    public List<Wn> getWn() {
        if (wn == null) {
            wn = new ArrayList<Wn>();
        }
        return this.wn;
    }

    /**
     * Recupera il valore della proprietà omega.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getOmega() {
        return omega;
    }

    /**
     * Imposta il valore della proprietà omega.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setOmega(String value) {
        this.omega = value;
    }

    /**
     * Recupera il valore della proprietà pb.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getPb() {
        return pb;
    }

    /**
     * Imposta il valore della proprietà pb.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setPb(String value) {
        this.pb = value;
    }

    /**
     * Recupera il valore della proprietà vn.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getVn() {
        return vn;
    }

    /**
     * Imposta il valore della proprietà vn.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setVn(String value) {
        this.vn = value;
    }

    /**
     * Recupera il valore della proprietà fn.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getFn() {
        return fn;
    }

    /**
     * Imposta il valore della proprietà fn.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setFn(String value) {
        this.fn = value;
    }

}
File Project Line
eu/fbk/dkm/pikes/resources/mpqa/JohanssonAnnotator.java pikes-resources 203
eu/fbk/dkm/pikes/resources/mpqa/JohanssonAnnotator.java pikes-resources 289
					opinion.setLabel("gold-eu.fbk.dkm.pikes.resources.mpqa-subjective");

					Opinion.OpinionExpression opinionExpression = opinion.createOpinionExpression(expressionSpan);
					DataElementNode expressionNode = (DataElementNode) entity.data.children.get(0);
					opinionExpression.setPolarity(expressionNode.attributes.get("pol"));
					opinionExpression.setStrength(expressionNode.attributes.get("int"));

					String holderString = expressionNode.attributes.get("ns");
					if (holderString != null) {
						String[] parts = holderString.split(",");

						holders:
						for (int i = parts.length - 1; i >= 0; i--) {
							String agentID = parts[i].replaceAll("[^0-9]", "");

							if (hiddenAgents.containsKey(agentID)) {
								opinionExpression.setSentimentProductFeature(hiddenAgents.get(agentID));
								break holders;
							}

							Set<Span<Term>> spans = agents.get(agentID);
							for (Span<Term> termSpan : spans) {
								Integer agentSentence = sentenceForSpan(termSpan);
								if (agentSentence == null) {
									continue;
								}
								if (!agentSentence.equals(sentence)) {
									continue;
								}
								if (termSpan == null) {
									continue;
								}
								holderSpan = termSpan;
								break holders;
							}
						}
					}

					if (holderSpan.size() > 0) {
						Opinion.OpinionHolder opinionHolder = opinion.createOpinionHolder(holderSpan);
					}
File Project Line
eu/fbk/dkm/pikes/resources/trec/Queries.java pikes-resources 70
eu/fbk/dkm/pikes/resources/trec/QueriesTSV.java pikes-resources 58
            String content = FileUtils.readFileToString(inputfile, Charsets.UTF_8);

            StringBuffer newContent = new StringBuffer();
            newContent.append("<root>\n");
            newContent.append(content
                    .replaceAll("<title>", "</num>\n<title>")
                    .replaceAll("<desc>", "</title>\n<desc>")
                    .replaceAll("<narr>", "</desc>\n<narr>")
                    .replaceAll("</top>", "</narr>\n</top>")
                    .replaceAll("R&D", "R&amp;D")
            );
            newContent.append("</root>\n");

            Document doc = dBuilder.parse(new ByteArrayInputStream(newContent.toString().getBytes(Charsets.UTF_8)));
            for (Element element : JOOX.$(doc).find("top")) {
                Element numElement = JOOX.$(element).find("num").get(0);
                Element titleElement = JOOX.$(element).find("title").get(0);
                Element descElement = JOOX.$(element).find("desc").get(0);

                String number = "q" + numElement.getTextContent().trim().substring(7).trim();
                //String title = titleElement.getTextContent().trim().replaceAll("\\s+", " ");
                String title = titleElement.getTextContent().trim().replaceAll("\\s+", " ");
                String desc = descElement.getTextContent().trim().substring(12).trim().replaceAll("\\s+", " ");
File Project Line
eu/fbk/dkm/pikes/resources/mpqa/CorpusPreprocessor.java pikes-resources 402
eu/fbk/dkm/pikes/resources/mpqa/CorpusPreprocessor.java pikes-resources 446
			fields.put("type", "expressive");
			String id = thisRecord.getValue("id");
			if (id != null) {
				fields.put("id", id);
			}

			final Span expressionSpan = thisRecord.getSpan().align(text);
			fields.put("expression", expressionSpan.toString());

			// Sentence
			Span sentenceSpan = getSentenceSpan(thisRecord, sentences, fields, text, documentURI);
			if (sentenceSpan == null) {
				continue;
			}

			for (final String name : DSA_FIELDS) {
				String value = thisRecord.getValue(name);
				if (value != null) {
					fields.put("dsa-" + name, value);
				}
			}

			// Holder
			String sources = thisRecord.getValue("nested-source");
			addSources(sources, agentRecords, lastRecords, sentenceSpan, fields, documentURI, text);

			// Emit TSV string
			tsvWriter.append(getTsvString(documentURI, fields));

			// Print debug
			LOGGER.debug(fields.get("type").toString());
			LOGGER.debug(fields.toString());
			for (String expression : fields.get("expression")) {
				LOGGER.debug(expression);
				Span span = new Span(expression);
				LOGGER.debug(span.apply(text));
			}
			System.out.println();
		}
File Project Line
eu/fbk/dkm/pikes/rdf/Renderer.java pikes-rdf 112
eu/fbk/dkm/pikes/rdf/naf/NAFRenderer.java pikes-rdf 477
    private static final Mustache loadTemplate(final Object spec) {
        Preconditions.checkNotNull(spec);
        try {
            if (spec instanceof Mustache) {
                return (Mustache) spec;
            }
            final DefaultMustacheFactory factory = new DefaultMustacheFactory();
            // factory.setExecutorService(Environment.getPool()); // BROKEN
            URL url = spec instanceof URL ? (URL) spec : null;
            if (url == null) {
                try {
                    url = Renderer.class.getResource(spec.toString());
                } catch (final Throwable ex) {
                    // ignore
                }
            }
            if (url == null) {
                final File file = spec instanceof File ? (File) spec : new File(spec.toString());
                if (file.exists()) {
                    url = file.toURI().toURL();
                }
            }
            if (url != null) {
                return factory.compile(new InputStreamReader(url.openStream(), Charsets.UTF_8),
                        url.toString());
            } else {
                return factory.compile(new StringReader(spec.toString()),
                        Hash.murmur3(spec.toString()).toString());
            }
        } catch (final IOException ex) {
            throw new IllegalArgumentException("Could not create Mustache template for " + spec);
        }
    }
File Project Line
ixa/kaflib/Opinion.java pikes-naflib 93
ixa/kaflib/Opinion.java pikes-naflib 210
ixa/kaflib/Opinion.java pikes-naflib 397
        }

        public List<Term> getTerms() {
            return this.span.getTargets();
        }

        public void addTerm(final Term term) {
            this.span.addTarget(term);
        }

        public void addTerm(final Term term, final boolean isHead) {
            this.span.addTarget(term, isHead);
        }

        public Span<Term> getSpan() {
            return this.span;
        }

        public void setSpan(final Span<Term> span) {
            this.span = span;
        }

        public ExternalRef getExternalRef(final String resource) {
            for (final ExternalRef ref : this.externalReferences) {
                if (ref.getResource().equalsIgnoreCase(resource)) {
                    return ref;
                }
            }
            return null;
        }

        public List<ExternalRef> getExternalRefs() {
            return this.externalReferences;
        }

        public void addExternalRef(final ExternalRef externalRef) {
            this.externalReferences.add(externalRef);
        }

        public void addExternalRefs(final List<ExternalRef> externalRefs) {
            this.externalReferences.addAll(externalRefs);
        }

        @Override
        public boolean equals(final Object object) {
            if (object == this) {
                return true;
            }
            if (!(object instanceof OpinionTarget)) {
File Project Line
ixa/kaflib/Entity.java pikes-naflib 141
ixa/kaflib/Feature.java pikes-naflib 112
    }

    public List<ExternalRef> getExternalRefs() {
	return externalReferences;
    }

    public void addExternalRef(ExternalRef externalRef) {
	externalReferences.add(externalRef);
    }

    public void addExternalRefs(List<ExternalRef> externalRefs) {
	externalReferences.addAll(externalRefs);
    }

    public String getSpanStr(Span<Term> span) {
	String str = "";
	for (Term term : span.getTargets()) {
	    if (!str.isEmpty()) {
		str += " ";
	    }
	    str += term.getStr();
	}
	return str;
    }

    public String getStr() {
	return getSpanStr(this.getSpans().get(0));
    }

    /** Deprecated */
    public List<List<Term>> getReferences() {
	List<List<Term>> list = new ArrayList<List<Term>>();
	for (Span<Term> span : this.references) {
	    list.add(span.getTargets());
	}
	return list;
    }

    /** Deprecated */
    public void addReference(List<Term> span) {
	this.references.add(KAFDocument.<Term>list2Span(span));
    }
}
File Project Line
eu/fbk/dkm/pikes/resources/ecb/ECBevaluator.java pikes-resources 205
eu/fbk/dkm/pikes/resources/ecb/ECBevaluator2.java pikes-resources 123
            baselineWriter.close();

//            Set<Set> goldClusters = new HashSet<>();
//            for (String key : goldTmpClusters.keySet()) {
//                Set<String> cluster = goldTmpClusters.get(key);
//                if (cluster.size() > 1 || !removeAloneClusters) {
//                    goldClusters.add(cluster);
//                }
//            }

//            LOGGER.info("Gold clusters: {}", goldClusters.size());

            in = new FileReader(inputCsv);
            records = CSVFormat.EXCEL.withHeader().parse(in);

            // Size must be always 4!
            int clusterID = 0;
            HashMap<String, Integer> clusterIndexes = new HashMap<>();
            HashMultimap<Integer, String> tmpClusters = HashMultimap.create();
            for (CSVRecord record : records) {
                Matcher matcher;

                String id1 = null;
                String id2 = null;
                matcher = tokenPattern.matcher(record.get(1));
                if (matcher.find()) {
                    id1 = matcher.group(1) + "_" + matcher.group(2) + "_" + matcher.group(3);
                }
                matcher = tokenPattern.matcher(record.get(3));
                if (matcher.find()) {
                    id2 = matcher.group(1) + "_" + matcher.group(2) + "_" + matcher.group(3);
                }

                Integer index1 = clusterIndexes.get(id1);
                Integer index2 = clusterIndexes.get(id2);

                if (index1 == null && index2 == null) {
                    clusterID++;
                    if (!checkGold || okEvents.contains(id2)) {
File Project Line
eu/fbk/shell/mdfsa/data/structures/DomainGraph.java pikes-raid 425
eu/fbk/shell/mdfsa/data/structures/DomainGraph.java pikes-raid 506
    double deadzone = this.deadzone;
    
    int judged = 0;
    double precision = 0.0;
    double recall = 0.0;
    
    for(DatasetInstance di: instances) {
      ArrayList<String> features = di.getFeatures();
      int testPolarity = di.getPolarity();
      
      double inferredPolarity = 0.0;
      double a = 0.0;
      double b = 0.0;
      double c = 0.0;
      double d = 0.0;
      int mappedFeatures = 0;
      for(String currentFeature: features) {
        //Long featureId = labels.get(currentFeature);
        ArrayList<Long> featureIds = this.graph.getFeatureIds(currentFeature);
        if(featureIds != null) {
          for(Long featureId: featureIds) {
            mappedFeatures++;
            FuzzyMembership fm = this.polarities.get(featureId);
            if(fm != null) {
              inferredPolarity += fm.getCentroid();
              a += fm.getA();
              b += fm.getB();
              c += fm.getC();
              d += fm.getD();
            }
          }
        }
      }
      a /= (double) mappedFeatures;
      b /= (double) mappedFeatures;
      c /= (double) mappedFeatures;
      d /= (double) mappedFeatures;
      //inferredPolarity /= (double) mappedFeatures;
      inferredPolarity = (b + c) / 2.0;
File Project Line
eu/fbk/dkm/pikes/rdf/RDFGenerator.java pikes-rdf 1978
eu/fbk/dkm/pikes/rdf/util/ProcessorASNorm.java pikes-rdf 63
        }

        private URI hash(final Resource subject, final URI predicate, final Value object) {
            final List<String> list = Lists.newArrayList();
            for (final Value value : new Value[] { subject, predicate, object }) {
                if (value instanceof URI) {
                    list.add("\u0001");
                    list.add(value.stringValue());
                } else if (value instanceof BNode) {
                    list.add("\u0002");
                    list.add(((BNode) value).getID());
                } else if (value instanceof Literal) {
                    final Literal l = (Literal) value;
                    list.add("\u0003");
                    list.add(l.getLabel());
                    if (l.getDatatype() != null) {
                        list.add(l.getDatatype().stringValue());
                    } else if (l.getLanguage() != null) {
                        list.add(l.getLanguage());
                    }
                }
            }
            final String id = Hash.murmur3(list.toArray(new String[list.size()])).toString();
File Project Line
eu/fbk/dkm/pikes/resources/ontonotes/senses/Inventory.java pikes-resources 21
eu/fbk/dkm/pikes/resources/util/onsenses/Inventory.java pikes-resources 26
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
    "commentary",
    "sense",
    "wordmeta"
})
@XmlRootElement(name = "inventory")
public class Inventory {

    @XmlAttribute(name = "lemma", required = true)
    @XmlJavaTypeAdapter(NormalizedStringAdapter.class)
    protected String lemma;
    protected String commentary;
    @XmlElement(required = true)
    protected List<Sense> sense;
    @XmlElement(name = "WORD_META", required = true)
    protected WORDMETA wordmeta;

    /**
     * Recupera il valore della proprietà lemma.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getLemma() {
        return lemma;
    }

    /**
     * Imposta il valore della proprietà lemma.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setLemma(String value) {
        this.lemma = value;
    }

    /**
     * Recupera il valore della proprietà commentary.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getCommentary() {
        return commentary;
    }

    /**
     * Imposta il valore della proprietà commentary.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setCommentary(String value) {
        this.commentary = value;
    }

    /**
     * Gets the value of the sense property.
     * 
     * <p>
     * This accessor method returns a reference to the live list,
     * not a snapshot. Therefore any modification you make to the
     * returned list will be present inside the JAXB object.
     * This is why there is not a <CODE>set</CODE> method for the sense property.
     * 
     * <p>
     * For example, to add a new item, do as follows:
     * <pre>
     *    getSense().add(newItem);
     * </pre>
     * 
     * 
     * <p>
     * Objects of the following type(s) are allowed in the list
     * {@link Sense }
     * 
     * 
     */
    public List<Sense> getSense() {
        if (sense == null) {
            sense = new ArrayList<Sense>();
        }
        return this.sense;
    }

    /**
     * Recupera il valore della proprietà wordmeta.
     * 
     * @return
     *     possible object is
     *     {@link WORDMETA }
     *     
     */
    public WORDMETA getWORDMETA() {
        return wordmeta;
    }

    /**
     * Imposta il valore della proprietà wordmeta.
     * 
     * @param value
     *     allowed object is
     *     {@link WORDMETA }
     *     
     */
    public void setWORDMETA(WORDMETA value) {
        this.wordmeta = value;
    }

}
File Project Line
eu/fbk/dkm/pikes/resources/trec/CR.java pikes-resources 45
eu/fbk/dkm/pikes/resources/trec/FBIS.java pikes-resources 50
eu/fbk/dkm/pikes/resources/trec/FR94.java pikes-resources 47
eu/fbk/dkm/pikes/resources/trec/FT.java pikes-resources 45
eu/fbk/dkm/pikes/resources/trec/LATIMES.java pikes-resources 49
                    .withHeader("Extract CR documents from TREC dataset and save them in NAF format")
                    .withOption("i", "input", "Input folder", "FOLDER", CommandLine.Type.DIRECTORY_EXISTING, true,
                            false, true)
                    .withOption("o", "output", "Output folder", "FOLDER", CommandLine.Type.DIRECTORY, true, false, true)
                    .withOption("u", "url-template", "URL template (with %d for the ID)", "URL",
                            CommandLine.Type.STRING, true, false, false)
                    .withLogger(LoggerFactory.getLogger("eu.fbk")) //
                    .parse(args);

            File inputDir = cmd.getOptionValue("input", File.class);

            String urlTemplate = DEFAULT_URL;
            if (cmd.hasOption("url-template")) {
                urlTemplate = cmd.getOptionValue("url-template", String.class);
            }

            File outputDir = cmd.getOptionValue("output", File.class);
            if (!outputDir.exists()) {
                outputDir.mkdirs();
            }

            for (final File file : Files.fileTreeTraverser().preOrderTraversal(inputDir)) {
                if (!file.isFile()) {
                    continue;
                }
File Project Line
eu/fbk/dkm/pikes/resources/mpqa/JohanssonAnnotator.java pikes-resources 294
eu/fbk/dkm/pikes/resources/mpqa/JohanssonAnnotator.java pikes-resources 353
					opinionExpression.setStrength(expressionNode.attributes.get("int"));

					String holderString = expressionNode.attributes.get("ns");
					if (holderString != null) {
						String[] parts = holderString.split(",");

						holders:
						for (int i = parts.length - 1; i >= 0; i--) {
							String agentID = parts[i].replaceAll("[^0-9]", "");

							if (hiddenAgents.containsKey(agentID)) {
								opinionExpression.setSentimentProductFeature(hiddenAgents.get(agentID));
								break holders;
							}

							Set<Span<Term>> spans = agents.get(agentID);
							for (Span<Term> termSpan : spans) {
								Integer agentSentence = sentenceForSpan(termSpan);
								if (agentSentence == null) {
									continue;
								}
								if (!agentSentence.equals(sentence)) {
									continue;
								}
								if (termSpan == null) {
									continue;
								}
								holderSpan = termSpan;
								break holders;
							}
						}
					}

					if (holderSpan.size() > 0) {
						Opinion.OpinionHolder opinionHolder = opinion.createOpinionHolder(holderSpan);
					}
				}
File Project Line
eu/fbk/dkm/pikes/resources/mpqa/JohanssonAnnotator.java pikes-resources 208
eu/fbk/dkm/pikes/resources/mpqa/JohanssonAnnotator.java pikes-resources 353
					opinionExpression.setStrength(expressionNode.attributes.get("int"));

					String holderString = expressionNode.attributes.get("ns");
					if (holderString != null) {
						String[] parts = holderString.split(",");

						holders:
						for (int i = parts.length - 1; i >= 0; i--) {
							String agentID = parts[i].replaceAll("[^0-9]", "");

							if (hiddenAgents.containsKey(agentID)) {
								opinionExpression.setSentimentProductFeature(hiddenAgents.get(agentID));
								break holders;
							}

							Set<Span<Term>> spans = agents.get(agentID);
							for (Span<Term> termSpan : spans) {
								Integer agentSentence = sentenceForSpan(termSpan);
								if (agentSentence == null) {
									continue;
								}
								if (!agentSentence.equals(sentence)) {
									continue;
								}
								if (termSpan == null) {
									continue;
								}
								holderSpan = termSpan;
								break holders;
							}
						}
					}

					if (holderSpan.size() > 0) {
						Opinion.OpinionHolder opinionHolder = opinion.createOpinionHolder(holderSpan);
					}
File Project Line
eu/fbk/shell/mdfsa/data/structures/DomainGraph.java pikes-raid 873
eu/fbk/shell/mdfsa/data/structures/DomainGraph.java pikes-raid 901
          new FileInputStream(modelPath + currentDataset + "." + type + ".mdfsa"));
      SerializableDomainGraph sdg = (SerializableDomainGraph) objectInputStream.readObject();
      this.prp = sdg.getPrp();
      this.graph = sdg.getGraph();
      this.polarities = sdg.getPolarities();
      this.conceptsConvergenceIterationsValues = sdg.getConceptsConvergenceIterationsValues();
      this.startPolarities = sdg.getStartPolarities();
      this.tempInDomainStartPolarities = sdg.getTempInDomainStartPolarities();
      this.tempOutDomainStartPolarities = sdg.getTempOutDomainStartPolarities();
      this.currentPolarities = sdg.getCurrentPolarities();
      this.tokensCounter = sdg.getTokensCounter();
      this.inDomainTokensCounter = sdg.getInDomainTokensCounter();
      this.outDomainTokensCounter = sdg.getOutDomainTokensCounter();
      this.currentGraphConvergenceValue = sdg.getCurrentGraphConvergenceValue();
      this.currentAveragePolarity = sdg.getCurrentAveragePolarity();
      this.iteration = sdg.getIteration();
      this.propagationRate = sdg.getPropagationRate();
      this.convergenceLimit = sdg.getConvergenceLimit();
      this.deadzone = sdg.getDeadzone();
      this.annealingRate = sdg.getAnnealingRate();
File Project Line
eu/fbk/dkm/pikes/resources/ecb/ECBPlusEvaluator.java pikes-resources 279
eu/fbk/dkm/pikes/resources/ecb/ECBPlusEvaluatorLemma.java pikes-resources 279
eu/fbk/dkm/pikes/resources/ecb/ECBevaluator.java pikes-resources 223
            HashMultimap<Integer, String> theClusters = HashMultimap.create();
            for (CSVRecord record : records) {
                Matcher matcher;

                String id1 = null;
                String id2 = null;
                matcher = tokenPattern.matcher(record.get(1));
                if (matcher.find()) {
                    id1 = matcher.group(1) + "_" + matcher.group(2) + "_" + matcher.group(3);
                }
                matcher = tokenPattern.matcher(record.get(3));
                if (matcher.find()) {
                    id2 = matcher.group(1) + "_" + matcher.group(2) + "_" + matcher.group(3);
                }

//                System.out.println(id1);
//                System.out.println(id2);

                Integer index1 = clusterIndexes.get(id1);
                Integer index2 = clusterIndexes.get(id2);

//                System.out.println(index1);
//                System.out.println(index2);

                if (index1 == null && index2 == null) {
                    clusterID++;
                    if (!checkGold || okEvents.contains(id2)) {
                        if (id2 != null) {
File Project Line
eu/fbk/dkm/pikes/raid/pipeline/PipelineTrainer.java pikes-raid 72
eu/fbk/dkm/pikes/raid/sbrs/SBRSTrainer.java pikes-raid 47
        this.jointSpan = Boolean.parseBoolean(properties.getProperty("joint", "false"));
        this.holderLinkTrainer = hasHolder ? LinkLabeller.train("NN", "PRP", "JJP", "DTP", "WP")
                : null;
        this.targetLinkTrainer = hasTarget ? LinkLabeller.train("NN", "PRP", "JJP", "DTP", "WP",
                "VB") : null;
        if (this.jointSpan) {
            final SpanLabeller.Trainer t = hasHolder || hasTarget ? SpanLabeller.train() : null;
            this.holderSpanTrainer = t;
            this.targetSpanTrainer = t;
        } else {
            this.holderSpanTrainer = hasHolder ? SpanLabeller.train() : null;
            this.targetSpanTrainer = hasTarget ? SpanLabeller.train() : null;
        }
        this.filter = NAFFilter.builder(false).withTermSenseCompletion(true)
                .withEntityAddition(true).withEntityRemoveOverlaps(true)
                .withEntitySpanFixing(true).withSRLPredicateAddition(true)
                .withSRLRemoveWrongRefs(true).withSRLSelfArgFixing(true).build();
    }

    @Override
    protected void doFilter(final KAFDocument document) {
File Project Line
eu/fbk/dkm/pikes/resources/ecb/ECBparser.java pikes-resources 32
eu/fbk/dkm/pikes/resources/tempeval/TMLtoNAF.java pikes-resources 31
eu/fbk/dkm/pikes/resources/treccani/TAOL.java pikes-resources 31
                    .withHeader("Convert file from ecb annotated txt to NAF")
                    .withOption("i", "input", "Input folder", "FOLDER",
                            CommandLine.Type.DIRECTORY_EXISTING, true, false, true)
                    .withOption("o", "output", "Output folder", "FOLDER",
                            CommandLine.Type.DIRECTORY, true, false, true)
                    .withOption("p", "prefix", String.format("Prefix (default %s)", DEFAULT_PREFIX), "PREFIX",
                            CommandLine.Type.STRING, true, false, false)
                    .withLogger(LoggerFactory.getLogger("eu.fbk")).parse(args);

            File inputFolder = cmd.getOptionValue("input", File.class);
            File outputFolder = cmd.getOptionValue("output", File.class);
            String prefix = cmd.getOptionValue("prefix", String.class, DEFAULT_PREFIX);

            if (!outputFolder.exists()) {
                outputFolder.mkdirs();
            }

            DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
            DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
File Project Line
eu/fbk/dkm/pikes/resources/trec/Queries.java pikes-resources 48
eu/fbk/dkm/pikes/resources/wt10g/ConvertDocs.java pikes-resources 71
                    .withHeader("Extract Queries documents from TREC dataset and save them in NAF format")
                    .withOption("i", "input", "Input file", "FILE", CommandLine.Type.FILE, true,
                            false, true)
                    .withOption("o", "output", "Output folder", "FOLDER", CommandLine.Type.DIRECTORY, true, false, true)
                    .withOption("u", "url-template", "URL template (with %d for the ID)", "URL",
                            CommandLine.Type.STRING, true, false, false)
                    .withLogger(LoggerFactory.getLogger("eu.fbk")) //
                    .parse(args);

            File inputfile = cmd.getOptionValue("input", File.class);
            File outputFolder = cmd.getOptionValue("output", File.class);

            String urlTemplate = DEFAULT_URL;
            if (cmd.hasOption("url-template")) {
                urlTemplate = cmd.getOptionValue("url-template", String.class);
            }

            DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
            DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();

            LOGGER.info(inputfile.getName());

            String content = FileUtils.readFileToString(inputfile, Charsets.UTF_8);
File Project Line
eu/fbk/dkm/pikes/resources/ontonotes/frames/ObjectFactory.java pikes-resources 28
eu/fbk/dkm/pikes/resources/util/propbank/ObjectFactory.java pikes-resources 25
@XmlRegistry
public class ObjectFactory {


    /**
     * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: eu.fbk.dkm.pikes.resources.ontonotes.frames
     * 
     */
    public ObjectFactory() {
    }

    /**
     * Create an instance of {@link Note }
     * 
     */
    public Note createNote() {
        return new Note();
    }

    /**
     * Create an instance of {@link Predicate }
     * 
     */
    public Predicate createPredicate() {
        return new Predicate();
    }

    /**
     * Create an instance of {@link Roleset }
     * 
     */
    public Roleset createRoleset() {
        return new Roleset();
    }

    /**
     * Create an instance of {@link Vnrole }
     * 
     */
    public Vnrole createVnrole() {
        return new Vnrole();
    }

    /**
     * Create an instance of {@link Role }
     * 
     */
    public Role createRole() {
        return new Role();
    }

    /**
     * Create an instance of {@link Frameset }
     * 
     */
    public Frameset createFrameset() {
        return new Frameset();
    }

    /**
     * Create an instance of {@link Roles }
     * 
     */
    public Roles createRoles() {
        return new Roles();
    }

    /**
     * Create an instance of {@link Arg }
     * 
     */
    public Arg createArg() {
        return new Arg();
    }

    /**
     * Create an instance of {@link Rel }
     * 
     */
    public Rel createRel() {
        return new Rel();
    }

    /**
     * Create an instance of {@link Text }
     * 
     */
    public Text createText() {
        return new Text();
    }

    /**
     * Create an instance of {@link Example }
     * 
     */
    public Example createExample() {
        return new Example();
    }

    /**
     * Create an instance of {@link Inflection }
     * 
     */
    public Inflection createInflection() {
        return new Inflection();
    }

}
File Project Line
eu/fbk/dkm/pikes/resources/ecb/ECBPlusEvaluator.java pikes-resources 279
eu/fbk/dkm/pikes/resources/ecb/ECBPlusEvaluatorLemma.java pikes-resources 279
eu/fbk/dkm/pikes/resources/ecb/ECBevaluator2.java pikes-resources 131
            HashMultimap<Integer, String> theClusters = HashMultimap.create();
            for (CSVRecord record : records) {
                Matcher matcher;

                String id1 = null;
                String id2 = null;
                matcher = tokenPattern.matcher(record.get(1));
                if (matcher.find()) {
                    id1 = matcher.group(1) + "_" + matcher.group(2) + "_" + matcher.group(3);
                }
                matcher = tokenPattern.matcher(record.get(3));
                if (matcher.find()) {
                    id2 = matcher.group(1) + "_" + matcher.group(2) + "_" + matcher.group(3);
                }

//                System.out.println(id1);
//                System.out.println(id2);

                Integer index1 = clusterIndexes.get(id1);
                Integer index2 = clusterIndexes.get(id2);

//                System.out.println(index1);
//                System.out.println(index2);

                if (index1 == null && index2 == null) {
                    clusterID++;
                    if (!checkGold || okEvents.contains(id2)) {
File Project Line
eu/fbk/dkm/pikes/tintop/server/EverythingHandler.java pikes-tintop 65
eu/fbk/dkm/pikes/tintop/server/TriplesHandler.java pikes-tintop 67
		try {

			HashMap<String, Object> demoProperties = new HashMap<>();
			demoProperties.put("renderer.template.title", "PIKES demo");
			if (backLink) {
				demoProperties.put("renderer.template.backlink", "javascript:history.back();");
			}
			else {
				demoProperties.put("renderer.template.backlink", pipeline.getDefaultConfig().getProperty("back_alt_link"));
				demoProperties.put("renderer.template.backlabel", pipeline.getDefaultConfig().getProperty("back_alt_text"));
			}

			boolean fusion = request.getParameter("rdf_fusion") != null;
			boolean normalization = request.getParameter("rdf_compaction") != null;

			demoProperties.put("generator.fusion", fusion);
			demoProperties.put("generator.normalization", normalization);

			NAFFilter filter = NAFFilter.builder().withProperties(pipeline.getDefaultConfig(), "filter").build();
			RDFGenerator generator = RDFGenerator.builder().withProperties(demoProperties, "generator").build();
File Project Line
ixa/kaflib/Entity.java pikes-naflib 56
ixa/kaflib/Feature.java pikes-naflib 41
	for (Span<Term> span : entity.getSpans()) {
	    /* Copy span */
	    List<Term> targets = span.getTargets();
	    List<Term> copiedTargets = new ArrayList<Term>();
	    for (Term term : targets) {
		Term copiedTerm = terms.get(term.getId());
		if (copiedTerm == null) {
		    throw new IllegalStateException("Term not found when copying " + id);
		}
		copiedTargets.add(copiedTerm);
	    }
	    if (span.hasHead()) {
		Term copiedHead = terms.get(span.getHead().getId());
		this.references.add(new Span<Term>(copiedTargets, copiedHead));
	    }
	    else {
		this.references.add(new Span<Term>(copiedTargets));
	    }
	}
	/* Copy external references */
	this.externalReferences = new ArrayList<ExternalRef>();
	for (ExternalRef externalRef : entity.getExternalRefs()) {
File Project Line
eu/fbk/dkm/pikes/resources/reader/LKCollectionReader.java pikes-resources 650
eu/fbk/dkm/pikes/resources/reader/LKCollectionReader.java pikes-resources 697
	private <T> ArrayList<T> tsort(ListMap<T, T> depGraph) {

		HashSet<T> starts = new HashSet<T>();
		for (T k : depGraph.keySet()) {
			starts.add(k);
		}

		for (T k : depGraph.keySet()) {
			starts.removeAll(depGraph.get(k));
		}

		if (starts.size() == 0) {
			throw new RuntimeException("cyclic or empty graph!");
		}

		LinkedList<T> q = new LinkedList(starts);
		ArrayList<T> out = new ArrayList();

		while (!q.isEmpty()) {
			T t = q.removeFirst();
			out.add(t);
			ArrayList<T> sl = depGraph.get(t);
			if (sl != null) {
File Project Line
ixa/kaflib/Mark.java pikes-naflib 54
ixa/kaflib/Term.java pikes-naflib 343
	this.sid = id;
    }

    public boolean hasType() {
	return type != null;
    }

    public String getType() {
	return type;
    }

    public void setType(String type) {
	this.type = type;
    }

    public boolean hasLemma() {
	return lemma != null;
    }

    public String getLemma() {
	return lemma;
    }

    public void setLemma(String lemma) {
	this.lemma = lemma;
    }

    public boolean hasPos() {
	return pos != null;
    }

    public String getPos() {
	return pos;
    }

    public void setPos(String pos) {
	this.pos = pos;
    }

    public boolean hasMorphofeat() {
	return morphofeat != null;
    }

    public String getMorphofeat() {
	return morphofeat;
    }

    public void setMorphofeat(String morphofeat) {
	this.morphofeat = morphofeat;
    }

    public boolean hasCase() {
	return markcase != null;
File Project Line
eu/fbk/dkm/pikes/resources/ontonotes/frames/Predicate.java pikes-resources 21
eu/fbk/dkm/pikes/resources/util/propbank/Predicate.java pikes-resources 19
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
    "noteOrRoleset"
})
@XmlRootElement(name = "predicate")
public class Predicate {

    @XmlAttribute(name = "lemma", required = true)
    @XmlJavaTypeAdapter(NormalizedStringAdapter.class)
    protected String lemma;
    @XmlElements({
        @XmlElement(name = "note", type = Note.class),
        @XmlElement(name = "roleset", type = Roleset.class)
    })
    protected List<Object> noteOrRoleset;

    /**
     * Recupera il valore della proprietà lemma.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getLemma() {
        return lemma;
    }

    /**
     * Imposta il valore della proprietà lemma.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setLemma(String value) {
        this.lemma = value;
    }

    /**
     * Gets the value of the noteOrRoleset property.
     * 
     * <p>
     * This accessor method returns a reference to the live list,
     * not a snapshot. Therefore any modification you make to the
     * returned list will be present inside the JAXB object.
     * This is why there is not a <CODE>set</CODE> method for the noteOrRoleset property.
     * 
     * <p>
     * For example, to add a new item, do as follows:
     * <pre>
     *    getNoteOrRoleset().add(newItem);
     * </pre>
     * 
     * 
     * <p>
     * Objects of the following type(s) are allowed in the list
     * {@link Note }
     * {@link Roleset }
     * 
     * 
     */
    public List<Object> getNoteOrRoleset() {
        if (noteOrRoleset == null) {
            noteOrRoleset = new ArrayList<Object>();
        }
        return this.noteOrRoleset;
    }

}
File Project Line
eu/fbk/shell/mdfsa/data/structures/SentenceStructuredRepresentation.java pikes-raid 132
eu/fbk/shell/mdfsa/data/structures/SentenceStructuredRepresentation.java pikes-raid 198
    this.semanticConcepts = new ArrayList<String>();
    //String terms = this.lexString.replaceAll("\\./\\.", "");
    //String[] termsList = terms.split(" ");
    String[] termsList = this.lexString.split(" ");
    boolean compoundNounFlag = false;
    for(String currentTerm : termsList) {
      String[] atom = currentTerm.split("/");
      if(atom.length > 1) {
        Integer stopFlag = wnl.getStopwords().get(atom[0]);
        if(stopFlag != null) continue;
        if(atom[1].compareTo("NN") == 0 || atom[1].compareTo("NNP") == 0 || atom[1].compareTo("NNPS") == 0 ||
           atom[1].compareTo("NNS") == 0 || atom[1].compareTo("FW") == 0) {
          String newAspect;
          if(compoundNounFlag == true) {
            newAspect = this.semanticConcepts.get(this.semanticConcepts.size() - 1);
File Project Line
eu/fbk/dkm/pikes/raid/mdfsa/parser/DatasetInstanceParser.java pikes-raid 117
eu/fbk/dkm/pikes/raid/mdfsa/parser/ReviewsParser.java pikes-raid 169
  }
  
  
  
  
  /**
   * Utility method that convert the blitzer review in the eswc2014 challenge format
   */
  public void convertReviewToESWCChallenge(String filename, String datasetName) {
    FileManager fm = new FileManager(filename, Mode.READ);
    //String content = fm.importFullTextContent();
    ArrayList<String> contents = fm.importSimpleTextContent();
    
    FileManager rdfOut = new FileManager("/home/drago/Documents/java_projects/research/nlp/multi_domain_fuzzy_sentiment_analysis/eswc2014_challenge_mdfsa_dragoni/task3/" + datasetName + ".validation.rdf.xml", Mode.WRITE);
    
    rdfOut.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
    rdfOut.write("<rdf:RDF xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\">");
    int reviewId = 1;
    //int startText = content.indexOf("<review_text");
    //int endText = content.indexOf("</review_text", startText + 10);
    //while (startText != -1) {
    for(String currentReview: contents) {
      /* Gets the review text */
      //String currentReview = content.substring(startText + 14, endText - 1).replaceAll("\n", "");
      currentReview = currentReview.replace("&", "&amp;");
      //currentReview = "I gave up to go to supermarkets yesterday.";
            
      /* Write the review in the RDF format */
      rdfOut.write("\t<rdf:Description rdf:about=\"http://sentic.net/challenge/sentence_" + reviewId + "\">");
      //rdfOut.write("\t\t<sentence xmlns=\"http://sentic.net/challenge/\" rdf:resource=\"http://sentic.net/challenge/sentence_" + reviewId + "\">");
      rdfOut.write("\t\t\t<text xmlns=\"http://sentic.net/challenge/\" rdf:datatype=\"http://www.w3.org/TR/rdf-text/\">");
      //rdfOut.write("\t\t\t<![CDATA[" + currentReview + "]]>");
      rdfOut.write("\t\t\t" + currentReview + "");
      rdfOut.write("\t\t\t</text>");
      //rdfOut.write("\t\t</sentence>");
      rdfOut.write("\t</rdf:Description>");
      
      
      /* Gets next text to analyze */
      //startText = content.indexOf("<review_text", endText + 10);
      //endText = content.indexOf("</review_text", startText + 10);
      //System.out.println(reviewId + " - " + startText + " - " + endText);
      reviewId++;
    }
    rdfOut.write("</rdf:RDF>");
    rdfOut.close();
    fm.close();
  }
  
  
}
File Project Line
eu/fbk/dkm/pikes/resources/ontonotes/frames/Arg.java pikes-resources 19
eu/fbk/dkm/pikes/resources/util/propbank/Arg.java pikes-resources 17
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
    "value"
})
@XmlRootElement(name = "arg")
public class Arg {

    @XmlAttribute(name = "n", required = true)
    @XmlJavaTypeAdapter(NormalizedStringAdapter.class)
    protected String n;
    @XmlAttribute(name = "f")
    @XmlJavaTypeAdapter(NormalizedStringAdapter.class)
    protected String f;
    @XmlValue
    protected String value;

    /**
     * Recupera il valore della proprietà n.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getN() {
        return n;
    }

    /**
     * Imposta il valore della proprietà n.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setN(String value) {
        this.n = value;
    }

    /**
     * Recupera il valore della proprietà f.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getF() {
        return f;
    }

    /**
     * Imposta il valore della proprietà f.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setF(String value) {
        this.f = value;
    }

    /**
     * Recupera il valore della proprietà value.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getvalue() {
        return value;
    }

    /**
     * Imposta il valore della proprietà value.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setvalue(String value) {
        this.value = value;
    }

}
File Project Line
eu/fbk/dkm/pikes/resources/ontonotes/senses/Wn.java pikes-resources 19
eu/fbk/dkm/pikes/resources/util/onsenses/Wn.java pikes-resources 24
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
    "value"
})
@XmlRootElement(name = "wn")
public class Wn {

    @XmlAttribute(name = "version", required = true)
    @XmlJavaTypeAdapter(NormalizedStringAdapter.class)
    protected String version;
    @XmlAttribute(name = "lemma")
    @XmlJavaTypeAdapter(NormalizedStringAdapter.class)
    protected String lemma;
    @XmlValue
    protected String value;

    /**
     * Recupera il valore della proprietà version.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getVersion() {
        return version;
    }

    /**
     * Imposta il valore della proprietà version.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setVersion(String value) {
        this.version = value;
    }

    /**
     * Recupera il valore della proprietà lemma.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getLemma() {
        return lemma;
    }

    /**
     * Imposta il valore della proprietà lemma.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setLemma(String value) {
        this.lemma = value;
    }

    /**
     * Recupera il valore della proprietà value.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getvalue() {
        return value;
    }

    /**
     * Imposta il valore della proprietà value.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setvalue(String value) {
        this.value = value;
    }

}
File Project Line
eu/fbk/dkm/pikes/resources/ecb/ECBPlusEvaluator.java pikes-resources 168
eu/fbk/dkm/pikes/resources/ecb/ECBPlusEvaluatorLemma.java pikes-resources 168
eu/fbk/dkm/pikes/resources/ecb/ECBevaluator.java pikes-resources 132
                if (FOLDER != null && !folder.equals(FOLDER)) {
                    continue;
                }

                LOGGER.debug(file.getAbsolutePath());
                KAFDocument document = KAFDocument.createFromFile(file);

                for (Coref coref : document.getCorefs()) {
                    if (coref.getType() == null) {
                        continue;
                    }
                    if (!coref.getType().equals("event-gold")) {
                        continue;
                    }

                    Integer cluster = Integer.parseInt(coref.getCluster());
                    String idCluster = String.valueOf(1000 * folder + cluster);

                    for (Span<Term> termSpan : coref.getSpans()) {
                        Term term = termSpan.getTargets().get(0);
                        String lemma = term.getLemma();
File Project Line
eu/fbk/dkm/pikes/rdf/Renderer.java pikes-rdf 567
eu/fbk/dkm/pikes/rdf/naf/NAFRenderer.java pikes-rdf 540
eu/fbk/dkm/pikes/resources/NAFFilter.java pikes-resources 1804
        }

        public Builder withProperties(final Map<?, ?> properties, @Nullable final String prefix) {
            final String p = prefix == null ? "" : prefix.endsWith(".") ? prefix : prefix + ".";
            for (final Map.Entry<?, ?> entry : properties.entrySet()) {
                if (entry.getKey() != null && entry.getValue() != null
                        && entry.getKey().toString().startsWith(p)) {
                    final String name = entry.getKey().toString().substring(p.length());
                    final String value = Strings.emptyToNull(entry.getValue().toString());
                    if ("template".equals(name)) {
File Project Line
eu/fbk/dkm/pikes/rdf/RDFGenerator.java pikes-rdf 239
eu/fbk/dkm/pikes/rdf/Renderer.java pikes-rdf 569
eu/fbk/dkm/pikes/rdf/naf/NAFRenderer.java pikes-rdf 542
eu/fbk/dkm/pikes/resources/NAFFilter.java pikes-resources 1815
        public Builder withProperties(final Map<?, ?> properties, @Nullable final String prefix) {
            final String p = prefix == null ? "" : prefix.endsWith(".") ? prefix : prefix + ".";
            for (final Map.Entry<?, ?> entry : properties.entrySet()) {
                if (entry.getKey() != null && entry.getValue() != null
                        && entry.getKey().toString().startsWith(p)) {
                    final String name = entry.getKey().toString().substring(p.length());
                    final String value = Strings.emptyToNull(entry.getValue().toString());
                    if ("fusion".equals(name)) {
File Project Line
eu/fbk/dkm/pikes/rdf/RDFGenerator.java pikes-rdf 1983
eu/fbk/dkm/pikes/rdf/util/ProcessorASNorm.java pikes-rdf 68
eu/fbk/dkm/pikes/rdf/util/ProcessorASNorm.java pikes-rdf 98
                if (value instanceof URI) {
                    list.add("\u0001");
                    list.add(value.stringValue());
                } else if (value instanceof BNode) {
                    list.add("\u0002");
                    list.add(((BNode) value).getID());
                } else if (value instanceof Literal) {
                    final Literal l = (Literal) value;
                    list.add("\u0003");
                    list.add(l.getLabel());
                    if (l.getDatatype() != null) {
                        list.add(l.getDatatype().stringValue());
                    } else if (l.getLanguage() != null) {
                        list.add(l.getLanguage());
                    }
                }
            }
File Project Line
eu/fbk/dkm/pikes/resources/trec/FBIS.java pikes-resources 179
eu/fbk/dkm/pikes/resources/trec/FT.java pikes-resources 118
            String docno = "";
            if (docnoElement != null) {
                docno = docnoElement.getTextContent().trim();
            }

            String date = "";
            if (dateElement != null) {
                date = dateElement.getTextContent().trim();
            }

            String headline = "";
            if (headlineElement != null) {
                headline = headlineElement.getTextContent().trim();
            }

            if (docno.equals("")) {
                LOGGER.error("DOCNO is empty");
            }

            String url = String.format(urlTemplate, docno);

            headline = headline.replace('\n', ' ');
            headline = headline.replaceAll("\\s+", " ");
            text = text.replace('\n', ' ');
            text = text.replaceAll("\\s+", " ");
File Project Line
eu/fbk/dkm/pikes/resources/conllAIDA/DistillEntities.java pikes-resources 88
eu/fbk/dkm/pikes/resources/conllAIDA/DistillEntities.java pikes-resources 138
                                    String type = entity.getType();
                                    List<ExternalRef> externalRefs = entity.getExternalRefs();
                                    HashMap<String, Float> refs = new HashMap();
                                    for (ExternalRef exref : externalRefs
                                            ) {
                                        if (exref.getResource().equalsIgnoreCase("dbpedia-candidates")) {
                                            String ref = exref.getReference();
                                            float confidence = exref.getConfidence();
                                            refs.put(ref, confidence);
                                        } else refs.put("null", 0.0f);
                                    }

                                    String span = entity.getStr();
                                    String IDs = "";
                                    Integer spanID = Integer.parseInt(entity.getTerms().get(0).getId().replace("t", "")) - 1;
                                    for (Term t : entity.getTerms()
File Project Line
eu/fbk/dkm/pikes/resources/ecb/ECBevaluator2.java pikes-resources 76
eu/fbk/dkm/pikes/resources/ecb/ECBextractor.java pikes-resources 43
            Set<String> okEvents = new HashSet<>();

            for (final File file : Files.fileTreeTraverser().preOrderTraversal(inputNaf)) {
                if (!file.isFile()) {
                    continue;
                }
                if (file.getName().startsWith(".")) {
                    continue;
                }

                String path = file.getParentFile().toString();
                Integer folder = Integer.parseInt(path.substring(path.lastIndexOf("/")).substring(1));
                Integer fileNum = Integer.parseInt(file.getName().substring(0, file.getName().length() - 4));

                LOGGER.debug(file.getAbsolutePath());
                KAFDocument document = KAFDocument.createFromFile(file);
File Project Line
ixa/kaflib/Predicate.java pikes-naflib 69
ixa/kaflib/Predicate.java pikes-naflib 216
        public String getStr() {
            String str = "";
            for (Term term : this.span.getTargets()) {
                if (!str.isEmpty()) {
                    str += " ";
                }
                str += term.getStr();
            }
            return str;
        }

        public ExternalRef getExternalRef(String resource) {
            for (ExternalRef ref : externalReferences) {
                if (ref.getResource().equalsIgnoreCase(resource)) {
                    return ref;
                }
            }
            return null;
        }

        public List<ExternalRef> getExternalRefs() {
            return externalReferences;
        }

        public void addExternalRef(ExternalRef externalRef) {
            externalReferences.add(externalRef);
        }

        public void addExternalRefs(List<ExternalRef> externalRefs) {
            externalReferences.addAll(externalRefs);
        }

        public List<String> getFlags() {
File Project Line
eu/fbk/dkm/pikes/resources/ecb/ECBevaluator.java pikes-resources 286
eu/fbk/dkm/pikes/resources/ecb/ECBevaluator2.java pikes-resources 78
eu/fbk/dkm/pikes/resources/ecb/ECBextractor.java pikes-resources 45
            for (final File file : Files.fileTreeTraverser().preOrderTraversal(inputNaf)) {
                if (!file.isFile()) {
                    continue;
                }
                if (file.getName().startsWith(".")) {
                    continue;
                }

                String path = file.getParentFile().toString();
                Integer folder = Integer.parseInt(path.substring(path.lastIndexOf("/")).substring(1));
                Integer fileNum = Integer.parseInt(file.getName().substring(0, file.getName().length() - 4));

                LOGGER.debug(file.getAbsolutePath());
                KAFDocument document = KAFDocument.createFromFile(file);
File Project Line
eu/fbk/dkm/pikes/raid/pipeline/LinkLabeller.java pikes-raid 494
eu/fbk/dkm/pikes/raid/pipeline/SpanLabeller.java pikes-raid 513
            }
            final Classifier classifier = Classifier.train(grid, this.trainingSet,
                    ConfusionMatrix.labelComparator(PrecisionRecall.Measure.F1, 1, true), 100000);

            // Log parameters of the best classifier
            LOGGER.info("Best classifier parameters: {}", classifier.getParameters());

            // Perform cross-validation and emit some performance statistics, if enabled
            if (analyze && LOGGER.isInfoEnabled()) {
                final List<LabelledVector> trainingPredictions = classifier.predict(false,
                        this.trainingSet);
                final ConfusionMatrix matrix = LabelledVector.evaluate(this.trainingSet,
                        trainingPredictions, 2);
                LOGGER.info("Performances on training set:\n{}", matrix);
                final ConfusionMatrix crossMatrix = Classifier.crossValidate(
                        classifier.getParameters(), this.trainingSet, 5, -1);
                LOGGER.info("5-fold cross-validation performances:\n{}", crossMatrix);
            }

            // Build and return the created link labeller
            return new LinkLabeller(classifier, this.posPrefixes);
File Project Line
eu/fbk/dkm/pikes/naflib/Corpus.java pikes-naflib 109
eu/fbk/dkm/pikes/naflib/Corpus.java pikes-naflib 131
    public Path file(final Object key) {
        try {
            int index;
            if (key instanceof Number) {
                index = ((Number) key).intValue();
            } else if (key instanceof File) {
                index = Arrays.binarySearch(this.files, ((File) key).toPath());
            } else if (key instanceof Path) {
                index = Arrays.binarySearch(this.files, key);
            } else {
                index = Arrays.binarySearch(this.files, Paths.get(key.toString()));
            }
            if (index < 0 || index >= this.files.length) {
                throw new IllegalArgumentException("No file in this corpus for " + key);
            }
File Project Line
eu/fbk/dkm/pikes/rdf/RDFGenerator.java pikes-rdf 745
eu/fbk/dkm/pikes/rdf/naf/NAFExtractor.java pikes-rdf 189
                emitMeta(docURI, DCTERMS.LANGUAGE,
                        ModelUtil.languageCodeToURI(this.document.getLang()));
            }

            // Emit an hash of the whitespace-normalized raw text, if available
            if (this.document.getRawText() != null) {
                final String rawText = this.document.getRawText();
                final StringBuilder builder = new StringBuilder();
                boolean addSpace = false;
                for (int i = 0; i < rawText.length(); ++i) {
                    final char c = rawText.charAt(i);
                    if (Character.isWhitespace(c)) {
                        addSpace = builder.length() > 0;
                    } else {
                        if (addSpace) {
                            builder.append(' ');
                            addSpace = false;
                        }
                        builder.append(c);
                    }
                }
File Project Line
eu/fbk/shell/mdfsa/data/structures/TreeGraphStatisticalModel.java pikes-raid 215
eu/fbk/shell/mdfsa/data/structures/TreeGraphStatisticalModel.java pikes-raid 257
              String key = new String(d[0] + "^^^" + d[2] + "^^^" + d[1]);
              t = domainModel.get(key);
              tI = domainIndependentModel.get(key);
              if(t == null) {
                t = new Tuple(1);
                t.setToken(key);
                t.setFrequency(1.0);
              } else {
                t.setFrequency(t.getFrequency() + 1.0);
              }
              if(tI == null) {
                tI = new Tuple(1);
                tI.setToken(key);
                tI.setFrequency(1.0);
              } else {
                tI.setFrequency(t.getFrequency() + 1.0);
              }
              domainModel.put(key, t);
              domainIndependentModel.put(key, tI);
File Project Line
eu/fbk/dkm/pikes/resources/ecb/ECBevaluator.java pikes-resources 117
eu/fbk/dkm/pikes/resources/ecb/ECBevaluator2.java pikes-resources 75
            HashMap<String, String> goldClusters = new HashMap<>();
            Set<String> okEvents = new HashSet<>();

            for (final File file : Files.fileTreeTraverser().preOrderTraversal(inputNaf)) {
                if (!file.isFile()) {
                    continue;
                }
                if (file.getName().startsWith(".")) {
                    continue;
                }

                String path = file.getParentFile().toString();
                Integer folder = Integer.parseInt(path.substring(path.lastIndexOf("/")).substring(1));
                Integer fileNum = Integer.parseInt(file.getName().substring(0, file.getName().length() - 4));
File Project Line
eu/fbk/dkm/pikes/resources/ecb/ECBmerger.java pikes-resources 47
eu/fbk/dkm/pikes/resources/ecb/ECBparser.java pikes-resources 43
            File outputFolder = cmd.getOptionValue("output", File.class);

            if (!outputFolder.exists()) {
                outputFolder.mkdirs();
            }

            DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
            DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();

            // uncomment to get the manual mention spans
            //Pattern MY_PATTERN = Pattern.compile("\\\">[^<]*</MENTION>");

            String tags;

            int i = 0;
            for (final File file : Files.fileTreeTraverser().preOrderTraversal(inputFolder)) {
                if (!file.isFile()) {
                    continue;
                }
                if (file.getName().startsWith(".")) {
                    continue;
                }

                String path = file.getParentFile().toString();
                String folder = path.substring(path.lastIndexOf("/"));
                String local_name = folder + File.separator + file.getName();

                String naf = nafFolder + File.separator + folder + File.separator + file.getName()
File Project Line
eu/fbk/shell/mdfsa/data/structures/TreeGraphStatisticalModel.java pikes-raid 215
eu/fbk/shell/mdfsa/data/structures/TreeGraphStatisticalModel.java pikes-raid 236
              String key = new String(d[0] + "^^^" + d[2] + "^^^" + d[1]);
              t = domainModel.get(key);
              tI = domainIndependentModel.get(key);
              if(t == null) {
                t = new Tuple(1);
                t.setToken(key);
                t.setFrequency(1.0);
              } else {
                t.setFrequency(t.getFrequency() + 1.0);
              }
              if(tI == null) {
                tI = new Tuple(1);
                tI.setToken(key);
                tI.setFrequency(1.0);
              } else {
                tI.setFrequency(t.getFrequency() + 1.0);
              }
              domainModel.put(key, t);
              domainIndependentModel.put(key, tI);
              
              /* Key: governor-dependent */
              key = new String(d[1] + "^^^" + d[2]);
File Project Line
eu/fbk/dkm/pikes/tintopclient/TintopOrchestrator.java pikes-tintop-client 303
eu/fbk/dkm/pikes/tintop/FolderOrchestrator.java pikes-tintop 289
            HashSet<String> skipPatterns = new HashSet<>();
            if (skip != null) {
                BufferedReader reader = new BufferedReader(new FileReader(skip));
                String line;
                while ((line = reader.readLine()) != null) {
                    line = line.trim();
                    skipPatterns.add(line);
                }
                reader.close();
            }

            if (!input.exists()) {
                logger.error("Input folder does not exist");
                System.exit(1);
            }

            if (!output.exists()) {
                if (!output.mkdirs()) {
                    logger.error("Unable to create output folder");
                    System.exit(1);
                }
            }
File Project Line
eu/fbk/dkm/pikes/naflib/StripNAF.java pikes-naflib 17
eu/fbk/dkm/pikes/resources/conllAIDA/DistillEntities.java pikes-resources 23
    private static final org.slf4j.Logger LOGGER = LoggerFactory.getLogger(StripNAF.class);
    private static SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ");


    public enum removeLayer {
        deps, chunks, entities, properties, categories, coreferences, opinions, relations, srl, constituency, timeExpressions, linkedEntities, constituencyStrings;
    }

    public static void main(String[] args) {
        try {
            final CommandLine cmd = CommandLine
                    .parser()
                    .withName("stripNAF")
                    .withHeader("Strip NAF files of unnecessary layers")
                    .withOption("i", "input-folder", "the folder of the input NAF corpus", "DIR", CommandLine.Type.DIRECTORY_EXISTING, true, false, true)
                    .withOption("o", "output-folder", "the folder of the input NAF corpus", "DIR", CommandLine.Type.DIRECTORY, true, false, true)
                    .withLogger(LoggerFactory.getLogger("eu.fbk")).parse(args);
File Project Line
eu/fbk/dkm/pikes/rdf/Renderer.java pikes-rdf 79
eu/fbk/dkm/pikes/rdf/naf/NAFRenderer.java pikes-rdf 53
    public static final Map<Object, String> DEFAULT_COLOR_MAP = ImmutableMap
            .<Object, String>builder() //
            .put("node", "#F0F0F0") //
            .put(NWR.PERSON, "#FFC8C8") //
            .put(NWR.ORGANIZATION, "#FFFF84") //
            .put(NWR.LOCATION, "#A9C5EB") //
            .put(KS.ATTRIBUTE, "#EEBBEE") //
            // .put(KS.MONEY, "#EEBBEE") //
            // .put(KS.FACILITY, "#FFC65B") //
            // .put(KS.PRODUCT, "#FFC65B") //
            // .put(KS.WORK_OF_ART, "#FFC65B") //
            .put(SUMO.PROCESS, "#CFE990") //
            .put(SUMO.RELATION, "#FFFFFF") //
            .put(OWLTIME.INTERVAL, "#B4D1B6") //
            .put(OWLTIME.DATE_TIME_INTERVAL, "#B4D1B6") //
            .put(OWLTIME.PROPER_INTERVAL, "#B4D1B6") //
            .put(NWR.MISC, "#D1BAA2") //
            // .put(KS.LAW, "#D1BAA2") //
            .build();
File Project Line
eu/fbk/dkm/pikes/rdf/Renderer.java pikes-rdf 400
eu/fbk/dkm/pikes/rdf/naf/NAFRenderer.java pikes-rdf 337
            final Model mentionModel = new LinkedHashModel();
            for (final Statement statement : model.filter(mentionID, null, null)) {
                final URI pred = statement.getPredicate();
                if (!NIF.BEGIN_INDEX.equals(pred) && !NIF.END_INDEX.equals(pred)
                        && !NIF.ANCHOR_OF.equals(pred) && !RDF.TYPE.equals(pred)
                        && !KS.MENTION_OF.equals(pred)) {
                    mentionModel.add(statement);
                }
            }
            if (!mentionModel.isEmpty()) {
                renderProperties(out, mentionModel, mentionID, false);
            }
            out.append("</td><td>");
            renderObject(out, model.filter(null, GAF.DENOTED_BY, mentionID).subjects(), model);
File Project Line
eu/fbk/dkm/pikes/resources/trec/CR.java pikes-resources 91
eu/fbk/dkm/pikes/resources/trec/FR94.java pikes-resources 150
eu/fbk/dkm/pikes/resources/trec/FT.java pikes-resources 88
eu/fbk/dkm/pikes/resources/trec/LATIMES.java pikes-resources 95
        StringBuffer stringBuffer = new StringBuffer();
        stringBuffer.append("<ROOT>\n");
        stringBuffer.append(Files.toString(inputFile, Charsets.UTF_8));
        stringBuffer.append("\n</ROOT>\n");

        InputStream is = new ByteArrayInputStream(stringBuffer.toString().getBytes());
        DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
        DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
        Document doc = dBuilder.parse(is);

        doc.getDocumentElement().normalize();

        int i = 0;
        for (Element element : JOOX.$(doc).find("DOC")) {
            Element docnoElement = JOOX.$(element).find("DOCNO").get(0);
            Element dateElement = JOOX.$(element).find("DATE").get(0);
File Project Line
eu/fbk/dkm/pikes/resources/trec/CR.java pikes-resources 115
eu/fbk/dkm/pikes/resources/trec/FBIS.java pikes-resources 175
                LOGGER.error("TEXT is null");
                continue;
            }

            String docno = "";
            if (docnoElement != null) {
                docno = docnoElement.getTextContent().trim();
            }

            String date = "";
            if (dateElement != null) {
                date = dateElement.getTextContent().trim();
            }

            String headline = "";
            if (headlineElement != null) {
                headline = headlineElement.getTextContent().trim();
            }

            if (docno.equals("")) {
                LOGGER.error("DOCNO is empty");
            }

            String url = String.format(urlTemplate, docno);

            headline = headline.replace('\n', ' ');
            headline = headline.replaceAll("\\s+", " ");
File Project Line
eu/fbk/dkm/pikes/resources/mpqa/CorpusPreprocessor.java pikes-resources 379
eu/fbk/dkm/pikes/resources/mpqa/CorpusPreprocessor.java pikes-resources 422
			}

			// Holder
			String sources = thisRecord.getValue("nested-source");
			addSources(sources, agentRecords, lastRecords, sentenceSpan, fields, documentURI, text);

			// Emit TSV string
			tsvWriter.append(getTsvString(documentURI, fields));

			// Print debug
			LOGGER.debug(fields.get("type").toString());
			LOGGER.debug(fields.toString());
			for (String expression : fields.get("expression")) {
				LOGGER.debug(expression);
				Span span = new Span(expression);
				LOGGER.debug(span.apply(text));
			}
			System.out.println();
		}

		// Expressive
		for (final Record thisRecord : annotations.getRecords("GATE_expressive-subjectivity")) {
File Project Line
eu/fbk/shell/mdfsa/data/structures/TreeGraphStatisticalModel.java pikes-raid 236
eu/fbk/shell/mdfsa/data/structures/TreeGraphStatisticalModel.java pikes-raid 257
              key = new String(d[1] + "^^^" + d[2]);
              t = domainModel.get(key);
              tI = domainIndependentModel.get(key);
              if(t == null) {
                t = new Tuple(1);
                t.setToken(key);
                t.setFrequency(1.0);
              } else {
                t.setFrequency(t.getFrequency() + 1.0);
              }
              if(tI == null) {
                tI = new Tuple(1);
                tI.setToken(key);
                tI.setFrequency(1.0);
              } else {
                tI.setFrequency(t.getFrequency() + 1.0);
              }
              domainModel.put(key, t);
              domainIndependentModel.put(key, tI);
File Project Line
eu/fbk/dkm/pikes/resources/ecb/ConvertECBPlus.java pikes-resources 36
eu/fbk/dkm/pikes/resources/enronEmailDataset/Email2NAF.java pikes-resources 75
                .withHeader("Convert ECB+ files to NAF")
                .withOption("i", "input-path", "the base path of the corpus", "DIR",
                        CommandLine.Type.DIRECTORY_EXISTING, true, false, true)
                .withOption("o", "output-path", "output NAF folder", "DIR",
                        CommandLine.Type.DIRECTORY, true, false, true)
                .withLogger(LoggerFactory.getLogger("eu.fbk")).parse(args);

        final File inputPath = cmd.getOptionValue("i", File.class);
        final File outputPath = cmd.getOptionValue("o", File.class);

        boolean opMkDirs = outputPath.mkdirs();
        if (!opMkDirs) {
            LOGGER.error("Unable to create folder {}", outputPath.getAbsolutePath());
        }
File Project Line
eu/fbk/dkm/pikes/resources/trec/CR.java pikes-resources 119
eu/fbk/dkm/pikes/resources/trec/FT.java pikes-resources 118
            String docno = "";
            if (docnoElement != null) {
                docno = docnoElement.getTextContent().trim();
            }

            String date = "";
            if (dateElement != null) {
                date = dateElement.getTextContent().trim();
            }

            String headline = "";
            if (headlineElement != null) {
                headline = headlineElement.getTextContent().trim();
            }

            if (docno.equals("")) {
                LOGGER.error("DOCNO is empty");
            }

            String url = String.format(urlTemplate, docno);

            headline = headline.replace('\n', ' ');
            headline = headline.replaceAll("\\s+", " ");
File Project Line
eu/fbk/dkm/pikes/tintop/util/framenet/MergeMateFramenet.java pikes-tintop 1354
eu/fbk/dkm/pikes/tintop/util/framenet/MergeMateFramenet.java pikes-tintop 1390
                    String value = outputMappingsForRoles.get(outputMapping).get(key);

                    String[] parts = value.split("@");
                    if (parts.length < 2) {
                        LOGGER.error("This is impossible!");
                        break;
                    }
                    URI fbURI = FrameBase.propertyFor(parts[0], parts[1]);
                    if (fbURI == null) {
                        LOGGER.error("This should never happen!");
                        LOGGER.debug(key);
                        LOGGER.debug(value);
                        break;
                    }

                    writer.append(outputMapping.toString()).append('\t');
                    writer.append(key).append('\t');
                    writer.append(value).append('\t');
File Project Line
eu/fbk/dkm/pikes/rdf/Renderer.java pikes-rdf 604
eu/fbk/dkm/pikes/rdf/naf/NAFRenderer.java pikes-rdf 571
            return this;
        }

        public Builder withColorMap(@Nullable final Map<Object, String> colorMap) {
            this.colorMap = colorMap;
            return this;
        }

        public Builder withStyleMap(@Nullable final Map<Object, String> styleMap) {
            this.styleMap = styleMap;
            return this;
        }

        public Builder withTemplate(@Nullable final Object template) {
            this.template = template == null ? null : loadTemplate(template);
            return this;
        }

        public Builder withTemplateParameter(final String name, @Nullable final Object value) {
            this.templateParameters.put(name, value);
            return this;
        }

        public Renderer build() {
            return new Renderer(this);
File Project Line
eu/fbk/dkm/pikes/resources/ontonotes/frames/Vnrole.java pikes-resources 20
eu/fbk/dkm/pikes/resources/util/propbank/Vnrole.java pikes-resources 18
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "")
@XmlRootElement(name = "vnrole")
public class Vnrole {

    @XmlAttribute(name = "vncls", required = true)
    @XmlJavaTypeAdapter(NormalizedStringAdapter.class)
    protected String vncls;
    @XmlAttribute(name = "vntheta", required = true)
    @XmlJavaTypeAdapter(CollapsedStringAdapter.class)
    protected String vntheta;

    /**
     * Recupera il valore della proprietà vncls.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getVncls() {
        return vncls;
    }

    /**
     * Imposta il valore della proprietà vncls.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setVncls(String value) {
        this.vncls = value;
    }

    /**
     * Recupera il valore della proprietà vntheta.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getVntheta() {
        return vntheta;
    }

    /**
     * Imposta il valore della proprietà vntheta.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setVntheta(String value) {
        this.vntheta = value;
    }

}
File Project Line
eu/fbk/dkm/pikes/resources/ecb/ECBevaluator.java pikes-resources 118
eu/fbk/dkm/pikes/resources/ecb/ECBextractor.java pikes-resources 43
            Set<String> okEvents = new HashSet<>();

            for (final File file : Files.fileTreeTraverser().preOrderTraversal(inputNaf)) {
                if (!file.isFile()) {
                    continue;
                }
                if (file.getName().startsWith(".")) {
                    continue;
                }

                String path = file.getParentFile().toString();
                Integer folder = Integer.parseInt(path.substring(path.lastIndexOf("/")).substring(1));
                Integer fileNum = Integer.parseInt(file.getName().substring(0, file.getName().length() - 4));
File Project Line
eu/fbk/dkm/pikes/resources/ecb/ECBevaluator.java pikes-resources 120
eu/fbk/dkm/pikes/resources/ecb/ECBevaluator.java pikes-resources 286
            for (final File file : Files.fileTreeTraverser().preOrderTraversal(inputNaf)) {
                if (!file.isFile()) {
                    continue;
                }
                if (file.getName().startsWith(".")) {
                    continue;
                }

                String path = file.getParentFile().toString();
                Integer folder = Integer.parseInt(path.substring(path.lastIndexOf("/")).substring(1));
                Integer fileNum = Integer.parseInt(file.getName().substring(0, file.getName().length() - 4));
File Project Line
eu/fbk/shell/mdfsa/data/structures/DomainGraph.java pikes-raid 74
eu/fbk/shell/mdfsa/data/structures/DomainGraph.java pikes-raid 180
      int polarity = di.getPolarity();
      
      for(String currentFeature: features) {
        
        ArrayList<Long> featureIds = this.graph.getFeatureIds(currentFeature);
        if(featureIds != null) {
          for(Long featureId: featureIds) {
            Double currentPolarity = this.startPolarities.get(featureId);
            if(currentPolarity == null) {
              currentPolarity = new Double(polarity);
              this.startPolarities.put(featureId, currentPolarity);
              this.currentPolarities.put(featureId, currentPolarity);
            } else {
              currentPolarity += polarity;
              this.startPolarities.put(featureId, currentPolarity);
              this.currentPolarities.put(featureId, currentPolarity);
            }
File Project Line
eu/fbk/dkm/pikes/resources/trec/CR.java pikes-resources 93
eu/fbk/dkm/pikes/resources/trec/FBIS.java pikes-resources 146
eu/fbk/dkm/pikes/resources/trec/FT.java pikes-resources 90
eu/fbk/dkm/pikes/resources/trec/LATIMES.java pikes-resources 97
        stringBuffer.append(Files.toString(inputFile, Charsets.UTF_8));
        stringBuffer.append("\n</ROOT>\n");

        InputStream is = new ByteArrayInputStream(stringBuffer.toString().getBytes());
        DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
        DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
        Document doc = dBuilder.parse(is);

        doc.getDocumentElement().normalize();

        int i = 0;
        for (Element element : JOOX.$(doc).find("DOC")) {
            Element docnoElement = JOOX.$(element).find("DOCNO").get(0);
            Element dateElement = JOOX.$(element).find("DATE").get(0);
File Project Line
ixa/kaflib/ReadWriteManager.java pikes-naflib 535
ixa/kaflib/ReadWriteManager.java pikes-naflib 578
                                    "Every property must contain a 'span' element inside 'references'");
                        }
                        List<Span<Term>> references = new ArrayList<Span<Term>>();
                        for (Element spanElem : spanElems) {
                            Span<Term> span = kaf.newTermSpan();
                            List<Element> targetElems = spanElem.getChildren();
                            if (targetElems.size() < 1) {
                                throw new IllegalStateException(
                                        "Every span in a property must contain at least one target inside");
                            }
                            for (Element targetElem : targetElems) {
                                String targetTermId = getAttribute("id", targetElem);
                                Term targetTerm = termIndex.get(targetTermId);
                                if (targetTerm == null) {
                                    throw new KAFNotValidException(
                                            "Term " + targetTermId + " not found when loading property " + pid);
File Project Line
eu/fbk/dkm/pikes/resources/ontonotes/senses/WORDMETA.java pikes-resources 19
eu/fbk/dkm/pikes/resources/util/onsenses/WORDMETA.java pikes-resources 23
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "")
@XmlRootElement(name = "WORD_META")
public class WORDMETA {

    @XmlAttribute(name = "authors", required = true)
    @XmlJavaTypeAdapter(NormalizedStringAdapter.class)
    protected String authors;
    @XmlAttribute(name = "sample_score")
    @XmlJavaTypeAdapter(NormalizedStringAdapter.class)
    protected String sampleScore;

    /**
     * Recupera il valore della proprietà authors.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getAuthors() {
        return authors;
    }

    /**
     * Imposta il valore della proprietà authors.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setAuthors(String value) {
        this.authors = value;
    }

    /**
     * Recupera il valore della proprietà sampleScore.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getSampleScore() {
        return sampleScore;
    }

    /**
     * Imposta il valore della proprietà sampleScore.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setSampleScore(String value) {
        this.sampleScore = value;
    }

}
File Project Line
eu/fbk/dkm/pikes/tintopclient/TintopOrchestrator.java pikes-tintop-client 67
eu/fbk/dkm/pikes/tintop/FolderOrchestrator.java pikes-tintop 86
            while (true) {
                String filename = null;
                try {
                    filename = getNextFile(session);
                    if (filename == null) {
                        break;
                    }

                    File file = new File(filename);
                    if (!file.exists()) {
                        break;
                    }

                    File outputFile = getOutputFile(file, session);

                    // todo: use parameters
                    outputFile = new File(outputFile.getAbsolutePath() + ".gz");

                    logger.debug("Output file: " + outputFile);

                    logger.info("Loading file: " + filename);
                    BufferedReader reader = new BufferedReader(new FileReader(filename));
                    String whole = IOUtils.toString(reader);
                    reader.close();
File Project Line
eu/fbk/dkm/pikes/resources/ecb/ECBPlusEvaluator.java pikes-resources 39
eu/fbk/dkm/pikes/resources/ecb/ECBPlusEvaluatorLemma.java pikes-resources 40
eu/fbk/dkm/pikes/resources/ecb/ECBevaluator.java pikes-resources 41
        writer.append(token.getMorphofeat()).append("\t");
        writer.append("_").append("\t");
        writer.append("_").append("\t");
        writer.append("_").append("\t");
        writer.append("_").append("\t");
        writer.append("_").append("\t");
        writer.append("_").append("\t");
        writer.append("_").append("\t");
        writer.append("_").append("\t");
        writer.append("_").append("\t");
        writer.append("_").append("\t");
File Project Line
eu/fbk/dkm/pikes/resources/ecb/ECBPlusEvaluator.java pikes-resources 40
eu/fbk/dkm/pikes/resources/ecb/ECBPlusEvaluatorLemma.java pikes-resources 39
eu/fbk/dkm/pikes/resources/ecb/ECBevaluator.java pikes-resources 40
        writer.append("_").append("\t");
        writer.append("_").append("\t");
        writer.append("_").append("\t");
        writer.append("_").append("\t");
        writer.append("_").append("\t");
        writer.append("_").append("\t");
        writer.append("_").append("\t");
        writer.append("_").append("\t");
        writer.append("_").append("\t");
        writer.append("_").append("\t");
        writer.append(last);
File Project Line
eu/fbk/dkm/pikes/resources/mpqa/CorpusPreprocessor.java pikes-resources 379
eu/fbk/dkm/pikes/resources/mpqa/CorpusPreprocessor.java pikes-resources 466
			}

			// Holder
			String sources = thisRecord.getValue("nested-source");
			addSources(sources, agentRecords, lastRecords, sentenceSpan, fields, documentURI, text);

			// Emit TSV string
			tsvWriter.append(getTsvString(documentURI, fields));

			// Print debug
			LOGGER.debug(fields.get("type").toString());
			LOGGER.debug(fields.toString());
			for (String expression : fields.get("expression")) {
				LOGGER.debug(expression);
				Span span = new Span(expression);
				LOGGER.debug(span.apply(text));
			}
			System.out.println();
		}
File Project Line
eu/fbk/dkm/pikes/raid/CreateTrainingForExpression.java pikes-raid 559
eu/fbk/dkm/pikes/raid/UpdateNafsWithResults.java pikes-raid 109
				SentiWordNet.init();
			}

			LOGGER.info("Parsing corpus");
			Corpus[] corpuses = new Corpus[2];
			if (trainList != null) {
				List<File> trainFiles = readList(trainList, mainFolder, "naf");
				List<File> testFiles = readList(testList, mainFolder, "naf");
				corpuses[0] = Corpus.create(false, trainFiles);
				corpuses[1] = Corpus.create(false, testFiles);
			}
			else {
				Corpus myCorpus = Corpus.create(false, mainFolder);
				corpuses = myCorpus.split(seed, split, 1.0f - split);
			}
File Project Line
eu/fbk/dkm/pikes/resources/ecb/ECBPlusEvaluator.java pikes-resources 244
eu/fbk/dkm/pikes/resources/ecb/ECBPlusEvaluatorLemma.java pikes-resources 244
eu/fbk/dkm/pikes/resources/ecb/ECBevaluator.java pikes-resources 189
                            theBaseline.put(id, last);
                        }
                        printToken(baselineBuilder, token, n, last);
                    }

                    goldBuilder.append("\n");
                    baselineBuilder.append("\n");

                    if (useThis) {
                        goldWriter.append(goldBuilder.toString());
                        baselineWriter.append(baselineBuilder.toString());
                    }
                }
//                break;
            }

            goldWriter.close();
            baselineWriter.close();

//            Set<Set> goldClusters = new HashSet<>();
//            for (String key : goldTmpClusters.keySet()) {
//                Set<String> cluster = goldTmpClusters.get(key);
//                if (cluster.size() > 1 || !removeAloneClusters) {
//                    goldClusters.add(cluster);
//                }
//            }

//            LOGGER.info("Gold clusters: {}", goldClusters.size());

            in = new FileReader(inputCsv);
            records = CSVFormat.EXCEL.withHeader().parse(in);

            // Size must be always 4!
            int clusterID = 0;
            HashMap<String, Integer> clusterIndexes = new HashMap<>();
            HashMultimap<Integer, String> theClusters = HashMultimap.create();
File Project Line
eu/fbk/dkm/pikes/rdf/Renderer.java pikes-rdf 348
eu/fbk/dkm/pikes/rdf/naf/NAFRenderer.java pikes-rdf 283
        out.append(shorten(KS.EXPRESSED_BY));
        out.append("</th></tr>\n");
        out.append("</thead>\n<tbody>\n");

        for (final Statement statement : this.statementComparator.sortedCopy(model)) {
            if (statement.getContext() != null) {
                out.append("<tr><td>");
                renderObject(out, statement.getSubject(), model);
                out.append("</td><td>");
                renderObject(out, statement.getPredicate(), model);
                out.append("</td><td>");
                renderObject(out, statement.getObject(), model);
                out.append("</td><td>");
                String separator = "";
                for (final Value mentionID : model.filter(statement.getContext(), KS.EXPRESSED_BY,
File Project Line
eu/fbk/dkm/pikes/resources/conllAIDA/DistillEntities.java pikes-resources 103
eu/fbk/dkm/pikes/resources/conllAIDA/DistillEntities.java pikes-resources 153
                                    for (Term t : entity.getTerms()
                                            ) {
                                        IDs += String.valueOf(Integer.parseInt(t.getId().replace("t", "")) - 1) + " ";
                                    }
                                    //System.out.println(span);
                                    //System.out.print(type);
                                    String references = refs.entrySet().stream()
                                            .sorted(Map.Entry.<String, Float>comparingByValue().reversed()).map(e -> e.getKey().replace("http://dbpedia.org/resource/", "") + " [" + e.getValue() + "]").collect(Collectors.joining("  "));
File Project Line
eu/fbk/dkm/pikes/resources/trec/FBIS.java pikes-resources 75
eu/fbk/dkm/pikes/resources/trec/FR94.java pikes-resources 72
eu/fbk/dkm/pikes/resources/trec/FT.java pikes-resources 67
                if (file.getName().startsWith(".")) {
                    continue;
                }

                String outputTemplate = outputDir.getAbsolutePath() + File.separator + file.getName();
                File newFolder = new File(outputTemplate);
                newFolder.mkdirs();

                outputTemplate += File.separator + "NAF";
                saveFile(file, outputTemplate, urlTemplate);
            }
        } catch (Exception e) {
            CommandLine.fail(e);
        }
    }

    private static void saveFile(File inputFile, String outputFilePattern, String urlTemplate)
            throws IOException, SAXException, ParserConfigurationException {

        LOGGER.info("Input file: {}", inputFile);

        StringBuffer stringBuffer = new StringBuffer();
        stringBuffer.append("<?xml version=\"1.0\"?>\n"
File Project Line
eu/fbk/dkm/pikes/resources/vuaopinion/CorpusAnnotator.java pikes-resources 37
eu/fbk/dkm/pikes/resources/vuaopinion/CorpusPreprocessor.java pikes-resources 61
			boolean forceOpinion = cmd.hasOption("f");
			 
			final File inputPath = cmd.getOptionValue("i", File.class);
			if (!inputPath.exists()) {
				throw new IOException(String.format("Folder %s does not exist", inputPath.getAbsolutePath()));
			}

			File kafPath = new File(inputPath.getAbsolutePath() + File.separator + "kaf");
			if (!kafPath.exists()) {
				throw new IOException(String.format("Folder %s does not exist", kafPath.getAbsolutePath()));
			}
			File nafPath = new File(inputPath.getAbsolutePath() + File.separator + "naf-parsed");
File Project Line
ixa/kaflib/Coref.java pikes-naflib 51
ixa/kaflib/Entity.java pikes-naflib 56
ixa/kaflib/Feature.java pikes-naflib 41
	for (Span<Term> span : coref.getSpans()) {
	    /* Copy span */
	    List<Term> targets = span.getTargets();
	    List<Term> copiedTargets = new ArrayList<Term>();
	    for (Term term : targets) {
		Term copiedTerm = terms.get(term.getId());
		if (copiedTerm == null) {
		    throw new IllegalStateException("Term not found when copying " + id);
		}
		copiedTargets.add(copiedTerm);
	    }
	    if (span.hasHead()) {
		Term copiedHead = terms.get(span.getHead().getId());
		this.mentions.add(new Span<Term>(copiedTargets, copiedHead));
File Project Line
eu/fbk/dkm/pikes/resources/ontonotes/frames/Frameset.java pikes-resources 19
eu/fbk/dkm/pikes/resources/util/propbank/Frameset.java pikes-resources 17
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
    "noteOrPredicate"
})
@XmlRootElement(name = "frameset")
public class Frameset {

    @XmlElements({
        @XmlElement(name = "note", type = Note.class),
        @XmlElement(name = "predicate", type = Predicate.class)
    })
    protected List<Object> noteOrPredicate;

    /**
     * Gets the value of the noteOrPredicate property.
     * 
     * <p>
     * This accessor method returns a reference to the live list,
     * not a snapshot. Therefore any modification you make to the
     * returned list will be present inside the JAXB object.
     * This is why there is not a <CODE>set</CODE> method for the noteOrPredicate property.
     * 
     * <p>
     * For example, to add a new item, do as follows:
     * <pre>
     *    getNoteOrPredicate().add(newItem);
     * </pre>
     * 
     * 
     * <p>
     * Objects of the following type(s) are allowed in the list
     * {@link Note }
     * {@link Predicate }
     * 
     * 
     */
    public List<Object> getNoteOrPredicate() {
        if (noteOrPredicate == null) {
            noteOrPredicate = new ArrayList<Object>();
        }
        return this.noteOrPredicate;
    }

}
File Project Line
eu/fbk/dkm/pikes/resources/ontonotes/frames/Roles.java pikes-resources 19
eu/fbk/dkm/pikes/resources/util/propbank/Roles.java pikes-resources 17
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
    "noteOrRole"
})
@XmlRootElement(name = "roles")
public class Roles {

    @XmlElements({
        @XmlElement(name = "note", type = Note.class),
        @XmlElement(name = "role", type = Role.class)
    })
    protected List<Object> noteOrRole;

    /**
     * Gets the value of the noteOrRole property.
     * 
     * <p>
     * This accessor method returns a reference to the live list,
     * not a snapshot. Therefore any modification you make to the
     * returned list will be present inside the JAXB object.
     * This is why there is not a <CODE>set</CODE> method for the noteOrRole property.
     * 
     * <p>
     * For example, to add a new item, do as follows:
     * <pre>
     *    getNoteOrRole().add(newItem);
     * </pre>
     * 
     * 
     * <p>
     * Objects of the following type(s) are allowed in the list
     * {@link Note }
     * {@link Role }
     * 
     * 
     */
    public List<Object> getNoteOrRole() {
        if (noteOrRole == null) {
            noteOrRole = new ArrayList<Object>();
        }
        return this.noteOrRole;
    }

}
File Project Line
ixa/kaflib/Entity.java pikes-naflib 109
ixa/kaflib/Feature.java pikes-naflib 89
    }

    /** Returns the term targets of the first span. When targets of other spans are needed getReferences() method should be used. */ 
    public List<Term> getTerms() {
	return this.references.get(0).getTargets();
    }

    /** Adds a term to the first span. */
    public void addTerm(Term term) {
	this.references.get(0).addTarget(term);
    }

    /** Adds a term to the first span. */
    public void addTerm(Term term, boolean isHead) {
	this.references.get(0).addTarget(term, isHead);
    }

    public List<Span<Term>> getSpans() {
	return this.references;
    }

    public void addSpan(Span<Term> span) {
File Project Line
ixa/kaflib/ReadWriteManager.java pikes-naflib 334
ixa/kaflib/ReadWriteManager.java pikes-naflib 379
                    List<Span<Term>> references = new ArrayList<Span<Term>>();
                    for (Element spanElem : spanElems) {
                        Span<Term> span = kaf.newTermSpan();
                        List<Element> targetElems = spanElem.getChildren();
                        if (targetElems.size() < 1) {
                            throw new IllegalStateException(
                                    "Every span in an entity must contain at least one target inside");
                        }
                        for (Element targetElem : targetElems) {
                            String targetTermId = getAttribute("id", targetElem);
                            Term targetTerm = termIndex.get(targetTermId);
                            if (targetTerm == null) {
                                throw new KAFNotValidException(
                                        "Term " + targetTermId + " not found when loading entity " + entId);
File Project Line
eu/fbk/dkm/pikes/resources/mpqa/JohanssonAnnotator.java pikes-resources 185
eu/fbk/dkm/pikes/resources/mpqa/JohanssonAnnotator.java pikes-resources 272
eu/fbk/dkm/pikes/resources/mpqa/JohanssonAnnotator.java pikes-resources 333
				for (LKAnnotationEntity entity : dseLayer.entityList) {

					Span<Term> expressionSpan = getSpanFromEntity(entity, document);
					Span<Term> holderSpan = KAFDocument.newTermSpan();
//					Span<Term> targetSpan = KAFDocument.newTermSpan();

					if (expressionSpan.size() == 0) {
						LOGGER.debug("Expression span is empty [{}/{}]", nafFile.getName(), entity.localURI);
						continue;
					}

					Integer sentence = sentenceForSpan(expressionSpan);
					if (sentence == null) {
						LOGGER.warn("Expression span is not in sentence [{}/{}]", nafFile.getName(), entity.localURI);
						continue;
					}

					Opinion opinion = document.newOpinion();
					opinion.setLabel("gold-eu.fbk.dkm.pikes.resources.mpqa-subjective");
File Project Line
eu/fbk/dkm/pikes/resources/ontonotes/frames/Rel.java pikes-resources 19
eu/fbk/dkm/pikes/resources/util/propbank/Rel.java pikes-resources 17
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
    "value"
})
@XmlRootElement(name = "rel")
public class Rel {

    @XmlAttribute(name = "f")
    @XmlJavaTypeAdapter(NormalizedStringAdapter.class)
    protected String f;
    @XmlValue
    protected String value;

    /**
     * Recupera il valore della proprietà f.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getF() {
        return f;
    }

    /**
     * Imposta il valore della proprietà f.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setF(String value) {
        this.f = value;
    }

    /**
     * Recupera il valore della proprietà value.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getvalue() {
        return value;
    }

    /**
     * Imposta il valore della proprietà value.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setvalue(String value) {
        this.value = value;
    }

}
File Project Line
eu/fbk/dkm/pikes/resources/ontonotes/frames/Text.java pikes-resources 19
eu/fbk/dkm/pikes/resources/util/propbank/Text.java pikes-resources 17
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
    "value"
})
@XmlRootElement(name = "text")
public class Text {

    @XmlAttribute(name = "src")
    @XmlJavaTypeAdapter(NormalizedStringAdapter.class)
    protected String src;
    @XmlValue
    protected String value;

    /**
     * Recupera il valore della proprietà src.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getSrc() {
        return src;
    }

    /**
     * Imposta il valore della proprietà src.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setSrc(String value) {
        this.src = value;
    }

    /**
     * Recupera il valore della proprietà value.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getvalue() {
        return value;
    }

    /**
     * Imposta il valore della proprietà value.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setvalue(String value) {
        this.value = value;
    }

}
File Project Line
eu/fbk/dkm/pikes/resources/trec/FBIS.java pikes-resources 146
eu/fbk/dkm/pikes/resources/trec/FR94.java pikes-resources 152
                .replaceAll("</?3>", "")
        );
        stringBuffer.append("\n</ROOT>\n");

        InputStream is = new ByteArrayInputStream(stringBuffer.toString().getBytes());
        DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
        DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
        Document doc = dBuilder.parse(is);

        doc.getDocumentElement().normalize();

        int i = 0;
        for (Element element : JOOX.$(doc).find("DOC")) {
            Element docnoElement = JOOX.$(element).find("DOCNO").get(0);
            Element dateElement = JOOX.$(element).find("DATE1").get(0);
File Project Line
eu/fbk/dkm/pikes/tintopclient/TintopOrchestrator.java pikes-tintop-client 93
eu/fbk/dkm/pikes/tintop/FolderOrchestrator.java pikes-tintop 122
                    logger.debug(naf);
                    if (naf != null) {
                        logger.info("Writing file " + outputFile);
                        Files.createParentDirs(outputFile);
                        try (Writer w = IO.utf8Writer(IO.buffer(IO.write(outputFile.getAbsolutePath())))) {
                            w.write(naf);
                        }
                    }

                } catch (final Throwable ex) {
                    logger.error(filename + " --- " + ex.getMessage());
                    markFileAsNotDone(filename);

                    try {
                        logger.info("Sleeping...");
                        Thread.sleep(sleepingTime);

Back to top

Last Published: 2017/05/24.

Reflow Maven skin by Andrius Velykis.

Data and Knowledge Management tools