public double[] buildFeatures(Relation relation) {
    List<Concept> concepts = Collections.emptyList();
    if (relation.getType() != null) {
      this.vector = new double[dimension + 1];
      this.vector[dimension] = relation.getType().getValue();
      concepts = EMRTrain2.getConcepts();
    } else {
      this.vector = new double[dimension];
      concepts = EmrTest.getConcepts();
    }

    SimilaritySequence sequence = new SimilaritySequence();
    sequence.setPosTagSequences(DataPreprocess.posSequence(relation));
    sequence.setLemmaSequences(DataPreprocess.lemmaSequence(relation));
    sequence.setPhraseChunks(DataPreprocess.phraseChunkSequence(relation));
    sequence.setShortestPaths(DataPreprocess.shortestPath(relation));
    sequence.setAllConceptType(DataPreprocess.conceptTypeSequence(relation, concepts));

    SimilarityDataHandler dataHandler = SimilarityDataHandler.getInstance();
    double[] posResult = dataHandler.statisticPosDistance(sequence);
    double[] lemmaResult = dataHandler.statisticLemmaDistance(sequence);
    double[] phraseChunkResult = dataHandler.statisticPhraseChunksDistance(sequence);
    double[] shortestPathResult = dataHandler.statisticShortestPathDistance(sequence);
    double[] conceptTypeResult = dataHandler.statisticConceptTypeDistance(sequence);

    for (int i = 0; i < posResult.length; i++) {
      this.vector[i] = posResult[i];
    }
    for (int i = 0; i < lemmaResult.length; i++) {
      this.vector[i + 9] = lemmaResult[i];
    }
    for (int i = 0; i < phraseChunkResult.length; i++) {
      this.vector[i + 18] = phraseChunkResult[i];
    }
    for (int i = 0; i < shortestPathResult.length; i++) {
      this.vector[i + 27] = shortestPathResult[i];
    }
    for (int i = 0; i < conceptTypeResult.length; i++) {
      this.vector[i + 36] = conceptTypeResult[i];
    }

    return this.vector;
  }
Beispiel #2
0
  public double[] buildFeatures(Relation relation) {
    this.isTrain = relation.getType() != null;

    // add element vector of each feature
    List<double[]> lstVector = new ArrayList<double[]>();
    lstVector.add(this.context.buildFeatures(relation));
    lstVector.add(this.single.buildFeatures(relation));
    lstVector.add(this.vicinity.buildFeatures(relation));

    this.vector = mergeVector(lstVector);
    return this.vector;
  }