Package org.maltparserx.core.helper

Examples of org.maltparserx.core.helper.URLFinder


        if (!learner.startsWith("lib")) {
          learner = "lib"+learner;
        }
        /* END: Temp fix during development of new liblinear and libsvm interface */
        featureModelFileName = featureModelFileName.replace("{learner}", learner);
        final URLFinder f = new URLFinder();
        featureModelFileName = configDir.copyToConfig(f.findURLinJars(featureModelFileName));
      } else {
        featureModelFileName = configDir.copyToConfig(featureModelFileName);
      }
      OptionManager.instance().overloadOptionValue(optionContainerIndex, "guide", "features", featureModelFileName);
      if (configDir.getInfoFileWriter() != null) {
View Full Code Here


    return new DataFormatInstance(entries, symbolTables, nullValueStrategy, this); //rootLabel, this);

  }
 
  public void parseDataFormatXMLfile(String fileName) throws MaltChainedException {
    final URLFinder f = new URLFinder();
    URL url = f.findURL(fileName);
    if (url == null) {
      throw new DataFormatException("The data format specifcation file '"+fileName+"'cannot be found. ");
    }
    parseDataFormatXMLfile(url);
  }
View Full Code Here

    return uniqueInstance;
  }
  */
 
  public void load(String urlstring) throws MaltChainedException {
    final URLFinder f = new URLFinder();
    load(f.findURL(urlstring));
  }
View Full Code Here

    nonTerminalSymbolTable = dataFormatInstance.getSymbolTables().addSymbolTable("CAT");
    edgelabelSymbolTable = dataFormatInstance.getSymbolTables().addSymbolTable("LABEL");
  }
 
  public void parseHeadRules(String fileName) throws MaltChainedException {
    final URLFinder f = new URLFinder();
    parseHeadRules(f.findURL(fileName));
  }
View Full Code Here

  public FlowChartSystem() {
    chartElements = new HashMap<String,ChartElement>();
  }
 
  public void load(String urlstring) throws MaltChainedException {
    final URLFinder f = new URLFinder();
    load(f.findURL(urlstring));
  }
