indicate 0.2.0__tar.gz → 0.3.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of indicate might be problematic. Click here for more details.

Files changed (78) hide show
  1. {indicate-0.2.0 → indicate-0.3.0}/PKG-INFO +25 -21
  2. {indicate-0.2.0 → indicate-0.3.0}/README.rst +2 -2
  3. {indicate-0.2.0 → indicate-0.3.0}/docs/source/conf.py +1 -1
  4. {indicate-0.2.0 → indicate-0.3.0}/indicate/data/get_affidavits/crawler/middlewares.py +4 -5
  5. {indicate-0.2.0 → indicate-0.3.0}/indicate/data/get_affidavits/crawler/settings.py +30 -30
  6. indicate-0.3.0/indicate/data/get_affidavits/crawler/spiders/crawler_spider.py +118 -0
  7. {indicate-0.2.0 → indicate-0.3.0}/indicate/data/get_espncricinfo/find_hindi_scorecards.py +5 -2
  8. indicate-0.3.0/indicate/data/get_espncricinfo/parse_hindi_scorecards.py +42 -0
  9. {indicate-0.2.0 → indicate-0.3.0}/indicate/decoder.py +36 -13
  10. indicate-0.3.0/indicate/encoder.py +34 -0
  11. indicate-0.3.0/indicate/hindi2english.py +172 -0
  12. indicate-0.3.0/indicate/logging.py +15 -0
  13. {indicate-0.2.0 → indicate-0.3.0}/indicate/tests/__init__.py +1 -1
  14. {indicate-0.2.0 → indicate-0.3.0}/indicate/tests/test_010_hindi_translate.py +4 -2
  15. {indicate-0.2.0 → indicate-0.3.0}/indicate/utils.py +48 -23
  16. {indicate-0.2.0 → indicate-0.3.0}/indicate.egg-info/PKG-INFO +25 -21
  17. {indicate-0.2.0 → indicate-0.3.0}/indicate.egg-info/SOURCES.txt +1 -30
  18. indicate-0.3.0/indicate.egg-info/requires.txt +20 -0
  19. indicate-0.3.0/indicate.egg-info/top_level.txt +4 -0
  20. indicate-0.3.0/pyproject.toml +68 -0
  21. indicate-0.3.0/setup.cfg +4 -0
  22. indicate-0.2.0/.gitattributes +0 -1
  23. indicate-0.2.0/.github/ISSUE_TEMPLATE/bug_report.md +0 -23
  24. indicate-0.2.0/.github/ISSUE_TEMPLATE/feature_request.md +0 -20
  25. indicate-0.2.0/.github/workflows/python-publish.yml +0 -36
  26. indicate-0.2.0/.github/workflows/test.yml +0 -51
  27. indicate-0.2.0/.gitignore +0 -16
  28. indicate-0.2.0/.travis.yml +0 -17
  29. indicate-0.2.0/Citation.cff +0 -11
  30. indicate-0.2.0/MANIFEST.in +0 -4
  31. indicate-0.2.0/appveyor.yml +0 -34
  32. indicate-0.2.0/docs/Makefile +0 -20
  33. indicate-0.2.0/docs/make.bat +0 -35
  34. indicate-0.2.0/docs/source/index.rst +0 -23
  35. indicate-0.2.0/docs/source/indicate.rst +0 -69
  36. indicate-0.2.0/docs/source/modules.rst +0 -7
  37. indicate-0.2.0/images/h2e_ed.png +0 -0
  38. indicate-0.2.0/indicate/data/affidavits.csv +0 -15597
  39. indicate-0.2.0/indicate/data/get_affidavits/Affidavit-1628221617.pdf +0 -0
  40. indicate-0.2.0/indicate/data/get_affidavits/crawler/spiders/crawler_spider.py +0 -88
  41. indicate-0.2.0/indicate/data/get_affidavits/scrape_affidavits.md +0 -22
  42. indicate-0.2.0/indicate/data/get_affidavits/scrapy.cfg +0 -11
  43. indicate-0.2.0/indicate/data/get_espncricinfo/all-matches.json +0 -1
  44. indicate-0.2.0/indicate/data/get_espncricinfo/parse_hindi_scorecards.py +0 -26
  45. indicate-0.2.0/indicate/data/iit/README.md +0 -13
  46. indicate-0.2.0/indicate/data/iit/en-hi.mined-pairs +0 -68922
  47. indicate-0.2.0/indicate/data/players_with_hindi_names.json +0 -1
  48. indicate-0.2.0/indicate/encoder.py +0 -24
  49. indicate-0.2.0/indicate/hindi2english.py +0 -138
  50. indicate-0.2.0/indicate/logging.py +0 -6
  51. indicate-0.2.0/indicate.egg-info/requires.txt +0 -9
  52. indicate-0.2.0/indicate.egg-info/top_level.txt +0 -1
  53. indicate-0.2.0/readthedocs.yml +0 -8
  54. indicate-0.2.0/requirements.txt +0 -4
  55. indicate-0.2.0/requirements_rtd.txt +0 -4
  56. indicate-0.2.0/setup.cfg +0 -8
  57. indicate-0.2.0/setup.py +0 -138
  58. indicate-0.2.0/tox.ini +0 -8
  59. {indicate-0.2.0 → indicate-0.3.0}/LICENSE +0 -0
  60. {indicate-0.2.0 → indicate-0.3.0}/indicate/__init__.py +0 -0
  61. {indicate-0.2.0 → indicate-0.3.0}/indicate/data/get_affidavits/crawler/__init__.py +0 -0
  62. {indicate-0.2.0 → indicate-0.3.0}/indicate/data/get_affidavits/crawler/items.py +0 -0
  63. {indicate-0.2.0 → indicate-0.3.0}/indicate/data/get_affidavits/crawler/pipelines.py +0 -0
  64. {indicate-0.2.0 → indicate-0.3.0}/indicate/data/get_affidavits/crawler/spiders/__init__.py +0 -0
  65. {indicate-0.2.0 → indicate-0.3.0}/indicate/data/model/hindi_to_english/english_tokens.json +0 -0
  66. {indicate-0.2.0 → indicate-0.3.0}/indicate/data/model/hindi_to_english/hindi_tokens.json +0 -0
  67. {indicate-0.2.0 → indicate-0.3.0}/indicate/data/model/hindi_to_english/saved_weights/decoder.weights.h5 +0 -0
  68. {indicate-0.2.0 → indicate-0.3.0}/indicate/data/model/hindi_to_english/saved_weights/encoder.weights.h5 +0 -0
  69. {indicate-0.2.0 → indicate-0.3.0}/indicate/notebooks/Data_Preparation.ipynb +0 -0
  70. {indicate-0.2.0 → indicate-0.3.0}/indicate/notebooks/Inference.ipynb +0 -0
  71. {indicate-0.2.0 → indicate-0.3.0}/indicate/notebooks/Inference_latest.ipynb +0 -0
  72. {indicate-0.2.0 → indicate-0.3.0}/indicate/notebooks/Train.ipynb +0 -0
  73. {indicate-0.2.0 → indicate-0.3.0}/indicate/notebooks/Train_latest.ipynb +0 -0
  74. {indicate-0.2.0 → indicate-0.3.0}/indicate/notebooks/Transliterate.ipynb +0 -0
  75. {indicate-0.2.0 → indicate-0.3.0}/indicate/notebooks/transliterate_cricket.ipynb +0 -0
  76. {indicate-0.2.0 → indicate-0.3.0}/indicate/transliterate.py +1 -1
  77. {indicate-0.2.0 → indicate-0.3.0}/indicate.egg-info/dependency_links.txt +0 -0
  78. {indicate-0.2.0 → indicate-0.3.0}/indicate.egg-info/entry_points.txt +0 -0
