Beispiel #1
0
  @Override
  public void initialize(UimaContext aContext) throws ResourceInitializationException {
    super.initialize(aContext);

    this.ts = new TreeSerializer();
    this.parameterList = Commons.getParameterList();
  }
Beispiel #2
0
  @Override
  public void initialize(UimaContext context) throws ResourceInitializationException {
    super.initialize(context);

    try {
      // setup connection
      ConnectionFactory factory = new ConnectionFactory();
      if (amqpUri == null) {
        factory.setHost("localhost");
      } else {
        factory.setUri(amqpUri);
      }
      Connection connection = factory.newConnection();
      LOG.info(" [RabbitWriter] Connected to Rabbit");

      // setup channels
      sendChannel = connection.createChannel();
      Map<String, Object> args = map();
      args.put("x-max-length", 1000);
      sendChannel.queueDeclare(queue, DURABLE, false, false, args);

    } catch (Exception e) {
      throw new ResourceInitializationException(e);
    }
  }
  @Override
  public void initialize(UimaContext context) throws ResourceInitializationException {
    super.initialize(context);

    modelProvider =
        new ModelProviderBase<File>() {
          {
            setContextObject(LangDetectLanguageIdentifier.this);

            setDefault(ARTIFACT_ID, "${groupId}.langdetect-model-${language}-${variant}");
            setDefault(
                LOCATION,
                "classpath:/${package}/lib/languageidentifier-${language}-${variant}.properties");
            setDefault(VARIANT, "wikipedia");

            setOverride(LOCATION, modelLocation);
            setOverride(LANGUAGE, "any");
            setOverride(VARIANT, variant);
          }

          @Override
          protected File produceResource(URL aUrl) throws IOException {
            try {
              DetectorFactory.clear();
              File profileFolder = ResourceUtils.getClasspathAsFolder(aUrl.toString(), false);
              DetectorFactory.loadProfile(profileFolder);
              return profileFolder;
            } catch (LangDetectException e) {
              throw new IOException(e);
            }
          }
        };
  }
  public void initialize(UimaContext uimaContext) throws ResourceInitializationException {
    super.initialize(uimaContext);
    if (windowTypeName != null)
      windowClass = InitializableFactory.getClass(windowTypeName, Annotation.class);

    if (leftParenthesis.length() != 1) {
      throw CleartkInitializationException.notSingleCharacter(
          PARAM_LEFT_PARENTHESIS, leftParenthesis);
    }
    leftParen = leftParenthesis.charAt(0);

    if (rightParenthesis.length() != 1) {
      throw CleartkInitializationException.notSingleCharacter(
          PARAM_RIGHT_PARENTHESIS, rightParenthesis);
    }
    rightParen = rightParenthesis.charAt(0);

    Class<? extends Annotation> parentheticalClass =
        InitializableFactory.getClass(parentheticalTypeName, Annotation.class);

    try {
      parentheticalConstructor =
          parentheticalClass.getConstructor(new Class[] {JCas.class, Integer.TYPE, Integer.TYPE});
    } catch (Exception e) {
      throw new ResourceInitializationException(e);
    }
  }
  @Override
  public void initialize(UimaContext context) throws ResourceInitializationException {
    super.initialize(context);

    this.outputDirectory = new File(outputDirectoryName);
    if (!this.outputDirectory.exists()) {
      this.outputDirectory.mkdirs();
    }
  }
 @Override
 public void initialize(UimaContext aContext) throws ResourceInitializationException {
   super.initialize(aContext);
   try {
     names = new HashSet<String>(readLines(dictionaryFile));
   } catch (IOException e) {
     throw new ResourceInitializationException(e);
   }
 }
  /**
   * The input files for each ngram level is read, splitted according to the frequency of the words
   * starting letter in the files and the split files are individually sorted and consolidated.
   */
  @Override
  public void collectionProcessComplete() throws AnalysisEngineProcessException {
    super.collectionProcessComplete();

    try {
      converter.createIndex();
    } catch (IOException e) {
      throw new AnalysisEngineProcessException(e);
    }
  }
  public void initialize(UimaContext aContext) throws ResourceInitializationException {
    super.initialize(aContext);

    modelName = "AnswerScoreDecisionForest" + scoringPhase + ".model";

    /* Load and parse the model. */
    try {
      loadModel(AnswerScoreDecisionForest.class.getResourceAsStream(modelName));
    } catch (Exception e) {
      throw new ResourceInitializationException(e);
    }
    logger.debug("model " + modelName);
  }
  @Override
  public void initialize(UimaContext aContext) throws ResourceInitializationException {
    super.initialize(aContext);

    patterns = new SplitPattern[rawPatterns.length];
    for (int i = 0; i < rawPatterns.length; i++) {
      if (rawPatterns[i].startsWith(INCLUDE_PREFIX)) {
        patterns[i] = new SplitPattern(rawPatterns[i].substring(INCLUDE_PREFIX.length()), true);
      } else if (rawPatterns[i].startsWith(EXCLUDE_PREFIX)) {
        patterns[i] = new SplitPattern(rawPatterns[i].substring(EXCLUDE_PREFIX.length()), false);
      } else {
        patterns[i] = new SplitPattern(rawPatterns[i], false);
      }
    }
  }
  @Override
  public void initialize(UimaContext context) throws ResourceInitializationException {
    super.initialize(context);

    try {
      this.converter = new Web1TConverter(outputPath, minNgramLength, maxNgramLength);
    } catch (IOException e) {
      throw new ResourceInitializationException(e);
    }

    converter.setWriteIndexes(createIndexes);
    converter.setSplitThreshold(splitThreshold);
    converter.setMinFrequency(minFreq);
    converter.setToLowercase(lowercase);
    converter.setOutputEncoding(outputEncoding);
  }
 @Override
 public void initialize(UimaContext context) throws ResourceInitializationException {
   super.initialize(context);
   instanceList = new InstanceList(new TokenSequence2FeatureSequence());
 }
 @Override
 public void initialize(UimaContext aContext) throws ResourceInitializationException {
   super.initialize(aContext);
   ampPattern = Pattern.compile(Pattern.quote("&amp;"));
 }
  @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);
  }