Example #1
0
        public Phrase(PhraseType type, params Phrase[] ConcatedPhrase)
        {
            this.PhType = type;
            if (ConcatedPhrase.Length == 0)
            {
                this.Level = -1;
            }
            else
            {
                this.Level = FindDeep(ConcatedPhrase);
            }
            if (ConcatedPhrase.Length != 0)
            {
                this.Start = ConcatedPhrase[0].Start;
                this.Line  = ConcatedPhrase[0].Line;
            }
            this.Length = FindLength(ConcatedPhrase);


            this.Value = new List <Phrase>();
            foreach (Phrase ph in ConcatedPhrase)
            {
                this.Value.Add(ph);
            }
        }
Example #2
0
        public Phrase(string phrase)
        {
            if (phrase.Length >= 2 && phrase.Substring(0, 2) == "- ")
            {
                include = false;
                phrase  = phrase.Substring(2).Trim();
            }
            else
            {
                include = true;
            }
            if (phrase.Length >= 1 && phrase.Substring(0, 1) == ">")
            {
                type   = PhraseType.English;
                phrase = phrase.Substring(1).Trim();
            }
            else
            {
                type = PhraseType.Arabic;
            }

            phrase = spaceRemover(phrase);
            string[]    phrasesplit = phrase.Split(" ");
            List <Word> wordList    = new List <Word>();

            for (int i = 0; i < phrasesplit.Length; i++)
            {
                Word newword = new Word(phrasesplit[i], type == PhraseType.English);
                if (!newword.isEmpty())
                {
                    wordList.Add(newword);
                }
            }
            words = wordList.ToArray();
        }
Example #3
0
        public override bool Equals(object obj)
        {
            Phrase phrase = obj as Phrase;

            if (phrase == null || Convert.IsDBNull(phrase))
            {
                return(false);
            }
            bool toReturn = string.Equals(TextPhrase, phrase.TextPhrase, StringComparison.OrdinalIgnoreCase) &&
                            PhraseType.Equals(phrase.PhraseType) && PhraseAuthor.Equals(phrase.PhraseAuthor);

            if (phrase.Entity == null)
            {
                toReturn = toReturn && Entity == null;
            }
            if (Entity == null)
            {
                toReturn = toReturn && phrase.Entity == null;
            }
            else
            {
                toReturn = toReturn && Entity.Equals(phrase.Entity);
            }
            return(toReturn);
        }
        public void Repository_should_save_translate()
        {
            var repository = new TranslationRepository(DbContext);

            var phraseType   = new PhraseType(7, "commodity", "کالا");
            var phrase       = new Phrase(15, "گندم", phraseType);
            var language     = new Language(1, "انگلیسی", "English", "EN");
            var translations = new List <Domain.Entities.Translation>()
            {
                new Domain.Entities.Translation(0, language, "Wheat")
            };
            var translatedPhrase = new TranslateBuilder()
                                   .WithPhrase(phrase)
                                   .WithTranslations(translations).Build();

            repository.Save(translatedPhrase);

            var id = translatedPhrase.Id;

            DbContext.ClearChangeTracker();


            var result = repository.GetById(id);

            Assert.Equal(result, translatedPhrase, new TranslatorEqualityComparer());
        }
Example #5
0
        public PhraseNotFound(Exception inner, PhraseType type)
            : base(inner)
        {
            this.Type = type;
            string type_text = ModelTextRules.PhraseTypeCommonNames[type];

            this.Text = "Не найдено: " + type_text;
        }
Example #6
0
        public PhraseNotFound(int start, int len, int line, PhraseType type) :
            base(start, len, line)
        {
            this.Type = type;
            string type_text = ModelTextRules.PhraseTypeCommonNames[type];

            this.Text = "Не найдено: " + type_text;
        }
