From 6d826b9c043918bd5a10c348606314ee651f464e Mon Sep 17 00:00:00 2001 From: Innokentii Smirnov Date: Mon, 26 May 2025 18:17:15 +0300 Subject: [PATCH 1/2] Initial database commit --- html/getHurrianDictionary.php | 21 +++++++++++ html/hurrianLexicalDatabase.sqlite | Bin 0 -> 8192 bytes html/updateHurrianDictionary.php | 15 ++++++++ ui/src/graphql.ts | 56 ++++++++++++++--------------- ui/src/urls.ts | 3 ++ ui/src/xmlEditor/hur/dictionary.ts | 16 +++++++++ 6 files changed, 83 insertions(+), 28 deletions(-) create mode 100644 html/getHurrianDictionary.php create mode 100644 html/hurrianLexicalDatabase.sqlite create mode 100644 html/updateHurrianDictionary.php diff --git a/html/getHurrianDictionary.php b/html/getHurrianDictionary.php new file mode 100644 index 00000000..0ff7480f --- /dev/null +++ b/html/getHurrianDictionary.php @@ -0,0 +1,21 @@ +query($sql); + $data = array(); + while ($row = $result->fetchArray()) + { + $data[$row['form']][] = $row['analysis']; + } + echo json_encode($data, JSON_UNESCAPED_UNICODE); +} +else +{ + echo '{}'; +} +?> \ No newline at end of file diff --git a/html/hurrianLexicalDatabase.sqlite b/html/hurrianLexicalDatabase.sqlite new file mode 100644 index 0000000000000000000000000000000000000000..04c9d47e45e3ad9b76636a660991b740c155e24d GIT binary patch literal 8192 zcmeI#F;Buk6bJAtmN=QZF&SkoKG434<1&$4+SZUQR8IGjDF zQTn-YsNd$M1zv zl1{PYO@1!tQc?Cr*9{u|mLvQYm2onUDb;sOR_Vp7d={-IM|aBUFd5y^s^NP5uU@A_ om-HT1`7n&*Xp{9Ho>aF#+G_?K-I)|`YQCOyV=AXoU;F*w4exec($sql); +} +$sql = "INSERT INTO 'wordforms' ('form', 'analysis') VALUES ('$word', '$analysis')"; +$db->exec($sql); +?> \ No newline at end of file diff --git a/ui/src/graphql.ts b/ui/src/graphql.ts index 59e044a6..264d42ee 100644 --- a/ui/src/graphql.ts +++ b/ui/src/graphql.ts @@ -761,8 +761,8 @@ export function useIndexLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions(IndexDocument, options); } -export function useIndexSuspenseQuery(baseOptions?: Apollo.SkipToken | Apollo.SuspenseQueryHookOptions) { - const options = baseOptions === Apollo.skipToken ? baseOptions : {...defaultOptions, ...baseOptions} +export function useIndexSuspenseQuery(baseOptions?: Apollo.SuspenseQueryHookOptions) { + const options = {...defaultOptions, ...baseOptions} return Apollo.useSuspenseQuery(IndexDocument, options); } export type IndexQueryHookResult = ReturnType; @@ -824,7 +824,7 @@ export const ManuscriptDocument = gql` * }, * }); */ -export function useManuscriptQuery(baseOptions: Apollo.QueryHookOptions & ({ variables: ManuscriptQueryVariables; skip?: boolean; } | { skip: boolean; }) ) { +export function useManuscriptQuery(baseOptions: Apollo.QueryHookOptions) { const options = {...defaultOptions, ...baseOptions} return Apollo.useQuery(ManuscriptDocument, options); } @@ -832,8 +832,8 @@ export function useManuscriptLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions const options = {...defaultOptions, ...baseOptions} return Apollo.useLazyQuery(ManuscriptDocument, options); } -export function useManuscriptSuspenseQuery(baseOptions?: Apollo.SkipToken | Apollo.SuspenseQueryHookOptions) { - const options = baseOptions === Apollo.skipToken ? baseOptions : {...defaultOptions, ...baseOptions} +export function useManuscriptSuspenseQuery(baseOptions?: Apollo.SuspenseQueryHookOptions) { + const options = {...defaultOptions, ...baseOptions} return Apollo.useSuspenseQuery(ManuscriptDocument, options); } export type ManuscriptQueryHookResult = ReturnType; @@ -897,7 +897,7 @@ export const UploadPicturesDocument = gql` * }, * }); */ -export function useUploadPicturesQuery(baseOptions: Apollo.QueryHookOptions & ({ variables: UploadPicturesQueryVariables; skip?: boolean; } | { skip: boolean; }) ) { +export function useUploadPicturesQuery(baseOptions: Apollo.QueryHookOptions) { const options = {...defaultOptions, ...baseOptions} return Apollo.useQuery(UploadPicturesDocument, options); } @@ -905,8 +905,8 @@ export function useUploadPicturesLazyQuery(baseOptions?: Apollo.LazyQueryHookOpt const options = {...defaultOptions, ...baseOptions} return Apollo.useLazyQuery(UploadPicturesDocument, options); } -export function useUploadPicturesSuspenseQuery(baseOptions?: Apollo.SkipToken | Apollo.SuspenseQueryHookOptions) { - const options = baseOptions === Apollo.skipToken ? baseOptions : {...defaultOptions, ...baseOptions} +export function useUploadPicturesSuspenseQuery(baseOptions?: Apollo.SuspenseQueryHookOptions) { + const options = {...defaultOptions, ...baseOptions} return Apollo.useSuspenseQuery(UploadPicturesDocument, options); } export type UploadPicturesQueryHookResult = ReturnType; @@ -972,7 +972,7 @@ export const TransliterationInputDocument = gql` * }, * }); */ -export function useTransliterationInputQuery(baseOptions: Apollo.QueryHookOptions & ({ variables: TransliterationInputQueryVariables; skip?: boolean; } | { skip: boolean; }) ) { +export function useTransliterationInputQuery(baseOptions: Apollo.QueryHookOptions) { const options = {...defaultOptions, ...baseOptions} return Apollo.useQuery(TransliterationInputDocument, options); } @@ -980,8 +980,8 @@ export function useTransliterationInputLazyQuery(baseOptions?: Apollo.LazyQueryH const options = {...defaultOptions, ...baseOptions} return Apollo.useLazyQuery(TransliterationInputDocument, options); } -export function useTransliterationInputSuspenseQuery(baseOptions?: Apollo.SkipToken | Apollo.SuspenseQueryHookOptions) { - const options = baseOptions === Apollo.skipToken ? baseOptions : {...defaultOptions, ...baseOptions} +export function useTransliterationInputSuspenseQuery(baseOptions?: Apollo.SuspenseQueryHookOptions) { + const options = {...defaultOptions, ...baseOptions} return Apollo.useSuspenseQuery(TransliterationInputDocument, options); } export type TransliterationInputQueryHookResult = ReturnType; @@ -1047,7 +1047,7 @@ export const ReviewTransliterationDocument = gql` * }, * }); */ -export function useReviewTransliterationQuery(baseOptions: Apollo.QueryHookOptions & ({ variables: ReviewTransliterationQueryVariables; skip?: boolean; } | { skip: boolean; }) ) { +export function useReviewTransliterationQuery(baseOptions: Apollo.QueryHookOptions) { const options = {...defaultOptions, ...baseOptions} return Apollo.useQuery(ReviewTransliterationDocument, options); } @@ -1055,8 +1055,8 @@ export function useReviewTransliterationLazyQuery(baseOptions?: Apollo.LazyQuery const options = {...defaultOptions, ...baseOptions} return Apollo.useLazyQuery(ReviewTransliterationDocument, options); } -export function useReviewTransliterationSuspenseQuery(baseOptions?: Apollo.SkipToken | Apollo.SuspenseQueryHookOptions) { - const options = baseOptions === Apollo.skipToken ? baseOptions : {...defaultOptions, ...baseOptions} +export function useReviewTransliterationSuspenseQuery(baseOptions?: Apollo.SuspenseQueryHookOptions) { + const options = {...defaultOptions, ...baseOptions} return Apollo.useSuspenseQuery(ReviewTransliterationDocument, options); } export type ReviewTransliterationQueryHookResult = ReturnType; @@ -1123,7 +1123,7 @@ export const XmlConversionDocument = gql` * }, * }); */ -export function useXmlConversionQuery(baseOptions: Apollo.QueryHookOptions & ({ variables: XmlConversionQueryVariables; skip?: boolean; } | { skip: boolean; }) ) { +export function useXmlConversionQuery(baseOptions: Apollo.QueryHookOptions) { const options = {...defaultOptions, ...baseOptions} return Apollo.useQuery(XmlConversionDocument, options); } @@ -1131,8 +1131,8 @@ export function useXmlConversionLazyQuery(baseOptions?: Apollo.LazyQueryHookOpti const options = {...defaultOptions, ...baseOptions} return Apollo.useLazyQuery(XmlConversionDocument, options); } -export function useXmlConversionSuspenseQuery(baseOptions?: Apollo.SkipToken | Apollo.SuspenseQueryHookOptions) { - const options = baseOptions === Apollo.skipToken ? baseOptions : {...defaultOptions, ...baseOptions} +export function useXmlConversionSuspenseQuery(baseOptions?: Apollo.SuspenseQueryHookOptions) { + const options = {...defaultOptions, ...baseOptions} return Apollo.useSuspenseQuery(XmlConversionDocument, options); } export type XmlConversionQueryHookResult = ReturnType; @@ -1198,7 +1198,7 @@ export const XmlReviewDocument = gql` * }, * }); */ -export function useXmlReviewQuery(baseOptions: Apollo.QueryHookOptions & ({ variables: XmlReviewQueryVariables; skip?: boolean; } | { skip: boolean; }) ) { +export function useXmlReviewQuery(baseOptions: Apollo.QueryHookOptions) { const options = {...defaultOptions, ...baseOptions} return Apollo.useQuery(XmlReviewDocument, options); } @@ -1206,8 +1206,8 @@ export function useXmlReviewLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions< const options = {...defaultOptions, ...baseOptions} return Apollo.useLazyQuery(XmlReviewDocument, options); } -export function useXmlReviewSuspenseQuery(baseOptions?: Apollo.SkipToken | Apollo.SuspenseQueryHookOptions) { - const options = baseOptions === Apollo.skipToken ? baseOptions : {...defaultOptions, ...baseOptions} +export function useXmlReviewSuspenseQuery(baseOptions?: Apollo.SuspenseQueryHookOptions) { + const options = {...defaultOptions, ...baseOptions} return Apollo.useSuspenseQuery(XmlReviewDocument, options); } export type XmlReviewQueryHookResult = ReturnType; @@ -1278,7 +1278,7 @@ export const ApprovalDocument = gql` * }, * }); */ -export function useApprovalQuery(baseOptions: Apollo.QueryHookOptions & ({ variables: ApprovalQueryVariables; skip?: boolean; } | { skip: boolean; }) ) { +export function useApprovalQuery(baseOptions: Apollo.QueryHookOptions) { const options = {...defaultOptions, ...baseOptions} return Apollo.useQuery(ApprovalDocument, options); } @@ -1286,8 +1286,8 @@ export function useApprovalLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions(ApprovalDocument, options); } -export function useApprovalSuspenseQuery(baseOptions?: Apollo.SkipToken | Apollo.SuspenseQueryHookOptions) { - const options = baseOptions === Apollo.skipToken ? baseOptions : {...defaultOptions, ...baseOptions} +export function useApprovalSuspenseQuery(baseOptions?: Apollo.SuspenseQueryHookOptions) { + const options = {...defaultOptions, ...baseOptions} return Apollo.useSuspenseQuery(ApprovalDocument, options); } export type ApprovalQueryHookResult = ReturnType; @@ -1360,8 +1360,8 @@ export function usePipelineOverviewLazyQuery(baseOptions?: Apollo.LazyQueryHookO const options = {...defaultOptions, ...baseOptions} return Apollo.useLazyQuery(PipelineOverviewDocument, options); } -export function usePipelineOverviewSuspenseQuery(baseOptions?: Apollo.SkipToken | Apollo.SuspenseQueryHookOptions) { - const options = baseOptions === Apollo.skipToken ? baseOptions : {...defaultOptions, ...baseOptions} +export function usePipelineOverviewSuspenseQuery(baseOptions?: Apollo.SuspenseQueryHookOptions) { + const options = {...defaultOptions, ...baseOptions} return Apollo.useSuspenseQuery(PipelineOverviewDocument, options); } export type PipelineOverviewQueryHookResult = ReturnType; @@ -1639,7 +1639,7 @@ export const UsersOverviewDocument = gql` * }, * }); */ -export function useUsersOverviewQuery(baseOptions: Apollo.QueryHookOptions & ({ variables: UsersOverviewQueryVariables; skip?: boolean; } | { skip: boolean; }) ) { +export function useUsersOverviewQuery(baseOptions: Apollo.QueryHookOptions) { const options = {...defaultOptions, ...baseOptions} return Apollo.useQuery(UsersOverviewDocument, options); } @@ -1647,8 +1647,8 @@ export function useUsersOverviewLazyQuery(baseOptions?: Apollo.LazyQueryHookOpti const options = {...defaultOptions, ...baseOptions} return Apollo.useLazyQuery(UsersOverviewDocument, options); } -export function useUsersOverviewSuspenseQuery(baseOptions?: Apollo.SkipToken | Apollo.SuspenseQueryHookOptions) { - const options = baseOptions === Apollo.skipToken ? baseOptions : {...defaultOptions, ...baseOptions} +export function useUsersOverviewSuspenseQuery(baseOptions?: Apollo.SuspenseQueryHookOptions) { + const options = {...defaultOptions, ...baseOptions} return Apollo.useSuspenseQuery(UsersOverviewDocument, options); } export type UsersOverviewQueryHookResult = ReturnType; diff --git a/ui/src/urls.ts b/ui/src/urls.ts index ece65659..540baffb 100644 --- a/ui/src/urls.ts +++ b/ui/src/urls.ts @@ -8,6 +8,9 @@ export const baseUrl = process.env.NODE_ENV !== 'development' export const apolloUri = `${baseServerUrl}/graphql.php`; +export const updateHurrianDictionaryUrl = baseServerUrl + '/updateHurrianDictionary.php'; +export const getHurrianDictionaryUrl = baseServerUrl + '/getHurrianDictionary.php'; + export const pictureUploadUrl = (mainIdentifier: string): string => `${baseServerUrl}/uploadPicture.php?id=${encodeURIComponent(mainIdentifier)}`; export const pictureBaseUrl = (mainIdentifier: string): string => `${baseServerUrl}/uploads/${encodeURIComponent(mainIdentifier)}`; diff --git a/ui/src/xmlEditor/hur/dictionary.ts b/ui/src/xmlEditor/hur/dictionary.ts index a6592589..f14194a0 100644 --- a/ui/src/xmlEditor/hur/dictionary.ts +++ b/ui/src/xmlEditor/hur/dictionary.ts @@ -7,9 +7,16 @@ import { setGlosses, saveGloss } from './glossUpdater'; import { MorphologicalAnalysis, writeMorphAnalysisValue } from '../../model/morphologicalAnalysis'; import { convertDictionary, updateDictionary } from './utility'; +import { updateHurrianDictionaryUrl, getHurrianDictionaryUrl } from '../../urls'; const dictionary: Map> = new Map(); +fetch(getHurrianDictionaryUrl, {method: 'GET'}).then(response => { + response.json().then(obj => { + upgradeDictionary(obj); + }); +}); + export function annotateHurrianWord(node: XmlElementNode): void { const transliteration: string = getText(node); const transcription: string = makeBoundTranscription(transliteration); @@ -64,6 +71,14 @@ export function annotateHurrianWord(node: XmlElementNode): void { } } +export function sendMorphologicalAnalysisToTheServer(word: string, analysis: string) { + const formData = new FormData(); + formData.append('word', word); + formData.append('analysis', analysis); + + fetch(updateHurrianDictionaryUrl, {method: 'POST', body: formData}); +} + export function updateHurrianDictionary(node: XmlElementNode, number: number, value: string): void { if (number === 1) { delete node.attributes.firstAnalysisIsPlaceholder; @@ -81,6 +96,7 @@ export function updateHurrianDictionary(node: XmlElementNode, number: number, va throw new Error(); } possibilities.add(value); + sendMorphologicalAnalysisToTheServer(transcription, value); saveGloss(number, value); } From e7b12838eb52acb1c8bb1e885c7359e52a7ae456 Mon Sep 17 00:00:00 2001 From: Innokentii Smirnov Date: Tue, 27 May 2025 18:09:58 +0300 Subject: [PATCH 2/2] Add database storage for lemmata (stems) --- html/hurrian/commonHurrian.php | 52 +++++++++ html/hurrian/getHurrianDictionary.php | 31 ++++++ .../getHurrianLexicon.php} | 8 +- html/hurrian/hurrianLexicalDatabase.sqlite | Bin 0 -> 16384 bytes html/hurrian/updateHurrianDictionary.php | 102 ++++++++++++++++++ html/hurrianLexicalDatabase.sqlite | Bin 8192 -> 0 bytes html/updateHurrianDictionary.php | 15 --- ui/src/urls.ts | 5 +- ui/src/xmlEditor/hur/dictionary.ts | 36 ++++--- ui/src/xmlEditor/hur/glossProvider.ts | 16 ++- ui/src/xmlEditor/hur/splitter.ts | 4 +- ui/src/xmlEditor/hur/standardAnalysis.ts | 10 +- 12 files changed, 238 insertions(+), 41 deletions(-) create mode 100644 html/hurrian/commonHurrian.php create mode 100644 html/hurrian/getHurrianDictionary.php rename html/{getHurrianDictionary.php => hurrian/getHurrianLexicon.php} (67%) create mode 100644 html/hurrian/hurrianLexicalDatabase.sqlite create mode 100644 html/hurrian/updateHurrianDictionary.php delete mode 100644 html/hurrianLexicalDatabase.sqlite delete mode 100644 html/updateHurrianDictionary.php diff --git a/html/hurrian/commonHurrian.php b/html/hurrian/commonHurrian.php new file mode 100644 index 00000000..3c306fcd --- /dev/null +++ b/html/hurrian/commonHurrian.php @@ -0,0 +1,52 @@ + diff --git a/html/hurrian/getHurrianDictionary.php b/html/hurrian/getHurrianDictionary.php new file mode 100644 index 00000000..75550e11 --- /dev/null +++ b/html/hurrian/getHurrianDictionary.php @@ -0,0 +1,31 @@ +query($sql); + $data = array(); + while ($row = $result->fetchArray()) + { + $fields = array($row['segmentation'], + $row['translation_de'], + $row['morph_tag'], + $row['part_of_speech'], + $row['det']); + $data[$row['transcription']][] = implode(' @ ', $fields); + } + echo json_encode($data, JSON_UNESCAPED_UNICODE); +} +else +{ + echo '{}'; +} +?> \ No newline at end of file diff --git a/html/getHurrianDictionary.php b/html/hurrian/getHurrianLexicon.php similarity index 67% rename from html/getHurrianDictionary.php rename to html/hurrian/getHurrianLexicon.php index 0ff7480f..4bbb1572 100644 --- a/html/getHurrianDictionary.php +++ b/html/hurrian/getHurrianLexicon.php @@ -5,12 +5,16 @@ if (file_exists($dbFileName)) { $db = new SQLite3($dbFileName); - $sql = "SELECT * FROM 'wordforms'"; + $sql = <<query($sql); $data = array(); while ($row = $result->fetchArray()) { - $data[$row['form']][] = $row['analysis']; + $key = $row['stem'].','.$row['part_of_speech']; + $data[$key][] = $row['translation_de']; } echo json_encode($data, JSON_UNESCAPED_UNICODE); } diff --git a/html/hurrian/hurrianLexicalDatabase.sqlite b/html/hurrian/hurrianLexicalDatabase.sqlite new file mode 100644 index 0000000000000000000000000000000000000000..121d06c218962e35e3571c0f4b2bc6e8ea863cbb GIT binary patch literal 16384 zcmeI&zi!$<7y$4)j6pqHM6GcthhA<=(I`9Ej@quj9KT;PW zwQC=sUE8H^&>>yO6SPl|sU7pr@TFh&n83n7#fucUZgT#9&zxA8^CHTN7^d%L2E1VuYXV0n(eoX-+Y6=-$<3-=so7Sovax4drD?omEzMb% z?Yirftlh^od&jO?PpiB8mFlte$UeR&lR}^Jpy|8)(CzV(RkM$3Q9NL6kMWTH5$-b2 zqwxX9$%9tQeOYgIsLSJ>bIZf^MA|5o@QE3%A&4agGYw^SEi-+S^~7WGZ@IFjaUu(1 z%kg@Czf%usI~MCxKdkp!^`OsKvor1xGhW1LBcI17#c0OSfC!gi*`$o-HR{P|!)Kf`ZYU{K&~>dp8aC)E=g}Y=%x`BCDWr>$TW6pBXcX3A zJcm=rl-YDPS?>Q;@&=J#EqgvJZE+-#=CJC*k(cey;>}a{#{qHt9x2 literal 0 HcmV?d00001 diff --git a/html/hurrian/updateHurrianDictionary.php b/html/hurrian/updateHurrianDictionary.php new file mode 100644 index 00000000..7ecfc731 --- /dev/null +++ b/html/hurrian/updateHurrianDictionary.php @@ -0,0 +1,102 @@ +exec($sql); +} + +//Lemma finden oder hinzufügen +$findLemma = <<query($findLemma); +$row = $result->fetchArray(); +if (!$row) { + $sql = <<exec($sql); + $result = $db->query($findLemma); + $row = $result->fetchArray(); +} +$lemma_id = $row['lemma_id']; + +//Suffixkette finden oder hinzufügen +$findSuffixChain = <<query($findSuffixChain); +$row = $result->fetchArray(); +if (!$row) { + $sql = <<exec($sql); + $result = $db->query($findSuffixChain); + $row = $result->fetchArray(); +} +$suffix_chain_id = $row['suffix_chain_id']; + +//Wortform finden oder hinzufügen +$findWordform = <<query($findWordform); +$row = $result->fetchArray(); + if (!$row) { + $sql = <<exec($sql); +} +?> \ No newline at end of file diff --git a/html/hurrianLexicalDatabase.sqlite b/html/hurrianLexicalDatabase.sqlite deleted file mode 100644 index 04c9d47e45e3ad9b76636a660991b740c155e24d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 8192 zcmeI#F;Buk6bJAtmN=QZF&SkoKG434<1&$4+SZUQR8IGjDF zQTn-YsNd$M1zv zl1{PYO@1!tQc?Cr*9{u|mLvQYm2onUDb;sOR_Vp7d={-IM|aBUFd5y^s^NP5uU@A_ om-HT1`7n&*Xp{9Ho>aF#+G_?K-I)|`YQCOyV=AXoU;F*w4exec($sql); -} -$sql = "INSERT INTO 'wordforms' ('form', 'analysis') VALUES ('$word', '$analysis')"; -$db->exec($sql); -?> \ No newline at end of file diff --git a/ui/src/urls.ts b/ui/src/urls.ts index 540baffb..c7a7dc9b 100644 --- a/ui/src/urls.ts +++ b/ui/src/urls.ts @@ -8,8 +8,9 @@ export const baseUrl = process.env.NODE_ENV !== 'development' export const apolloUri = `${baseServerUrl}/graphql.php`; -export const updateHurrianDictionaryUrl = baseServerUrl + '/updateHurrianDictionary.php'; -export const getHurrianDictionaryUrl = baseServerUrl + '/getHurrianDictionary.php'; +export const updateHurrianDictionaryUrl = baseServerUrl + '/hurrian/updateHurrianDictionary.php'; +export const getHurrianDictionaryUrl = baseServerUrl + '/hurrian/getHurrianDictionary.php'; +export const getHurrianLexiconUrl = baseServerUrl + '/hurrian/getHurrianLexicon.php'; export const pictureUploadUrl = (mainIdentifier: string): string => `${baseServerUrl}/uploadPicture.php?id=${encodeURIComponent(mainIdentifier)}`; diff --git a/ui/src/xmlEditor/hur/dictionary.ts b/ui/src/xmlEditor/hur/dictionary.ts index f14194a0..64772216 100644 --- a/ui/src/xmlEditor/hur/dictionary.ts +++ b/ui/src/xmlEditor/hur/dictionary.ts @@ -80,24 +80,26 @@ export function sendMorphologicalAnalysisToTheServer(word: string, analysis: str } export function updateHurrianDictionary(node: XmlElementNode, number: number, value: string): void { - if (number === 1) { - delete node.attributes.firstAnalysisIsPlaceholder; - } - const transcription: string = node.attributes.trans || ''; - let possibilities: Set | undefined; - if (dictionary.has(transcription)) { - possibilities = dictionary.get(transcription); - } - else { - possibilities = new Set(); - dictionary.set(transcription, possibilities); - } - if (possibilities === undefined) { - throw new Error(); + if (value.split(' @ ', 3)[1] !== '') { + if (number === 1) { + delete node.attributes.firstAnalysisIsPlaceholder; + } + const transcription: string = node.attributes.trans || ''; + let possibilities: Set | undefined; + if (dictionary.has(transcription)) { + possibilities = dictionary.get(transcription); + } + else { + possibilities = new Set(); + dictionary.set(transcription, possibilities); + } + if (possibilities === undefined) { + throw new Error(); + } + possibilities.add(value); + sendMorphologicalAnalysisToTheServer(transcription, value); + saveGloss(number, value); } - possibilities.add(value); - sendMorphologicalAnalysisToTheServer(transcription, value); - saveGloss(number, value); } export function getDictionary(): { [key: string]: string[] } { diff --git a/ui/src/xmlEditor/hur/glossProvider.ts b/ui/src/xmlEditor/hur/glossProvider.ts index 85733632..152ee8cf 100644 --- a/ui/src/xmlEditor/hur/glossProvider.ts +++ b/ui/src/xmlEditor/hur/glossProvider.ts @@ -1,11 +1,23 @@ import {convertDictionary, updateDictionary} from './utility'; +import { getHurrianLexiconUrl } from '../../urls'; //Dieses Modul kann Bedeutungen von Stämmen speichern und nachschlagen. const glosses: Map> = new Map(); -function getKey(word: string, pos: string): string +fetch(getHurrianLexiconUrl, {method: 'GET'}).then(response => { + response.json().then(obj => { + upgradeGlosses(obj); + }); +}); + +function preprocessStem(stem: string): string +{ + return stem.replace('(', '').replace(')', ''); +} + +function getKey(stem: string, pos: string): string { - return word + ',' + pos; + return preprocessStem(stem) + ',' + pos; } export function storeGloss(word: string, pos: string, gloss: string) diff --git a/ui/src/xmlEditor/hur/splitter.ts b/ui/src/xmlEditor/hur/splitter.ts index 68a9d413..50668c51 100644 --- a/ui/src/xmlEditor/hur/splitter.ts +++ b/ui/src/xmlEditor/hur/splitter.ts @@ -17,7 +17,7 @@ export function getStem(segmentation: string): string { export function getGrammaticalMorphemes(segmentation: string): string { const i: number = findBoundary(segmentation); if (i == segmentation.length) { - return ''; + return '-'; } else { return segmentation.substring(i); @@ -28,6 +28,6 @@ export function getStemAndGrammaticalMorphemes(segmentation: string): [string, s const i: number = findBoundary(segmentation); const stem: string = segmentation.substring(0, i); const grammaticalMorphemes = - i == segmentation.length ? '' : segmentation.substring(i); + i == segmentation.length ? '-' : segmentation.substring(i); return [stem, grammaticalMorphemes]; } diff --git a/ui/src/xmlEditor/hur/standardAnalysis.ts b/ui/src/xmlEditor/hur/standardAnalysis.ts index 68eba2a6..814c1e75 100644 --- a/ui/src/xmlEditor/hur/standardAnalysis.ts +++ b/ui/src/xmlEditor/hur/standardAnalysis.ts @@ -4,6 +4,13 @@ import { MorphologicalAnalysis } from '../../model/morphologicalAnalysis'; import { SelectableLetteredAnalysisOption } from '../../model/analysisOptions'; import { getGrammaticalMorphemes } from './splitter'; +function postprocessSegmentation(segmentation: string): string { + if (segmentation.endsWith('-')) { + segmentation = segmentation.substring(0, segmentation.length - 1); + } + return segmentation; +} + // Erstellt morphologische Analysen für Wörter, die im Lexicon fehlen. // Das unbekannte Wort wird zuerst durch die Funktion "segment" in Morpheme getrennt, möglicherweise auf mehrere verschiedene Weisen. // Der grammatische Teil der Segmentierung, die Suffixe und Enklitika, werden dann durch "analyze" grammatisch analysiert. Auch hier mehrere Optionen möglich. @@ -13,7 +20,8 @@ export function makeStandardAnalyses(transcription: string): MorphologicalAnalys const segmentations: [string, string][] = segment(transcription); for (let i = 0; i < segmentations.length; i++) { - const [segmentation, pos] = segmentations[i]; + const [initialSegmentation, pos] = segmentations[i]; + const segmentation = postprocessSegmentation(initialSegmentation); let ma: MorphologicalAnalysis; const grammaticalMorphemes = getGrammaticalMorphemes(segmentation); const tags: string[] | null = analyze(grammaticalMorphemes, pos);