Package dk.brics.automaton

Examples of dk.brics.automaton.Automaton


    }
    public static Automaton getLanguageRangeAutomaton(String languageRange) {
        if ("*".equals(languageRange))
            return s_anyStringWithNonemptyLangTag;
        else {
            Automaton languageTagPart=BasicAutomata.makeString(languageRange.toLowerCase()).concatenate(s_languagePatternEnd);
            return s_anyString.concatenate(s_separator).concatenate(languageTagPart);
        }
    }
View Full Code Here


    public ValueSpaceSubset createValueSpaceSubset(DatatypeRestriction datatypeRestriction) {
        assert s_managedDatatypeURIs.contains(datatypeRestriction.getDatatypeURI());
        if (datatypeRestriction.getNumberOfFacetRestrictions()==0)
            return ANY_URI_ALL;
        else {
            Automaton automaton=getAutomatonFor(AnyURIValueSpaceSubset.s_anyURI,datatypeRestriction);
            if (automaton==null)
                return EMPTY_SUBSET;
            else
                return new AnyURIValueSpaceSubset(automaton);
        }
View Full Code Here

    public ValueSpaceSubset conjoinWithDR(ValueSpaceSubset valueSpaceSubset,DatatypeRestriction datatypeRestriction) {
        assert s_managedDatatypeURIs.contains(datatypeRestriction.getDatatypeURI());
        if (valueSpaceSubset==EMPTY_SUBSET || datatypeRestriction.getNumberOfFacetRestrictions()==0)
            return valueSpaceSubset;
        else {
            Automaton restrictionAutomaton=getAutomatonFor(((AnyURIValueSpaceSubset)valueSpaceSubset).m_automaton,datatypeRestriction);
            if (restrictionAutomaton==null)
                return EMPTY_SUBSET;
            else
                return new AnyURIValueSpaceSubset(restrictionAutomaton);
        }
View Full Code Here

    public ValueSpaceSubset conjoinWithDRNegation(ValueSpaceSubset valueSpaceSubset,DatatypeRestriction datatypeRestriction) {
        assert s_managedDatatypeURIs.contains(datatypeRestriction.getDatatypeURI());
        if (valueSpaceSubset==EMPTY_SUBSET || datatypeRestriction.getNumberOfFacetRestrictions()==0)
            return EMPTY_SUBSET;
        else {
            Automaton restrictionAutomaton=getAutomatonFor(AnyURIValueSpaceSubset.s_anyURI,datatypeRestriction);
            if (restrictionAutomaton==null)
                return valueSpaceSubset;
            Automaton difference=((AnyURIValueSpaceSubset)valueSpaceSubset).m_automaton.minus(restrictionAutomaton);
            if (difference.isEmpty())
                return EMPTY_SUBSET;
            else
                return new AnyURIValueSpaceSubset(difference);
        }
    }
View Full Code Here

                minLength=Math.max(minLength,(Integer)facetDataValue);
                maxLength=Math.min(maxLength,(Integer)facetDataValue);
            }
            else if ((XSD_NS+"pattern").equals(facetURI)) {
                String pattern=(String)facetDataValue;
                Automaton facetAutomaton=AnyURIValueSpaceSubset.getPatternAutomaton(pattern);
                automaton=automaton.intersection(facetAutomaton);
            }
            else
                throw new UnsupportedFacetException("Facet with URI '"+facetURI+"' not supported on xsd:anyURI.");
        }
View Full Code Here

      next.get(contents.charAt(pathlen)).addContents(contents, pathlen+1);
    }
  }
 
  Automaton toAutomaton() {
    Automaton a = new Automaton();
    a.getInitialState();   
    a.setInitialState(makeState());
    return a;
  }
