/// <summary> /// Create a ToParentBlockJoinQuery. /// </summary> /// <param name="childQuery"> Query matching child documents. </param> /// <param name="parentsFilter"> Filter (must produce FixedBitSet /// per-segment, like <see cref="FixedBitSetCachingWrapperFilter"/>) /// identifying the parent documents. </param> /// <param name="scoreMode"> How to aggregate multiple child scores /// into a single parent score. /// </param> public ToParentBlockJoinQuery(Query childQuery, Filter parentsFilter, ScoreMode scoreMode) { _origChildQuery = childQuery; _childQuery = childQuery; _parentsFilter = parentsFilter; _scoreMode = scoreMode; }
public BlockJoinWeight(Query joinQuery, Weight childWeight, Filter parentsFilter, ScoreMode scoreMode) : base() { JoinQuery = joinQuery; ChildWeight = childWeight; ParentsFilter = parentsFilter; ScoreMode = scoreMode; }
private ToParentBlockJoinQuery(Query origChildQuery, Query childQuery, Filter parentsFilter, ScoreMode scoreMode) : base() { _origChildQuery = origChildQuery; _childQuery = childQuery; _parentsFilter = parentsFilter; _scoreMode = scoreMode; }
private TopDocs CreateExpectedTopDocs(string queryValue, bool from, ScoreMode scoreMode, IndexIterationContext context) { var hitsToJoinScores = @from ? context.FromHitsToJoinScore[queryValue] : context.ToHitsToJoinScore[queryValue]; var hits = new JCG.List <KeyValuePair <int, JoinScore> >(hitsToJoinScores); hits.Sort(Comparer <KeyValuePair <int, JoinScore> > .Create((hit1, hit2) => { float score1 = hit1.Value.Score(scoreMode); float score2 = hit2.Value.Score(scoreMode); int cmp = score2.CompareTo(score1); if (cmp != 0) { return(cmp); } return(hit1.Key - hit2.Key); })); ScoreDoc[] scoreDocs = new ScoreDoc[Math.Min(10, hits.Count)]; for (int i = 0; i < scoreDocs.Length; i++) { KeyValuePair <int, JoinScore> hit = hits[i]; scoreDocs[i] = new ScoreDoc(hit.Key, hit.Value.Score(scoreMode)); } return(new TopDocs(hits.Count, scoreDocs, hits.Count == 0 ? float.NaN : hits[0].Value.Score(scoreMode))); }
float afkTimeOut = 30; //seconds of afk until game goes back to menu public void SetGameMode(BasicMode mode) { gameMode = mode; MaxScore = mode.maxPoints; scoreMode = mode.scoreMode; StartingLives = mode.maxPoints; maxTime = mode.maxTime; }
public Data(bool shuffle, ScoreMode mode, YololChip chip, Dictionary <string, Value>[] inputs, Dictionary <string, Value>[] outputs) { Shuffle = shuffle; Mode = mode; Chip = chip; In = inputs; Out = outputs; }
public BlockJoinWeight(Query joinQuery, Weight childWeight, Filter parentsFilter, ScoreMode scoreMode) : base() { this.joinQuery = joinQuery; this.childWeight = childWeight; this.parentsFilter = parentsFilter; this.scoreMode = scoreMode; }
public BlockJoinScorer(Weight weight, Scorer childScorer, FixedBitSet parentBits, int firstChildDoc, ScoreMode scoreMode, IBits acceptDocs) : base(weight) { //System.out.println("Q.init firstChildDoc=" + firstChildDoc); _parentBits = parentBits; _childScorer = childScorer; _scoreMode = scoreMode; _acceptDocs = acceptDocs; _nextChildDoc = firstChildDoc; }
public Challenge(ulong id, string name, string checkIndicator, IReadOnlyList <IReadOnlyDictionary <string, Value> > inputs, IReadOnlyList <IReadOnlyDictionary <string, Value> > outputs, DateTime?endTime, ChallengeDifficulty difficulty, string description, bool shuffle, ScoreMode scoreMode) { Id = id; Name = name; CheckIndicator = checkIndicator; Inputs = inputs; Outputs = outputs; EndTime = endTime; Difficulty = difficulty; Description = description; ScoreMode = scoreMode; ShuffleTests = shuffle; }
protected virtual void Test300spartans(bool multipleValues, ScoreMode scoreMode) { const string idField = "id"; const string toField = "productId"; Directory dir = NewDirectory(); RandomIndexWriter w = new RandomIndexWriter(Random, dir, NewIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(Random)) .SetMergePolicy(NewLogMergePolicy())); // 0 Document doc = new Document(); doc.Add(new TextField("description", "random text", Field.Store.NO)); doc.Add(new TextField("name", "name1", Field.Store.NO)); doc.Add(new TextField(idField, "0", Field.Store.NO)); w.AddDocument(doc); doc = new Document(); doc.Add(new TextField("price", "10.0", Field.Store.NO)); for (int i = 0; i < 300; i++) { doc.Add(new TextField(toField, "" + i, Field.Store.NO)); if (!multipleValues) { w.AddDocument(doc); doc.RemoveFields(toField); } } w.AddDocument(doc); IndexSearcher indexSearcher = new IndexSearcher(w.GetReader()); w.Dispose(); // Search for product Query joinQuery = JoinUtil.CreateJoinQuery(toField, multipleValues, idField, new TermQuery(new Term("price", "10.0")), indexSearcher, scoreMode); TopDocs result = indexSearcher.Search(joinQuery, 10); assertEquals(1, result.TotalHits); assertEquals(0, result.ScoreDocs[0].Doc); indexSearcher.IndexReader.Dispose(); dir.Dispose(); }
// Calculates and returns the current score and max score in a two element array public int[] CalculateScore(ScoreMode scoreMode) { mode = scoreMode; // Initialise counts score = 0; maxScore = 0; // Now add the scores for treasures and progress TreasureScore(); ProgressScore(); // Deduct any penalties for saving, using hints or taking too many turns DeductPenalties(); return(new int[] { score, maxScore }); }
/// <summary> /// Method for query time joining. /// <p/> /// Execute the returned query with a <seealso cref="IndexSearcher"/> to retrieve all documents that have the same terms in the /// to field that match with documents matching the specified fromQuery and have the same terms in the from field. /// <p/> /// In the case a single document relates to more than one document the <code>multipleValuesPerDocument</code> option /// should be set to true. When the <code>multipleValuesPerDocument</code> is set to <code>true</code> only the /// the score from the first encountered join value originating from the 'from' side is mapped into the 'to' side. /// Even in the case when a second join value related to a specific document yields a higher score. Obviously this /// doesn't apply in the case that <seealso cref="ScoreMode.None"/> is used, since no scores are computed at all. /// </p> /// Memory considerations: During joining all unique join values are kept in memory. On top of that when the scoreMode /// isn't set to <seealso cref="ScoreMode.None"/> a float value per unique join value is kept in memory for computing scores. /// When scoreMode is set to <seealso cref="ScoreMode.Avg"/> also an additional integer value is kept in memory per unique /// join value. /// </summary> /// <param name="fromField"> The from field to join from </param> /// <param name="multipleValuesPerDocument"> Whether the from field has multiple terms per document </param> /// <param name="toField"> The to field to join to </param> /// <param name="fromQuery"> The query to match documents on the from side </param> /// <param name="fromSearcher"> The searcher that executed the specified fromQuery </param> /// <param name="scoreMode"> Instructs how scores from the fromQuery are mapped to the returned query </param> /// <returns>A <see cref="Query"/> instance that can be used to join documents based on the terms in the from and to field</returns> /// <exception cref="IOException"> If I/O related errors occur </exception> public static Query CreateJoinQuery(string fromField, bool multipleValuesPerDocument, string toField, Query fromQuery, IndexSearcher fromSearcher, ScoreMode scoreMode) { switch (scoreMode) { case ScoreMode.None: TermsCollector termsCollector = TermsCollector.Create(fromField, multipleValuesPerDocument); fromSearcher.Search(fromQuery, termsCollector); return new TermsQuery(toField, fromQuery, termsCollector.CollectorTerms); case ScoreMode.Total: case ScoreMode.Max: case ScoreMode.Avg: TermsWithScoreCollector termsWithScoreCollector = TermsWithScoreCollector.Create(fromField, multipleValuesPerDocument, scoreMode); fromSearcher.Search(fromQuery, termsWithScoreCollector); return new TermsIncludingScoreQuery(toField, multipleValuesPerDocument, termsWithScoreCollector.CollectedTerms, termsWithScoreCollector.ScoresPerTerm, fromQuery); default: throw new System.ArgumentException(string.Format("Score mode {0} isn't supported.", scoreMode)); } }
private TopDocs CreateExpectedTopDocs(string queryValue, bool from, ScoreMode scoreMode, IndexIterationContext context) { var hitsToJoinScores = @from ? context.FromHitsToJoinScore[queryValue] : context.ToHitsToJoinScore[queryValue]; var hits = new List <KeyValuePair <int, JoinScore> >(hitsToJoinScores.EntrySet()); hits.Sort(new ComparerAnonymousInnerClassHelper(this, scoreMode)); ScoreDoc[] scoreDocs = new ScoreDoc[Math.Min(10, hits.Count)]; for (int i = 0; i < scoreDocs.Length; i++) { KeyValuePair <int, JoinScore> hit = hits[i]; scoreDocs[i] = new ScoreDoc(hit.Key, hit.Value.Score(scoreMode)); } return(new TopDocs(hits.Count, scoreDocs, hits.Count == 0 ? float.NaN : hits[0].Value.Score(scoreMode))); }
internal virtual float Score(ScoreMode mode) { switch (mode) { case ScoreMode.None: return(1.0f); case ScoreMode.Total: return(total); case ScoreMode.Avg: return(total / count); case ScoreMode.Max: return(maxScore); } throw new ArgumentException("Unsupported ScoreMode: " + mode); }
/// <summary> /// Chooses the right <seealso cref="TermsWithScoreCollector"/> implementation. /// </summary> /// <param name="field">The field to collect terms for.</param> /// <param name="multipleValuesPerDocument">Whether the field to collect terms for has multiple values per document.</param> /// <returns>A <see cref="TermsWithScoreCollector"/> instance</returns> internal static TermsWithScoreCollector Create(string field, bool multipleValuesPerDocument, ScoreMode scoreMode) { if (multipleValuesPerDocument) { switch (scoreMode) { case ScoreMode.Avg: return new Mv.Avg(field); default: return new Mv(field, scoreMode); } } switch (scoreMode) { case ScoreMode.Avg: return new Sv.Avg(field); default: return new Sv(field, scoreMode); } }
void Start() { _gravityScript = GameObject.Find("Gravity").GetComponent <Gravity>(); _mainMode = SceneManager.GetActiveScene().name.Contains("Level") || SceneManager.GetActiveScene().name.Contains("level"); if (_mainMode) { _timerScript = GameObject.Find("Timer").GetComponent <Timer>(); } else if (SceneManager.GetActiveScene().name == "ScoreMode") { _scoreModeScript = GameObject.Find("Score Mode").GetComponent <ScoreMode>(); } _rigidbody = GetComponent <Rigidbody2D>(); _multiTick = 0; _cheatTime = 4; _levelTime = 1.5f; }
internal TermsWithScoreCollector(string field, ScoreMode scoreMode) { this._field = field; this._scoreMode = scoreMode; }
internal Sv(string field, ScoreMode scoreMode) : base(field, scoreMode) { }
/// <summary> /// Chooses the right <see cref="TermsWithScoreCollector"/> implementation. /// </summary> /// <param name="field">The field to collect terms for.</param> /// <param name="multipleValuesPerDocument">Whether the field to collect terms for has multiple values per document.</param> /// <param name="scoreMode">See <see cref="ScoreMode"/></param> /// <returns>A <see cref="TermsWithScoreCollector"/> instance</returns> internal static TermsWithScoreCollector Create(string field, bool multipleValuesPerDocument, ScoreMode scoreMode) { if (multipleValuesPerDocument) { switch (scoreMode) { case ScoreMode.Avg: return(new MV.Avg(field)); default: return(new MV(field, scoreMode)); } } switch (scoreMode) { case ScoreMode.Avg: return(new SV.Avg(field)); default: return(new SV(field, scoreMode)); } }
public static void SetFadeEqDieMode() { scoreMode = ScoreMode.fadeEqDie; }
void Update() { if (Input.GetKeyDown(KeyCode.Escape) || GamepadInput.GamePad.GetButtonDown(GamepadInput.GamePad.Button.Start, GamepadInput.GamePad.Index.Any)) { if (!isPaused) //if (roundState != RoundState.PAUSED) { { Pause(); } else { UnPause(); } } if (roundState != RoundState.PAUSED) { if (roundState != RoundState.PLAYING && (!warmupOn || round != -1)) { roundState = RoundState.PLAYING; } freezeTimer -= Time.deltaTime; //Goes negative for fading //Set mode-specific variables switch (mode) { case (GameMode.CORE): restartTime = 2.5f; teams = 2; minPlayers = 2; maxPlayers = 4; //scoreToWin = 60; scoreMode = ScoreMode.GOAL; scorePerRound = false; //Technically true, but the hook is for the goal shot useRespawns = true; respawnTime = 4; break; case (GameMode.FFA): restartTime = 10; teams = 0; minPlayers = 2; maxPlayers = 4; //scoreToWin=20; scoreMode = ScoreMode.KILL; scorePerRound = false; useRespawns = true; respawnTime = 3; break; case (GameMode.DUEL): restartTime = 1.5f; teams = 0; minPlayers = 2; maxPlayers = 2; //scoreToWin = 10; scoreMode = ScoreMode.LMS; scorePerRound = true; useRespawns = false; respawnTime = 0; break; } //Winners switch (scoreMode) { //case(ScoreMode.GOAL): // winners = PlayerManager.lastScoredGoal; // break; case (ScoreMode.LMS): winners = PlayerManager.lastAlive; break; case (ScoreMode.KILL): //Round never ends break; } //End round if (scoreMode == ScoreMode.KILL) { for (int i = 0; i < (teams == 0 ? PlayerManager.ActivePlayers().Length : teams); ++i) { if (PlayerManager.TeamScore(i) >= scoreToWin) { winners = PlayerManager.TeamPlayers(i); //EndGame(); if (!endSequenceInitiated) { InterfaceManager.ShowStatsScreen(); } endSequenceInitiated = true; break; } } } else if (winners != null && !roundOver) { EndRound(winners); } //Hard reset (debug) if (Input.GetKeyDown(KeyCode.Space)) { //Restart (); } if (PlayerManager.gameReady && roundState == RoundState.SETUP) { roundState = RoundState.RESPAWN; } //Editor if (mode != lastMode) { PlayerManager.Refresh(); lastMode = mode; } maxPlayers = Mathf.Max(minPlayers, maxPlayers); scoreToWin = Mathf.Max(1, scoreToWin); } }
private void ExecuteRandomJoin(bool multipleValuesPerDocument, int maxIndexIter, int maxSearchIter, int numberOfDocumentsToIndex) { for (int indexIter = 1; indexIter <= maxIndexIter; indexIter++) { if (Verbose) { Console.WriteLine("indexIter=" + indexIter); } Directory dir = NewDirectory(); RandomIndexWriter w = new RandomIndexWriter(Random, dir, NewIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(Random, MockTokenizer.KEYWORD, false)) .SetMergePolicy(NewLogMergePolicy())); bool scoreDocsInOrder = TestJoinUtil.Random.NextBoolean(); IndexIterationContext context = CreateContext(numberOfDocumentsToIndex, w, multipleValuesPerDocument, scoreDocsInOrder); IndexReader topLevelReader = w.GetReader(); w.Dispose(); for (int searchIter = 1; searchIter <= maxSearchIter; searchIter++) { if (Verbose) { Console.WriteLine("searchIter=" + searchIter); } IndexSearcher indexSearcher = NewSearcher(topLevelReader); int r = Random.Next(context.RandomUniqueValues.Length); bool from = context.RandomFrom[r]; string randomValue = context.RandomUniqueValues[r]; FixedBitSet expectedResult = CreateExpectedResult(randomValue, from, indexSearcher.IndexReader, context); Query actualQuery = new TermQuery(new Term("value", randomValue)); if (Verbose) { Console.WriteLine("actualQuery=" + actualQuery); } var scoreModeLength = Enum.GetNames(typeof(ScoreMode)).Length; ScoreMode scoreMode = (ScoreMode)Random.Next(scoreModeLength); if (Verbose) { Console.WriteLine("scoreMode=" + scoreMode); } Query joinQuery; if (from) { joinQuery = JoinUtil.CreateJoinQuery("from", multipleValuesPerDocument, "to", actualQuery, indexSearcher, scoreMode); } else { joinQuery = JoinUtil.CreateJoinQuery("to", multipleValuesPerDocument, "from", actualQuery, indexSearcher, scoreMode); } if (Verbose) { Console.WriteLine("joinQuery=" + joinQuery); } // Need to know all documents that have matches. TopDocs doesn't give me that and then I'd be also testing TopDocsCollector... FixedBitSet actualResult = new FixedBitSet(indexSearcher.IndexReader.MaxDoc); TopScoreDocCollector topScoreDocCollector = TopScoreDocCollector.Create(10, false); indexSearcher.Search(joinQuery, new CollectorAnonymousClass2(scoreDocsInOrder, actualResult, topScoreDocCollector)); // Asserting bit set... if (Verbose) { Console.WriteLine("expected cardinality:" + expectedResult.Cardinality); DocIdSetIterator iterator = expectedResult.GetIterator(); for (int doc = iterator.NextDoc(); doc != DocIdSetIterator.NO_MORE_DOCS; doc = iterator.NextDoc()) { Console.WriteLine(string.Format("Expected doc[{0}] with id value {1}", doc, indexSearcher.Doc(doc).Get("id"))); } Console.WriteLine("actual cardinality:" + actualResult.Cardinality); iterator = actualResult.GetIterator(); for (int doc = iterator.NextDoc(); doc != DocIdSetIterator.NO_MORE_DOCS; doc = iterator.NextDoc()) { Console.WriteLine(string.Format("Actual doc[{0}] with id value {1}", doc, indexSearcher.Doc(doc).Get("id"))); } } assertEquals(expectedResult, actualResult); // Asserting TopDocs... TopDocs expectedTopDocs = CreateExpectedTopDocs(randomValue, from, scoreMode, context); TopDocs actualTopDocs = topScoreDocCollector.GetTopDocs(); assertEquals(expectedTopDocs.TotalHits, actualTopDocs.TotalHits); assertEquals(expectedTopDocs.ScoreDocs.Length, actualTopDocs.ScoreDocs.Length); if (scoreMode == ScoreMode.None) { continue; } assertEquals(expectedTopDocs.MaxScore, actualTopDocs.MaxScore, 0.0f); for (int i = 0; i < expectedTopDocs.ScoreDocs.Length; i++) { if (Verbose) { Console.WriteLine(string.Format(CultureInfo.InvariantCulture, "Expected doc: {0} | Actual doc: {1}\n", expectedTopDocs.ScoreDocs[i].Doc, actualTopDocs.ScoreDocs[i].Doc)); Console.WriteLine(string.Format(CultureInfo.InvariantCulture, "Expected score: {0} | Actual score: {1}\n", expectedTopDocs.ScoreDocs[i].Score, actualTopDocs.ScoreDocs[i].Score)); } assertEquals(expectedTopDocs.ScoreDocs[i].Doc, actualTopDocs.ScoreDocs[i].Doc); assertEquals(expectedTopDocs.ScoreDocs[i].Score, actualTopDocs.ScoreDocs[i].Score, 0.0f); Explanation explanation = indexSearcher.Explain(joinQuery, expectedTopDocs.ScoreDocs[i].Doc); assertEquals(expectedTopDocs.ScoreDocs[i].Score, explanation.Value, 0.0f); } } topLevelReader.Dispose(); dir.Dispose(); } }
public CustomFiltersScoreDescriptor <T> ScoreMode(ScoreMode scoreMode) { this._ScoreMode = scoreMode; return(this); }
/// <summary> /// Allows to set how inner children matching affects scoring of parent. /// </summary> public NestedQuery <T> ScoreMode(ScoreMode scoreMode = Net.Queries.ScoreMode.avg) { RegisterJsonPart("'score_mode': {0}", scoreMode.AsString().Quotate()); return(this); }
public static void SetFadeIsNotTheEnd() { scoreMode = ScoreMode.fadeIsNotTheEnd; }
public ComparerAnonymousInnerClassHelper(TestJoinUtil outerInstance, ScoreMode scoreMode) { OuterInstance = outerInstance; ScoreMode = scoreMode; }
/// <summary> /// Method for query time joining. /// <para/> /// Execute the returned query with a <see cref="IndexSearcher"/> to retrieve all documents that have the same terms in the /// to field that match with documents matching the specified <paramref name="fromQuery"/> and have the same terms in the from field. /// <para/> /// In the case a single document relates to more than one document the <paramref name="multipleValuesPerDocument"/> option /// should be set to true. When the <paramref name="multipleValuesPerDocument"/> is set to <c>true</c> only the /// the score from the first encountered join value originating from the 'from' side is mapped into the 'to' side. /// Even in the case when a second join value related to a specific document yields a higher score. Obviously this /// doesn't apply in the case that <see cref="ScoreMode.None"/> is used, since no scores are computed at all. /// <para/> /// Memory considerations: During joining all unique join values are kept in memory. On top of that when the <paramref name="scoreMode"/> /// isn't set to <see cref="ScoreMode.None"/> a float value per unique join value is kept in memory for computing scores. /// When <paramref name="scoreMode"/> is set to <see cref="ScoreMode.Avg"/> also an additional integer value is kept in memory per unique /// join value. /// </summary> /// <param name="fromField"> The from field to join from </param> /// <param name="multipleValuesPerDocument"> Whether the from field has multiple terms per document </param> /// <param name="toField"> The to field to join to </param> /// <param name="fromQuery"> The query to match documents on the from side </param> /// <param name="fromSearcher"> The searcher that executed the specified <paramref name="fromQuery"/> </param> /// <param name="scoreMode"> Instructs how scores from the <paramref name="fromQuery"/> are mapped to the returned query </param> /// <returns>A <see cref="Query"/> instance that can be used to join documents based on the terms in the from and to field</returns> /// <exception cref="IOException"> If I/O related errors occur </exception> public static Query CreateJoinQuery(string fromField, bool multipleValuesPerDocument, string toField, Query fromQuery, IndexSearcher fromSearcher, ScoreMode scoreMode) { switch (scoreMode) { case ScoreMode.None: TermsCollector termsCollector = TermsCollector.Create(fromField, multipleValuesPerDocument); fromSearcher.Search(fromQuery, termsCollector); return(new TermsQuery(toField, fromQuery, termsCollector.CollectorTerms)); case ScoreMode.Total: case ScoreMode.Max: case ScoreMode.Avg: TermsWithScoreCollector termsWithScoreCollector = TermsWithScoreCollector.Create(fromField, multipleValuesPerDocument, scoreMode); fromSearcher.Search(fromQuery, termsWithScoreCollector); return(new TermsIncludingScoreQuery(toField, multipleValuesPerDocument, termsWithScoreCollector.CollectedTerms, termsWithScoreCollector.ScoresPerTerm, fromQuery)); default: throw new ArgumentException(string.Format("Score mode {0} isn't supported.", scoreMode)); } }
public string ModeFormat(ScoreMode pos) => ModeToNames[pos];
internal MV(string field, ScoreMode scoreMode) : base(field, scoreMode) { }
public CustomFiltersScoreQueryDescriptor <T> ScoreMode(ScoreMode scoreMode) { ((ICustomFiltersScoreQuery)this).ScoreMode = scoreMode; return(this); }
void Start() { scoreMode = ScoreMode.fadeIsNotTheEnd; }
public BlockJoinScorer(Weight weight, Scorer childScorer, FixedBitSet parentBits, int firstChildDoc, ScoreMode scoreMode, Bits acceptDocs) : base(weight) { //System.out.println("Q.init firstChildDoc=" + firstChildDoc); _parentBits = parentBits; _childScorer = childScorer; _scoreMode = scoreMode; _acceptDocs = acceptDocs; _nextChildDoc = firstChildDoc; }
public CustomFiltersScoreDescriptor <T> ScoreMode(ScoreMode scoreMode) { scoreMode.ThrowIfNull("scoreMode"); this._ScoreMode = scoreMode; return(this); }
public void StartScoring(ScoreMode mode, float startTime) { currentMode = mode; scoreStartTime = startTime; }