コード例 #1
0
        public EdgeNGramTokenFilter(LuceneVersion version, TokenStream input, Side side, int minGram, int maxGram)
            : base(input)
        {
            //if (version == null)
            //{
            //    throw new ArgumentException("version must not be null");
            //}

            if (version.OnOrAfter(LuceneVersion.LUCENE_44) && side == Side.BACK)
            {
                throw new ArgumentException("Side.BACK is not supported anymore as of Lucene 4.4, use ReverseStringFilter up-front and afterward");
            }

            if (!Enum.IsDefined(typeof(Side), side))
            {
                throw new ArgumentException("sideLabel must be either front or back");
            }

            if (minGram < 1)
            {
                throw new ArgumentException("minGram must be greater than zero");
            }

            if (minGram > maxGram)
            {
                throw new ArgumentException("minGram must not be greater than maxGram");
            }

            this.version   = version;
            this.charUtils = version.OnOrAfter(LuceneVersion.LUCENE_44) ? CharacterUtils.GetInstance(version) : CharacterUtils.GetJava4Instance(version);
            this.minGram   = minGram;
            this.maxGram   = maxGram;
            this.side      = side;

            this.termAtt    = AddAttribute <ICharTermAttribute>();
            this.offsetAtt  = AddAttribute <IOffsetAttribute>();
            this.posIncrAtt = AddAttribute <IPositionIncrementAttribute>();
            this.posLenAtt  = AddAttribute <IPositionLengthAttribute>();
        }
コード例 #2
0
    public override void UpdateCombatControls()
    {
        if (GameController.state == GameState.Combat)
        {
            if (character.isIdle)
            {
                if (obstacle.enabled)
                {
                    obstacle.enabled = false;
                    return;
                }

                if (character.remainingActions > 0)
                {
                    RangedAttackAbility rangedAttack = character.GetCastableAbilities <RangedAttackAbility>()
                                                       .OrderByDescending(m => m.threatRating).FirstOrDefault();

                    if (rangedAttack != null)
                    {
                        target = CharacterUtils.GetClosestCharacter(GameController.instance.party, character.position);

                        if (target != null)
                        {
                            NeverdawnCamera.AddTargetLerped(target.transform);
                            hasFallback = false;

                            float distance = Vector3.Distance(character.position, target.position);

                            if (distance > rangedAttack.weapon.estimatedRange + character.remainingSteps)
                            {
                                if (character.remainingSteps > 0.0f)
                                {
                                    character.PushAction(new CharacterNavigateToAction(target.position, character.remainingSteps, false,
                                                                                       rangedAttack.weapon.estimatedRange - 0.1f));
                                }
                                else
                                {
                                    GameController.instance.combatController.EndTurn(this);
                                    return;
                                }
                            }
                            else
                            {
                                // Get positions and sort by strategic value (furthest away from target!)
                                List <Vector3> positions = sampleSurroundings(20, character.remainingSteps);
                                positions = positions.OrderByDescending(p => Vector3.Distance(p, target.position)).ToList();

                                // No position found yet!
                                bool    hasPosition    = false;
                                Vector3 targetPosition = Vector3.negativeInfinity;
                                Vector3 targetVelocity = Vector3.negativeInfinity;
                                Vector3 force;

                                foreach (Vector3 position in positions)
                                {
                                    Vector3 direction = target.position - position;
                                    direction.y = 0.0f;
                                    direction.Normalize();

                                    launchTransform.position = position;
                                    launchTransform.forward  = direction;

                                    Vector3 launchPosition = launchTransform.TransformPoint(rangedAttack.weapon.projectileSpawn);

                                    if (tryHitTarget(rangedAttack, launchPosition, target.frame, out force, 5))
                                    {
                                        targetPosition = position;
                                        targetVelocity = force;
                                        hasPosition    = true;
                                        break;
                                    }
                                }

                                if (hasPosition)
                                {
                                    rangedAttack.targetVelocity = targetVelocity;
                                    rangedAttack.caster         = character;

                                    character.PushAction(new CharacterNavigateToAction(targetPosition, character.remainingSteps, false));
                                    character.PushAction(rangedAttack.Prepare());
                                    character.PushAction(rangedAttack.Cast());
                                }
                                else
                                {
                                    if (hasFallback)
                                    {
                                        rangedAttack.targetVelocity = fallBackVelocity;
                                        rangedAttack.caster         = character;

                                        character.PushAction(new CharacterNavigateToAction(fallbackPosition, character.remainingSteps, false));
                                        character.PushAction(rangedAttack.Prepare());
                                        character.PushAction(rangedAttack.Cast());
                                    }
                                    else
                                    {
                                        GameController.instance.combatController.EndTurn(this);
                                    }
                                }
                            }
                        }
                        else
                        {
                            GameController.instance.combatController.EndTurn(this);
                        }
                    }
                    else
                    {
                        EndCombatTurn();
                    }
                }
                else
                {
                    if (target)
                    {
                        NeverdawnCamera.RemoveTargetLerped(target.transform);
                    }

                    EndCombatTurn();
                }
            }
        }


        if (character.isIdle)
        {
            if (!obstacle.enabled)
            {
                obstacle.enabled = true;
            }
        }
    }
