public BinaryPerceptron(IDriver driver, double[] weights, string workspace, double learningRate = 0.1, double threshold = 0.5) { _driver = driver; Client = Neo4JHelper.ConnectDb(); Weights = weights; LearningRate = learningRate; Threshold = threshold; Workspace = workspace; }
//public static List<Neo4jConnection> GetGraphDetails(this ScenarioContext context, string graph) //{ // List<Neo4jConnection> graphDetails = new List<Neo4jConnection>(); // switch (graph) // { // case constants.publish: // graphDetails.Add(new Neo4jConnection() // { // graphName = context.GetEnv().neo4JGraphName, // uri = context.GetEnv().neo4JUrl, // userName = context.GetEnv().neo4JUid, // password = context.GetEnv().neo4JPassword // }); // if (context.GetEnv().neo4JUrl1.Length > 0) // graphDetails.Add(new Neo4jConnection() // { // graphName = context.GetEnv().neo4JGraphName1, // uri = context.GetEnv().neo4JUrl1, // userName = context.GetEnv().neo4JUid, // password = context.GetEnv().neo4JPassword // }); // break; // case constants.preview: // graphDetails.Add(new Neo4jConnection() // { // graphName = context.GetEnv().neo4JGraphNameDraft, // uri = context.GetEnv().neo4JUrlDraft, // userName = context.GetEnv().neo4JUidDraft, // password = context.GetEnv().neo4JPasswordDraft // }); // if (context.GetEnv().neo4JUrlDraft1.Length > 0) // graphDetails.Add(new Neo4jConnection() // { // graphName = context.GetEnv().neo4JGraphNameDraft1, // uri = context.GetEnv().neo4JUrlDraft1, // userName = context.GetEnv().neo4JUidDraft, // password = context.GetEnv().neo4JPasswordDraft // }); // break; // } // return graphDetails; //} //public static List<Neo4JHelper> GetGraphConnections(this ScenarioContext context, string graph) //{ // List<Neo4JHelper> connections; // string contextRef = $"graphCol_{graph}"; // if (context.ContainsKey(contextRef)) // { // connections = (List<Neo4JHelper>)context[contextRef]; // } // else // { // connections = new List<Neo4JHelper>(); // foreach (var conn in context.GetGraphDetails(graph)) // { // connections.Add(new Neo4JHelper(conn)); // } // context[contextRef] = connections; // } // // verify connections // foreach( var conn in connections) // { // while (!conn.Verify()) // { // conn.connect(); // } // } // return connections; //} public static Neo4JHelper GetGraphConnection(this ScenarioContext context, string graph, int instance = 0) { Neo4JHelper connection; string graphUri; string userId; string password; string graphName; int connectionAttempts; switch (graph) { case constants.publish: graphUri = instance == 0 ? context.GetEnv().neo4JUrl : context.GetEnv().neo4JUrl1; graphName = instance == 0 ? context.GetEnv().neo4JGraphName : context.GetEnv().neo4JGraphName1; userId = context.GetEnv().neo4JUid; password = context.GetEnv().neo4JPassword; break; case constants.preview: graphUri = instance == 0 ? context.GetEnv().neo4JUrlDraft : context.GetEnv().neo4JUrlDraft1; graphName = instance == 0 ? context.GetEnv().neo4JGraphNameDraft : context.GetEnv().neo4JGraphNameDraft1; userId = context.GetEnv().neo4JUidDraft; password = context.GetEnv().neo4JPasswordDraft; break; default: return(null); } string contextRef = $"graph_{graph}{instance}"; if (context.ContainsKey(contextRef)) { connection = (Neo4JHelper)context[contextRef]; } else { connection = new Neo4JHelper(graphName); connection.Connect(graphUri, userId, password); context[contextRef] = connection; } connectionAttempts = context.ContainsKey($"Attempts{contextRef}") ? (int)context[$"Attempts{contextRef}"] : 0; connection.Verify(); //if (!connection.Verify(connectionAttempts > maxAttempts)) //{ // context.Remove(contextRef); // context[$"Attempts{contextRef}"] = ++connectionAttempts; // connection = GetGraphConnection(context, graph, instance); //} return(connection); }
public Neo4JHelper GetGraphConnection(string key, string graphName, string graphUri, string userId, string password) { if (graphConnections == null) { graphConnections = new Dictionary <string, Neo4JHelper>(); } if (!graphConnections.ContainsKey(key)) { Neo4JHelper newConn = new Neo4JHelper(graphName); newConn.Connect(graphUri, userId, password); graphConnections[key] = newConn; } graphConnections[key].Verify(); return(graphConnections[key]); }
public void GivenIHaveMadeSureThatWithRelatedJobProfilesArePresentInTheGraphDatastore(string p0) { // check how many skills exist for occupations with related job profile var statementTemplate = (p0.ToLower().Equals("skills") ? cypher_skillWithRelatedJobProfile : cypher_occupationWithRelatedJobProfile); // var statementParameters = new Dictionary<string, object> { { "uri", context.Get<string>(keyGeneratedUri) } }; Neo4JHelper graphConnection = context.GetGraphConnection(constants.publish); int numberOfRecords = graphConnection.GetRecordCount(statementTemplate, null); if (numberOfRecords < 1) { // add a record graphConnection.ExecuteTableQuery(cypher_AddJobProfileAndRelationToOccupation, null); } // check success numberOfRecords = graphConnection.GetRecordCount(statementTemplate, null); numberOfRecords.Should().BeGreaterThan(0); // store in context context.SetExpectedRecordCount(numberOfRecords); }