@@ -1,46 +1,50 @@
1
- Metadata-Version: 2.2
1
+ Metadata-Version: 2.4
2
2
  Name: indicate
3
- Version: 0.2.0
3
+ Version: 0.3.0
4
4
  Summary: Transliterations to/from Indian languages
5
- Home-page: https://github.com/in-rolls/indicate
6
- Author: Rajashekar Chintalapati, Gaurav Sood
7
- Author-email: rajshekar.ch@gmail.com, gsood07@gmail.com
5
+ Author-email: Rajashekar Chintalapati <rajshekar.ch@gmail.com>, Gaurav Sood <gsood07@gmail.com>
8
6
  License: MIT
9
- Keywords: transliterate indic hindi english
7
+ Project-URL: Homepage, https://github.com/in-rolls/indicate
8
+ Project-URL: Repository, https://github.com/in-rolls/indicate
9
+ Keywords: transliterate,indic,hindi,english
10
10
  Classifier: Development Status :: 3 - Alpha
11
11
  Classifier: Intended Audience :: Developers
12
12
  Classifier: License :: OSI Approved :: MIT License
13
- Classifier: Programming Language :: Python :: 3.6
14
- Classifier: Programming Language :: Python :: 3.7
15
13
  Classifier: Programming Language :: Python :: 3.8
