Beispiel #1
0
 public TokenPageRanks GetTokenPageRank(TokenIds tokenIds)
 {
     return _getTokenPageRankCmd.Receive(tokenIds);
 }
Beispiel #2
0
        public void TestFlattenToDistinct()
        {
            var t0 = new MetadataTokenId
            {
                Id = 1,
                RslvAsmIdx = 0,
                Items = new[]
                {
                    new MetadataTokenId
                    {
                        Id = 2,
                        RslvAsmIdx = 0,
                        Items = new[]
                        {
                            new MetadataTokenId {Id = 3, RslvAsmIdx = 0},
                            new MetadataTokenId
                            {
                                Id = 4,
                                RslvAsmIdx = 0,
                                Items = new[]
                                {
                                    new MetadataTokenId {Id = 1, RslvAsmIdx = 1},
                                    new MetadataTokenId {Id = 2, RslvAsmIdx = 1}
                                }
                            },
                            new MetadataTokenId
                            {
                                Id = 5,
                                RslvAsmIdx = 0,
                                Items = new[] {new MetadataTokenId {Id = 1, RslvAsmIdx = 1}}
                            }

                        },

                    },
                    new MetadataTokenId {Id = 6, RslvAsmIdx = 0},
                    new MetadataTokenId {Id = 7, RslvAsmIdx = 0}
                }
            };
            var t1 = new MetadataTokenId
            {
                Id = 8,
                RslvAsmIdx = 0,
                Items = new[]
                {
                    new MetadataTokenId
                    {
                        Id = 9,
                        RslvAsmIdx = 0,
                        Items = new[] {new MetadataTokenId {Id = 1, RslvAsmIdx = 0}}
                    }
                }
            };
            var testSubject = new TokenIds {Tokens = new[] {t0, t1}};
            var testResult = testSubject.FlattenToDistinct();
            Assert.IsNotNull(testResult);
            Assert.AreNotEqual(0, testResult.Length);
            Assert.AreEqual(11, testResult.Length);

            testResult = testSubject.FlattenToDistinct(true);
            Assert.IsNotNull(testResult);
            Assert.AreNotEqual(0, testResult.Length);
            Assert.AreEqual(11,testResult.Length);

            var t1x0 = testResult.FirstOrDefault(x => x.Id == 1 && x.RslvAsmIdx == 0);
            Assert.IsNotNull(t1x0);
            Assert.IsNotNull(t1x0.Items);
            Assert.AreNotEqual(0,t1x0.Items.Length);
            Assert.AreEqual(3, t1x0.Items.Length);
        }
Beispiel #3
0
        internal Tuple<int,int,double>[] ResolveTokenPageRanks(TokenIds tokens)
        {
            if (tokens == null)
                return null;
            var adjGraph = tokens.GetAdjancencyMatrix(true);
            Re.Efx.RTempDir = _myProgram.LogDirectory;
            var pageRank = Re.Efx.GetPageRank(adjGraph.Item2);
            var idx = adjGraph.Item1;
            var valsOut = new List<Tuple<int, int, double>>();
            for (var i = 0; i < idx.Count; i++)
            {
                if (i >= pageRank.Length)
                    break;
                var asmIdx = idx[i].RslvAsmIdx;
                var token = idx[i].Id;
                var pr = pageRank[i];
                valsOut.Add(new Tuple<int, int, double>(asmIdx,token,pr));
            }

            return valsOut.ToArray();
        }