コード例 #3
0
        public void LoadNpcAppearance(uint id)
        {
            using (MySqlConnection conn = new MySqlConnection(String.Format("Server={0}; Port={1}; Database={2}; UID={3}; Password={4}", ConfigConstants.DATABASE_HOST, ConfigConstants.DATABASE_PORT, ConfigConstants.DATABASE_NAME, ConfigConstants.DATABASE_USERNAME, ConfigConstants.DATABASE_PASSWORD)))
            {
                try
                {
                    conn.Open();

                    string query = @"
                                    SELECT                 
                                    base,
                                    size,
                                    hairStyle,
                                    hairHighlightColor,
                                    hairVariation,
                                    faceType,   
                                    characteristics,
                                    characteristicsColor,
                                    faceEyebrows,
                                    faceIrisSize,
                                    faceEyeShape,
                                    faceNose,
                                    faceFeatures,
                                    faceMouth,
                                    ears,
                                    hairColor,
                                    skinColor,
                                    eyeColor,
                                    voice,
                                    mainHand,
                                    offHand,
                                    spMainHand,
                                    spOffHand,
                                    throwing,
                                    pack,
                                    pouch,
                                    head,
                                    body,
                                    legs,
                                    hands,
                                    feet,
                                    waist,
                                    neck,
                                    leftEar,
                                    rightEar,
                                    leftIndex,
                                    rightIndex,
                                    leftFinger,
                                    rightFinger
                                    FROM gamedata_actor_appearance
                                    WHERE id = @templateId
                                    ";

                    MySqlCommand cmd = new MySqlCommand(query, conn);
                    cmd.Parameters.AddWithValue("@templateId", id);

                    using (MySqlDataReader reader = cmd.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            //Handle Appearance
                            modelId = reader.GetUInt32(0);
                            appearanceIds[Character.SIZE]           = reader.GetUInt32(1);
                            appearanceIds[Character.COLORINFO]      = (uint)(reader.GetUInt32(16) | (reader.GetUInt32(15) << 10) | (reader.GetUInt32(17) << 20)); //17 - Skin Color, 16 - Hair Color, 18 - Eye Color
                            appearanceIds[Character.FACEINFO]       = PrimitiveConversion.ToUInt32(CharacterUtils.GetFaceInfo(reader.GetByte(6), reader.GetByte(7), reader.GetByte(5), reader.GetByte(14), reader.GetByte(13), reader.GetByte(12), reader.GetByte(11), reader.GetByte(10), reader.GetByte(9), reader.GetByte(8)));
                            appearanceIds[Character.HIGHLIGHT_HAIR] = (uint)(reader.GetUInt32(3) | reader.GetUInt32(2) << 10);                                    //5- Hair Highlight, 4 - Hair Style
                            appearanceIds[Character.VOICE]          = reader.GetUInt32(17);
                            appearanceIds[Character.MAINHAND]       = reader.GetUInt32(19);
                            appearanceIds[Character.OFFHAND]        = reader.GetUInt32(20);
                            appearanceIds[Character.SPMAINHAND]     = reader.GetUInt32(21);
                            appearanceIds[Character.SPOFFHAND]      = reader.GetUInt32(22);
                            appearanceIds[Character.THROWING]       = reader.GetUInt32(23);
                            appearanceIds[Character.PACK]           = reader.GetUInt32(24);
                            appearanceIds[Character.POUCH]          = reader.GetUInt32(25);
                            appearanceIds[Character.HEADGEAR]       = reader.GetUInt32(26);
                            appearanceIds[Character.BODYGEAR]       = reader.GetUInt32(27);
                            appearanceIds[Character.LEGSGEAR]       = reader.GetUInt32(28);
                            appearanceIds[Character.HANDSGEAR]      = reader.GetUInt32(29);
                            appearanceIds[Character.FEETGEAR]       = reader.GetUInt32(30);
                            appearanceIds[Character.WAISTGEAR]      = reader.GetUInt32(31);
                            appearanceIds[Character.NECKGEAR]       = reader.GetUInt32(32);
                            appearanceIds[Character.R_EAR]          = reader.GetUInt32(33);
                            appearanceIds[Character.L_EAR]          = reader.GetUInt32(34);
                            appearanceIds[Character.R_INDEXFINGER]  = reader.GetUInt32(35);
                            appearanceIds[Character.L_INDEXFINGER]  = reader.GetUInt32(36);
                            appearanceIds[Character.R_RINGFINGER]   = reader.GetUInt32(37);
                            appearanceIds[Character.L_RINGFINGER]   = reader.GetUInt32(38);
                        }
                    }
                }
                catch (MySqlException e)
                { Console.WriteLine(e); }
                finally
                {
                    conn.Dispose();
                }
            }
        }
