Пример #1
0
        private string formatComment(string text)
        {
            StringBuilder stringBuilder = new StringBuilder("");

            if (text == null)
            {
                return(stringBuilder.toString());
            }
            Pattern      pattern      = Pattern.compile("[\\n\\r\\f]+");
            CharSequence charSequence = CharSequence.Cast(text);

            if (pattern.matcher(charSequence).find())
            {
                string[] array = String.instancehelper_split(text, new StringBuilder().append('[').append(JSGFRuleGrammar.LINE_SEPARATOR).append("]+").toString());
                stringBuilder.append("/**").append(JSGFRuleGrammar.LINE_SEPARATOR);
                stringBuilder.append("  *").append(array[0]).append(JSGFRuleGrammar.LINE_SEPARATOR);
                for (int i = 1; i < array.Length; i++)
                {
                    stringBuilder.append("  *").append(array[i]).append(JSGFRuleGrammar.LINE_SEPARATOR);
                }
                stringBuilder.append("  */");
                return(stringBuilder.toString());
            }
            return(new StringBuilder().append("//").append(text).toString());
        }
Пример #2
0
        public static string toXML(ConfigurationManager cm)
        {
            StringBuilder stringBuilder = new StringBuilder();

            stringBuilder.append("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n");
            stringBuilder.append("\n<!--    Sphinx-4 Configuration file--> \n\n");
            stringBuilder.append("<config>");
            Pattern  pattern          = Pattern.compile("\\_\\{(\\w+)\\}");
            Map      globalProperties = cm.getGlobalProperties();
            Iterator iterator         = globalProperties.entrySet().iterator();

            while (iterator.hasNext())
            {
                Map.Entry    entry        = (Map.Entry)iterator.next();
                string       text         = (string)entry.getKey();
                Pattern      pattern2     = pattern;
                object       _ref         = text;
                CharSequence charSequence = CharSequence.Cast(_ref);
                Matcher      matcher      = pattern2.matcher(charSequence);
                text = ((!matcher.matches()) ? text : matcher.group(1));
                stringBuilder.append("\n\t<property name=\"").append(text).append("\" value=\"").append((string)entry.getValue()).append("\"/>");
            }
            iterator = cm.getComponentNames().iterator();
            while (iterator.hasNext())
            {
                string text2 = (string)iterator.next();
                stringBuilder.append("\n\n").append(ConfigurationManagerUtils.propSheet2XML(text2, cm.getPropertySheet(text2)));
            }
            stringBuilder.append("\n</config>");
            return(stringBuilder.toString());
        }
        private static bool matches(Pattern pattern, string _ref)
        {
            CharSequence charSequence = CharSequence.Cast(_ref);
            Matcher      matcher      = pattern.matcher(charSequence);

            return(matcher.matches());
        }
Пример #4
0
 public static string getLogPrefix(ConfigurationManager cm)
 {
     if (cm.getConfigURL() != null)
     {
         StringBuilder stringBuilder = new StringBuilder();
         string        name          = new File(cm.getConfigURL().getFile()).getName();
         object        obj           = ".sxl";
         object        obj2          = "";
         object        obj3          = obj;
         CharSequence  charSequence  = CharSequence.Cast(obj3);
         CharSequence  charSequence2 = charSequence;
         obj3         = obj2;
         charSequence = CharSequence.Cast(obj3);
         string text = String.instancehelper_replace(name, charSequence2, charSequence);
         object obj4 = ".xml";
         obj3         = "";
         obj2         = obj4;
         charSequence = CharSequence.Cast(obj2);
         CharSequence charSequence3 = charSequence;
         obj2         = obj3;
         charSequence = CharSequence.Cast(obj2);
         return(stringBuilder.append(String.instancehelper_replace(text, charSequence3, charSequence)).append('.').toString());
     }
     return("S4CM.");
 }
Пример #5
0
            public override int getNextNode(object obj)
            {
                Pattern      pattern      = this.pattern;
                object       _ref         = (string)obj;
                CharSequence charSequence = CharSequence.Cast(_ref);

                return((!pattern.matcher(charSequence).matches()) ? this.qfalse : this.qtrue);
            }
        private void usMoneyToWords(string text)
        {
            int num = String.instancehelper_indexOf(text, 46);

            if (USEnglishTokenizer.matches(USEnglishTokenizer.illionPattern, (string)this.tokenItem.findFeature("n.name")))
            {
                NumberExpander.expandReal(String.instancehelper_substring(text, 1), this.wordRelation);
            }
            else if (num == -1)
            {
                string text2 = String.instancehelper_substring(text, 1);
                this.tokenToWords(text2);
                if (String.instancehelper_equals(text2, "1"))
                {
                    this.wordRelation.addWord("dollar");
                }
                else
                {
                    this.wordRelation.addWord("dollars");
                }
            }
            else if (num == String.instancehelper_length(text) - 1 || String.instancehelper_length(text) - num > 3)
            {
                NumberExpander.expandReal(String.instancehelper_substring(text, 1), this.wordRelation);
                this.wordRelation.addWord("dollars");
            }
            else
            {
                string       text3         = String.instancehelper_substring(text, 1, num);
                object       obj           = ",";
                object       obj2          = "";
                CharSequence charSequence  = CharSequence.Cast(obj);
                CharSequence charSequence2 = CharSequence.Cast(obj2);
                string       text2         = String.instancehelper_replace(text3, charSequence2, charSequence);
                string       text4         = String.instancehelper_substring(text, num + 1);
                NumberExpander.expandNumber(text2, this.wordRelation);
                if (String.instancehelper_equals(text2, "1"))
                {
                    this.wordRelation.addWord("dollar");
                }
                else
                {
                    this.wordRelation.addWord("dollars");
                }
                if (!String.instancehelper_equals(text4, "00"))
                {
                    NumberExpander.expandNumber(text4, this.wordRelation);
                    if (String.instancehelper_equals(text4, "01"))
                    {
                        this.wordRelation.addWord("cent");
                    }
                    else
                    {
                        this.wordRelation.addWord("cents");
                    }
                }
            }
        }