Example #7
0
 /// <summary>
 /// Evaluates the current player rating
 /// </summary>
 /// <param name="player">Player's last choice</param>
 /// <param name="ai"> AI last answer </param>
 /// <returns> Current rating of the player </returns>
 public int Evaluate(PhraseType player, PhraseType ai)
 {
     _lastRating  = _finalRating;
     _ratingAC   += DetermineWinner(player, ai);
     _finalRating = MAX_EVALUATION + _ratingAC;
     _finalRating = Mathf.Clamp(_finalRating, 0, MAX_EVALUATION);
     return(_finalRating);
 }
Example #8
0
        /// <summary>
        /// Constructs a textual phrase.
        /// </summary>
        /// <param name="phraseType">Identifies the phrase type.</param>
        /// <param name="voice">Identifies the voice.</param>
        /// <param name="encoding">Specifies the audio encoding.</param>
        /// <param name="sampleRate">Specfies the audio sampling rate.</param>
        /// <param name="text">The text or SSML to be spoken.</param>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="text"/> is <b>null.</b></exception>
        /// <remarks>
        /// <note>
        /// It's often more convenient to use one of the static methods.
        /// </note>
        /// </remarks>
        public Phrase(PhraseType phraseType, string voice, TtsEncoding encoding, TtsSampleRate sampleRate, string text)
        {
            if (text == null)
            {
                throw new ArgumentNullException("text");
            }

            this.PhraseType = phraseType;
            this.IsOneTime  = false;
            this.Voice      = voice;
            this.Encoding   = encoding;
            this.SampleRate = sampleRate;
            this.Text       = text;
        }
Example #9
0
        public FakeData(PhraseType infoType, Language language) : base()
        {
            _infoType = infoType;
            _language = language;
            var types     = new PhraseTypes();
            var commodity = types[7];
            var langs     = new Languages();
            var arabic    = langs[2];
            var english   = langs[1];

            _translates = new List <Translator>();
            _translates.Add(new Translator(1, new Phrase(1, "قیر", commodity), arabic, ""));
            _translates.Add(new Translator(2, new Phrase(2, "گندم", commodity), arabic, ""));
            _translates.Add(new Translator(3, new Phrase(3, "طلا", commodity), arabic, ""));
            _translates.Add(new Translator(4, new Phrase(4, "باقر", commodity), english, ""));
            _translates.Add(new Translator(5, new Phrase(5, "تیم ملی", commodity), english, ""));
            _translates.Add(new Translator(6, new Phrase(6, "تیرآهن", commodity), arabic, ""));
            _translates.Add(new Translator(7, new Phrase(7, "شیر", commodity), arabic, ""));
            _translates.Add(new Translator(8, new Phrase(8, "مرغ", commodity), english, ""));
            _translates.Add(new Translator(9, new Phrase(9, "جون", commodity), english, ""));
            _translates.Add(new Translator(10, new Phrase(10, "آدمیزاد", commodity), arabic, ""));
            _translates.Add(new Translator(1, new Phrase(1, "قیر", commodity), english, ""));
            _translates.Add(new Translator(2, new Phrase(2, "گندم", commodity), english, ""));
        }
Example #10
0
 public int DetermineWinner(PhraseType player, PhraseType ai)
 {
     return(((int)player + (-(int)ai)) % 4);
 }
Example #11
0
        private PhraseType GetPhraseTypeById(int phraseTypeId)
        {
            PhraseType phraseType = _repository.GetPhraseTypeById(phraseTypeId);

            return(phraseType);
        }
Example #12
0
 private Phrase GetPhraseById(int phraseId, PhraseType phraseType)
 {
     return(_repository.GetPhraseById(phraseId, phraseType));
 }
