Skip to content

Commit 70ed725

Browse files
committed
Merge remote-tracking branch 'refs/remotes/origin/master'
2 parents 18d6a40 + 2e3161b commit 70ed725

File tree

7 files changed

+107
-77
lines changed

7 files changed

+107
-77
lines changed

client/README.md

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,33 @@
1-
# client-vue
1+
# TueR – Tübingen Retrieval (Frontend)
22

3-
This template should help get you started developing with Vue 3 in Vite.
3+
This is the frontend for the **TüR******bingen **R**etrieval-project, built with Vue 3 and Vite.
44

5-
## Recommended IDE Setup
5+
## Requirements
66

7-
[VSCode](https://code.visualstudio.com/) + [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar) (and disable Vetur).
7+
- [bun.sh](https://bun.sh) (the runtime environment for this project)
88

9-
## Type Support for `.vue` Imports in TS
9+
## Getting Started
1010

11-
TypeScript cannot handle type information for `.vue` imports by default, so we replace the `tsc` CLI with `vue-tsc` for type checking. In editors, we need [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar) to make the TypeScript language service aware of `.vue` types.
12-
13-
## Customize configuration
14-
15-
See [Vite Configuration Reference](https://vitejs.dev/config/).
16-
17-
## Project Setup
11+
To install the dependencies, run:
1812

1913
```sh
2014
bun install
2115
```
2216

23-
### Compile and Hot-Reload for Development
17+
## Start the server and start opening doors to Tübingen
18+
19+
To start the development server, run:
2420

2521
```sh
2622
bun dev
2723
```
2824

29-
### Type-Check, Compile and Minify for Production
25+
This starts the development server at <http://localhost:5173>.
3026

31-
```sh
32-
bun build
33-
```
27+
---
3428

35-
### Lint with [ESLint](https://eslint.org/)
29+
**Note**:
3630

37-
```sh
38-
bun lint
39-
```
31+
Make sure to have the backend running as well. You can find the backend at [engine](../engine).
32+
33+
---

client/src/components/SearchResult.vue

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,18 @@
2424
class="px-3 py-1 bg-primary-100 text-primary-600 rounded-full text-xs font-medium">
2525
{{ tag }}
2626
</span>
27-
<span class="px-3 py-1 bg-primary-100 text-primary-600 rounded-full text-xs font-medium" v-if="result.score">
27+
<!-- <span class="px-3 py-1 bg-primary-100 text-primary-600 rounded-full text-xs font-medium" v-if="result.score">
2828
{{ Math.round((result.score ?? 0) * 100) / 100 }}%
29-
</span>
29+
</span> -->
3030
</div>
3131
<div class="mt-4">
32-
<button @click="toggleSummary"
32+
<button @click="toggleSummary" :disabled="loadingSummary"
3333
class="text-sm text-primary-600 hover:text-primary-700 font-medium focus:outline-none">
3434
{{ showSummary ? 'Hide' : 'Show' }} Summary
3535
</button>
36+
<div v-if="loadingSummary"
37+
class="animate-spin rounded-full h-4 w-4 border-t-2 border-b-2 border-primary-500 mx-2">
38+
</div>
3639
</div>
3740
<transition
3841
enter-active-class="transition ease-out duration-200"
@@ -74,12 +77,9 @@ interface SearchResultProps {
7477
7578
const { result } = defineProps<SearchResultProps>()
7679
77-
const showSummary = ref(false)
78-
const summary = ref('')
7980
8081
const showPreview = ref(false)
8182
const preview = ref('')
82-
8383
const togglePreview = async () => {
8484
showPreview.value = !showPreview.value
8585
if (preview.value) {
@@ -90,14 +90,23 @@ const togglePreview = async () => {
9090
preview.value = URL.createObjectURL(await response.blob())
9191
}
9292
93+
const loadingSummary = ref(false)
94+
const showSummary = ref(false)
95+
const summary = ref('')
9396
const toggleSummary = async () => {
97+
loadingSummary.value = true
9498
showSummary.value = !showSummary.value
95-
if (result.summary) {
99+
if (summary.value) {
100+
loadingSummary.value = false
96101
return
97102
}
98103
99-
const response = await fetch(`${ENGINE_ENDPOINT}/summary/${result.id}`)
100-
summary.value = await response.text()
104+
summary.value = await fetch(`${ENGINE_ENDPOINT}/summary/${result.id}`)
105+
.then((res) => res.json())
106+
.then((data) => {
107+
loadingSummary.value = false
108+
return data.summary
109+
})
101110
}
102111
103112
//watch(() => result.url, downloadPreview, { immediate: true })

client/src/stores/search.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ const dummyResults: SearchResult[] = [
2424
export const useSearchStore = defineStore('search', () => {
2525
const localStore = useLocal()
2626

27+
const lastQuery = ref('')
2728
const internalResults = ref<SearchResult[]>([])
2829
const results = computed(() => {
2930
const results = internalResults.value
@@ -35,11 +36,13 @@ export const useSearchStore = defineStore('search', () => {
3536

3637
function search(query: string) {
3738
if (query === '') {
38-
internalResults.value = dummyResults
39+
internalResults.value = []
3940
return
4041
}
4142

42-
fetch(`${ENGINE_ENDPOINT}/search?query=${query}`)
43+
lastQuery.value = query
44+
45+
return fetch(`${ENGINE_ENDPOINT}/search?query=${query}`)
4346
.then((response) => response.json())
4447
.then((data: ApiSearchResultsResponse) => {
4548
internalResults.value = data.results
@@ -51,6 +54,7 @@ export const useSearchStore = defineStore('search', () => {
5154
return {
5255
results,
5356
lastSearches,
57+
lastQuery,
5458
search
5559
}
5660
})

client/src/views/SearchView.vue

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@
3838
{{ lastSearch }}
3939
</span>
4040
</div>
41+
<div v-if="searched && results.length > 0" class="text-gray-600 mt-8">
42+
Found {{ results.length }} {{ results.length === 0 ? 'door' : 'doors' }} for "{{ lastQuery }}"
43+
</div>
4144
<div v-if="loading" class="text-center text-gray-600 mt-8">
4245
<div class="animate-spin rounded-full h-12 w-12 border-t-2 border-b-2 border-tertiary-500 mx-auto"></div>
4346
<p class="mt-4">{{ TITLE }}</p>
@@ -56,7 +59,7 @@
5659
</li>
5760
</transition-group>
5861
<p v-else-if="searched && results.length === 0" class="text-center text-gray-600 mt-8">
59-
No results found. Try another search term.
62+
No doors found for "{{ lastQuery }}". Try another search term.
6063
</p>
6164
</div>
6265
</div>
@@ -73,15 +76,15 @@ import { gsap } from 'gsap'
7376
import SearchResult from '@/components/SearchResult.vue'
7477
7578
const searchStore = useSearchStore()
76-
const { results, lastSearches } = storeToRefs(searchStore)
79+
const { results, lastSearches, lastQuery } = storeToRefs(searchStore)
7780
7881
const loading = false
7982
8083
const query = ref('')
8184
const searched = ref(false)
8285
const search = () => {
83-
searched.value = true
84-
searchStore.search(query.value)
86+
searched.value = false
87+
searchStore.search(query.value)?.then(() => searched.value = true)
8588
}
8689
8790

engine/README.md

Lines changed: 59 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,21 @@
1-
# Search Engine
1+
# TueR – Tübingen Retrieval (Engine)
22

3-
## Usage
4-
5-
- To crawl pages, you need to run the following command:
3+
This is the engine for the **TüR** (****bingen **R**etrieval) project, built with Python, Flask, DuckDB, and lots of
4+
motivation.
65

7-
```
8-
python main.py --online
9-
```
10-
- Run the following command to start the server:
11-
12-
```
13-
python server.py
14-
```
6+
## Table of Contents
157

16-
- Open your browser and navigate to `http://localhost:8000/` to view the application.
8+
1. [Requirements](#requirements)
9+
2. [Installation](#installation)
10+
3. [Usage](#usage)
11+
4. [Server](#server)
12+
5. [Known Issues](#known-issues)
1713

1814
## Requirements
1915

20-
- `Python 3`
21-
- `pip`
22-
- `virtualenv`
16+
- Python 3
17+
- pip
18+
- virtualenv
2319

2420
## Installation
2521

@@ -28,40 +24,64 @@
2824
- Download and install the latest version of Python 3 from the official website.
2925

3026
2. **Install virtualenv:**
27+
```shell
28+
pip install virtualenv
29+
```
3130

32-
- Open a terminal and run the following command:
33-
31+
3. **Create and activate a virtual environment:**
32+
```shell
33+
virtualenv --python=3.11 .venv
34+
source .venv/bin/activate
3435
```
35-
pip install virtualenv
36+
37+
4. **Install requirements:**
38+
```shell
39+
pip install -r requirements.txt
40+
python -m spacy download en_core_web_sm
3641
```
3742

38-
3. **Create a virtual environment:**
43+
## Usage
3944

40-
- Create the virtual environment:
45+
### Crawl pages:
4146

42-
```
43-
virtualenv --python=3.11 .venv
44-
```
47+
```shell
48+
python main.py --online
49+
```
4550

46-
- Activate the virtual environment:
51+
### Start the server:
4752

48-
```
49-
source .venv/bin/activate
50-
```
53+
```shell
54+
python server.py
55+
```
5156

52-
4. **Install requirements:**
57+
### Access the application:
5358

54-
- Ensure you have a requirements.txt file in your project directory.
55-
- Run the following command to install the dependencies:
59+
Open your browser and navigate to [http://localhost:8000/](http://localhost:8000/)
5660

57-
```
58-
pip install -r requirements.txt
59-
```
61+
## Server
6062

61-
- For the text-processing part, we use `spaCy`. You need to download the English model by running the following command:
63+
The server is built with Flask and runs on port 8000 by default. To start the server, use the following command:
6264

63-
```
64-
python -m spacy download en_core_web_sm
65-
```
65+
```shell
66+
python server.py
67+
```
68+
69+
You can see a list of all available routes by navigating to <http://localhost:8000/site-map>.
70+
71+
---
72+
73+
**Important:**
74+
75+
- The server will only work if you have crawled some pages before.
76+
- For the summarization you will need a strong CPU and a lot of RAM, as the summarization is done on the fly and can be
77+
quite resource-intensive.
78+
---
79+
80+
## Known Issues
81+
82+
The pipeline will not stop by itself, even if reached the maximum sites.
83+
You will have to stop it manually by pressing `Ctrl + C` in the terminal.
84+
But it will be able to resume from where it left off when you restart it.
6685

67-
5. **Start developing the project**
86+
When the offline pipeline runs, it will try to finish completely before stopping.
87+
If you force stop it, the pipeline will not save the state because it's saved in `crawlies.db.wal`.

engine/server.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,14 +112,14 @@ def summarize(doc_id):
112112
def doc_count():
113113
con = dbcon.cursor()
114114

115+
# Get the number of documents
115116
doc_count = con.execute(
116117
"""
117118
SELECT COUNT(*) FROM documents
118119
"""
119120
).fetchall()[0][0]
120121

121122
con.cursor()
122-
123123
return jsonify({"doc_count": doc_count})
124124

125125

engine/similarity.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def most_similar(word: str, topn=7) -> list:
1717
1818
Args:
1919
word (str): The word to find similar words to.
20-
topn (int, optional): Amount of similiar words we want to have. Defaults to 7.
20+
topn (int, optional): Number of similar words we want to have. Default to 7.
2121
2222
Returns:
2323
list: A list of tuples containing the most similar words and their similarity score.

0 commit comments

Comments
 (0)