コード例 #1
0
ファイル: WordTokenizer.cs プロジェクト: vczh-codeplex/gac
        private string[] TokenizeInternal(string input)
        {
            TokenSelector tc = new TokenSelector();

            TokenizeInternal(input, null, tc);
            return(tc.Result);
        }
コード例 #2
0
        /// <summary>Try to locate the required token for the server.</summary>
        /// <param name="authType">of the SASL client</param>
        /// <returns>Token<?> for server, or null if no token available</returns>
        /// <exception cref="System.IO.IOException">- token selector cannot be instantiated</exception>
        private Org.Apache.Hadoop.Security.Token.Token <object> GetServerToken(RpcHeaderProtos.RpcSaslProto.SaslAuth
                                                                               authType)
        {
            TokenInfo tokenInfo = SecurityUtil.GetTokenInfo(protocol, conf);

            Log.Debug("Get token info proto:" + protocol + " info:" + tokenInfo);
            if (tokenInfo == null)
            {
                // protocol has no support for tokens
                return(null);
            }
            TokenSelector <object> tokenSelector = null;

            try
            {
                tokenSelector = System.Activator.CreateInstance(tokenInfo.Value());
            }
            catch (InstantiationException e)
            {
                throw new IOException(e.ToString());
            }
            catch (MemberAccessException e)
            {
                throw new IOException(e.ToString());
            }
            return(tokenSelector.SelectToken(SecurityUtil.BuildTokenService(serverAddr), ugi.
                                             GetTokens()));
        }
コード例 #3
0
ファイル: WordTokenizer.cs プロジェクト: vczh-codeplex/gac
        void TokenizeInternal(string input, Token previous, TokenSelector tokenSelector)
        {
            if (input.Length == 0)
            {
                tokenSelector.AddChoice(previous);
            }
            else
            {
                List <Tuple <string, int> > candidates = new List <Tuple <string, int> >();
                this.libraryRoot.Search(input, 0, candidates);

                if (candidates.Count > 0)
                {
                    foreach (var candidate in candidates)
                    {
                        Token token = new Token();
                        token.word       = candidate.Item1;
                        token.score      = candidate.Item2;
                        token.previous   = previous;
                        token.totalScore = previous == null ? token.score : token.score + previous.score;
                        TokenizeInternal(input.Substring(token.word.Length), token, tokenSelector);
                    }
                }
                else
                {
                    Token token = new Token();
                    token.word       = input[0].ToString();
                    token.score      = 0;
                    token.previous   = previous;
                    token.totalScore = previous == null ? 0 : previous.score;
                    TokenizeInternal(input.Substring(token.word.Length), token, tokenSelector);
                }
            }
        }