View Full Code Here

  }
 
  public void initDataFormat() throws MaltChainedException {
    String inputFormatName = OptionManager.instance().getOptionValue(containerIndex, "input", "format").toString().trim();
    String outputFormatName = OptionManager.instance().getOptionValue(containerIndex, "output", "format").toString().trim();
    final URLFinder f = new URLFinder();

    if (configDirectory != null && configDirectory.exists()) {
      if (outputFormatName.length() == 0 || inputFormatName.equals(outputFormatName)) {
        URL inputFormatURL = f.findURLinJars(inputFormatName);
        if (inputFormatURL != null) {
          outputFormatName = inputFormatName = this.copyToConfig(inputFormatURL);
        } else {
          outputFormatName = inputFormatName = this.copyToConfig(inputFormatName);
        }
      } else {
        URL inputFormatURL = f.findURLinJars(inputFormatName);
        if (inputFormatURL != null) {
          inputFormatName = this.copyToConfig(inputFormatURL);
        } else {
          inputFormatName = this.copyToConfig(inputFormatName);
        }
        URL outputFormatURL = f.findURLinJars(outputFormatName);
        if (inputFormatURL != null) {
          outputFormatName = this.copyToConfig(outputFormatURL);
        } else {
          outputFormatName = this.copyToConfig(outputFormatName);
        }
      }
      OptionManager.instance().overloadOptionValue(containerIndex, "input", "format", inputFormatName);
    } else {
      if (outputFormatName.length() == 0) {
        outputFormatName = inputFormatName;
      }
    }
    dataFormatInstances = new HashMap<String, DataFormatInstance>(3);
    inputFormatURL = findURL(inputFormatName);
    outputFormatURL = findURL(outputFormatName);
    if (outputFormatURL != null) {
      try {
        InputStream is = outputFormatURL.openStream();
      } catch (FileNotFoundException e) {
        outputFormatURL = f.findURL(outputFormatName);
      } catch (IOException e) {
        outputFormatURL = f.findURL(outputFormatName);
      }
    } else {
      outputFormatURL = f.findURL(outputFormatName);
    }
    dataFormatManager = new DataFormatManager(inputFormatURL, outputFormatURL);
   
    String mode = OptionManager.instance().getOptionValue(containerIndex, "config", "flowchart").toString().trim();
    if (mode.equals("parse")) {
      symbolTables = new TrieSymbolTableHandler(TrieSymbolTableHandler.ADD_NEW_TO_TMP_STORAGE);
//      symbolTables = new TrieSymbolTableHandler(TrieSymbolTableHandler.ADD_NEW_TO_TRIE);
    } else {
      symbolTables = new TrieSymbolTableHandler(TrieSymbolTableHandler.ADD_NEW_TO_TRIE);
    }
    if (dataFormatManager.getInputDataFormatSpec().getDataStructure() == DataStructure.PHRASE) {
      if (mode.equals("learn")) {
        Set<Dependency> deps = dataFormatManager.getInputDataFormatSpec().getDependencies();
        for (Dependency dep : deps) {
          URL depFormatURL = f.findURLinJars(dep.getUrlString());
          if (depFormatURL != null) {
            this.copyToConfig(depFormatURL);
          } else {
            this.copyToConfig(dep.getUrlString());
          }
View Full Code Here

    return source.getName();
    }
   

    public String copyToConfig(String fileUrl) throws MaltChainedException {
      final URLFinder f = new URLFinder();
      URL url = f.findURL(fileUrl);
      if (url == null) {
        throw new ConfigurationException("The file or URL '"+fileUrl+"' could not be found. ");
      }
      return copyToConfig(url);
    }
View Full Code Here

      JarFile jar = new JarFile(in);
      JarOutputStream tempJar = new JarOutputStream(new FileOutputStream(out));
          byte[] buffer = new byte[BUFFER];
          int bytesRead;
          final StringBuilder sb = new StringBuilder();
          final URLFinder f = new URLFinder();

          for (Enumeration<JarEntry> entries = jar.entries(); entries.hasMoreElements(); ) {
              JarEntry inEntry = (JarEntry) entries.nextElement();
              InputStream entryStream = jar.getInputStream(inEntry);
              JarEntry outEntry = versioning.getJarEntry(inEntry);
             
              if (!versioning.hasChanges(inEntry, outEntry)) {
                tempJar.putNextEntry(outEntry);
                while ((bytesRead = entryStream.read(buffer)) != -1) {
                  tempJar.write(buffer, 0, bytesRead);
                }
              } else {
                tempJar.putNextEntry(outEntry);
                BufferedReader br = new BufferedReader(new InputStreamReader(entryStream));
                String line = null;
                sb.setLength(0);
                while ((line = br.readLine()) != null) {
                  sb.append(line);
                  sb.append('\n');
                }
                String outString = versioning.modifyJarEntry(inEntry, outEntry, sb);
                tempJar.write(outString.getBytes());
              }
          }
          if (versioning.getFeatureModelXML() != null && versioning.getFeatureModelXML().startsWith("/appdata")) {
            int index = versioning.getFeatureModelXML().lastIndexOf('/');
            BufferedInputStream bis = new BufferedInputStream(f.findURLinJars(versioning.getFeatureModelXML()).openStream());
            tempJar.putNextEntry(new JarEntry(versioning.getNewConfigName()+"/" +versioning.getFeatureModelXML().substring(index+1)));
              int n = 0;
            while ((n = bis.read(buffer, 0, BUFFER)) != -1) {
              tempJar.write(buffer, 0, n);
            }
              bis.close();
          }
          if (versioning.getInputFormatXML() != null && versioning.getInputFormatXML().startsWith("/appdata")) {
            int index = versioning.getInputFormatXML().lastIndexOf('/');
            BufferedInputStream bis = new BufferedInputStream(f.findURLinJars(versioning.getInputFormatXML()).openStream());
            tempJar.putNextEntry(new JarEntry(versioning.getNewConfigName()+"/" +versioning.getInputFormatXML().substring(index+1)));
              int n = 0;
            while ((n = bis.read(buffer, 0, BUFFER)) != -1) {
              tempJar.write(buffer, 0, n);
            }
View Full Code Here

    if (dataFormat == null) {
      dataFormat = new DataFormatSpecification();
      dataFormat.parseDataFormatXMLfile(dataFormatUrl);
      fileNameDataFormatSpecs.put(dataFormatUrl.toString(), dataFormat);
      nameDataFormatSpecs.put(dataFormat.getDataFormatName(), dataFormat);
      final URLFinder f = new URLFinder();
     
      for (Dependency dep : dataFormat.getDependencies()) {
        loadDataFormat(f.findURLinJars(dep.getUrlString()));
      }
    }
    return dataFormat;
  }
View Full Code Here

  }
 
  public void initReader(Class<? extends SyntaxGraphReader> syntaxGraphReader, String inputFile, String inputCharSet, String readerOptions, int iterations) throws MaltChainedException {
    try {
      final URLFinder f = new URLFinder();
      reader = syntaxGraphReader.newInstance();
      if (inputFile == null || inputFile.length() == 0 || inputFile.equals("/dev/stdin")) {
        reader.open(System.in, inputCharSet);
      } else if (new File(inputFile).exists()) {
        reader.setNIterations(iterations);
        reader.open(inputFile, inputCharSet);
      } else {
        reader.setNIterations(iterations);
        reader.open(f.findURL(inputFile), inputCharSet);
      }
      reader.setDataFormatInstance(inputDataFormatInstance);
      reader.setOptions(readerOptions);
    } catch (InstantiationException e) {
      throw new DataFormatException("The data reader '"+syntaxGraphReader.getName()+"' cannot be initialized. ", e);
View Full Code Here

TOP

Related Classes of org.maltparserx.core.helper.URLFinder

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.