Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
arildm committed May 27, 2024
2 parents e82fda9 + 9087000 commit e146990
Show file tree
Hide file tree
Showing 124 changed files with 3,920 additions and 3,385 deletions.
80 changes: 79 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,83 @@
# Changelog

## [9.6.0] - 2024-05-27

### Added

- Frontpage with description, news, corpus updates and example search queries [#341](https://github.com/spraakbanken/korp-frontend/issues/341)
- Configurable generated link in corpus info [#355](https://github.com/spraakbanken/korp-frontend/issues/355)
- Loading spinner in the autocomplete for structural values (`structServiceAutocomplete`)

### Changed

- Newsdesk moved from icon+popup in header to frontpage [#348](https://github.com/spraakbanken/korp-frontend/issues/348)
- Switched to parsing news from YAML file, using new setting `news_url` instead of `news_desk_url` (see [docs/frontend_devel.md](frontend_devel.md)) [#348](https://github.com/spraakbanken/korp-frontend/issues/348)
- The "medial part" option now includes first/last parts also for lemgram search [#347](https://github.com/spraakbanken/korp-frontend/issues/347)
- Improved UI reactivity for Simple search
- Make the search button(s) more visible [#308](https://github.com/spraakbanken/korp-frontend/issues/308)
- Use native checkboxes in corpus chooser, not images [#362](https://github.com/spraakbanken/korp-frontend/issues/362)
- Replaced JQuery Flot library with Chart.js, used in corpus chooser time graph
- Added TypeScript definitions for Korp backend parameters and responses
- Wrapped `GraphProxy`, `KwicProxy`, `LemgramProxy`, `StatsProxy` and `TimeProxy` with factories; see [@/util/Factory](./app/scripts/util.ts)
- Removed the `stats_rewrite` config option, as the change above eliminated the need for this
- Removed globals – import them instead (or their members):
- `authenticationProxy`
- `settings`
- `currentMode`
- `currentModeParallel`
- `CQP`
- `model`
- `CorpusListing`
- `ParallelCorpusListing`
- `statisticsService`
- `regescape`
- `unregescape`
- `safeApply`
- Removed the `warning` directive – use the `korp-warning` class directly instead.
- Removed the unused `toBody` directive
- Converted the `timeInterval` directive to a component `datetimePicker`
- Renamed localization functions (just like the template filters) and moved them to `@/i18n`:
- `getLocaleString` to `loc`
- `getLocaleStringObject` to `locObj`
- `translateAttribute` to `locAttribute` (also moved the optional `lang` parameter last)
- Renamed lemgram/saldo functions:
- `lemgramToString` to `lemgramToHtml`
- `lemgramToPlainString` to `lemgramToString`
- `isLemgramId` to `isLemgram`
- `saldoToString` to `saldoToHtml`
- `saldoToPlaceholderString` to `saldoToString`
- Removed `window.util` and converted its members to exported functions:
- lemgram/saldo functions
- `setDownloadLinks`
- `httpConfAddMethod`, `httpConfAddMethodAngular`, `httpConfAddMethodFetch`
- `collatorSort`
- Revised number formatting:
- Removed `formatDecimalString` and `prettyNumbers`
- Added `formatRelativeHits` to format a number with exactly one decimal
- All occurrences of relative hit counts now use this
- Added `hitCountHtml` to consistently format a relative+absolute tuple
- Revised the `locationSearch` and `searchHash` util functions:
- Deprecated global `locationSearch` in favor of using `$location` directly
- Removed global `searchHash` in favor of using `$location` directly
- Added `locationSearchGet`/`locationSearchSet` to expose `$location.search` to code outside Angular
- Removed map layer "Stamen Watercolor" [#339](https://github.com/spraakbanken/korp-frontend/issues/339)
- Removed dependency `jquery.format`

### Fixed

- Statistics subquery incorrect when using repetition and boundaries [#354](https://github.com/spraakbanken/korp-frontend/issues/354)
- Correct order of numbers in trend diagram table (first relative, then absolute)
- Update number formatting in statistics table when switching language
- Disable Trend diagram and Map buttons while waiting for statistics search to finish [#346](https://github.com/spraakbanken/korp-frontend/issues/346)
- Error when clicking trend diagram with multiple series [#358](https://github.com/spraakbanken/korp-frontend/issues/358)
- Broken singleValue component [#361](https://github.com/spraakbanken/korp-frontend/issues/361)
- Strip HTML from total hits in annotated KWIC dowload
- Fix dynamic translation for tabs, filters etc
- Modes in "More" menu sorted locale-awarely
- Allow dash in attribute name
- Restore UI message when search gives no hits
- The `corpus_info` request uses `GET` when possible

## [9.5.3] - 2024-03-11

### Added
Expand Down Expand Up @@ -134,7 +212,7 @@
- Lots of bug fixes for the sidebar

[unreleased]: https://github.com/spraakbanken/korp-frontend/compare/master...dev
[9.5.3]: https://github.com/spraakbanken/korp-frontend/releases/tag/v9.5.3
[9.6.0]: https://github.com/spraakbanken/korp-frontend/releases/tag/v9.6.0
[9.5.2]: https://github.com/spraakbanken/korp-frontend/releases/tag/v9.5.2
[9.5.1]: https://github.com/spraakbanken/korp-frontend/releases/tag/v9.5.1
[9.5.0]: https://github.com/spraakbanken/korp-frontend/releases/tag/v9.5.0
Expand Down
49 changes: 31 additions & 18 deletions app/config/statistics_config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
/** @format */
import _ from "lodash"
import settings from "@/settings"
import { lemgramToHtml, regescape, saldoToHtml } from "@/util"
import { locAttribute } from "@/i18n"

let customFunctions = {}

Expand All @@ -9,7 +12,10 @@ try {
console.log("No module for statistics functions available")
}

let getCqp = function (hitValues, ignoreCase) {
export function getCqp(hitValues, ignoreCase) {
const positionalAttributes = ["word", ...Object.keys(settings.corpusListing.getCurrentAttributes())]
let hasPositionalAttributes = false

var tokens = []
for (var i = 0; i < hitValues.length; i++) {
var token = hitValues[i]
Expand All @@ -19,13 +25,21 @@ let getCqp = function (hitValues, ignoreCase) {
var values = token[attribute]
andExpr.push(reduceCqp(attribute, values, ignoreCase))
}

// Flag if any of the attributes is positional
if (positionalAttributes.includes(attribute)) hasPositionalAttributes = true
}
tokens.push("[" + andExpr.join(" & ") + "]")
}
return `<match> ${tokens.join(" ")} []* </match>`

// If reducing by structural attributes only, then `hitValues` has only the first match token,
// so allow any number of subsequent tokens in the match.
if (!hasPositionalAttributes) tokens.push("[]{0,}")

return `<match> ${tokens.join(" ")} </match>`
}

let reduceCqp = function (type, tokens, ignoreCase) {
function reduceCqp(type, tokens, ignoreCase) {
let attrs = settings.corpusListing.getCurrentAttributes()
if (attrs[type] && attrs[type].stats_cqp) {
// A stats_cqp function should call regescape for the value as appropriate
Expand All @@ -39,6 +53,7 @@ let reduceCqp = function (type, tokens, ignoreCase) {
case "lex":
case "lemma":
case "sense":
case "transformer-neighbour":
if (tokens[0] === "") return "ambiguity(" + type + ") = 0"
else var res
if (tokens.length > 1) {
Expand Down Expand Up @@ -69,24 +84,24 @@ let reduceCqp = function (type, tokens, ignoreCase) {
case "pos":
case "deprel":
case "msd":
return $.format('%s="%s"', [type, tokens[0]])
return `${type}="${tokens[0]}"`
case "text_blingbring":
case "text_swefn":
return $.format('_.%s contains "%s"', [type, tokens[0]])
return `_.${type} contains "${tokens[0]}"`
default:
if (attrs[type]) {
// word attributes
const op = attrs[type]["type"] === "set" ? " contains " : "="
return $.format('%s%s"%s"', [type, op, tokens[0]])
return `${type}${op}"${tokens[0]}"`
} else {
// structural attributes
return $.format('_.%s="%s"', [type, tokens[0]])
return `_.${type}="${tokens[0]}"`
}
}
}

// Get the html (no linking) representation of the result for the statistics table
let reduceStringify = function (type, values, structAttributes) {
export function reduceStringify(type, values, structAttributes) {
let attrs = settings.corpusListing.getCurrentAttributes()

if (attrs[type] && attrs[type].stats_stringify) {
Expand All @@ -99,7 +114,7 @@ let reduceStringify = function (type, values, structAttributes) {
return values.join(" ")
case "pos":
var output = _.map(values, function (token) {
return util.translateAttribute(null, attrs["pos"].translation, token)
return locAttribute(attrs["pos"].translation, token)
}).join(" ")
return output
case "saldo":
Expand All @@ -109,11 +124,11 @@ let reduceStringify = function (type, values, structAttributes) {
case "lemma":
case "sense":
if (type == "saldo" || type == "sense") {
var stringify = util.saldoToString
var stringify = saldoToHtml
} else if (type == "lemma") {
stringify = (lemma) => lemma.replace(/_/g, " ")
} else {
stringify = util.lemgramToString
stringify = lemgramToHtml
}

var html = _.map(values, function (token) {
Expand All @@ -123,9 +138,12 @@ let reduceStringify = function (type, values, structAttributes) {

return html.join(" ")

case "transformer-neighbour":
return values.map((value) => value.replace(/:.*/g, "")).join(" ")

case "deprel":
var output = _.map(values, function (token) {
return util.translateAttribute(null, attrs["deprel"].translation, token)
return locAttribute(attrs["deprel"].translation, token)
}).join(" ")
return output
case "msd_orig": // TODO: OMG this is corpus specific, move out to config ASAP (ASU corpus)
Expand All @@ -145,7 +163,7 @@ let reduceStringify = function (type, values, structAttributes) {
} else if (value === "") {
return "-"
} else if (structAttributes.translation) {
return util.translateAttribute(null, structAttributes.translation, value)
return locAttribute(structAttributes.translation, value)
} else {
return value
}
Expand All @@ -154,8 +172,3 @@ let reduceStringify = function (type, values, structAttributes) {
}
}
}

export default {
getCqp,
reduceStringify,
}
Binary file removed app/img/checked.png
Binary file not shown.
Binary file removed app/img/intermediate.png
Binary file not shown.
Binary file removed app/img/unchecked.png
Binary file not shown.
1 change: 1 addition & 0 deletions app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ <h2>You need JavaScript to run Korp.</h2>
<header></header>
<div class="px-3 pb-3" id="content">
<searchtabs></searchtabs>
<frontpage></frontpage>
<results></results>
</div>
</div>
Expand Down
61 changes: 13 additions & 48 deletions app/index.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
/** @format */
import $ from "jquery"
import currentMode from "@/mode"
import { locationSearchGet } from "@/util"

import settings from 'korp_config'

window.settings = settings
settings.markup = {
msd: require("./markup/msd.html")
}

let $ = require("jquery");
window.jQuery = $;
window.$ = $;
window.jQuery = $
window.$ = $

require("slickgrid/slick.grid.css")
require("./styles/ui_mods.css")
Expand All @@ -27,43 +23,20 @@ require("./styles/styles.scss")
require("./styles/textreader.css")

require("components-jqueryui/ui/widget.js")
require("components-jqueryui/ui/widgets/sortable.js")
require("components-jqueryui/ui/widgets/dialog.js")

require("angular")
require("angular-ui-bootstrap/src/typeahead")
require("angular-ui-bootstrap/src/tooltip")
require("angular-ui-bootstrap/src/modal")
require("angular-ui-bootstrap/src/tabs")
require("angular-ui-bootstrap/src/dropdown")
require("angular-ui-bootstrap/src/pagination")
require("angular-ui-bootstrap/src/datepicker")
require("angular-ui-bootstrap/src/timepicker")
require("angular-ui-bootstrap/src/buttons")
require("angular-ui-bootstrap/src/popover")

require("angular-spinner")
require("angular-ui-sortable/src/sortable")

require("jquerylocalize")
require("jqueryhoverintent")
require("./lib/jquery.format.js")

window.c = console
window.currentMode = new URLSearchParams(window.location.search).get('mode') || "default"

try {
// modes-files are optional and have customizing code
require(`modes/${currentMode}_mode.js`)
// modes-files are optional and have customizing code
require(`modes/${currentMode}_mode.js`)
} catch (error) {
console.log("No mode file available for mode:", currentMode)
if (error.code != "MODULE_NOT_FOUND") console.error("Error importing mode file:", error)
}

require("angular-dynamic-locale/dist/tmhDynamicLocale.js")

require("jquery-flot/jquery.flot.js")
require("jquery-flot/jquery.flot.stack.js")

require("slickgrid/lib/jquery.event.drag-2.3.0")
require("slickgrid/slick.core")
require("slickgrid/slick.grid")
Expand All @@ -76,25 +49,14 @@ require("./scripts/jq_extensions.js")
window.moment = require("moment")
window.CSV = require("comma-separated-values/csv")

require("./lib/leaflet-settings.js")
require("leaflet")
require("leaflet.markercluster")
require("leaflet-providers")
require("geokorp/dist/scripts/geokorp")
require("geokorp/dist/scripts/geokorp-templates")
require("angular-filter/index.js")


require("./lib/jquery.tooltip.pack.js")

require("./scripts/components/sidebar.js")

require("./scripts/statistics.js")
require("./scripts/cqp_parser/CQPParser.js")
require("./scripts/cqp_parser/cqp.js")
require("./scripts/util.js")
require("./scripts/pie-widget.js")
require("./scripts/model.js")
require("./scripts/widgets.js")
require("./scripts/main.js")
require("./scripts/app.js")
Expand All @@ -118,5 +80,8 @@ require("./scripts/struct_services.js")
require("./scripts/directives.js")
require("./scripts/directives/scroll.js")
require("./scripts/filter_directives.js")
require("./scripts/newsdesk.js")
require("./scripts/matomo.js")

// TODO Remove, currently used in tests
/** @deprecated */
window.locationSearch = locationSearchGet
Loading

0 comments on commit e146990

Please sign in to comment.