コード例 #4
0
 // for testing ONLY
 internal ICUNormalizer2CharFilter(TextReader input, Normalizer2 normalizer, int bufferSize)
     : base(input)
 {
     this.normalizer = normalizer ?? throw new ArgumentNullException(nameof(normalizer)); // LUCENENET specific - changed from IllegalArgumentException to ArgumentNullException (.NET convention)
     this.tmpBuffer  = CharacterUtils.NewCharacterBuffer(bufferSize);
 }
コード例 #5
0
    // Update is called once per frame
    public override void UpdateCombatControls()
    {
        base.UpdateCombatControls();

        if (character.isIdle)
        {
            if (obstacle.enabled)
            {
                obstacle.enabled = false;
                return;
            }

            if (character.remainingActions > 0)
            {
                MeleeAttackAbility meleeAbility = character.GetCastableAbilities <MeleeAttackAbility>()
                                                  .Where(a => a.CharacterHasEnoughMana(character))
                                                  .OrderByDescending(m => m.threatRating).FirstOrDefault();

                if (meleeAbility != null)
                {
                    MeleeAttackAbility currentAbility = meleeAbility;

                    target = CharacterUtils.GetClosestCharacter(GameController.instance.party, character.position);

                    if (target != null)
                    {
                        if (character.currentTile.IsAdjacent(target.currentTile))
                        {
                            if (currentAbility.IsCastable(character))
                            {
                                currentAbility.caster = character;
                                currentAbility.target = target.frame;

                                character.PushAction(currentAbility.Prepare());
                                character.PushAction(currentAbility.Cast());
                            }
                        }
                        else
                        {
                            if (character.remainingSteps > 0)
                            {
                                character.PushAction(new CharacterNavigateToTileAction(target.currentTile, true));
                            }
                            else
                            {
                                EndCombatTurn();
                                return;
                            }
                        }
                    }
                    else
                    {
                        EndCombatTurn();
                    }
                }
                else
                {
                    EndCombatTurn();
                }
            }
            else
            {
                EndCombatTurn();
            }
        }

        if (character.isIdle && character.isAlive)
        {
            if (!obstacle.enabled)
            {
                obstacle.enabled = true;
            }
        }
    }
コード例 #6
0
 private byte[] ConvertKeyToBytes(string key)
 {
     return
         (CharacterUtils.ToArray(
              CharacterUtils.PackBytes(_transcoder.ConvertToBytes(CharacterUtils.FilterOutDashes(key)), 5)));
 }
