# A Cloud-Native Web Application for Assisted Metadata Generation and Retrieval: THESPIAN-NER +
## 4 The Web Service Description: THESIIAN-NER
### (Semi)Automatic Query Creation  
As stated before, users may select named entities to compose their queries by simply using the user interface (see Table 1 for a relation between CRMhs ontology (classes, properties) [25] and the NER labels (see Table 4 for their relation with the MongoDB JSON keys); they can either perform a logic OR or a logic AND on the labels. As an example, choosing the named entity '[PERSON]' from the Person (PER, #BE98D0) list, the user may cast the query on the database with the corresponding {key: value} of {studyObject.author: '[PERSON]'}, as shown graphically in Table 5.  
Figure 6: The NER web page after the ArcheoNER analysis. It can be seen the labels ordered by the number of entities found. On the left, under the annotated text, it is possible to see the button to show the summarised text.  
The logic OR refers to the possibility of casting a query, searching for entries having at least one of the desired named entities. On the contrary, the logic AND query means that the metadata entry must have at least one of the selected named entities for each label (see Figure 8 for details).  
\begin{table}
\begin{tabular}{c c c} \hline
**CRMhs Entry (C, P)** & **THESPIAN-Mask JSON Key** & **NER Label** \\ \hline HS\_Study\_Object, has\_name & studyObject.Name & ART, BIO \\ HS\_Study\_Object, was\_created\_by & studyObject.author & PER \\ HS\_Study\_Object, has\_period & studyObject.period & PRD \\ HS\_Period, has\_start\_date(has\_end\_date) & studyObject.periodStart(periodEnd) & TSP \\ HS\_Study\_Object, has\_location & studyObject.locationLabel & LOC \\ HS\_Study\_Object, was\_found\_at & studyObject.provenanceLabel & STI \\ HS\_Study\_Object, has\_owner & studyObject.owner & ORG \\ HS\_Analysis, was\_performed\_by & analysis.institution & ORG \\ HS\_Analysis, was\_performed\_at & analysis.location & LOC \\ HS\_Analysis, was\_performed\_during & analysis.startDate(endData) & TSP \\ HS\_Sample\_Preparation, used\_method & sample.preparation.method & ACT \\ \hline \end{tabular}
\end{table}
Table 4: Map between CRMhs ontology classes and properties (C, P) and ArcheoNER labels.  
Figure 7: The NER web page after the ArcheoNER analysis. In the opened timespan section, the list of entities are shown. The button for the entity selection can be seen on the right of the entity’s name. At the bottom right, is possible to see the two buttons for querying the database, whereas on the opposite side it is possible to see the number of the chosen entities and the button to generate the prefilled metadata mask and open it in the THESPIAN-Mask web page.  
The JSON object for the MongoDB query is thus built by giving it the appropriate MongoDB dictionary, with the MongoDB (see Figure 7), as well as the MongoDB (see Figure 7), as well as the MongoDB (see Figure 7).  
The MongoDB operator selects the documents where the value of a field is an array that contains all the specified elements, whereas the Mongo operator selects the documents where the value of a field equals any value in the specified array).  
When users click the relevant button (see Figure 7), an HTTP GET request is made to the THESPIAN-Mask back end. The request made uses the mongoose.js module to query the MongoDB database and retrieve records whose metadata entries match the composed query.  
The entries are thus sent back as JSON objects and rendered on the page, where users may download them (as JSON or XML) or the associated files (usually raw or elaborated data coming from scientific analysis of cultural heritage). In the future, users may also be able to open the web-based analysis services offered in the cloud [10; 26; 27].