14
+ Classifier: Programming Language :: Python :: 3.9
15
+ Classifier: Programming Language :: Python :: 3.10
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
16
18
  Classifier: Topic :: Scientific/Engineering :: Information Analysis
17
19
  Classifier: Topic :: Software Development :: Libraries :: Python Modules
18
20
  Classifier: Topic :: Utilities
21
+ Requires-Python: >=3.8
22
+ Description-Content-Type: text/x-rst
19
23
  License-File: LICENSE
20
24
  Requires-Dist: tqdm
21
25
  Requires-Dist: func-timeout
22
- Requires-Dist: tensorflow==2.18.0
26
+ Requires-Dist: tensorflow<3.0.0,>=2.18.0
27
+ Requires-Dist: importlib-resources>=5.0.0; python_version < "3.9"
23
28
  Provides-Extra: dev
29
+ Requires-Dist: black>=23.0.0; extra == "dev"
30
+ Requires-Dist: isort>=5.12.0; extra == "dev"
31
+ Requires-Dist: flake8>=6.0.0; extra == "dev"
32
+ Requires-Dist: mypy>=1.0.0; extra == "dev"
33
+ Requires-Dist: pytest>=7.0.0; extra == "dev"
34
+ Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
35
+ Requires-Dist: pre-commit>=3.0.0; extra == "dev"
24
36
  Requires-Dist: check-manifest; extra == "dev"
25
37
  Provides-Extra: test
26
38
  Requires-Dist: coverage; extra == "test"
27
- Dynamic: author
28
- Dynamic: author-email
29
- Dynamic: classifier
30
- Dynamic: description
31
- Dynamic: home-page
32
- Dynamic: keywords
33
- Dynamic: license
34
- Dynamic: provides-extra
35
- Dynamic: requires-dist
36
- Dynamic: summary
39
+ Requires-Dist: tox; extra == "test"
40
+ Dynamic: license-file
37
41
 
38
42
  ==================================================
39
43
  Indicate: Transliterate Indic Languages to English
40
44
  ==================================================
41
45
 
42
- .. image:: https://app.travis-ci.com/in-rolls/indicate.svg?branch=master
43
- :target: https://travis-ci.org/in-rolls/indicate
46
+ .. image:: https://notarypy.soodoku.workers.dev/badge/indicate/0.2.1/indicate-0.2.1-py3-none-any.whl
47
+ :target: https://pypi.org/integrity/indicate/0.2.1/indicate-0.2.1-py3-none-any.whl/provenance
44
48
  .. image:: https://img.shields.io/pypi/v/indicate.svg
45
49
  :target: https://pypi.python.org/pypi/indicate
46
50
  .. image:: https://readthedocs.org/projects/indicate/badge/?version=latest
@@ -2,8 +2,8 @@
2
2
  Indicate: Transliterate Indic Languages to English
3
3
  ==================================================
4
4
 
5
- .. image:: https://app.travis-ci.com/in-rolls/indicate.svg?branch=master
6
- :target: https://travis-ci.org/in-rolls/indicate
5
+ .. image:: https://notarypy.soodoku.workers.dev/badge/indicate/0.2.1/indicate-0.2.1-py3-none-any.whl
6
+ :target: https://pypi.org/integrity/indicate/0.2.1/indicate-0.2.1-py3-none-any.whl/provenance
7
7
  .. image:: https://img.shields.io/pypi/v/indicate.svg
8
8
  :target: https://pypi.python.org/pypi/indicate
9
9
  .. image:: https://readthedocs.org/projects/indicate/badge/?version=latest
@@ -14,7 +14,7 @@ sys.path.insert(1, os.path.abspath('../../'))
14
14
  project = 'indicate'