Пример #7
0
        public static string stripGlobalSymbol(string symbol)
        {
            Pattern      pattern      = ConfigurationManagerUtils.globalSymbolPattern;
            CharSequence charSequence = CharSequence.Cast(symbol);
            Matcher      matcher      = pattern.matcher(charSequence);

            if (matcher.matches())
            {
                return(matcher.group(1));
            }
            return(symbol);
        }
        public virtual List expand(string text)
        {
            string        inputText     = this.simplifyChars(text);
            CharTokenizer charTokenizer = new CharTokenizer();

            charTokenizer.setWhitespaceSymbols(" \t\n\r");
            charTokenizer.setSingleCharSymbols("");
            charTokenizer.setPrepunctuationSymbols("\"'`({[");
            charTokenizer.setPostpunctuationSymbols("\"'`.,:;!?(){}[]");
            charTokenizer.setInputText(inputText);
            Utterance utterance = new Utterance(charTokenizer);
            Relation  relation;

            if ((relation = utterance.getRelation("Token")) == null)
            {
                string text2 = "token relation does not exist";

                throw new IllegalStateException(text2);
            }
            this.wordRelation = WordRelation.createWordRelation(utterance, this);
            this.tokenItem    = relation.getHead();
            while (this.tokenItem != null)
            {
                FeatureSet features = this.tokenItem.getFeatures();
                string     @string  = features.getString("name");
                this.tokenToWords(@string);
                this.tokenItem = this.tokenItem.getNext();
            }
            ArrayList arrayList = new ArrayList();

            for (Item item = utterance.getRelation("Word").getHead(); item != null; item = item.getNext())
            {
                if (!String.instancehelper_isEmpty(item.toString()))
                {
                    string       text3        = item.toString();
                    object       _ref         = "#";
                    CharSequence charSequence = CharSequence.Cast(_ref);
                    if (!String.instancehelper_contains(text3, charSequence))
                    {
                        arrayList.add(item.toString());
                    }
                }
            }
            return(arrayList);
        }
Пример #9
0
        public static URL resourceToURL(string location)
        {
            Pattern      pattern      = ConfigurationManagerUtils.jarPattern;
            object       _ref         = location;
            CharSequence charSequence = CharSequence.Cast(_ref);
            Matcher      matcher      = pattern.matcher(charSequence);

            if (matcher.matches())
            {
                string text = matcher.group(1);
                return(ClassLiteral <ConfigurationManagerUtils> .Value.getResource(text));
            }
            if (String.instancehelper_indexOf(location, 58) == -1)
            {
                location = new StringBuilder().append("file:").append(location).toString();
            }
            return(new URL(location));
        }
Пример #10
0
        public static void expandOrdinal(string rawNumberString, WordRelation wordRelation)
        {
            object       obj           = ",";
            object       obj2          = "";
            object       _ref          = obj;
            CharSequence charSequence  = CharSequence.Cast(_ref);
            CharSequence charSequence2 = charSequence;

            _ref         = obj2;
            charSequence = CharSequence.Cast(_ref);
            NumberExpander.expandNumber(String.instancehelper_replace(rawNumberString, charSequence2, charSequence), wordRelation);
            Item tail = wordRelation.getTail();

            if (tail != null)
            {
                FeatureSet features = tail.getFeatures();
                string     @string  = features.getString("name");
                string     text     = NumberExpander.findMatchInArray(@string, NumberExpander.digit2num, NumberExpander.ord2num);
                if (text == null)
                {
                    text = NumberExpander.findMatchInArray(@string, NumberExpander.digit2teen, NumberExpander.ord2teen);
                }
                if (text == null)
                {
                    text = NumberExpander.findMatchInArray(@string, NumberExpander.digit2enty, NumberExpander.ord2enty);
                }
                if (String.instancehelper_equals(@string, "hundred"))
                {
                    text = "hundredth";
                }
                else if (String.instancehelper_equals(@string, "thousand"))
                {
                    text = "thousandth";
                }
                else if (String.instancehelper_equals(@string, "billion"))
                {
                    text = "billionth";
                }
                if (text != null)
                {
                    wordRelation.setLastWord(text);
                }
            }
        }
