Skip to content

Commit

Permalink
Invert "in order" to "in free order"
Browse files Browse the repository at this point in the history
  • Loading branch information
arildm committed Feb 15, 2024
1 parent 4677189 commit e289391
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 44 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## [9.5.2-dev]

### Changed

- The "in order" option is inverted, so it is now "in free order" and unchecked by default (but still `in_order` in the URL query param and in the API)

## [9.5.1] - 2024-02-12

### Changed
Expand Down
10 changes: 5 additions & 5 deletions app/scripts/components/advanced_search.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ export const advancedSearchComponent = {
on-search="$ctrl.onSearch()"
on-search-save="$ctrl.onSearchSave(name)"
></search-submit>
<input id="inOrderChkAdv" type="checkbox" ng-model="$ctrl.inOrder" />
<label for="inOrderChkAdv">
{{'in_order_chk' | loc:$root.lang}}
<input id="freeOrderChkAdv" type="checkbox" ng-model="$ctrl.freeOrder" />
<label for="freeOrderChkAdv">
{{'free_order_chk' | loc:$root.lang}}
<i
class="fa fa-info-circle text-gray-400"
uib-tooltip="{{'order_help' | loc:$root.lang}}"
Expand All @@ -52,7 +52,7 @@ export const advancedSearchComponent = {
function (compareSearches, $location, $timeout) {
const $ctrl = this

$ctrl.inOrder = $location.search().in_order == null
$ctrl.freeOrder = $location.search().in_order == null

if ($location.search().search && $location.search().search.split("|")) {
var [type, ...expr] = $location.search().search.split("|")
Expand All @@ -69,7 +69,7 @@ export const advancedSearchComponent = {
$location.search("search", null)
$location.search("page", null)
$location.search("within", null)
$location.search("in_order", !$ctrl.inOrder ? false : null)
$location.search("in_order", $ctrl.freeOrder ? false : null)
$timeout(() => $location.search("search", `cqp|${$ctrl.cqp}`), 0)
}

Expand Down
30 changes: 15 additions & 15 deletions app/scripts/components/extended/standard_extended.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ export const extendedStandardComponent = {
on-search-save="$ctrl.onSearchSave(name)"
disabled="$ctrl.repeatError || $ctrl.orderError"
></search-submit>
<input id="inOrderChkExt" type="checkbox" ng-model="inOrder" ng-disabled="!$ctrl.inOrderEnabled" />
<label for="inOrderChkExt"> {{'in_order_chk' | loc:$root.lang}}</label>
<input id="freeOrderChkExt" type="checkbox" ng-model="freeOrder" ng-disabled="!$ctrl.freeOrderEnabled" />
<label for="freeOrderChkExt"> {{'free_order_chk' | loc:$root.lang}}</label>
<span> {{'and' | loc:$root.lang}} </span>
<span>{{'within' | loc:$root.lang}}</span>
<select
Expand All @@ -48,16 +48,16 @@ export const extendedStandardComponent = {
const ctrl = this

ctrl.lang = $rootScope.lang
$scope.inOrder = $location.search().in_order == null
/** Whether the "in order" option is applicable. */
ctrl.inOrderEnabled = true
$scope.freeOrder = $location.search().in_order != null
/** Whether the "free order" option is applicable. */
ctrl.freeOrderEnabled = true
ctrl.orderError = false

// TODO this is *too* weird
function triggerSearch() {
$location.search("search", null)
$location.search("page", null)
$location.search("in_order", !$scope.inOrder && ctrl.inOrderEnabled ? false : null)
$location.search("in_order", $scope.freeOrder && ctrl.freeOrderEnabled ? false : null)
$timeout(function () {
$location.search("search", "cqp")
if (!_.keys(settings["default_within"]).includes(ctrl.within)) {
Expand Down Expand Up @@ -95,26 +95,26 @@ export const extendedStandardComponent = {
c.log("Error", e)
}

ctrl.validateInOrder()
ctrl.validateFreeOrder()

$location.search("cqp", cqp)
}

$scope.$watch("inOrder", () => {
ctrl.validateInOrder()
$scope.$watch("freeOrder", () => {
ctrl.validateFreeOrder()
})

/** Trigger error if the "in order" option is incompatible with the query */
ctrl.validateInOrder = () => {
/** Trigger error if the "free order" option is incompatible with the query */
ctrl.validateFreeOrder = () => {
const cqpObjs = CQP.parse(ctrl.cqp)
if (!CQP.supportsInOrder(cqpObjs)) {
// If query doesn't support free word order, and the "in order" checkbox has been unchecked,
// If query doesn't support free word order, and the "free order" checkbox is checked,
// then disable search, show explanation and let user resolve the conflict
ctrl.orderError = !$scope.inOrder
ctrl.inOrderEnabled = !$scope.inOrder
ctrl.orderError = $scope.freeOrder
ctrl.freeOrderEnabled = $scope.freeOrder
} else {
ctrl.orderError = false
ctrl.inOrderEnabled = true
ctrl.freeOrderEnabled = true
}
}

Expand Down
25 changes: 13 additions & 12 deletions app/scripts/components/simple_search.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ export const simpleSearchComponent = {
></search-submit>
<div class="opts">
<input
id="inOrderChk"
id="freeOrderChk"
type="checkbox"
ng-model="$ctrl.inOrder"
ng-disabled="!$ctrl.inOrderEnabled"
ng-model="$ctrl.freeOrder"
ng-disabled="!$ctrl.freeOrderEnabled"
/>
<label for="inOrderChk"> {{'in_order_chk' | loc:$root.lang}}</label>
<label for="freeOrderChk"> {{'free_order_chk' | loc:$root.lang}}</label>
<span> {{'and' | loc:$root.lang}} </span>
<span> {{'and_include' | loc:$root.lang}} </span>
<input id="prefixChk" type="checkbox" ng-model="$ctrl.prefix" />
Expand Down Expand Up @@ -89,9 +89,10 @@ export const simpleSearchComponent = {
ctrl.onChange(event.value, false)
})

ctrl.inOrder = $location.search().in_order == null
/** Whether the "in order" option is applicable. */
ctrl.inOrderEnabled = false
/** Whether tokens should be matched in arbitrary order. */
ctrl.freeOrder = $location.search().in_order != null
/** Whether the "free order" option is applicable. */
ctrl.freeOrderEnabled = false
ctrl.prefix = $location.search().prefix != null
ctrl.mid_comp = $location.search().mid_comp != null
ctrl.suffix = $location.search().suffix != null
Expand All @@ -104,7 +105,7 @@ export const simpleSearchComponent = {

// triggers watch on searches.activeSearch
ctrl.updateSearch = function () {
$location.search("in_order", !ctrl.inOrder && ctrl.inOrderEnabled ? false : null)
$location.search("in_order", ctrl.freeOrder && ctrl.freeOrderEnabled ? false : null)
$location.search("prefix", ctrl.prefix ? true : null)
$location.search("mid_comp", ctrl.mid_comp ? true : null)
$location.search("suffix", ctrl.suffix ? true : null)
Expand Down Expand Up @@ -233,7 +234,7 @@ export const simpleSearchComponent = {
ctrl.lemgram = search.val
}
$rootScope.simpleCQP = CQP.expandOperators(ctrl.getCQP())
ctrl.updateInOrderEnabled()
ctrl.updateFreeOrderEnabled()
ctrl.doSearch()
}
})
Expand All @@ -247,12 +248,12 @@ export const simpleSearchComponent = {
ctrl.currentText = null
}

ctrl.updateInOrderEnabled()
ctrl.updateFreeOrderEnabled()
}

ctrl.updateInOrderEnabled = () => {
ctrl.updateFreeOrderEnabled = () => {
const cqpObjs = CQP.parse(ctrl.getCQP() || "[]")
ctrl.inOrderEnabled = CQP.supportsInOrder(cqpObjs)
ctrl.freeOrderEnabled = CQP.supportsInOrder(cqpObjs)
}

ctrl.doSearch = function () {
Expand Down
8 changes: 4 additions & 4 deletions app/translations/locale-eng.json
Original file line number Diff line number Diff line change
Expand Up @@ -346,8 +346,8 @@
"add_filter_value": "Add",

"repeat_error": "Error: Not possible to repeat from 0 for all tokens.",
"order_error": "Error: Disabling \"in order\" requires multiple tokens, no repetition, no boundaries and no wildcards.",
"order_help": "Disabling the \"in order\" option is compatible with queries that have multiple tokens, no repetition, no boundaries and no wildcards.",
"order_error": "Error: The \"in free order\" option requires multiple tokens, no repetition, no boundaries and no wildcards.",
"order_help": "The \"in free order\" option is compatible with queries that have multiple tokens, no repetition, no boundaries and no wildcards.",

"choose_value": "Choose a value",
"login_needed_for_corpora": "Login needed for access to",
Expand All @@ -358,13 +358,13 @@
"go_to_start": "Go to start page",

"stats_warn": "Statistics is disabled",
"stats_not_in_order_warn": "Statistics is currently not supported when \"in order\" is disabled.",
"stats_not_in_order_warn": "Statistics currently do not support the \"in free order\" search option.",

"read_in_strix": "Read this text in Strix",
"read_in_korp": "Read this text in Korp",
"add_token": "Add token",

"in_order_chk": "in order",
"free_order_chk": "in free order",
"prefix_chk": "initial part",
"compound_middle": "medial part",
"suffix_chk": "final part",
Expand Down
8 changes: 4 additions & 4 deletions app/translations/locale-swe.json
Original file line number Diff line number Diff line change
Expand Up @@ -344,8 +344,8 @@
"add_filter_value": "Lägg till",

"repeat_error": "Fel: Det går inte att upprepa från 0 på alla token.",
"order_error": "Fel: Det går bara att välja bort \"i följd\" om sökfrågan har flera tokens samt inga repetitioner, gränser eller tomma token.",
"order_help": "Att välja bort \"i följd\" är kompatibelt med sökfrågor som har flera tokens samt inga repetitioner, gränser eller tomma token.",
"order_error": "Fel: Alternativet \"i fri följd\" fungerar bara om sökfrågan har flera tokens samt inga repetitioner, gränser eller tomma token.",
"order_help": "Alternativet \"i fri följd\" är kompatibelt med sökfrågor som har flera tokens samt inga repetitioner, gränser eller tomma token.",

"choose_value": "Välj ett värde",
"login_needed_for_corpora": "Inloggning behövs för åtkomst till",
Expand All @@ -356,13 +356,13 @@
"go_to_start": "Gå till startsidan",

"stats_warn": "Statistiken är avaktiverad",
"stats_not_in_order_warn": "Statistiken stödjs för nuvarande inte när \"i följd\" är avaktiverad.",
"stats_not_in_order_warn": "Statistiken stödjer för närvarande inte sökalternativet \"i fri följd\".",

"read_in_strix": "Läs texten i Strix",
"read_in_korp": "Läs i Korp",
"add_token": "Lägg till token",

"in_order_chk": "i följd",
"free_order_chk": "i fri följd",
"prefix_chk": "förled",
"compound_middle": "mellanled",
"suffix_chk": "efterled",
Expand Down
4 changes: 2 additions & 2 deletions doc/user_manual_eng.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ the search button or hitting Enter.

Below the search field are a selection of check boxes, giving you a few options for your search.

**In order**
**In free order**
When searching for more than one word, the default search requires all words to occur in exactly the given order next to each
other. By unchecking the *in order* box, the search will instead find all sentences containing the search words, but the
other. By checking the *in free order* box, the search will instead find all sentences containing the search words, but the
order does not matter, and they do not need to be next to each other.

**Initial part and final part**
Expand Down
4 changes: 2 additions & 2 deletions doc/user_manual_swe.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ För att göra en lemgramsökning väljer man ett av dessa med piltangenterna sa

Under sökfältet finns ett antal kryssrutor med inställningsmöjligheter för ens sökning.

**I följd**
**I fri följd**
Vid sökning på fler än ett ord görs som standard en frassökning, vilket innebär att man enbart får träffar där sökorden
förekommer i exakt den ordning man angivit, och direkt efter varandra.
Genom att kryssa ur rutan *i följd* söks det i stället efter meningar som innehåller samtliga
Genom att kryssa i rutan *i fri följd* söks det i stället efter meningar som innehåller samtliga
sökord, i valfri ordning och inte nödvändigtvis intill varandra.

**Förled och efterled**
Expand Down

0 comments on commit e289391

Please sign in to comment.