コード例 #1
0
  public static void main(String... args) throws Exception {

    System.out.println("+++Compiled New++++");

    nonTerminal = VSMUtil.getNonTerminal(args);

    LOGGER = VSMLogger.setup(FeatureVectors.class.getName() + "." + nonTerminal);

    featureDictionary =
        VSMContant.FEATURE_DICTIONARY + nonTerminal.toLowerCase() + "/dictionary.ser";

    wordDictionaryPath = VSMContant.WORD_DICT;

    LOGGER.info("Reading the Feature Dictionary Object");
    dictionaryBean = ReadSerializedDictionary.readSerializedDictionary(featureDictionary, LOGGER);

    LOGGER.info("Reading the word dictionary object");
    wordDictBean = VSMReadSerialWordDict.readSerializedDictionary(wordDictionaryPath);

    outsideFeatureDictionary = dictionaryBean.getOutsideFeatureDictionary();

    insideFeatureDictionary = dictionaryBean.getInsideFeatureDictionary();

    wordDictionary = wordDictBean.getWordDictionary();

    LOGGER.info(
        "Got the syntactic and semantic feature dictionaries, with word dictionary dimensions: "
            + wordDictionary.size());

    treeReader = VSMUtil.getTreeReader(VSMContant.SICK_TRIAL_TREES);

    LOGGER.info("GOT Training Trees File Iterator: " + treeReader);

    int treeCount = 0;

    while (treeReader.hasNext()) {

      getSynaxTree();

      if (syntaxTree != null) {

        treeCount += 1;

        syntaxTree = treeNormalizer.process(syntaxTree);

        constituentsMap = syntaxTree.getConstituents();

        Iterator<Tree<String>> nodeTrees = syntaxTree.iterator();

        while (nodeTrees.hasNext()) {

          insideTree = nodeTrees.next();

          if (!insideTree.isLeaf() && insideTree.getLabel().equalsIgnoreCase(nonTerminal)) {

            createSparseVectors();

            serializeVectorBean(treeCount);

            System.out.println("Serialized the feature vector***");
          }
        }
      }
    }

    LOGGER.info("Done Creating the Sparse Vectors For the Non Terminal: " + nonTerminal);
  }