Beispiel #1
0
        public int gen_chain_char(string[] words, int len, string[] result, char head, char tail, bool enable_loop)
        {
            if (!((head <= 'z' && head >= 'a') || (head == '\0')))
            {
                throw new Exception("首字母不符合规范");
            }
            if (!((tail <= 'z' && tail >= 'a') || (tail == '\0')))
            {
                throw new Exception("尾字母不符合规范");
            }

            if (head == '\0')
            {
                head = '#';
            }
            if (tail == '\0')
            {
                tail = '#';
            }

            Word.setWeightChosen('c');

            if (!enable_loop) //没有-r的情况
            {
                ReadFile readFile = new ReadFile();
                readFile.buildWordList(words);
                readFile.run2();
                Topo tp = new Topo();
                tp.run(head, tail);
                return(tp.getLongesChain().getWeight());
            }
            else //有
            {
                ReadFile readFile = new ReadFile();
                readFile.buildWordList(words);
                WordChainProcessor wcp    = new WordChainProcessor(ReadFile.GetWordChainUnDo(), 'c', head, tail);
                WordChain          wchain = wcp.getResultChain();
                return(wchain.getWeight());
            }
            throw new NotImplementedException();
        }
Beispiel #2
0
        public WordChain build_chain_char(string[] words, int len, string[] result, char head, char tail, bool enable_loop)
        {
            Word.setWeightChosen('c');

            if (!enable_loop) //没有-r的情况
            {
                ReadFile readFile = new ReadFile();
                readFile.buildWordList(words);
                readFile.run2();
                Topo tp = new Topo();
                tp.run(head, tail);
                return(tp.getLongesChain());
            }
            else //有
            {
                ReadFile readFile = new ReadFile();
                readFile.buildWordList(words);
                WordChainProcessor wcp    = new WordChainProcessor(ReadFile.GetWordChainUnDo(), 'c', head, tail);
                WordChain          wchain = wcp.getResultChain();
                return(wchain);
            }
            throw new NotImplementedException();
        }