コード例 #7
0
 public void GetAllCharactersInUnicodeCategory_CategoryShouldNotContainCharacter_CategoryDoesNotContainCharacter(UnicodeCategory category, char character)
 {
     Assert.False(CharacterUtils.GetAllCharactersInUnicodeCategory(category).Contains(character));
 }
コード例 #8
0
    // Update is called once per frame
    public override void UpdateCombatControls()
    {
        base.UpdateCombatControls();

        if (character.isIdle)
        {
            if (obstacle.enabled)
            {
                obstacle.enabled = false;
                return;
            }

            if (character.remainingActions > 0)
            {
                MeleeAttackAbility meleeAbility = character.GetCastableAbilities <MeleeAttackAbility>()
                                                  .OrderByDescending(m => m.threatRating).FirstOrDefault();

                if (meleeAbility != null)
                {
                    target = CharacterUtils.GetClosestCharacter(GameController.instance.party, character.position);

                    if (target != null)
                    {
                        float distance = Vector3.Distance(character.position, target.position);

                        if (distance > meleeAbility.attackRange)
                        {
                            if (character.remainingSteps > 0.0f)
                            {
                                character.PushAction(new CharacterNavigateToAction(target.position, character.remainingSteps, false,
                                                                                   meleeAbility.attackRange - 0.1f));
                            }
                            else
                            {
                                EndCombatTurn();
                                return;
                            }
                        }
                        else
                        {
                            meleeAbility.caster = character;
                            meleeAbility.target = target.frame;

                            character.PushAction(meleeAbility.Prepare());
                            character.PushAction(meleeAbility.Cast());
                        }
                    }
                    else
                    {
                        EndCombatTurn();
                    }
                }
                else
                {
                    EndCombatTurn();
                }
            }
            else
            {
                EndCombatTurn();
            }
        }



        if (character.isIdle)
        {
            if (!obstacle.enabled)
            {
                obstacle.enabled = true;
            }
        }
    }
コード例 #9
0
 public void IsSentenceFinalPunctuation_CharacterIsNotSentenceFinalPunctuation_ReturnsFalse(char c)
 {
     Assert.IsFalse(CharacterUtils.IsSentenceFinalPunctuation(c));
 }
コード例 #10
0
        public void EndsWithSentenceFinalPunctuation_TextDoesNotEndWithSFP_ReturnsFalse(string text)
        {
            var actual = CharacterUtils.EndsWithSentenceFinalPunctuation(text);

            Assert.IsFalse(actual);
        }
コード例 #11
0
 public void GetAllCharactersInUnicodeCategory_CategoryShouldContainCharacter_CategoryContainsCharacter(UnicodeCategory category, char character)
 {
     Assert.True(CharacterUtils.GetAllCharactersInUnicodeCategory(category).Contains(character));
 }
コード例 #12
0
        public void InsertDashes()
        {
            string output = CharacterUtils.ToString(CharacterUtils.InsertDashes("ABCDEABCDEABCDEABCDEABCDE"));

            Assert.AreEqual("ABCDE-ABCDE-ABCDE-ABCDE-ABCDE", output);
        }
コード例 #13
0
 private string ConvertBytesToKey(byte[] bytes)
 {
     return
         (CharacterUtils.ToString(
              CharacterUtils.InsertDashes(_transcoder.ConvertToAlphas(CharacterUtils.UnpackBytes(bytes, 5)))));
 }
コード例 #14
0
 private List <GameEntity> GetAlive(CharacterType type)
 {
     return(CharacterUtils.FindAll(_allCharacters.AsEnumerable(), type)
            .Where(CharacterUtils.IsNotDead)
            .ToList());
 }