Пример #11
0
        public override float getProbability(WordSequence wordSequence)
        {
            int num = wordSequence.size();

            if (num > this.maxDepth)
            {
                string text = new StringBuilder().append("Unsupported NGram: ").append(wordSequence.size()).toString();

                throw new Error(text);
            }
            Float @float;

            if (num == this.maxDepth)
            {
                @float = (Float)this.ngramProbCache.get(wordSequence);
                if (@float != null)
                {
                    this.ngramHits++;
                    return(@float.floatValue());
                }
                this.ngramMisses++;
            }
            @float = this.getNGramProbability(wordSequence);
            if (num == this.maxDepth)
            {
                this.ngramProbCache.put(wordSequence, @float);
            }
            if (this.logFile != null && @float != null)
            {
                PrintWriter   printWriter   = this.logFile;
                StringBuilder stringBuilder = new StringBuilder();
                string        text2         = wordSequence.toString();
                object        obj           = "][";
                object        obj2          = " ";
                object        _ref          = obj;
                CharSequence  charSequence  = CharSequence.Cast(_ref);
                CharSequence  charSequence2 = charSequence;
                _ref         = obj2;
                charSequence = CharSequence.Cast(_ref);
                printWriter.println(stringBuilder.append(String.instancehelper_replace(text2, charSequence2, charSequence)).append(" : ").append(Float.toString(@float.floatValue())).toString());
            }
            return(@float.floatValue());
        }
Пример #12
0
 private void loadClusters(string[] array)
 {
     this.clusters = new ArrayList[array.Length];
     for (int i = 0; i < array.Length; i++)
     {
         this.clusters[i] = null;
     }
     for (int i = 2; i < array.Length; i++)
     {
         string       text         = array[i];
         string       text2        = text;
         object       _ref         = this.tie;
         CharSequence charSequence = CharSequence.Cast(_ref);
         if (String.instancehelper_contains(text2, charSequence))
         {
             string[]  array2    = String.instancehelper_split(text, Pattern.quote(this.tie));
             ArrayList arrayList = new ArrayList(Arrays.asList(array2));
             this.clusters[i] = arrayList;
         }
     }
 }
Пример #13
0
		public virtual List expand(string text)
		{
			text = String.instancehelper_replace(text, '’', '\'');
			text = String.instancehelper_replace(text, '‘', ' ');
			text = String.instancehelper_replace(text, '”', ' ');
			text = String.instancehelper_replace(text, '“', ' ');
			text = String.instancehelper_replace(text, '"', ' ');
			text = String.instancehelper_replace(text, '»', ' ');
			text = String.instancehelper_replace(text, '«', ' ');
			text = String.instancehelper_replace(text, '–', '-');
			text = String.instancehelper_replace(text, '—', ' ');
			text = String.instancehelper_replace(text, '…', ' ');
			string text2 = text;
			object obj = " - ";
			object obj2 = " ";
			CharSequence charSequence = CharSequence.Cast(obj);
			CharSequence charSequence2 = CharSequence.Cast(obj2);

			text = String.instancehelper_replace(text2, charSequence2, charSequence);
			text = String.instancehelper_replaceAll(text, "[/_*%]", " ");
			text = String.instancehelper_toLowerCase(text);
			string[] array = String.instancehelper_split(text, "[.,?:!;()]");
			return Arrays.asList(array);
		}
Пример #14
0
        public static void setProperty(ConfigurationManager cm, string propName, string propValue)
        {
            if (!ConfigurationManagerUtils.assertionsDisabled && propValue == null)
            {
                throw new AssertionError();
            }
            Map          map            = ConfigurationManagerUtils.listAllsPropNames(cm);
            Set          componentNames = cm.getComponentNames();
            object       _ref;
            CharSequence charSequence;

            if (!map.containsKey(propName))
            {
                string text = propName;
                _ref         = "->";
                charSequence = CharSequence.Cast(_ref);
                if (!String.instancehelper_contains(text, charSequence) && !componentNames.contains(propName))
                {
                    string text2 = new StringBuilder().append("No property or configurable '").append(propName).append("' in configuration '").append(cm.getConfigURL()).append("'!").toString();

                    throw new RuntimeException(text2);
                }
            }
            if (componentNames.contains(propName))
            {
                try
                {
                    Class confClass = Class.forName(propValue, ConfigurationManagerUtils.__GetCallerID()).asSubclass(ClassLiteral <Configurable> .Value);
                    ConfigurationManagerUtils.setClass(cm.getPropertySheet(propName), confClass);
                }
                catch (ClassNotFoundException ex)
                {
                    throw new RuntimeException(ex);
                }
            }
            string text3 = propName;

            _ref         = "->";
            charSequence = CharSequence.Cast(_ref);
            if (!String.instancehelper_contains(text3, charSequence) && ((List)map.get(propName)).size() > 1)
            {
                string text4 = new StringBuilder().append("Property-name '").append(propName).append("' is ambiguous with respect to configuration '").append(cm.getConfigURL()).append("'. Use 'componentName->propName' to disambiguate your request.").toString();

                throw new RuntimeException(text4);
            }
            string text5 = propName;

            _ref         = "->";
            charSequence = CharSequence.Cast(_ref);
            string componentName;

            if (String.instancehelper_contains(text5, charSequence))
            {
                string[] array = String.instancehelper_split(propName, "->");
                componentName = array[0];
                propName      = array[1];
            }
            else
            {
                componentName = ((PropertySheet)((List)map.get(propName)).get(0)).getInstanceName();
            }
            ConfigurationManagerUtils.setProperty(cm, componentName, propName, propValue);
        }
