private void iterateLines(EntityLineProcessor processor) { var totalSize = new FileInfo(_freebaseDataFile).Length; using (var fileStream = File.OpenRead(_freebaseDataFile)) using (var file = new StreamReader(fileStream)) { var currentLine = 0; while (!file.EndOfStream) { ++currentLine; if (currentLine % 100000 == 0) { var currentPosition = fileStream.Position; Console.WriteLine("{0:0.00}", 100.0 * currentPosition / totalSize); } var line = file.ReadLine(); var parts = line.Split('\t'); var entity1 = getId(parts[0]); var edge = FreebaseDbProvider.GetShortEdgeName(parts[1]); var targetMids = parts[2].Split(' '); var targetEntities = new string[targetMids.Length]; for (var i = 0; i < targetMids.Length; ++i) { targetEntities[i] = getId(intern(targetMids[i])); } processor(intern(entity1), intern(edge), targetEntities); } } }
internal string GetLabel(string mid) { var entry = GetEntryFromId(FreebaseDbProvider.GetId(mid)); if (entry == null) { return(null); } return(entry.Label); }
internal FreebaseGraphLayer(FreebaseDbProvider db) { _db = db; }
internal void AddTargetMid(string mid) { TargetIds.Add(FreebaseDbProvider.GetId(mid)); }
internal EntityInfo GetEntity(DbPointer pointer) { var entry = GetEntry(pointer); return(new EntityInfo(FreebaseDbProvider.GetMid(entry.Id), entry.Label, entry.Targets.Where(t => !t.Item1.IsOutcoming).Count(), entry.Targets.Where(t => t.Item1.IsOutcoming).Count(), entry.Description)); }
private string getId(string id) { return(FreebaseDbProvider.GetId(id)); }