コード例 #15
0
        public System.Collections.Generic.IReadOnlyList <Block> GetScriptBlocks(bool join)
        {
            if (!join)
            {
                return(GetScriptBlocks());
            }

            EnsureBlockCount();

            if (!join || m_blockCount == 0)
            {
                return(m_blocks);
            }

            var list = new List <Block>(m_blockCount);

            if (SingleVoice)
            {
                list.Add(m_blocks[0].Clone());
                var prevBlock = list.Single();
                prevBlock.MatchesReferenceText = false;
                var narrator = CharacterVerseData.GetStandardCharacterId(BookId, CharacterVerseData.StandardCharacter.Narrator);
                for (var i = 1; i < m_blockCount; i++)
                {
                    var clonedBlock = m_blocks[i].Clone();
                    clonedBlock.MatchesReferenceText = false;
                    if (!clonedBlock.CharacterIsStandard)
                    {
                        clonedBlock.CharacterId = narrator;
                    }

                    if (!clonedBlock.IsParagraphStart || (clonedBlock.IsFollowOnParagraphStyle && !CharacterUtils.EndsWithSentenceFinalPunctuation(prevBlock.GetText(false))))                     // && clonedBlock.CharacterId == prevBlock.CharacterId)
                    {
                        prevBlock.CombineWith(clonedBlock);
                    }
                    else
                    {
                        list.Add(clonedBlock);
                        prevBlock = clonedBlock;
                    }
                }
            }
            else
            {
                list.Add(m_blocks[0]);
                if (m_styleSheet == null)
                {
                    m_styleSheet = SfmLoader.GetUsfmStylesheet();
                }

                for (var i = 1; i < m_blockCount; i++)
                {
                    var block     = m_blocks[i];
                    var prevBlock = list.Last();

                    if (block.MatchesReferenceText == prevBlock.MatchesReferenceText &&
                        block.CharacterIdInScript == prevBlock.CharacterIdInScript && (block.Delivery ?? Empty) == (prevBlock.Delivery ?? Empty))
                    {
                        bool combine = false;
                        if (block.MatchesReferenceText)
                        {
                            combine = block.ReferenceBlocks.Single().StartsWithEllipsis ||
                                      ((!block.IsParagraphStart || (block.IsFollowOnParagraphStyle && !CharacterUtils.EndsWithSentenceFinalPunctuation(prevBlock.GetText(false)))) &&
                                       !block.ContainsVerseNumber &&
                                       ((!block.ReferenceBlocks.Single().BlockElements.OfType <Verse>().Any() &&
                                         !CharacterUtils.EndsWithSentenceFinalPunctuation(prevBlock.GetText(false))) ||
                                        block.ReferenceBlocks.Single().BlockElements.OfType <ScriptText>().All(t => t.Content.All(IsWhiteSpace)) ||
                                        prevBlock.ReferenceBlocks.Single().BlockElements.OfType <ScriptText>().All(t => t.Content.All(IsWhiteSpace))));
                        }
                        else if (!block.StartsAtVerseStart)
                        {
                            var style = (StyleAdapter)m_styleSheet.GetStyle(block.StyleTag);
                            combine = !block.IsParagraphStart || (style.IsPoetic && !CharacterUtils.EndsWithSentenceFinalPunctuation(prevBlock.GetText(false)));
                        }
                        if (combine)
                        {
                            list[list.Count - 1] = Block.CombineBlocks(prevBlock, block);
                            continue;
                        }
                    }
                    list.Add(block);
                }
            }
            return(list);
        }