15
15
  copyright = '2023, rajashekar chintalapati and gaurav sood'
16
16
  author = 'rajashekar chintalapati and gaurav sood'
17
- release = '0.1.0'
17
+ release = '0.3.0'
18
18
 
19
19
  # -- General configuration ---------------------------------------------------
20
20
  # https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
@@ -3,10 +3,9 @@
3
3
  # See documentation in:
4
4
  # https://docs.scrapy.org/en/latest/topics/spider-middleware.html
5
5
 
6
- from scrapy import signals
7
-
8
6
  # useful for handling different item types with a single interface
9
- from itemadapter import is_item, ItemAdapter
7
+ from itemadapter import ItemAdapter, is_item
8
+ from scrapy import signals
10
9
 
11
10
 
12
11
  class CrawlerSpiderMiddleware:
@@ -53,7 +52,7 @@ class CrawlerSpiderMiddleware:
53
52
  yield r
54
53
 
55
54
  def spider_opened(self, spider):
56
- spider.logger.info('Spider opened: %s' % spider.name)
55
+ spider.logger.info("Spider opened: %s" % spider.name)
57
56
 
58
57
 
59
58
  class CrawlerDownloaderMiddleware:
@@ -100,4 +99,4 @@ class CrawlerDownloaderMiddleware:
100
99
  pass
101
100
 
102
101
  def spider_opened(self, spider):
103
- spider.logger.info('Spider opened: %s' % spider.name)
102
+ spider.logger.info("Spider opened: %s" % spider.name)
@@ -7,82 +7,82 @@
7
7
  # https://docs.scrapy.org/en/latest/topics/downloader-middleware.html
8
8
  # https://docs.scrapy.org/en/latest/topics/spider-middleware.html
9
9
 
10
- BOT_NAME = 'crawler'
10
+ BOT_NAME = "crawler"
11
11
 
12
- SPIDER_MODULES = ['crawler.spiders']
13
- NEWSPIDER_MODULE = 'crawler.spiders'
12
+ SPIDER_MODULES = ["crawler.spiders"]
13
+ NEWSPIDER_MODULE = "crawler.spiders"
14
14
 
15
15
 
16
16
  # Crawl responsibly by identifying yourself (and your website) on the user-agent
17
- USER_AGENT = 'crawler (+https://affidavit.eci.gov.in)'
17
+ USER_AGENT = "crawler (+https://affidavit.eci.gov.in)"
18
18
 
19
19
  # Obey robots.txt rules
20
20
  ROBOTSTXT_OBEY = True
21
21
 
22
22
  # Configure maximum concurrent requests performed by Scrapy (default: 16)
23
- #CONCURRENT_REQUESTS = 32
23
+ # CONCURRENT_REQUESTS = 32
24
24
 
25
25
  # Configure a delay for requests for the same website (default: 0)
26
26
  # See https://docs.scrapy.org/en/latest/topics/settings.html#download-delay
27
27
  # See also autothrottle settings and docs
28
- #DOWNLOAD_DELAY = 3
28
+ # DOWNLOAD_DELAY = 3
29
29
  # The download delay setting will honor only one of:
30
- #CONCURRENT_REQUESTS_PER_DOMAIN = 16
31
- #CONCURRENT_REQUESTS_PER_IP = 16
30
+ # CONCURRENT_REQUESTS_PER_DOMAIN = 16
31
+ # CONCURRENT_REQUESTS_PER_IP = 16
32
32
 
33
33
  # Disable cookies (enabled by default)
34
- #COOKIES_ENABLED = False
34
+ # COOKIES_ENABLED = False
35
35
 
36
36
  # Disable Telnet Console (enabled by default)
37
- #TELNETCONSOLE_ENABLED = False
37
+ # TELNETCONSOLE_ENABLED = False
38
38
 
39
39
  # Override the default request headers:
40
- #DEFAULT_REQUEST_HEADERS = {
40
+ # DEFAULT_REQUEST_HEADERS = {
41
41
  # 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
42
42
  # 'Accept-Language': 'en',
43
- #}
43
+ # }
44
44
 
45
45
  # Enable or disable spider middlewares
46
46
  # See https://docs.scrapy.org/en/latest/topics/spider-middleware.html
