Package org.apache.uima.annotator.dict_annot.dictionary.impl

Examples of org.apache.uima.annotator.dict_annot.dictionary.impl.HashMapDictionary


      HashMapDictionaryBuilder dictBuilder = new HashMapDictionaryBuilder();
      // create dictionary file parser
      DictionaryFileParser fileParser = new DictionaryFileParserImpl();
      fileParser.parseDictionaryFile(dictFile.getAbsolutePath(), stream,
            dictBuilder);
      HashMapDictionary dict = (HashMapDictionary) dictBuilder.getDictionary();

      // read dictionary entries
      ArrayList<String> entries = getDictionaryEntries(dictFile);

      for (int i = 0; i < entries.size(); i++) {

         Assert.assertTrue("Missing in dictionary: " + entries.get(i), dict
               .contains(entries.get(i)));
      }

      Assert.assertTrue(dict.contains("CpE"));
      Assert.assertTrue(dict.contains("CPE"));
      Assert.assertTrue(dict.contains("cpe"));
      Assert.assertEquals(2761, dict.getEntryCount());
   }
View Full Code Here


      // create dictionary file parser
      DictionaryFileParser fileParser = new DictionaryFileParserImpl();
      fileParser.parseDictionaryFile(dictFile.getAbsolutePath(), stream,
            dictBuilder);

      HashMapDictionary dict = (HashMapDictionary) dictBuilder.getDictionary();

      // read dictionary entries
      ArrayList<String> entries = getDictionaryEntries(dictFile);

      for (int i = 0; i < entries.size(); i++) {

         Assert.assertTrue("Missing in dictionary: " + entries.get(i), dict
               .contains(entries.get(i)));
      }

      Assert.assertFalse(dict.contains("CpE"));
      Assert.assertTrue(dict.contains("CPE"));
      Assert.assertTrue(dict.contains("cpe"));
      Assert.assertEquals(3337, dict.getEntryCount());
   }
View Full Code Here

      HashMapDictionaryBuilder dictBuilder = new HashMapDictionaryBuilder();
      // create dictionary file parser
      DictionaryFileParser fileParser = new DictionaryFileParserImpl();
      fileParser.parseDictionaryFile(dictFile.getAbsolutePath(), stream,
            dictBuilder);
      HashMapDictionary dict = (HashMapDictionary) dictBuilder.getDictionary();

      // read dictionary entries
      ArrayList<String> entries = getDictionaryEntries(dictFile);

      for (int i = 0; i < entries.size(); i++) {

         StringTokenizer tokenizer = new StringTokenizer(entries.get(i),
               dictBuilder.getMultiWordSeparator());

         ArrayList<String> list = new ArrayList<String>();
         while (tokenizer.hasMoreTokens()) {
            list.add(tokenizer.nextToken());
         }
         String[] multiWord = list.toArray(new String[] {});

         Assert.assertTrue("Missing in dictionary: " + entries.get(i), dict
               .contains(multiWord));
      }

      Assert.assertEquals(5, dict.getEntryCount());
      Assert.assertFalse(dict.contains(new String[] { "Unstructured",
            "Information", "Management", "Architecture" }));
      Assert.assertTrue(dict.contains(new String[] { "new", "York" }));
      Assert.assertTrue(dict.contains(new String[] { "new", "York", "City" }));
   }
View Full Code Here

      HashMapDictionaryBuilder dictBuilder = new HashMapDictionaryBuilder();
      // create dictionary file parser
      DictionaryFileParser fileParser = new DictionaryFileParserImpl();
      fileParser.parseDictionaryFile(dictFile.getAbsolutePath(), stream,
            dictBuilder);
      HashMapDictionary dict = (HashMapDictionary) dictBuilder.getDictionary();

      // read dictionary entries
      ArrayList<String> entries = getDictionaryEntries(dictFile);

      for (int i = 0; i < entries.size(); i++) {

         StringTokenizer tokenizer = new StringTokenizer(entries.get(i),
               dictBuilder.getMultiWordSeparator());

         ArrayList<String> list = new ArrayList<String>();
         while (tokenizer.hasMoreTokens()) {
            list.add(tokenizer.nextToken());
         }
         String[] multiWord = list.toArray(new String[] {});

         Assert.assertTrue("Missing in dictionary: " + entries.get(i), dict
               .contains(multiWord));
      }

      Assert.assertEquals(4, dict.getEntryCount());
      Assert.assertFalse(dict.contains(new String[] { "Unstructured",
            "Information", "Management", "Architecture" }));
      Assert.assertTrue(dict.contains(new String[] { "new", "yORk" }));
      Assert.assertTrue(dict.contains(new String[] { "new", "york", "city" }));
      Assert.assertFalse(dict.contains("new"));
   }
View Full Code Here

      HashMapDictionaryBuilder dictBuilder = new HashMapDictionaryBuilder();
      // create dictionary file parser
      DictionaryFileParser fileParser = new DictionaryFileParserImpl();
      fileParser.parseDictionaryFile(dictFile.getAbsolutePath(), stream,
            dictBuilder);
      HashMapDictionary dict = (HashMapDictionary) dictBuilder.getDictionary();

      // read dictionary entries
      ArrayList<String> entries = getDictionaryEntries(dictFile);

      for (int i = 0; i < entries.size(); i++) {

         StringTokenizer tokenizer = new StringTokenizer(entries.get(i),
               dictBuilder.getMultiWordSeparator());

         ArrayList<String> list = new ArrayList<String>();
         while (tokenizer.hasMoreTokens()) {
            list.add(tokenizer.nextToken());
         }
         String[] multiWord = list.toArray(new String[] {});

         Assert.assertTrue("Missing in dictionary: " + entries.get(i), dict
               .contains(multiWord));
      }

      Assert.assertEquals(4, dict.getEntryCount());
      Assert.assertFalse(dict.contains(new String[] { "Unstructured",
            "Information", "Management", "Architecture" }));
      Assert.assertTrue(dict.contains(new String[] { "new", "yORk" }));
      Assert.assertTrue(dict.contains(new String[] { "new", "york", "city" }));
      Assert.assertFalse(dict.contains("new"));
   }
View Full Code Here

      HashMapDictionaryBuilder dictBuilder = new HashMapDictionaryBuilder();
      // create dictionary file parser
      DictionaryFileParser fileParser = new DictionaryFileParserImpl();
      fileParser.parseDictionaryFile(dictFile.getAbsolutePath(), stream,
            dictBuilder);
      HashMapDictionary dict = (HashMapDictionary) dictBuilder.getDictionary();

      //create dictionary content output file
      File outputFile = new File(JUnitExtension
            .getFile("DictionaryBuilderTests"),
            "dictionaryPrinting_testoutput.txt");
      FileWriter writer = new FileWriter(outputFile);

      //print dictionary content to file
      dict.printDictionary(writer);
     
      writer.flush();
      writer.close();
     
      //compare dictionary content with reference content
View Full Code Here

TOP

Related Classes of org.apache.uima.annotator.dict_annot.dictionary.impl.HashMapDictionary

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.