diff --git a/src/components/DataDisplay/DataDisplayKeywordInContext.vue b/src/components/DataDisplay/DataDisplayKeywordInContext.vue index ed6a63e..0fe2f3d 100644 --- a/src/components/DataDisplay/DataDisplayKeywordInContext.vue +++ b/src/components/DataDisplay/DataDisplayKeywordInContext.vue @@ -73,9 +73,9 @@ const selectedKWIC: Ref = ref(null);
- {{ query.finalQuery }} + {{ query.type }}: {{ query.userInput }} + - { const allSeries = queries.value.map((query: CorpusQuery) => { return { color: query.color, - name: `${query.finalQuery} ${query.corpus}${query.subCorpus ? ` / ${query.subCorpus}` : ""}`, + name: `${query.type}: ${query.userInput} ${query.corpus}${ + query.subCorpus ? ` / ${query.subCorpus}` : "" + }`, data: categories.value .map((category) => query.data.mediaSources.find(({ media }) => category === media)) // @ts-ignore @@ -47,13 +49,11 @@ const expand = ref(false);
- - {{ query.finalQuery }} - + {{ query.type }}: {{ query.userInput }}
-
+
- {{ query.finalQuery }} + {{ query.type }}: {{ query.userInput }} +
diff --git a/src/components/DataDisplay/DataDisplayRegionalFrequencies.vue b/src/components/DataDisplay/DataDisplayRegionalFrequencies.vue index e966659..a5584df 100644 --- a/src/components/DataDisplay/DataDisplayRegionalFrequencies.vue +++ b/src/components/DataDisplay/DataDisplayRegionalFrequencies.vue @@ -29,16 +29,14 @@ const expand = ref(false);
- {{ query.finalQuery }} + {{ query.type }}: {{ query.userInput }} + -
- - {{ query.finalQuery }} - + {{ query.type }}: {{ query.userInput }} @@ -48,13 +46,14 @@ const expand = ref(false); -
+
- {{ query.finalQuery }} + {{ query.type }}: {{ query.userInput }} +
diff --git a/src/components/DataDisplay/DataDisplayWordFormFrequencies.vue b/src/components/DataDisplay/DataDisplayWordFormFrequencies.vue index b3ea3cd..0e1e876 100644 --- a/src/components/DataDisplay/DataDisplayWordFormFrequencies.vue +++ b/src/components/DataDisplay/DataDisplayWordFormFrequencies.vue @@ -26,9 +26,7 @@ const expand = ref(false);
- - {{ query.finalQuery }} - + {{ query.type }}: {{ query.userInput }}
-
+
- {{ query.finalQuery }} + {{ query.type }}: {{ query.userInput }} + - +
diff --git a/src/components/DataDisplay/DataDisplayYearlyFrequencies.vue b/src/components/DataDisplay/DataDisplayYearlyFrequencies.vue index e32c382..4a1d58a 100644 --- a/src/components/DataDisplay/DataDisplayYearlyFrequencies.vue +++ b/src/components/DataDisplay/DataDisplayYearlyFrequencies.vue @@ -12,8 +12,9 @@ const series = computed(() => queries.value .filter((q: CorpusQuery) => !q.loading.yearlyFrequencies) .map((query: CorpusQuery) => ({ - name: `${query.finalQuery} ${query.corpus}${query.subCorpus ? ` / ${query.subCorpus}` : ""}`, - + name: `${query.type}: ${query.userInput} ${query.corpus}${ + query.subCorpus ? ` / ${query.subCorpus}` : "" + }`, data: query.data.yearlyFrequencies .sort((a, b) => b.year - a.year) .map((point) => [point.year, mode.value === "relative" ? point.relative : point.absolute]), @@ -40,9 +41,7 @@ const series = computed(() =>
- - {{ query.finalQuery }} - + {{ query.type }}: {{ query.userInput }}
-
+
- {{ query.finalQuery }} + {{ query.type }}: {{ query.userInput }} +
diff --git a/src/components/Search/QueryItem.vue b/src/components/Search/QueryItem.vue index 9978700..921c0b1 100644 --- a/src/components/Search/QueryItem.vue +++ b/src/components/Search/QueryItem.vue @@ -12,26 +12,31 @@ const storeQuery = queries.queries.find((q) => q.id === props.query.id) as unkno - - {{ props.query.finalQuery }} - {{ props.query.finalQuery }} - - -
-
+
+
+ -
+ + {{ props.query.userInput }} + {{ props.query.userInput }} +
+ +
- - - {{ props.query.type }} + + +
+ + {{ props.query.type }} +
+
diff --git a/src/components/Search/Search.vue b/src/components/Search/Search.vue index 5ecd831..5a5c9ae 100644 --- a/src/components/Search/Search.vue +++ b/src/components/Search/Search.vue @@ -4,15 +4,16 @@ import SearchDimensions from "./SearchDimensions.vue"; const query = useQuery(); -const newSelectedType: Ref = ref("word"); +const newSelectedType: Ref = ref("iqueryrow"); const newUserInput = ref(""); const CORPUS_QUERY_TYPES = [ - { value: "custom", description: "Custom search" }, - { value: "lc", description: "Lemma C Search (ToDo)" }, - { value: "lc*", description: "LemmaC with wildcard" }, - { value: "lemma", description: "Lemma search" }, - { value: "word", description: "Word Search" }, + { value: "charrow", description: "Character Search" }, + { value: "cqlrow", description: "Custom Query Lang Search" }, + { value: "iqueryrow", description: "Simplie Search (iquery)" }, + { value: "lemmarow", description: "Lemma Search" }, + { value: "phraserow", description: "Phrase search" }, + { value: "wordrow", description: "Word search" }, ]; const searchSettings = useSearchSettingsStore(); diff --git a/src/composables/useMediaSourceSearch.ts b/src/composables/useMediaSourceSearch.ts index 23df3e9..2dd8fca 100644 --- a/src/composables/useMediaSourceSearch.ts +++ b/src/composables/useMediaSourceSearch.ts @@ -34,7 +34,7 @@ export function useMediaSourceSearch() { freqlevel: 1, ml1attr: "doc.docsrc", ml1ctx: "0~0 > 0", - json: { concordance_query: [{ queryselector: "iqueryrow", iquery: query.userInput }] }, + json: { concordance_query: query.concordance_query }, //q: `${query.preparedQuery};${corpora.corporaForSearch};fttattr=doc.docsrc;fcrit=doc.id;flimit=0;format=json`, }, }); @@ -45,13 +45,6 @@ export function useMediaSourceSearch() { // } const mediaSourceData = mediaSources.value as FreqMLDocsRC; - console.log({ - mediaSourceData, - blocks: mediaSourceData.Blocks, - // @ts-ignore - items: mediaSourceData.Blocks[0]?.Items, - }); - // @ts-ignore const WordformData = (mediaSourceData.Blocks || [])[0]?.Items ?? []; WordformData.forEach(({ frq, Word, fpm }) => { diff --git a/src/composables/useRegionsSearch.ts b/src/composables/useRegionsSearch.ts index 61231d1..93f3f3a 100644 --- a/src/composables/useRegionsSearch.ts +++ b/src/composables/useRegionsSearch.ts @@ -27,7 +27,7 @@ export function useRegionsSearch() { freqlevel: 1, ml1attr: "doc.region", ml1ctx: "0~0 > 0", - json: { concordance_query: [{ queryselector: "iqueryrow", iquery: query.userInput }] }, + json: { concordance_query: query.concordance_query }, }, }); diff --git a/src/composables/useWordFormsSearch.ts b/src/composables/useWordFormsSearch.ts index b047510..4bb2ae8 100644 --- a/src/composables/useWordFormsSearch.ts +++ b/src/composables/useWordFormsSearch.ts @@ -28,7 +28,7 @@ export function useWordFormsSearch() { pagesize: 20, kwicleftctx: "100#", kwicrightctx: "100#", - json: { concordance_query: [{ queryselector: "iqueryrow", iquery: query.userInput }] }, + json: { concordance_query: query.concordance_query }, }, }); console.log({ freqtWords: freqtWords.value }); diff --git a/src/stores/query.ts b/src/stores/query.ts index cba6757..6e52de6 100644 --- a/src/stores/query.ts +++ b/src/stores/query.ts @@ -3,33 +3,50 @@ import { type Ref, ref } from "vue"; import { useCorporaStore } from "./corpora"; +const keyToKey = { + charrow: 'char', + cqlrow: 'cql', + iqueryrow: 'iquery', + lemmarow: 'lemma', + phraserow: 'phrase', + wordrow: 'word', +} + export const useQuery = defineStore( - "query", + "queryNew", () => { const nextQueryId = ref(0); const queries = ref([]) as Ref>; const corporaStore = useCorporaStore(); + function addQuery(userInput: string, type: CorpusQueryType) { let finalQuery = ""; + + + const concordance_query: Partial = { + + } + + concordance_query[keyToKey[type]] = userInput; + concordance_query.queryselector = type; + + // for old (regional Frequencies) switch (type) { - case "word": + case "wordrow": finalQuery = `[word="${userInput}"]`; break; - case "lemma": + case "lemmarow": finalQuery = `[lemma="${userInput}"]`; break; - case "lc": - finalQuery = `[lc="${userInput.toLowerCase()}"]`; - break; - case "lc*": - finalQuery = `[lc=".*${userInput.toLowerCase()}.*"]`; - break; - case "custom": + case "cqlrow": finalQuery = userInput; break; default: // default is word search finalQuery = `[word="${userInput}"]`; } + + + const colorId = nextQueryId.value % colors.length; // so not to overshoot array const query: CorpusQuery = { id: nextQueryId.value++, @@ -39,6 +56,7 @@ export const useQuery = defineStore( finalQuery, corpus: corporaStore.selectedCorpus?.corpname ?? "", subCorpus: corporaStore.selectedSubCorpus?.n ?? "", + concordance_query: concordance_query as ConcordanceQuery, preparedQuery: `aword,${finalQuery}`, // note: this is done in the old project, so we do it here too showPicker: false, data: { diff --git a/src/types/query.d.ts b/src/types/query.d.ts index 638bd83..9bcb51f 100644 --- a/src/types/query.d.ts +++ b/src/types/query.d.ts @@ -1,4 +1,11 @@ -type CorpusQueryType = "custom" | "lc" | "lc*" | "lemma" | "word"; +type CorpusQueryType = "charrow" | "cqlrow" | "iqueryrow" | "lemmarow" | "phraserow" | "wordrow"; + +type CorpusQueryTypeValue = 'char' | + 'cql' | + 'iquery' | + 'lemma' | + 'phrase' | + 'word'; type Region = "agesamt" | "amitte" | "aost" | "asuedost" | "awest" | "spezifisch"; @@ -43,6 +50,8 @@ interface QueryData { keywordInContext: Array; } + +type ConcordanceQuery = Record<'queryselector', CorpusQueryType> & Record interface CorpusQuery { id: number; type: CorpusQueryType; @@ -53,7 +62,7 @@ interface CorpusQuery { showPicker: boolean; corpus: string; subCorpus: string; - + concordance_query: ConcordanceQuery; loading: { yearlyFrequencies: boolean; wordFormFrequencies: boolean;