47
- #SPIDER_MIDDLEWARES = {
47
+ # SPIDER_MIDDLEWARES = {
48
48
  # 'crawler.middlewares.CrawlerSpiderMiddleware': 543,
49
- #}
49
+ # }
50
50
 
51
51
  # Enable or disable downloader middlewares
52
52
  # See https://docs.scrapy.org/en/latest/topics/downloader-middleware.html
53
- #DOWNLOADER_MIDDLEWARES = {
53
+ # DOWNLOADER_MIDDLEWARES = {
54
54
  # 'crawler.middlewares.CrawlerDownloaderMiddleware': 543,
55
- #}
55
+ # }
56
56
 
57
57
  # Enable or disable extensions
58
58
  # See https://docs.scrapy.org/en/latest/topics/extensions.html
59
- #EXTENSIONS = {
59
+ # EXTENSIONS = {
60
60
  # 'scrapy.extensions.telnet.TelnetConsole': None,
61
- #}
61
+ # }
62
62
 
63
63
  # Configure item pipelines
64
64
  # See https://docs.scrapy.org/en/latest/topics/item-pipeline.html
65
- #ITEM_PIPELINES = {
65
+ # ITEM_PIPELINES = {
66
66
  # 'crawler.pipelines.CrawlerPipeline': 300,
67
- #}
67
+ # }
68
68
 
69
69
  # Enable and configure the AutoThrottle extension (disabled by default)
70
70
  # See https://docs.scrapy.org/en/latest/topics/autothrottle.html
71
- #AUTOTHROTTLE_ENABLED = True
71
+ # AUTOTHROTTLE_ENABLED = True
72
72
  # The initial download delay
73
- #AUTOTHROTTLE_START_DELAY = 5
73
+ # AUTOTHROTTLE_START_DELAY = 5
74
74
  # The maximum download delay to be set in case of high latencies
75
- #AUTOTHROTTLE_MAX_DELAY = 60
75
+ # AUTOTHROTTLE_MAX_DELAY = 60
76
76
  # The average number of requests Scrapy should be sending in parallel to
77
77
  # each remote server
78
- #AUTOTHROTTLE_TARGET_CONCURRENCY = 1.0
78
+ # AUTOTHROTTLE_TARGET_CONCURRENCY = 1.0
79
79
  # Enable showing throttling stats for every response received:
80
- #AUTOTHROTTLE_DEBUG = False
80
+ # AUTOTHROTTLE_DEBUG = False
81
81
 
82
82
  # Enable and configure HTTP caching (disabled by default)
83
83
  # See https://docs.scrapy.org/en/latest/topics/downloader-middleware.html#httpcache-middleware-settings
