private void findRandomEdgeTopic(out EdgeNavigationData edgeTopic, out string edgeHypothesis) { var rndIndex = _rnd.Next(_edges.Length); var edge = _edges[rndIndex]; edgeTopic = _data.GetEdgeData(edge); var hypotheses = edgeTopic.ExpressionVotes.ToArray(); var totalVoteCount = hypotheses.Select(t => Math.Abs(t.Item2)).Sum() + 1; //TODO format edge to be readable edgeHypothesis = formatFreebaseEdge(edgeTopic.Edge); var repetitionCount = hypotheses.Length * 5; for (var i = 0; i < repetitionCount; ++i) { var hypothesisSample = hypotheses[i % hypotheses.Length]; var threshold = 1.0 * Math.Max(1, hypothesisSample.Item2) / totalVoteCount; if (_rnd.NextDouble() >= threshold) { continue; } edgeHypothesis = hypothesisSample.Item1; } }
private void setRandomTopic() { _currentEntityTopic = null; _currentEdgeTopic = null; _currentEdgeHypothesis = null; _initialEdgeHypothesis = null; //TODO select random state _currentState = NavigationDialogState.ExpectsEdgeHint; switch (_currentState) { case NavigationDialogState.ExpectsEntityLabelHint: _currentEntityTopic = getRandomEntityTopic(); return; case NavigationDialogState.ExpectsEdgeHint: findRandomEdgeTopic(out _currentEdgeTopic, out _currentEdgeHypothesis); _initialEdgeHypothesis = _currentEdgeHypothesis; _currentEdgeRepresentant = getRandomEdgeRepresentant(_currentEdgeTopic.Edge); return; } }