コード例 #16
0
        public bool IsValidDottedNameNode(DottedNameNode node, TexlBinding binding, OperationCapabilityMetadata metadata, IOpDelegationStrategy opDelStrategy)
        {
            Contracts.AssertValue(node);
            Contracts.AssertValue(binding);
            Contracts.AssertValueOrNull(opDelStrategy);

            var isRowScoped = binding.IsRowScope(node);

            if (!isRowScoped)
            {
                return(IsValidNode(node, binding));
            }

            bool isRowScopedDelegationExempted;

            if (!IsValidRowScopedDottedNameNode(node, binding, metadata, out isRowScopedDelegationExempted))
            {
                var telemetryMessage = string.Format("Kind:{0}, isRowScoped:{1}",
                                                     node.Kind, isRowScoped);

                SuggestDelegationHintAndAddTelemetryMessage(node, binding, telemetryMessage);
                return(false);
            }

            if (isRowScopedDelegationExempted)
            {
                binding.SetBlockScopedConstantNode(node);
                return(true);
            }

            if (binding.TryGetFullRecordRowScopeAccessInfo(node, out var firstNameInfo))
            {
                // This means that this row scoped field is from some parent scope which is non-delegatable. That should deny delegation at that point.
                // For this scope, this means that value will be provided from some other source.
                // For example, AddColumns(CDS As Left, "Column1", LookUp(CDS1, Left.Name in FirstName))
                // CDS - *[Name:s], CDS1 - *[FirstName:s]
                if (GetCapabilityMetadata(firstNameInfo) == null)
                {
                    return(true);
                }
            }

            if (!binding.GetType(node.Left).HasExpandInfo)
            {
                DPath columnPath;
                if (!BinderUtils.TryConvertNodeToDPath(binding, node, out columnPath) || !metadata.IsDelegationSupportedByColumn(columnPath, _function.FunctionDelegationCapability))
                {
                    var safeColumnName = CharacterUtils.MakeSafeForFormatString(columnPath.ToDottedSyntax());
                    var message        = string.Format(StringResources.Get(TexlStrings.OpNotSupportedByColumnSuggestionMessage_OpNotSupportedByColumn), safeColumnName);
                    SuggestDelegationHintAndAddTelemetryMessage(node, binding, message, TexlStrings.OpNotSupportedByColumnSuggestionMessage_OpNotSupportedByColumn, safeColumnName);
                    TrackingProvider.Instance.SetDelegationTrackerStatus(DelegationStatus.NoDelSupportByColumn, node, binding, _function, DelegationTelemetryInfo.CreateNoDelSupportByColumnTelemetryInfo(columnPath.ToDottedSyntax()));
                    return(false);
                }

                // If there is any operator applied on this node then check if column supports operation.
                return(opDelStrategy?.IsOpSupportedByColumn(metadata, node, columnPath, binding) ?? true);
            }

            // If there is an entity reference then we need to do additional verification.
            IExpandInfo info           = binding.GetType(node.Left).ExpandInfo.VerifyValue();
            var         dataSourceInfo = info.ParentDataSource;

            IDataEntityMetadata entityMetadata;

            if (!dataSourceInfo.DataEntityMetadataProvider.TryGetEntityMetadata(info.Identity, out entityMetadata))
            {
                var telemetryMessage = string.Format("Kind:{0}, isRowScoped:{1}, no metadata found for entity {2}",
                                                     node.Kind, isRowScoped, CharacterUtils.MakeSafeForFormatString(info.Identity));

                SuggestDelegationHintAndAddTelemetryMessage(node, binding, telemetryMessage);
                return(false);
            }

            OperationCapabilityMetadata entityCapabilityMetadata = GetScopedOperationCapabilityMetadata(entityMetadata.DelegationMetadata);
            string maybeLogicalName;
            DName  columnName = node.Right.Name;

            if (entityMetadata.DisplayNameMapping.TryGetFromSecond(node.Right.Name.Value, out maybeLogicalName))
            {
                columnName = new DName(maybeLogicalName);
            }

            var entityColumnPath = DPath.Root.Append(columnName);

            if (!entityCapabilityMetadata.IsDelegationSupportedByColumn(entityColumnPath, _function.FunctionDelegationCapability))
            {
                var safeColumnName = CharacterUtils.MakeSafeForFormatString(columnName.Value);
                var message        = string.Format(StringResources.Get(TexlStrings.OpNotSupportedByColumnSuggestionMessage_OpNotSupportedByColumn), safeColumnName);
                SuggestDelegationHintAndAddTelemetryMessage(node, binding, message, TexlStrings.OpNotSupportedByColumnSuggestionMessage_OpNotSupportedByColumn, safeColumnName);
                TrackingProvider.Instance.SetDelegationTrackerStatus(DelegationStatus.NoDelSupportByColumn, node, binding, _function, DelegationTelemetryInfo.CreateNoDelSupportByColumnTelemetryInfo(columnName));
                return(false);
            }

            // If there is any operator applied on this node then check if column supports operation.
            return(opDelStrategy?.IsOpSupportedByColumn(entityCapabilityMetadata, node, entityColumnPath, binding) ?? true);
        }