84
- #HTTPCACHE_ENABLED = True
85
- #HTTPCACHE_EXPIRATION_SECS = 0
86
- #HTTPCACHE_DIR = 'httpcache'
87
- #HTTPCACHE_IGNORE_HTTP_CODES = []
88
- #HTTPCACHE_STORAGE = 'scrapy.extensions.httpcache.FilesystemCacheStorage'
84
+ # HTTPCACHE_ENABLED = True
85
+ # HTTPCACHE_EXPIRATION_SECS = 0
86
+ # HTTPCACHE_DIR = 'httpcache'
87
+ # HTTPCACHE_IGNORE_HTTP_CODES = []
88
+ # HTTPCACHE_STORAGE = 'scrapy.extensions.httpcache.FilesystemCacheStorage'
@@ -0,0 +1,118 @@
1
+ import re
2
+
3
+ from crawler.items import CrawlerItem, Fixture
4
+ from scrapy import Request, Spider
5
+ from scrapy.linkextractors import LinkExtractor
6
+ from scrapy.selector import Selector
7
+ from scrapy.spiders import CrawlSpider, Rule
8
+
9
+
10
+ class CrawlerSpider(Spider):
11
+ name = "crawler"
12
+ allowed_domains = ["affidavit.eci.gov.in"]
13
+ start_urls = [
14
+ "https://affidavit.eci.gov.in",
15
+ ]
16
+ rules = [
17
+ Rule(LinkExtractor(allow=r"show-profile"), callback="parse_product"),
18
+ ]
19
+ unique_id = 0
20
+
21
+ def parse(self, response):
22
+ # questions = Selector(response).xpath('//ul[@class="table"]/li')
23
+ questions = response.selector
24
+ print("11111111111111111111", questions)
25
+ # get next page
26
+ for p in questions.css(".pagination"):
27
+ detail_link = p.xpath('li[@class="page-item"]')
28
+ # print ('------------------', detail_link)
29
+ for link in detail_link:
30
+ n = link.extract()
31
+ # print ('_____________________',n)
32
+ matches = re.findall('rel="next"', n)
33
+ # print(matches)
34
+ if matches:
35
+ next_link = link.xpath("a/@href").extract()
36
+ print("kakakakakakak", next_link)
37
+ yield Request(next_link[0], callback=self.parse)
38
+
39
+ # item['name_english'] = tr.xpath('td[2]/div[@class="details-name"]/h4/text()').extract()
40
+
41
+ for tr in questions.css("table#data-tab>tbody>tr"):
42
+ item = Fixture()
43
+ detail_link = tr.xpath('td[1]/div[@class="img-bx"]/a/@href').extract()
44
+ # print ('=======================', detail_link)
45
+ item["name_english"] = tr.xpath(
46
+ 'td[2]/div[@class="details-name"]/h4/text()'
47
+ ).extract()
48
+ # item['link'] =detail_link
49
+ # yield item
50
+ yield Request(detail_link[0], callback=self.parse_product)
51
+
52
+ def parse_product(self, response):
53
+ # questions = Selector(response).xpath('//ul[@class="table"]/li')
54
+ questions = response.selector
55
+ print("2222222222222222", questions)
56
+ # for sec in questions.css('section'):
57
+ # print ('3333333333333333',sec)
58
+ can_details = questions.css("section")[0]
59
+ # can_per_details = questions.css('section')[1]
60
+ can_details = can_details.xpath(
61
+ 'div/div/div/div/div[@class="card-body"]/div/div'
62
+ )
63
+ can_details = can_details[1].xpath("div")
64
+ # name = can_details[3]
65
+
66
+ item = Fixture()
67
+ self.unique_id += 1
68
+ item["unique_id"] = self.unique_id
69
+ item["party_name"] = (
70
+ can_details[0].xpath("div[2]/text()").extract()[0].strip("\n").strip()
71
+ )
72
+ item["name_english"] = (
73
+ can_details[2]
74
+ .xpath("div[2]/div/p/b/text()")
75
+ .extract()[0]
76
+ .strip("\n")
77
+ .strip()
78
+ )
79
+ item["name_hindi"] = (
80
+ can_details[3]
81
+ .xpath("div[2]/div/p/b/text()")
82
+ .extract()[0]
83
+ .strip("\n")
84
+ .strip()
85
+ )
86
+ item["assembly_constituency"] = (
87
+ can_details[4].xpath("div[2]/div/p/text()").extract()[0].strip("\n").strip()
88
+ )
89
+ item["state"] = (
90
+ can_details[5].xpath("div[2]/div/p/text()").extract()[0].strip("\n").strip()
91
+ )
92
+ item["application_uploaded"] = (
93
+ can_details[6].xpath("div[2]/div/p/text()").extract()
94
+ )
95
+ item["current_status"] = can_details[7].xpath("div[2]/div/p/text()").extract()
96
+
97
+ can_per_details = questions.css("section")[1]
98
+ can_per_details = can_per_details.xpath(
99
+ 'div/div[@class="row"]/div/div/div/div/div/form/div/div[1]/div'
100
+ )
101
+
102
+ item["fathers_or_husbands_name_english"] = (
103
+ can_per_details[0].xpath("div/p/text()").extract()
104
+ )
105
+ item["fathers_or_husbands_name_hindi"] = (
106
+ can_per_details[1].xpath("div/p/text()").extract()
107
+ )
108
+ item["name"] = can_per_details[2].xpath("div/p/text()").extract()
109
+
110
+ item["address"] = can_per_details[4].xpath("div/p/text()").extract()
111
+ item["age"] = can_per_details[6].xpath("div/p/text()").extract()
112
+ # item['url'] = can_per_details[0].xpath('div[2]/text()').extract()[0].strip('\n').strip()
113
+ # item['photo_url'] = can_per_details[0].xpath('div[2]/text()').extract()[0].strip('\n').strip()
114
+ # item['photo_filename_with_unique_id'] = can_per_details[0].xpath('div[2]/text()').extract()[0].strip('\n').strip()
115
+ # item['affidavit_filename_with_unique_id'] = can_per_details[0].xpath('div[2]/text()').extract()[0].strip(
116
+ #'\n').strip()
117
+
118
+ yield item
@@ -1,5 +1,6 @@
1
- import json
2
1
  import datetime
