public static void TestQueryIsTypeFields() { const string filename = "Resources/TypeProperties.nt"; const string outputPath = "CreateIndexIsTypeFields"; outputPath.DeleteIfExists(); Assert.False(Directory.Exists(outputPath)); new EntitiesIndexer(filename, outputPath).Index(); var query = "chile"; var types = new MultiLabelTypeQuery(outputPath, query).Query(); var all = new MultiLabelEntityQuery(outputPath, query).Query(); Assert.Empty(types); Assert.Single(all); query = "country"; types = new MultiLabelTypeQuery(outputPath, query).Query(); all = new MultiLabelEntityQuery(outputPath, query).Query(); Assert.Single(types); Assert.Single(all); outputPath.DeleteIfExists(); }
public void TestMultiQueryBarackObamaShouldShowFirst() { const string filename = "Resources/QueryMulti.nt"; const string outputPath = "QueryMultiIndexBarack"; outputPath.DeleteIfExists(); new EntitiesIndexer(filename, outputPath).Index(); var actual = new MultiLabelEntityQuery(outputPath, "Obama").Query().FirstOrDefault(); Debug.Assert(actual != null, nameof(actual) + " != null"); Assert.Equal("Q76", actual.Id); outputPath.DeleteIfExists(); }
public void TestWithEndWildcardQueryResults() { const string filename = "Resources/QueryWildcardOnePerLetter.nt"; const string outputPath = "OneLetterWildcardWithAsterisk"; outputPath.DeleteIfExists(); new EntitiesIndexer(filename, outputPath).Index(); var actual = new MultiLabelEntityQuery(outputPath, "Oba*").Query().FirstOrDefault(); Debug.Assert(actual != null, nameof(actual) + " != null"); Assert.Equal("Q76000000", actual.Id); outputPath.DeleteIfExists(); }
public void TestMultiQueryMichelleObamaShouldShowFirst() { const string filename = "Resources/QueryMulti.nt"; const string outputPath = "QueryMultiIndexMichelle"; outputPath.DeleteIfExists(); new EntitiesIndexer(filename, outputPath).Index(); var entity = new MultiLabelEntityQuery(outputPath, "Michelle Obama").Query().FirstOrDefault(); Debug.Assert(entity != null, nameof(entity) + " != null"); Assert.Equal("Q13133", entity.Id); outputPath.DeleteIfExists(); }
public void TestRankMultiQuery_ShouldBeSortedByRank_OnlyLabels() { const string filename = "Resources/QueryRanksOnlyLabels.nt"; const string outputPath = "QueryRanksSortedByPageRankOnlyLabels"; outputPath.DeleteIfExists(); new EntitiesIndexer(filename, outputPath).Index(); var entities = new MultiLabelEntityQuery(outputPath, "EntityQ").Query().ToArray(); Assert.Equal("Q6", entities[0].Id); //0.222 Assert.Equal("Q4", entities[1].Id); //0.180 Assert.Equal("Q7", entities[2].Id); //0.180 Assert.Equal("Q1", entities[3].Id); //0.138 Assert.Equal("Q5", entities[4].Id); //0.128 Assert.Equal("Q2", entities[5].Id); //0.087 Assert.Equal("Q3", entities[6].Id); //0.061 outputPath.DeleteIfExists(); }
public void TestTopQueryEntitiesResults() { const string filename = "Resources/QueryEntityWildcardAllResults.nt"; const string outputPath = "AllEntitiesResultsWildcardQueriesFullWord"; outputPath.DeleteIfExists(); new EntitiesIndexer(filename, outputPath).Index(); var actual = new MultiLabelEntityQuery(outputPath, "*").Query().ToArray(); Assert.NotEmpty(actual); Assert.Equal("Q6", actual[0].Id); //0.222 Assert.Equal("Q4", actual[1].Id); //0.180 Assert.Equal("Q7", actual[2].Id); //0.180 Assert.Equal("Q1", actual[3].Id); //0.138 Assert.Equal("Q5", actual[4].Id); //0.128 Assert.Equal("Q2", actual[5].Id); //0.087 Assert.Equal("Q3", actual[6].Id); //0.061 outputPath.DeleteIfExists(); }
public IActionResult Run(string term) { var filteredItems = new MultiLabelEntityQuery(LuceneDirectoryDefaults.EntityIndexPath, term).Query(); return(Json(filteredItems)); }