Пример #15
0
        private void readHeader(DataInputStream dataInputStream)
        {
            int num = this.readInt(dataInputStream, this.bigEndian);

            if (num != String.instancehelper_length("Darpa Trigram LM") + 1 && num != String.instancehelper_length("Darpa Quadrigram LM") + 1 && num != String.instancehelper_length("Darpa \\d-gram LM") - 1)
            {
                num = Utilities.swapInteger(num);
                if (num != String.instancehelper_length("Darpa Trigram LM") + 1 && num != String.instancehelper_length("Darpa Quadrigram LM") + 1 && num != String.instancehelper_length("Darpa \\d-gram LM") - 1)
                {
                    string text = new StringBuilder().append("Bad binary LM file magic number: ").append(num).append(", not an LM dumpfile?").toString();

                    throw new Error(text);
                }
                this.bigEndian = false;
            }
            string text2 = this.readString(dataInputStream, num - 1);
            sbyte  b     = (sbyte)dataInputStream.readByte();

            this.bytesRead += 1L;
            CharSequence charSequence;

            if (!String.instancehelper_equals(text2, "Darpa Trigram LM") && !String.instancehelper_equals(text2, "Darpa Quadrigram LM"))
            {
                string text3 = "Darpa \\d-gram LM";
                object _ref  = text2;
                charSequence = CharSequence.Cast(_ref);
                if (!Pattern.matches(text3, charSequence))
                {
                    string text4 = new StringBuilder().append("Bad binary LM file header: ").append(text2).toString();

                    throw new Error(text4);
                }
            }
            if (String.instancehelper_equals(text2, "Darpa Trigram LM"))
            {
                this.maxNGram = 3;
            }
            else if (String.instancehelper_equals(text2, "Darpa Quadrigram LM"))
            {
                this.maxNGram = 4;
            }
            else
            {
                Pattern pattern  = Pattern.compile("\\d");
                Pattern pattern2 = pattern;
                object  _ref     = text2;
                charSequence = CharSequence.Cast(_ref);
                Matcher matcher = pattern2.matcher(charSequence);
                this.maxNGram = Integer.parseInt(matcher.group());
            }
            int num2 = this.readInt(dataInputStream, this.bigEndian);

            this.skipStreamBytes(dataInputStream, (long)num2);
            this.numberNGrams        = new int[this.maxNGram];
            this.NGramOffset         = new long[this.maxNGram];
            this.NGramProbTable      = new float[this.maxNGram][];
            this.NGramBackoffTable   = new float[this.maxNGram][];
            this.NGramSegmentTable   = new int[this.maxNGram][];
            this.numberNGrams[0]     = 0;
            this.logNGramSegmentSize = 9;
            int num3 = this.readInt(dataInputStream, this.bigEndian);

            this.bytesPerField = 2;
            if (num3 <= 0)
            {
                this.readInt(dataInputStream, this.bigEndian);
                if (num3 <= -3)
                {
                    this.bytesPerField = 4;
                }
                int i;
                while ((i = this.readInt(dataInputStream, this.bigEndian)) != 0)
                {
                    this.bytesRead += (long)dataInputStream.skipBytes(i);
                }
                if (num3 == -2)
                {
                    this.logNGramSegmentSize = this.readInt(dataInputStream, this.bigEndian);
                    if (this.logNGramSegmentSize < 1 || this.logNGramSegmentSize > 15)
                    {
                        string text5 = "log2(bg_seg_sz) outside range 1..15";

                        throw new Error(text5);
                    }
                }
                this.numberNGrams[0] = this.readInt(dataInputStream, this.bigEndian);
            }
            else
            {
                this.numberNGrams[0] = num3;
            }
            if (this.numberNGrams[0] <= 0)
            {
                string text6 = new StringBuilder().append("Bad number of unigrams: ").append(this.numberNGrams[0]).append(", must be > 0.").toString();

                throw new Error(text6);
            }
            for (int i = 1; i < this.maxNGram; i++)
            {
                int[] array  = this.numberNGrams;
                int   num4   = i;
                int   num5   = this.readInt(dataInputStream, this.bigEndian);
                int   num6   = num4;
                int[] array2 = array;
                int   num7   = num5;
                array2[num6] = num5;
                if (num7 < 0)
                {
                    string text7 = new StringBuilder().append("Bad number of ").append(String.valueOf(i)).append("-grams: ").append(this.numberNGrams[i]).toString();

                    throw new Error(text7);
                }
            }
        }
        private void tokenToWords(string text)
        {
            FeatureSet features = this.tokenItem.getFeatures();
            string     @string  = features.getString("name");
            int        num      = String.instancehelper_length(text);

            if (features.isPresent("phones"))
            {
                this.wordRelation.addWord(text);
            }
            else if ((String.instancehelper_equals(text, "a") || String.instancehelper_equals(text, "A")) && (this.tokenItem.getNext() == null || !String.instancehelper_equals(text, @string) || !String.instancehelper_equals((string)this.tokenItem.findFeature("punc"), "")))
            {
                this.wordRelation.addWord("_a");
            }
            else if (USEnglishTokenizer.matches(USEnglishTokenizer.alphabetPattern, text))
            {
                if (USEnglishTokenizer.matches(USEnglishTokenizer.romanNumbersPattern, text))
                {
                    this.romanToWords(text);
                }
                else if (USEnglishTokenizer.matches(USEnglishTokenizer.illionPattern, text) && USEnglishTokenizer.matches(USEnglishTokenizer.usMoneyPattern, (string)this.tokenItem.findFeature("p.name")))
                {
                    this.wordRelation.addWord(text);
                    this.wordRelation.addWord("dollars");
                }
                else if (USEnglishTokenizer.matches(USEnglishTokenizer.drStPattern, text))
                {
                    this.drStToWords(text);
                }
                else if (String.instancehelper_equals(text, "Mr"))
                {
                    this.tokenItem.getFeatures().setString("punc", "");
                    this.wordRelation.addWord("mister");
                }
                else if (String.instancehelper_equals(text, "Mrs"))
                {
                    this.tokenItem.getFeatures().setString("punc", "");
                    this.wordRelation.addWord("missus");
                }
                else if (num == 1 && Character.isUpperCase(String.instancehelper_charAt(text, 0)) && String.instancehelper_equals((string)this.tokenItem.findFeature("n.whitespace"), " ") && Character.isUpperCase(String.instancehelper_charAt((string)this.tokenItem.findFeature("n.name"), 0)))
                {
                    features.setString("punc", "");
                    string text2 = String.instancehelper_toLowerCase(text);
                    if (String.instancehelper_equals(text2, "a"))
                    {
                        this.wordRelation.addWord("_a");
                    }
                    else
                    {
                        this.wordRelation.addWord(text2);
                    }
                }
                else if (!this.isStateName(text))
                {
                    if (num > 1 && !this.isPronounceable(text))
                    {
                        NumberExpander.expandLetters(text, this.wordRelation);
                    }
                    else
                    {
                        this.wordRelation.addWord(String.instancehelper_toLowerCase(text));
                    }
                }
            }
            else if (USEnglishTokenizer.matches(USEnglishTokenizer.dottedAbbrevPattern, text))
            {
                object obj  = ".";
                object obj2 = "";

                CharSequence charSequence = CharSequence.Cast(obj);

                CharSequence charSequence2 = CharSequence.Cast(obj2);

                NumberExpander.expandLetters(String.instancehelper_replace(text, charSequence2, charSequence), this.wordRelation);
            }
            else if (USEnglishTokenizer.matches(USEnglishTokenizer.commaIntPattern, text))
            {
                object       obj4          = ",";
                object       obj3          = "";
                object       obj2          = obj4;
                CharSequence charSequence  = CharSequence.Cast(obj4);
                CharSequence charSequence3 = CharSequence.Cast(obj3);
                string       text3         = String.instancehelper_replace(text, charSequence3, charSequence);
                object       obj5          = "'";
                obj2         = "";
                charSequence = CharSequence.Cast(obj5);
                CharSequence charSequence4 = charSequence;
                charSequence = CharSequence.Cast(obj2);
                NumberExpander.expandReal(String.instancehelper_replace(text3, charSequence4, charSequence), this.wordRelation);
            }
            else if (USEnglishTokenizer.matches(USEnglishTokenizer.sevenPhoneNumberPattern, text))
            {
                int    num2         = String.instancehelper_indexOf(text, 45);
                string numberString = String.instancehelper_substring(text, 0, num2);
                string text4        = String.instancehelper_substring(text, num2 + 1);
                NumberExpander.expandDigits(numberString, this.wordRelation);
                this.wordRelation.addBreak();
                NumberExpander.expandDigits(text4, this.wordRelation);
            }
            else if (this.matchesPartPhoneNumber(text))
            {
                string text2 = (string)this.tokenItem.findFeature("punc");
                if (String.instancehelper_equals(text2, ""))
                {
                    this.tokenItem.getFeatures().setString("punc", ",");
                }
                NumberExpander.expandDigits(text, this.wordRelation);
                this.wordRelation.addBreak();
            }
            else if (USEnglishTokenizer.matches(USEnglishTokenizer.numberTimePattern, text))
            {
                int    num2         = String.instancehelper_indexOf(text, 58);
                string numberString = String.instancehelper_substring(text, 0, num2);
                string text4        = String.instancehelper_substring(text, num2 + 1);
                NumberExpander.expandNumber(numberString, this.wordRelation);
                if (!String.instancehelper_equals(text4, "00"))
                {
                    NumberExpander.expandID(text4, this.wordRelation);
                }
            }
            else if (USEnglishTokenizer.matches(USEnglishTokenizer.digits2DashPattern, text))
            {
                this.digitsDashToWords(text);
            }
            else if (USEnglishTokenizer.matches(USEnglishTokenizer.digitsPattern, text))
            {
                this.digitsToWords(text);
            }
            else if (num == 1 && Character.isUpperCase(String.instancehelper_charAt(text, 0)) && String.instancehelper_equals((string)this.tokenItem.findFeature("n.whitespace"), " ") && Character.isUpperCase(String.instancehelper_charAt((string)this.tokenItem.findFeature("n.name"), 0)))
            {
                features.setString("punc", "");
                string text2 = String.instancehelper_toLowerCase(text);
                if (String.instancehelper_equals(text2, "a"))
                {
                    this.wordRelation.addWord("_a");
                }
                else
                {
                    this.wordRelation.addWord(text2);
                }
            }
            else if (USEnglishTokenizer.matches(USEnglishTokenizer.doublePattern, text))
            {
                NumberExpander.expandReal(text, this.wordRelation);
            }
            else if (USEnglishTokenizer.matches(USEnglishTokenizer.ordinalPattern, text))
            {
                string text2 = String.instancehelper_substring(text, 0, num - 2);
                NumberExpander.expandOrdinal(text2, this.wordRelation);
            }
            else if (USEnglishTokenizer.matches(USEnglishTokenizer.usMoneyPattern, text))
            {
                this.usMoneyToWords(text);
            }
            else if (num > 0 && String.instancehelper_charAt(text, num - 1) == '%')
            {
                this.tokenToWords(String.instancehelper_substring(text, 0, num - 1));
                this.wordRelation.addWord("percent");
            }
            else if (USEnglishTokenizer.matches(USEnglishTokenizer.numessPattern, text))
            {
                NumberExpander.expandNumess(String.instancehelper_substring(text, 0, num - 1), this.wordRelation);
            }
            else if (USEnglishTokenizer.matches(USEnglishTokenizer.digitsSlashDigitsPattern, text) && String.instancehelper_equals(text, @string))
            {
                this.digitsSlashDigitsToWords(text);
            }
            else if (String.instancehelper_indexOf(text, 45) != -1)
            {
                this.dashToWords(text);
            }
            else if (num > 1 && !USEnglishTokenizer.matches(USEnglishTokenizer.alphabetPattern, text))
            {
                this.notJustAlphasToWords(text);
            }
            else if (String.instancehelper_equals(text, "&"))
            {
                this.wordRelation.addWord("and");
            }
            else if (!String.instancehelper_equals(text, "-"))
            {
                this.wordRelation.addWord(String.instancehelper_toLowerCase(text));
            }
        }
        private string getInputLine()
        {
            string text = [email protected]();

            if (text == null)
            {
                return(null);
            }
            int          num          = 0;
            int          num2         = 0;
            int          num3         = 0;
            Pattern      pattern      = CommandInterpreter.historyPush;
            object       _ref         = text;
            CharSequence charSequence = CharSequence.Cast(_ref);
            Matcher      matcher      = pattern.matcher(charSequence);

            if (matcher.matches())
            {
                num  = 1;
                num2 = 1;
                text = matcher.group(1);
            }
            if (String.instancehelper_startsWith(text, "^"))
            {
                Pattern pattern2 = CommandInterpreter.editPattern;
                _ref         = text;
                charSequence = CharSequence.Cast(_ref);
                matcher      = pattern2.matcher(charSequence);
                if (matcher.matches())
                {
                    string text2 = matcher.group(1);
                    string text3 = matcher.group(2);
                    PatternSyntaxException ex2;
                    try
                    {
                        Pattern pattern3 = Pattern.compile(text2);
                        Pattern pattern4 = pattern3;
                        _ref         = this.history.getLast(0);
                        charSequence = CharSequence.Cast(_ref);
                        Matcher matcher2 = pattern4.matcher(charSequence);
                        if (matcher2.find())
                        {
                            text = matcher2.replaceFirst(text3);
                            num2 = 1;
                        }
                        else
                        {
                            num3 = 1;
                            this.putResponse(new StringBuilder().append(text).append(": substitution failed").toString());
                        }
                    }
                    catch (PatternSyntaxException ex)
                    {
                        ex2 = ex;
                        goto IL_114;
                    }
                    goto IL_144;
IL_114:
                    PatternSyntaxException ex3 = ex2;
                    num3 = 1;
                    this.putResponse(new StringBuilder().append("Bad regexp: ").append(ex3.getDescription()).toString());
                    IL_144 :;
                }
                else
                {
                    num3 = 1;
                    this.putResponse("bad substitution sytax, use ^old^new^");
                }
            }
            else
            {
                Pattern pattern5 = CommandInterpreter.bbPattern;
                _ref         = text;
                charSequence = CharSequence.Cast(_ref);
                if ((matcher = pattern5.matcher(charSequence)).find())
                {
                    text = matcher.replaceAll(this.history.getLast(0));
                    num2 = 1;
                }
                else if (String.instancehelper_startsWith(text, "!"))
                {
                    if (String.instancehelper_matches(text, "!\\d+"))
                    {
                        int num4 = Integer.parseInt(String.instancehelper_substring(text, 1));
                        text = this.history.get(num4);
                    }
                    else if (String.instancehelper_matches(text, "!-\\d+"))
                    {
                        int num4 = Integer.parseInt(String.instancehelper_substring(text, 2));
                        text = this.history.getLast(num4 - 1);
                    }
                    else
                    {
                        text = this.history.findLast(String.instancehelper_substring(text, 1));
                    }
                    num2 = 1;
                }
            }
            if (num3 != 0)
            {
                return("");
            }
            if (!String.instancehelper_isEmpty(text))
            {
                this.history.add(text);
            }
            if (num2 != 0)
            {
                this.putResponse(text);
            }
            return((num == 0) ? text : "");
        }