2
+ import json
3
+
3
4
  import requests
4
5
  from espncricinfo.match import Match
5
6
 
@@ -19,7 +20,9 @@ with open("all-matches.json", "r") as matches_file:
19
20
  if datetime.datetime(y, m, d) > datetime.datetime(2021, 4, 8):
20
21
  print(match_id)
21
22
  r = requests.get(match.match_url)
22
- hindi_url = r.url.replace("/series/", "/hindi/series/").replace("live-cricket-score", "full-scorecard")
23
+ hindi_url = r.url.replace("/series/", "/hindi/series/").replace(
24
+ "live-cricket-score", "full-scorecard"
25
+ )
23
26
  r = requests.get(hindi_url)
24
27
  if r.status_code == 404:
25
28
  hindi_url = None
@@ -0,0 +1,42 @@
1
+ import datetime
2
+ import json
3
+
4
+ import requests
5
+ from bs4 import BeautifulSoup
6
+ from espncricinfo.match import Match
7
+
8
+ players = []
9
+
10
+ with open("hindi_matches.json", "r") as matches_file:
11
+ hindi_matches = json.load(matches_file)
12
+ for match in hindi_matches:
13
+ print(match)
14
+ m = Match(match)
15
+ r = requests.get(m.match_url)
16
+ hindi_url = r.url.replace("/series/", "/hindi/series/").replace(
17
+ "live-cricket-score", "full-scorecard"
18
+ )
19
+ hindi_content = requests.get(hindi_url).text
20
+ soup = BeautifulSoup(hindi_content, "html.parser")
21
+ text = soup.find("script", id="__NEXT_DATA__").string
22
+ hindi_json = json.loads(text)
23
+ if "data" in hindi_json["props"]["pageProps"]:
24
+ for team_players in hindi_json["props"]["pageProps"]["data"]["pageData"][
25
+ "content"
26
+ ]["matchPlayers"]["teamPlayers"]:
27
+ for player in team_players["players"]:
28
+ players.append(
29
+ {
30
+ "id": player["player"]["id"],
31
+ "hindi_name": player["player"]["name"],
32
+ "hindi_long_name": player["player"]["longName"],
33
+ "english_name": player["player"]["indexName"],
34
+ "gender": player["player"]["gender"],
35
+ "date_of_birth": player["player"]["dateOfBirth"],
36
+ "country_id": player["player"]["countryTeamId"],
37
+ "slug": player["player"]["slug"],
38
+ }
39
+ )
40
+
41
+ with open("players_with_hindi_names.json", "w") as outfile:
42
+ json.dump(players, outfile)
@@ -1,12 +1,23 @@
1
+ from typing import Any, List, Optional, Tuple
2
+
1
3
  import tensorflow as tf
2
4
 
3
5
  from .logging import get_logger
4
6
 
5
7
  logger = get_logger()
6
8
 
9
+
7
10
  class Decoder(tf.keras.Model):
8
- def __init__(self, vocab_size, embedding_dim, dec_units, batch_sz,
9
- max_length_input, max_length_output, attention_type='luong'):
11
+ def __init__(
12
+ self,
13
+ vocab_size: int,
14
+ embedding_dim: int,
15
+ dec_units: int,
16
+ batch_sz: int,
17
+ max_length_input: int,
18
+ max_length_output: int,
19
+ attention_type: str = "luong",
20
+ ) -> None:
10
21
  super(Decoder, self).__init__()
11
22
  self.batch_sz = batch_sz
12
23
  self.dec_units = dec_units
@@ -22,32 +33,43 @@ class Decoder(tf.keras.Model):
22
33
 
23
34
  # Define the fundamental cell for decoder recurrent structure
24
35
  self.decoder_rnn_cell = tf.keras.layers.LSTMCell(self.dec_units)
