Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QNTM-5869: Search keywords split mechanism #9271

Merged
merged 18 commits into from
Dec 14, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/DynamoCore/Search/SearchDictionary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ internal SearchDictionary(ILogger logger = null)

protected readonly Dictionary<V, Dictionary<string, double>> entryDictionary =
new Dictionary<V, Dictionary<string, double>>();

/// <summary>
/// Indicates whether experimental search mode is turned on.
/// </summary>
internal bool ExperimentalSearch { get; set; } = false;

private List<IGrouping<string, Tuple<V, double>>> tagDictionary;

Expand Down Expand Up @@ -350,6 +355,15 @@ internal IEnumerable<V> Search(string query, int minResultsForTolerantSearch = 0
query = query.ToLower();

var subPatterns = SplitOnWhiteSpace(query);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just as a question; should this code be wrapped in #if DEBUG statements? Probably not necessary, but I am doing the same type of code and wanted to get the group thought about if it is needed/wanted or not.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think because this code is already in the debug only menu it's fine not to use a compiler flag. On the other hand, for performance impacting code - like Console.WriteLine I would use a debug flag:
https://stackoverflow.com/questions/18464833/console-writeline-effect-on-performance

// Experimental Search
if (ExperimentalSearch)
{
var subPatternsList = subPatterns.ToList();
subPatternsList.Insert(0, query);
subPatterns = (subPatternsList).ToArray();
}

foreach (var pair in tagDictionary.Where(x => MatchWithQueryString(x.Key, subPatterns)))
{
ComputeWeightAndAddToDictionary(query, pair, searchDict);
Expand Down
9 changes: 9 additions & 0 deletions src/DynamoCoreWpf/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions src/DynamoCoreWpf/Properties/Resources.en-US.resx
Original file line number Diff line number Diff line change
Expand Up @@ -2192,4 +2192,8 @@ Do you want to install the latest Dynamo update?</value>
<value>Truncate Search Results</value>
<comment>Debug Menu | Truncate Search Results</comment>
</data>
<data name="DynamoViewDebugMenuExperimentalSearch" xml:space="preserve">
<value>Experimental Search</value>
<comment>Debug menu | Experimental Search</comment>
</data>
</root>
4 changes: 4 additions & 0 deletions src/DynamoCoreWpf/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -2192,4 +2192,8 @@ Want to publish a different package?</value>
<value>Truncate Search Results</value>
<comment>Debug menu | Truncate Search Results</comment>
</data>
<data name="DynamoViewDebugMenuExperimentalSearch" xml:space="preserve">
<value>Experimental Search</value>
<comment>Debug Menu | Experimental Search</comment>
</data>
</root>
13 changes: 13 additions & 0 deletions src/DynamoCoreWpf/ViewModels/Core/DynamoViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,19 @@ public bool EnableTSpline
}
}

/// <summary>
/// Indicates whether experimental search mode is turned on.
/// For internal debug use only. Do not use!
/// </summary>
public bool ExperimentalSearch
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should have a summary /// tag if this a public API - does it need to be public?

{
get { return model.SearchModel.ExperimentalSearch; }
set
{
model.SearchModel.ExperimentalSearch = value;
}
}

/// <summary>
/// Indicates whether search results should be truncated (currently to 20 items).
/// </summary>
Expand Down
7 changes: 6 additions & 1 deletion src/DynamoCoreWpf/Views/Core/DynamoView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -785,10 +785,15 @@
Header="{x:Static p:Resources.DynamoViewDebugMenuShowDebugAST}"
IsChecked="{Binding ShowDebugASTs}"></MenuItem>
<MenuItem Focusable="False"
Name="ExperimentalSearch"
Name="TruncateSearchResults"
Copy link
Collaborator Author

@scottmitchell scottmitchell Dec 14, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ColinDayOrg FYI I renamed your menu item name

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, thanks. I am assuming that the "TruncateSearchResults" menu has been checked to test if it still works as expected after this change?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just did a quick test to verify that the menu still works in the current master codebase after this specific change, so it seems ok to me.

IsCheckable="True"
IsChecked="{Binding TruncateSearchResults}"
Header="{x:Static p:Resources.DynamoViewDebugMenuTruncateSearchResults}" />
<MenuItem Focusable="False"
Name="ExperimentalSearch"
IsCheckable="True"
IsChecked="{Binding ExperimentalSearch}"
Header="{x:Static p:Resources.DynamoViewDebugMenuExperimentalSearch}" />
<MenuItem Focusable="False"
Name="ForceReexec"
Header="{x:Static p:Resources.DynamoViewDebugMenuForceReExecute}"
Expand Down