コード例 #17
0
        internal static string GenerateColumnNamesMappingForSortByColumns(DType sourceType)
        {
            Contracts.Assert(sourceType.IsTable);

            var    allColumns = sourceType.GetNames(DPath.Root);
            string separator  = string.Empty;

            var primitiveColumnsAndComparatorIds = new StringBuilder();

            primitiveColumnsAndComparatorIds.Append("{");

            foreach (var column in allColumns)
            {
                if (column.Type.IsPrimitive && !column.Type.IsOptionSet)
                {
                    primitiveColumnsAndComparatorIds.AppendFormat("{0}\"{1}\":{2}", separator, CharacterUtils.EscapeString(column.Name),
                                                                  GetSortComparatorIdForType(column.Type));
                    separator = ",";
                }
            }
            primitiveColumnsAndComparatorIds.Append("}");

            return(primitiveColumnsAndComparatorIds.ToString());
        }
コード例 #18
0
ファイル: UpperCaseFilter.cs プロジェクト: voquanghoa/YAFNET
 /// <summary>
 /// Create a new <see cref="UpperCaseFilter"/>, that normalizes token text to upper case.
 /// </summary>
 /// <param name="matchVersion"> See <see cref="LuceneVersion"/> </param>
 /// <param name="in"> <see cref="TokenStream"/> to filter </param>
 public UpperCaseFilter(LuceneVersion matchVersion, TokenStream @in)
     : base(@in)
 {
     termAtt   = AddAttribute <ICharTermAttribute>();
     charUtils = CharacterUtils.GetInstance(matchVersion);
 }
コード例 #19
0
 public override void Visit(TypedNameNode node, Context context)
 {
     context._sb.Append(CharacterUtils.EscapeName(node.Identifier));
     context._sb.Append(" As ");
     node.Kind.Accept(this, context);
 }
コード例 #20
0
        public EdgeNGramTokenFilter(LuceneVersion version, TokenStream input, Side side, int minGram, int maxGram)
            : base(input)
        {
            // LUCENENET specific - version cannot be null because it is a value type.

            if (version.OnOrAfter(LuceneVersion.LUCENE_44) && side == Side.BACK)
            {
                throw new ArgumentException("Side.BACK is not supported anymore as of Lucene 4.4, use ReverseStringFilter up-front and afterward");
            }

            if (!side.IsDefined())
            {
                throw new ArgumentOutOfRangeException(nameof(side), "sideLabel must be either front or back"); // LUCENENET specific - changed from IllegalArgumentException to ArgumentOutOfRangeException (.NET convention)
            }

            if (minGram < 1)
            {
                throw new ArgumentOutOfRangeException(nameof(minGram), "minGram must be greater than zero"); // LUCENENET specific - changed from IllegalArgumentException to ArgumentOutOfRangeException (.NET convention)
            }

            if (minGram > maxGram)
            {
                throw new ArgumentException("minGram must not be greater than maxGram");
            }

            this.version   = version;
            this.charUtils = version.OnOrAfter(LuceneVersion.LUCENE_44) ? CharacterUtils.GetInstance(version) : CharacterUtils.GetJava4Instance(version);
            this.minGram   = minGram;
            this.maxGram   = maxGram;
            this.side      = side;

            this.termAtt    = AddAttribute <ICharTermAttribute>();
            this.offsetAtt  = AddAttribute <IOffsetAttribute>();
            this.posIncrAtt = AddAttribute <IPositionIncrementAttribute>();
            this.posLenAtt  = AddAttribute <IPositionLengthAttribute>();
        }
コード例 #21
0
 /// <summary>
 /// Create a new UpperCaseFilter, that normalizes token text to upper case.
 /// </summary>
 /// <param name="matchVersion"> See <a href="#version">above</a> </param>
 /// <param name="in"> TokenStream to filter </param>
 public UpperCaseFilter(Version matchVersion, TokenStream @in) : base(@in)
 {
     charUtils = CharacterUtils.getInstance(matchVersion);
 }