Marc Kupietz | 12a9fe8 | 2020-06-16 14:27:57 +0200 | [diff] [blame] | 1 | #!/usr/bin/env python3 |
Marc Kupietz | 6d53974 | 2020-06-25 18:33:20 +0200 | [diff] [blame] | 2 | from KorAPClient import KorAPClient, KorAPConnection |
Marc Kupietz | 12a9fe8 | 2020-06-16 14:27:57 +0200 | [diff] [blame] | 3 | import plotly.express as px |
Marc Kupietz | 12a9fe8 | 2020-06-16 14:27:57 +0200 | [diff] [blame] | 4 | |
| 5 | QUERY = "Hello World" |
| 6 | YEARS = range(2010, 2019) |
| 7 | COUNTRIES = ["DE", "CH"] |
| 8 | |
Marc Kupietz | 6d53974 | 2020-06-25 18:33:20 +0200 | [diff] [blame] | 9 | kcon = KorAPConnection(verbose=True) |
Marc Kupietz | 12a9fe8 | 2020-06-16 14:27:57 +0200 | [diff] [blame] | 10 | |
| 11 | vcs = ["textType=/Zeit.*/ & pubPlaceKey=" + c + " & pubDate in " + str(y) for c in COUNTRIES for y in YEARS] |
Marc Kupietz | 6d53974 | 2020-06-25 18:33:20 +0200 | [diff] [blame] | 12 | df = KorAPClient.ipm(kcon.frequencyQuery(QUERY, vcs)) |
| 13 | print(df) |
| 14 | |
Marc Kupietz | 12a9fe8 | 2020-06-16 14:27:57 +0200 | [diff] [blame] | 15 | df['Year'] = [y for c in COUNTRIES for y in YEARS] |
| 16 | df['Country'] = [c for c in COUNTRIES for y in YEARS] |
| 17 | |
| 18 | fig = px.line(df, title=QUERY, x="Year", y="ipm", color="Country", |
| 19 | error_y="conf.high", error_y_minus="conf.low") |
| 20 | fig.show() |