Package org.maltparserx.core.propagation

Examples of org.maltparserx.core.propagation.PropagationException


            Element root = null;

            root = db.parse(url.openStream()).getDocumentElement();

            if (root == null) {
              throw new PropagationException("The propagation specification file '"+url.getFile()+"' cannot be found. ");
            }
           
            readPropagationSpecs(root, propagationSpecs);
        } catch (IOException e) {
          throw new PropagationException("The propagation specification file '"+url.getFile()+"' cannot be found. ", e);
        } catch (ParserConfigurationException e) {
          throw new PropagationException("Problem parsing the file "+url.getFile()+". ", e);
        } catch (SAXException e) {
          throw new PropagationException("Problem parsing the file "+url.getFile()+". ", e);
        }
  }
View Full Code Here


  }
 
  private void readPropagationSpec(Element propagation, PropagationSpecs propagationSpecs) throws MaltChainedException {
    int nFrom = propagation.getElementsByTagName("from").getLength();
    if (nFrom < 1 && nFrom > 1) {
      throw new PropagationException("Propagation specification wrongly formatted: Number of 'from' elements is '"+nFrom+"', must be 1.");
    }
   
    int nTo = propagation.getElementsByTagName("to").getLength();
    if (nTo < 1 && nTo > 1) {
      throw new PropagationException("Propagation specification wrongly formatted: Number of 'to' elements is '"+nTo+"', must be 1.");
    }
   
    int nFor = propagation.getElementsByTagName("for").getLength();
    if (nFor > 1) {
      throw new PropagationException("Propagation specification wrongly formatted: Number of 'for' elements is '"+nFor+"', at most 1.");
    }
   
    int nOver = propagation.getElementsByTagName("over").getLength();
    if (nOver > 1) {
      throw new PropagationException("Propagation specification wrongly formatted: Number of 'over' elements is '"+nOver+"',at most 1.");
    }
    String fromText = ((Element)propagation.getElementsByTagName("from").item(0)).getTextContent().trim();
    if (fromText.length() == 0) {
      throw new PropagationException("Propagation specification wrongly formatted: The 'from' element is empty");
    }
    String toText = ((Element)propagation.getElementsByTagName("to").item(0)).getTextContent().trim();
    if (toText.length() == 0) {
      throw new PropagationException("Propagation specification wrongly formatted: The 'to' element is empty");
    }
    String forText = "";
    if (nFor != 0) {
      forText = ((Element)propagation.getElementsByTagName("for").item(0)).getTextContent().trim();
    }
View Full Code Here

TOP

Related Classes of org.maltparserx.core.propagation.PropagationException

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.