コード例 #1
0
  @Override
  public void initialize(UimaContext aContext) throws ResourceInitializationException {
    super.initialize(aContext);

    posMappingProvider =
        MappingProviderFactory.createPosMappingProvider(
            posMappingLocation, posTagset, getLanguage());
  }
コード例 #2
0
  @Override
  public void initialize(UimaContext aContext) throws ResourceInitializationException {
    super.initialize(aContext);

    posMappingProvider =
        MappingProviderFactory.createPosMappingProvider(
            posMappingLocation, posTagset, getLanguage());

    constituentMappingProvider =
        MappingProviderFactory.createConstituentMappingProvider(
            constituentMappingLocation, constituentTagset, getLanguage());

    converter = new PennTreeToJCasConverter(posMappingProvider, constituentMappingProvider);
    converter.setInternTags(internTags);
    converter.setWriteTracesToText(writeTracesToText);
    converter.setCreatePosTags(false); // We handle POS tags via the column already
    converter.setRootLabel("TOP");
  }
コード例 #3
0
  @Override
  public void initialize(UimaContext aContext) throws ResourceInitializationException {
    super.initialize(aContext);

    modelProvider =
        new ModelProviderBase<TreeTaggerWrapper<Token>>() {
          private TreeTaggerWrapper<Token> treetagger;

          {
            setContextObject(TreeTaggerPosTagger.this);

            setDefault(ARTIFACT_ID, "${groupId}.treetagger-model-tagger-${language}-${variant}");
            setDefault(
                LOCATION, "classpath:/${package}/lib/tagger-${language}-${variant}.properties");
            // setDefaultVariantsLocation("de/tudarmstadt/ukp/dkpro/core/treetagger/lib/tagger-default-variants.map");
            setDefault(VARIANT, "le"); // le = little-endian

            setOverride(LOCATION, modelLocation);
            setOverride(LANGUAGE, language);
            setOverride(VARIANT, variant);

            treetagger = new TreeTaggerWrapper<Token>();
            treetagger.setPerformanceMode(performanceMode);
            DKProExecutableResolver executableProvider = new DKProExecutableResolver(treetagger);
            executableProvider.setExecutablePath(executablePath);
            treetagger.setExecutableProvider(executableProvider);
            treetagger.setAdapter(
                new TokenAdapter<Token>() {
                  @Override
                  public String getText(Token aObject) {
                    synchronized (aObject.getCAS()) {
                      return aObject.getCoveredText();
                    }
                  }
                });
          }

          @Override
          protected TreeTaggerWrapper<Token> produceResource(URL aUrl) throws IOException {
            Properties meta = getResourceMetaData();
            String encoding = modelEncoding != null ? modelEncoding : meta.getProperty("encoding");
            String tagset = meta.getProperty("pos.tagset");

            File modelFile = ResourceUtils.getUrlAsFile(aUrl, true);

            // Reconfigure tagger
            treetagger.setModel(modelFile.getPath() + ":" + encoding);

            // Get tagset
            List<String> tags = TreeTaggerModelUtil.getTagset(modelFile, encoding);
            SingletonTagset posTags = new SingletonTagset(POS.class, tagset);
            posTags.addAll(tags);
            addTagset(posTags);

            if (printTagSet) {
              getContext().getLogger().log(INFO, getTagset().toString());
            }

            return treetagger;
          }
        };

    posMappingProvider =
        MappingProviderFactory.createPosMappingProvider(
            posMappingLocation, language, modelProvider);
  }