Example #13
0
 public PhraseTypeTemplate(PhraseType type, params PhraseType[] template)
 {
     this.PhType          = type;
     this.PhTemplate      = template;
     this.ConcatedPhrases = template.Length;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="FindHighlightRule" /> class.
 /// </summary>
 /// <param name="source">The source.</param>
 /// <param name="phraseType"></param>
 /// <param name="comparisoneRule">The comparisone rule.</param>
 public FindHighlightRule(ISearchSource source, PhraseType phraseType, StringComparison comparisoneRule)
 {
     _source = source;
     _phraseType = phraseType;
     _comparisonRule = comparisoneRule;
 }
Example #15
0
 internal ToTranslateRequestBuilder WithPhraseType(PhraseType type)
 {
     _type = type;
     return(this);
 }
Example #16
0
 public void SetValue(String variable, String value)
 {
     if (variable.ToLower().Trim().Equals("numtracks"))
     {
         NumTracks = Int32.Parse(value);
     }
     else if (variable.ToLower().Trim().Equals("numdrawntracks"))
     {
         NumDrawnTracks = Int32.Parse(value);
     }
     else if (variable.ToLower().Trim().Equals("rpenabletype"))
     {
         RPEnableType = (RockPowerEnableTypes)Enum.Parse(typeof(RockPowerEnableTypes), value.Trim().ToUpper());
     }
     else if (variable.ToLower().Trim().Equals("dimensions"))
     {
         Dimensions = (BoardDimensions)Enum.Parse(typeof(BoardDimensions), value.Trim().ToUpper());
     }
     else if (variable.ToLower().Trim().Equals("codename"))
     {
         CodeName = value;
     }
     else if (variable.ToLower().Trim().Equals("fullname"))
     {
         FullName = value;
     }
     else if (variable.ToLower().Trim().Equals("containsheldnotes"))
     {
         ContainsHeldNotes = Boolean.Parse(value);
     }
     else if (variable.ToLower().Trim().Equals("canwhammy"))
     {
         CanWhammy = Boolean.Parse(value);
     }
     else if (variable.ToLower().Trim().Equals("canhopo"))
     {
         CanHOPO = Boolean.Parse(value);
     }
     else if (variable.ToLower().Trim().Equals("hassolos"))
     {
         HasSolos = Boolean.Parse(value);
     }
     else if (variable.ToLower().Trim().Equals("pitchshifts"))
     {
         PitchShifts = Boolean.Parse(value);
     }
     else if (variable.ToLower().Trim().Equals("containstext"))
     {
         ContainsText = Boolean.Parse(value);
     }
     else if (variable.ToLower().Trim().Equals("typesofphrase"))
     {
         TypesOfPhrases = (PhraseType)Enum.Parse(Type.GetType("PhraseType"), value.Trim().ToUpper());
     }
     else if (variable.ToLower().Trim().Equals("needsstrum"))
     {
         NeedsStrum = Boolean.Parse(value);
     }
     else if (variable.ToLower().Trim().Equals("maxmultiplier"))
     {
         MaxMultiplier = Int32.Parse(value);
     }
     else if (variable.ToLower().Trim().Equals("overmultiplier"))
     {
         OverMultiplier = value;
     }
     else if (variable.ToLower().Trim().Equals("bumpnotes"))
     {
         BumpNotes = 0;
         value     = value.Trim();
         while (value.Length > 0)
         {
             if (value.IndexOf(',') < 0)
             {
                 BumpNotes |= (((ulong)1) << Int32.Parse(value.Trim()));
                 break;
             }
             else
             {
                 BumpNotes |= (((ulong)1) << Int32.Parse(value.Substring(0, value.IndexOf(',')).Trim()));
                 value      = value.Substring(value.IndexOf(',') + 1).Trim();
             }
         }
     }
     else if (variable.ToLower().Trim().Equals("colors"))
     {
         value = value.Trim();
         int index = 0;;
         while (value.Length > 0)
         {
             if (value.IndexOf(',') < 0)
             {
                 break;
             }
             colorIndices[index] = Int32.Parse(value.Substring(0, value.IndexOf(',')).Trim());
             value = value.Substring(value.IndexOf(',') + 1).Trim();
             index++;
         }
     }
     else if (variable.ToLower().Trim().Equals("diffsame"))
     {
         DiffSame = Boolean.Parse(value);
     }
     else
     {
         throw new InvalidOperationException("Invalid Instrument Variable Name: " + variable);
     }
 }
Example #17
0
 public PhraseBuilder()
 {
     _id         = 0;
     _phraseType = new PhraseTypeBuilder().Build();
 }
Example #18
0
 public PhraseBuilder WithPhraseType(PhraseType phraseType)
 {
     _phraseType = phraseType;
     return(this);
 }
Example #19
0
        // build segments up into noun, verb and indirect object phrases
        public void readSegments(List <clsSegment> segments)
        {
            // get the is and verb concepts
            clsConcept isConcept   = memory.recallConcept("is");
            clsConcept verbConcept = memory.recallConcept("verb");

            List <clsPhrase> Topics = new List <clsPhrase>();

            // loop fragements and segments since the commas are not nessisarily the end of a phrase
            clsPhrase  phrase;
            clsPattern pattern;


            PhraseType currentPhraseType = PhraseType.noun;


            // starting subject phrase
            phrase            = new clsPhrase(memory);
            phrase.type       = PhraseType.noun;
            currentPhraseType = PhraseType.noun;
            this.phrases.Add(phrase);

            foreach (clsSegment segment in segments)
            {
                // look up pattern for this segment
                pattern = memory.recallCreatePattern(segment.text);

                if (pattern.text == "are")
                {
                    int x = 2;
                }

                if (currentPhraseType == PhraseType.noun)
                {
                    // if pattern still fits the expected phrase keep adding
                    if (pattern.objectRelationships(isConcept, verbConcept).Count == 0)
                    {
                        phrase.patterns.Add(pattern);                                                                 // keep adding to subject phrase until we hit a verb
                    }
                    else
                    {
                        // starting new verb phrase
                        phrase            = new clsPhrase(memory);
                        phrase.type       = PhraseType.verb;
                        currentPhraseType = PhraseType.verb;
                        this.phrases.Add(phrase);
                    }
                }

                // building verb phrase
                if (currentPhraseType == PhraseType.verb)
                {
                    if (pattern.objectRelationships(isConcept, verbConcept).Count > 0)
                    {
                        phrase.patterns.Add(pattern);                                                                // keep adding to verb phrase until we hit word that is not a verb
                    }
                    else
                    {
                        // starting object phrase
                        phrase            = new clsPhrase(memory);
                        phrase.type       = PhraseType.absolute;
                        currentPhraseType = PhraseType.absolute;
                        this.phrases.Add(phrase);
                    }
                }

                // building object phrase
                if (currentPhraseType == PhraseType.absolute)
                {
                    phrase.patterns.Add(pattern);
                }
            }

            // add last phase to phrases
            this.phrases.Add(phrase); // keep adding to object phrase
        }
 /// <summary>
 /// 添加词和词类
 /// </summary>
 /// <param name="phrase">词</param>
 /// <param name="pt">词类</param>
 public void AddPhraseResult(string phrase, PhraseType pt)
 {
     _strs.Add(phrase);
     _types.Add(pt);
 }
Example #21
0
 /// <summary>
 /// Initializes a new instance of the <see cref="FindHighlightRule" /> class.
 /// </summary>
 /// <param name="source">The source.</param>
 /// <param name="phraseType"></param>
 /// <param name="comparisoneRule">The comparisone rule.</param>
 public FindHighlightRule(ISearchSource source, PhraseType phraseType, StringComparison comparisoneRule)
 {
     _source         = source;
     _phraseType     = phraseType;
     _comparisonRule = comparisoneRule;
 }
Example #22
0
 public ToTranslateRequest(PhraseType phraseType, Language language)
 {
     PhraseType = phraseType;
     Language   = language;
 }
 public PhraseTypeAttribute(PhraseType phraseType, string pattern = null)
 {
     PhraseType = phraseType;
     Pattern    = pattern ?? string.Empty;
 }