Ejemplo n.º 1
0
  private CNGramsStats extractFragment(final String content, String label)
      throws SemanticAnalysisException {
    int nGramRank = -1;

    CText document = new CText(content);
    CNGramsStats nGramsFrequencyStats = new CNGramsStats(label);

    CNGramsGenerator nGramsExtractor = new CNGramsGenerator(nGramsFrequencyStats);
    if (nGramsExtractor.extract(document, content)) {
      nGramsFrequencyStats = nGramsExtractor.getNGramsFrequencyStats();
      if (nGramsFrequencyStats != null) {
        NTaxonomiesConn taxonomyConnection =
            CTaxonomyConnectionsPool.getInstance().getLabelsAndCatsConnection();
        CTaxonomyExtractor taxonomyExtractor = new CTaxonomyExtractor(taxonomyConnection);
        if (taxonomyExtractor.extract(document)) {

          /*
           * Walk through the list of taxonomyInstance nouns from
           * this document document to extract statistics for the label.
           */
          int rank = 0;
          /*
          for( CTaxonomyInstance taxonomyInstance : document.getObjectsMap().values()) {
          	if( label.compareTo(taxonomyInstance.getLabel()) == 0) {
          		nGramRank = rank;
          		break;
          	}
          	rank++;
          }
          */
        }
      }
    }

    return (nGramRank >= 0) ? nGramsFrequencyStats : null;
  }
 /** Create a text semantic service. */
 public CTextSemanticService(short index) throws SemanticAnalysisException {
   _taxonomyConnection = CTaxonomyConnectionsPool.getInstance().getLabelsConnection();
   _textIndex = index;
 }