Пример #18
0
        public static Lattice readSlf(InputStream stream)
        {
            Lattice          lattice          = new Lattice();
            LineNumberReader lineNumberReader = new LineNumberReader(new InputStreamReader(stream));
            int    num  = 0;
            int    num2 = 0;
            int    num3 = 0;
            int    num4 = 1;
            double num5 = 9.5;
            string text;

            while ((text = lineNumberReader.readLine()) != null)
            {
                string       text2        = text;
                object       obj          = "Node definitions";
                CharSequence charSequence = CharSequence.Cast(obj);
                if (String.instancehelper_contains(text2, charSequence))
                {
                    num2 = 0;
                    num  = 1;
                }
                else
                {
                    string text3 = text;
                    obj          = "Link definitions";
                    charSequence = CharSequence.Cast(obj);
                    if (String.instancehelper_contains(text3, charSequence))
                    {
                        num2 = 1;
                        num  = 0;
                    }
                    else if (!String.instancehelper_startsWith(text, "#"))
                    {
                        if (num != 0)
                        {
                            string[] array = String.instancehelper_split(text, "\\s+");
                            if (array.Length != 3 || !String.instancehelper_startsWith(array[0], "I=") || !String.instancehelper_startsWith(array[1], "t=") || !String.instancehelper_startsWith(array[2], "W="))
                            {
                                lineNumberReader.close();
                                string text4 = new StringBuilder().append("Unknown node definition: ").append(text).toString();

                                throw new IOException(text4);
                            }
                            int    num6      = Integer.parseInt(String.instancehelper_substring(array[0], 2));
                            long   beginTime = ByteCodeHelper.d2l(Double.parseDouble(String.instancehelper_substring(array[1], 2)) * 1000.0);
                            string text5     = String.instancehelper_substring(array[2], 2);
                            int    isFiller  = 0;
                            if (num6 == num3 || String.instancehelper_equals(text5, "!ENTER"))
                            {
                                text5    = "<s>";
                                isFiller = 1;
                            }
                            if (num6 == num4 || String.instancehelper_equals(text5, "!EXIT"))
                            {
                                text5    = "</s>";
                                isFiller = 1;
                            }
                            if (String.instancehelper_equals(text5, "!NULL"))
                            {
                                text5    = "<sil>";
                                isFiller = 1;
                            }
                            if (String.instancehelper_startsWith(text5, "["))
                            {
                                isFiller = 1;
                            }
                            Word word = new Word(text5, new Pronunciation[0], isFiller != 0);
                            Node node = lattice.addNode(Integer.toString(num6), word, beginTime, -1L);
                            if (String.instancehelper_equals(text5, "<s>"))
                            {
                                lattice.setInitialNode(node);
                            }
                            if (String.instancehelper_equals(text5, "</s>"))
                            {
                                lattice.setTerminalNode(node);
                            }
                        }
                        else if (num2 != 0)
                        {
                            string[] array = String.instancehelper_split(text, "\\s+");
                            if (array.Length != 5 || !String.instancehelper_startsWith(array[1], "S=") || !String.instancehelper_startsWith(array[2], "E=") || !String.instancehelper_startsWith(array[3], "a=") || !String.instancehelper_startsWith(array[4], "l="))
                            {
                                lineNumberReader.close();
                                string text6 = new StringBuilder().append("Unknown edge definition: ").append(text).toString();

                                throw new IOException(text6);
                            }
                            string text7         = String.instancehelper_substring(array[1], 2);
                            string text8         = String.instancehelper_substring(array[2], 2);
                            double acousticScore = Double.parseDouble(String.instancehelper_substring(array[3], 2));
                            double lmScore       = Double.parseDouble(String.instancehelper_substring(array[4], 2)) * num5;
                            lattice.addEdge((Node)lattice.nodes.get(text7), (Node)lattice.nodes.get(text8), acousticScore, lmScore);
                        }
                        else
                        {
                            if (String.instancehelper_startsWith(text, "start="))
                            {
                                string text9 = text;
                                object obj2  = "start=";
                                obj = "";
                                object obj3 = obj2;
                                charSequence = CharSequence.Cast(obj3);
                                CharSequence charSequence2 = charSequence;
                                obj3         = obj;
                                charSequence = CharSequence.Cast(obj3);
                                num3         = Integer.parseInt(String.instancehelper_replace(text9, charSequence2, charSequence));
                            }
                            if (String.instancehelper_startsWith(text, "end="))
                            {
                                string text10 = text;
                                object obj4   = "end=";
                                object obj3   = "";
                                obj          = obj4;
                                charSequence = CharSequence.Cast(obj);
                                CharSequence charSequence3 = charSequence;
                                obj          = obj3;
                                charSequence = CharSequence.Cast(obj);
                                num4         = Integer.parseInt(String.instancehelper_replace(text10, charSequence3, charSequence));
                            }
                            if (String.instancehelper_startsWith(text, "lmscale="))
                            {
                                string text11 = text;
                                object obj5   = "lmscale=";
                                obj = "";
                                object obj3 = obj5;
                                charSequence = CharSequence.Cast(obj3);
                                CharSequence charSequence4 = charSequence;
                                obj3         = obj;
                                charSequence = CharSequence.Cast(obj3);
                                num5         = Double.parseDouble(String.instancehelper_replace(text11, charSequence4, charSequence));
                            }
                        }
                    }
                }
            }
            Iterator iterator = lattice.nodes.values().iterator();

            while (iterator.hasNext())
            {
                Node     node2     = (Node)iterator.next();
                Iterator iterator2 = node2.getLeavingEdges().iterator();
                while (iterator2.hasNext())
                {
                    Edge edge = (Edge)iterator2.next();
                    if (node2.getEndTime() < 0L || node2.getEndTime() > edge.getToNode().getBeginTime())
                    {
                        node2.setEndTime(Math.max(edge.getToNode().getBeginTime(), node2.getBeginTime()));
                    }
                }
            }
            return(lattice);
        }
