File size: 3,230 Bytes
fad86ee
 
 
 
 
 
 
 
 
1fe03d2
fad86ee
1fe03d2
 
fad86ee
 
 
 
 
e63bd3d
 
 
 
fad86ee
198eca9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e63bd3d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
---
dataset_info:
  features:
  - name: question
    dtype: string
  - name: answer
    dtype: string
  splits:
  - name: train
    num_bytes: 130703
    num_examples: 250
  download_size: 54948
  dataset_size: 130703
configs:
- config_name: default
  data_files:
  - split: train
    path: data/train-*
task_categories:
- question-answering
language:
- ja
---

Japanese construction themes FAQs scraped from [https://www.city.yokohama.lg.jp/business/bunyabetsu/kenchiku/annai/faq/qa.html](https://www.city.yokohama.lg.jp/business/bunyabetsu/kenchiku/annai/faq/qa.html).

Downloaded using the following code:

```python
import requests
from lxml import html
import pandas as pd
from datasets import Dataset

hrefs = [
    "/business/bunyabetsu/kenchiku/annai/faq/ji-annnai.html",
    "/business/bunyabetsu/kenchiku/tetsuduki/kakunin/qa-kakunin.html",
    "/business/bunyabetsu/kenchiku/tetsuduki/teikihoukoku/seido/01.html",
    "/business/bunyabetsu/kenchiku/tetsuduki/teikihoukoku/seido/07.html",
    "/business/bunyabetsu/kenchiku/tetsuduki/doro/qa-doro.html",
    "/business/bunyabetsu/kenchiku/tetsuduki/doro/qa-doro.html",
    "/business/bunyabetsu/kenchiku/bosai/kyoai/jigyou/qanda.html",
    "/business/bunyabetsu/kenchiku/tetsuduki/kyoka/43.html",
    "/business/bunyabetsu/kenchiku/takuchi/toiawase/keikakuho/tokeihou.html",
    "/business/bunyabetsu/kenchiku/takuchi/toiawase/kiseiho/takuzo.html",
    "/business/bunyabetsu/kenchiku/takuchi/toiawase/keikakuho/q4-1.html",
    "/business/bunyabetsu/kenchiku/kankyo-shoene/casbee/hairyo/qa.html",
    "/business/bunyabetsu/kenchiku/tetsuduki/jorei/machizukuri/fukumachiqa.html",
    "/business/bunyabetsu/kenchiku/kankyo-shoene/chouki/qa-chouki.html",
    "/business/bunyabetsu/kenchiku/kankyo-shoene/huuti/qa-huuchi.html",
    "/kurashi/machizukuri-kankyo/kotsu/toshikotsu/chushajo/jorei/qa.html",
]

url_stem = "https://www.city.yokohama.lg.jp"

def get_question_text(url):
    # Send a GET request to the webpage
    response = requests.get(url)

    # Parse the HTML content
    tree = html.fromstring(response.content)
    
    question_data = []

    # Use XPath to find the desired elements
    for qa_element in tree.xpath('//div[@class="contents-area"]/section'):
        question_data.append({
            "question": qa_element.xpath('.//div[@class="question-text"]/text()')[0],
            "answer": "\n".join(qa_element.xpath('.//div[@class="answer-text"]/div/p/text()'))
        })
    
    return question_data

qa_list = []
for href in hrefs:
    print(href)
    qa_list.extend(get_question_text(url_stem + href))

df = pd.DataFrame(qa_list)

df.question = df.question.apply(lambda x: x[len(x.split()[0]):] if " " in x[:7] or " " in x[:7] else x)
df.answer = df.answer.apply(lambda x: x[len(x.split()[0]):] if " " in x[:7] or " " in x[:7] else x)

df.question = df.question.str.strip()
df.answer = df.answer.str.strip()

df.question = df.question.apply(lambda x: x[:-len(x.split("<")[-1])-1] if "<" in x else x)
df.answer = df.answer.apply(lambda x: x[:-len(x.split("<")[-1])-1] if "<" in x else x)

df.question = df.question.str.strip()
df.answer = df.answer.str.strip()

Dataset.from_pandas(df).push_to_hub("lightblue/architecture_faqs")
```