25
- self.decoder_rnn = tf.keras.layers.RNN(self.decoder_rnn_cell, return_sequences=True, return_state=True)
36
+ self.decoder_rnn = tf.keras.layers.RNN(
37
+ self.decoder_rnn_cell, return_sequences=True, return_state=True
38
+ )
26
39
 
27
40
  # Create attention mechanism
28
41
  # For Luong attention: project the query to match the encoder output's dimension (dec_units)
29
- if self.attention_type == 'luong':
42
+ if self.attention_type == "luong":
30
43
  self.query_layer = tf.keras.layers.Dense(dec_units)
31
44
 
32
45
  self.attention_mechanism = self.build_attention_mechanism(None)
33
46
 
34
- def build_attention_mechanism(self, memory):
35
- if self.attention_type == 'bahdanau':
47
+ def build_attention_mechanism(
48
+ self, memory: Optional[tf.Tensor]
49
+ ) -> tf.keras.layers.Layer:
50
+ if self.attention_type == "bahdanau":
36
51
  return tf.keras.layers.AdditiveAttention()
37
52
  else:
38
53
  return tf.keras.layers.Attention()
39
54
 
40
- def call(self, inputs, initial_state, encoder_outputs):
55
+ def call(
56
+ self,
57
+ inputs: tf.Tensor,
58
+ initial_state: List[tf.Tensor],
59
+ encoder_outputs: tf.Tensor,
60
+ ) -> Tuple[tf.Tensor, Tuple[tf.Tensor, tf.Tensor], tf.Tensor]:
41
61
  # Get the embeddings of the inputs
42
62
  x = self.embedding(inputs)
43
63
 
44
- if self.attention_type == 'luong':
45
- query = self.query_layer(x)
64
+ if self.attention_type == "luong":
65
+ query = self.query_layer(x)
46
66
  else:
47
- query = x
67
+ query = x
48
68
 
49
69
  # Feature dimensions to the attention layer
50
- attention_output, attention_weights = self.attention_mechanism([query, encoder_outputs], return_attention_scores=True)
70
+ attention_output, attention_weights = self.attention_mechanism(
71
+ [query, encoder_outputs], return_attention_scores=True
72
+ )
51
73
  # Concatenate the attention output with the LSTM Cell output
52
74
  lstm_input = tf.concat([attention_output, x], axis=-1)
53
75
  # Process through the LSTM cell
@@ -56,7 +78,8 @@ class Decoder(tf.keras.Model):
56
78
  outputs = self.fc(outputs)
57
79
  return outputs, (state_h, state_c), attention_weights
58
80
 
59
- def build_initial_state(self, batch_sz, encoder_state):
81
+ def build_initial_state(
82
+ self, batch_sz: int, encoder_state: List[tf.Tensor]
83
+ ) -> List[tf.Tensor]:
60
84
  hidden_state, cell_state = encoder_state
61
85
  return [hidden_state, cell_state]
62
-
@@ -0,0 +1,34 @@
1
+ from typing import Any, List, Tuple
2
+
3
+ import tensorflow as tf
4
+
5
+
6
+ class Encoder(tf.keras.Model):
7
+ def __init__(
8
+ self, vocab_size: int, embedding_dim: int, enc_units: int, batch_sz: int
9
+ ) -> None:
10
+ super(Encoder, self).__init__()
11
+ self.batch_sz = batch_sz
12
+ self.enc_units = enc_units
13
+ self.embedding = tf.keras.layers.Embedding(vocab_size, embedding_dim)
14
+
15
+ ##-------- LSTM layer in Encoder ------- ##
16
+ self.lstm_layer = tf.keras.layers.LSTM(
17
+ self.enc_units,
18
+ return_sequences=True,
19
+ return_state=True,
20
+ recurrent_initializer="glorot_uniform",
21
+ )
22
+
23
+ def call(
24
+ self, x: tf.Tensor, hidden: List[tf.Tensor], training: bool = None
25
+ ) -> Tuple[tf.Tensor, tf.Tensor, tf.Tensor]:
26
+ x = self.embedding(x)
27
+ output, h, c = self.lstm_layer(x, initial_state=hidden)
28
+ return output, h, c
29
+
30
+ def initialize_hidden_state(self) -> List[tf.Tensor]:
31
+ return [
32
+ tf.zeros((self.batch_sz, self.enc_units)),
33
+ tf.zeros((self.batch_sz, self.enc_units)),
34
+ ]