View Full Code Here

            sb.append(Integer.toString(getNumberForOntId(custType)));
          }
          sb.append("))?");
        }
        //System.out.println(sb.toString());
        Automaton subAut = new RegExp(sb.toString()).toAutomaton();
        //System.out.println(subAut.isDeterministic());
        //mainAut = mainAut.union(subAut);
        List<Automaton> autList = autLists.get(type);
        if(autList == null) {
          autList = new ArrayList<Automaton>();
View Full Code Here

 
  private void buildForType(String type) {
    if(autLists.containsKey(type)) {
      if(verbose) System.out.print("Building DFA for: " + type + " at " + new GregorianCalendar().getTime() + "...");
      if(verbose) System.out.println();
      Automaton mainAut;
      //if(verbose) System.out.println("Building DFA from " + autLists.get(type).size() + " items.");
      mainAut = Automaton.union(autLists.get(type));
      System.gc();
      if(verbose) {
        System.out.println("Memory: " + Runtime.getRuntime().freeMemory() + " " + Runtime.getRuntime().totalMemory() + " " + Runtime.getRuntime().maxMemory());
      }
      mainAut.determinize();
      if(verbose) {
        System.out.println("DFA initialised");
        System.out.println("Memory: " + Runtime.getRuntime().freeMemory() + " " + Runtime.getRuntime().totalMemory() + " " + Runtime.getRuntime().maxMemory());
      }
      runAuts.put(type, new RunAutomaton(mainAut, false));
      autLists.remove(type);     
    }
    if(simpleAuts.containsKey(type)) {
      if(verbose) System.out.println("Building DFA for: " + type + "b at " + new GregorianCalendar().getTime() + "... ");
      Automaton mainAut = simpleAuts.get(type).toAutomaton();
      if(verbose) System.out.println("DFA initialised");
      runAuts.put(type + "b", new RunAutomaton(mainAut, false));     
      simpleAuts.remove(type);
    }
  }
View Full Code Here

  }
 
  private void finishInit() {
    for(String type : new HashSet<String>(autLists.keySet())) {
      if(verbose) System.out.println("Building DFA for: " + type + " at " + new GregorianCalendar().getTime() + "...");
      Automaton mainAut;
      //if(verbose) System.out.println("Building DFA from " + autLists.get(type).size() + " items.");
      mainAut = Automaton.union(autLists.get(type));
      System.gc();
      if(verbose) {
        System.out.println("Memory: " + Runtime.getRuntime().freeMemory() + " " + Runtime.getRuntime().totalMemory() + " " + Runtime.getRuntime().maxMemory());
      }
      mainAut.determinize();
      if(verbose) System.out.println("DFA initialised");
      if(verbose) {
        System.out.println("Memory: " + Runtime.getRuntime().freeMemory() + " " + Runtime.getRuntime().totalMemory() + " " + Runtime.getRuntime().maxMemory());
      }
      runAuts.put(type, new RunAutomaton(mainAut, false));
      autLists.remove(type);
    }
    for(String type : new HashSet<String>(simpleAuts.keySet())) {
      if(verbose) System.out.println("Building DFA for: " + type + "b at " + new GregorianCalendar().getTime() + "... ");
      Automaton mainAut = simpleAuts.get(type).toAutomaton();
      if(verbose) System.out.println("DFA initialised");
      runAuts.put(type + "b", new RunAutomaton(mainAut, false));     
      simpleAuts.remove(type);
    }
    if(verbose) System.out.println("All DFAs built");
View Full Code Here

      if (isRE(pattern)) {
        // Replace ${username} with ":USERNAME:" as : is not legal
        // in a reference and the string :USERNAME: is not likely to
        // be a valid part of the regex. This later allows the pattern
        // prefix to be clipped, saving time on evaluation.
        Automaton am = RefControl.toRegExp(
            template.replace(Collections.singletonMap("username", ":USERNAME:")))
            .toAutomaton();
        String rePrefix = am.getCommonPrefix();
        prefix = rePrefix.substring(0, rePrefix.indexOf(":USERNAME:"));
      } else {
        prefix = pattern.substring(0, pattern.indexOf("${"));
      }
    }
View Full Code Here

TOP

Related Classes of dk.brics.automaton.Automaton

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.