Пример #19
0
        public virtual void loadHTK(string nom)
        {
            try
            {
                BufferedReader bufferedReader = new BufferedReader(new FileReader(nom));
                this.ngauss = 0;
                this.ncoefs = 0;
                CharSequence charSequence;
                for (;;)
                {
                    string text = bufferedReader.readLine();
                    if (text == null)
                    {
                        break;
                    }
                    string text2 = text;
                    object _ref  = "<MEAN>";
                    charSequence = CharSequence.Cast(_ref);
                    if (String.instancehelper_contains(text2, charSequence))
                    {
                        this.ngauss++;
                        if (this.ncoefs == 0)
                        {
                            StringTokenizer stringTokenizer = new StringTokenizer(text);
                            stringTokenizer.nextToken();
                            this.ncoefs = Integer.parseInt(stringTokenizer.nextToken());
                        }
                    }
                }
                bufferedReader.close();
                this.allocate();
                bufferedReader = new BufferedReader(new FileReader(nom));
                int num = 0;
                for (;;)
                {
                    string text = bufferedReader.readLine();
                    if (text == null)
                    {
                        break;
                    }
                    string text3 = text;
                    object _ref  = "<MEAN>";
                    charSequence = CharSequence.Cast(_ref);
                    if (String.instancehelper_contains(text3, charSequence))
                    {
                        text = bufferedReader.readLine();
                        StringTokenizer stringTokenizer = new StringTokenizer(text);
                        int             num2            = 0;
                        while (stringTokenizer.hasMoreTokens())
                        {
                            string text4 = stringTokenizer.nextToken();
                            this.setMean(num, num2, Float.parseFloat(text4));
                            num2++;
                        }
                        text = bufferedReader.readLine();
                        string text5 = text;
                        _ref         = "<VARIANCE>";
                        charSequence = CharSequence.Cast(_ref);
                        if (!String.instancehelper_contains(text5, charSequence))
                        {
                            goto Block_8;
                        }
                        text            = bufferedReader.readLine();
                        stringTokenizer = new StringTokenizer(text);
                        num2            = 0;
                        while (stringTokenizer.hasMoreTokens())
                        {
                            string text4 = stringTokenizer.nextToken();
                            this.setVar(num, num2, Float.parseFloat(text4));
                            num2++;
                        }
                        num++;
                    }
                }
                bufferedReader.close();
                this.precomputeDistance();
                goto IL_19B;
Block_8:
                bufferedReader.close();

                throw new IOException();
            }
            catch (IOException ex)
            {
                Throwable.instancehelper_printStackTrace(ex);
            }
IL_19B:
            return;
        }