-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding 2 methods to find lang based on name
- Loading branch information
Rajashekar Chintalapati
committed
Aug 18, 2024
1 parent
c00156c
commit c1a0647
Showing
17 changed files
with
284 additions
and
113 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"n": 1, "g": 2, "i": 3, "m": 4, "c": 5, "w": 6, "u": 7, "e": 8, "v": 9, "d": 10, "a": 11, "l": 12, "t": 13, "s": 14, "q": 15, "b": 16, "f": 17, "o": 18, "z": 19, "p": 20, "r": 21, "k": 22, "h": 23, "y": 24, "x": 25, "j": 26, "<PAD>": 0} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
sindhi | ||
nepali | ||
kannada | ||
marathi | ||
mizo | ||
adi | ||
garo | ||
tagin | ||
assamese | ||
hindi | ||
odia | ||
french | ||
punjabi | ||
naga languages | ||
english | ||
chenchu | ||
urdu | ||
bengali | ||
maithili | ||
dogri | ||
kokborok | ||
santali | ||
kashmiri | ||
gujarati | ||
apatani | ||
tulu | ||
konkani | ||
telugu | ||
malayalam | ||
tamil | ||
meitei | ||
khasi | ||
gondi | ||
bodo | ||
nishi | ||
chakma | ||
pahari and kumauni |
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import torch.nn as nn | ||
|
||
class LanguagePredictor(nn.Module): | ||
def __init__(self, num_chars, embedding_dim=64, lstm_hidden_dim=128, num_languages=37): | ||
super(LanguagePredictor, self).__init__() | ||
self.embedding = nn.Embedding(num_chars, embedding_dim) | ||
self.lstm = nn.LSTM(embedding_dim, lstm_hidden_dim, batch_first=True) | ||
self.fc1 = nn.Linear(lstm_hidden_dim, num_languages) | ||
self.fc2 = nn.Linear(lstm_hidden_dim, num_languages) | ||
self.fc3 = nn.Linear(lstm_hidden_dim, num_languages) | ||
|
||
def forward(self, x, lengths): | ||
x = self.embedding(x) | ||
x = nn.utils.rnn.pack_padded_sequence(x, lengths, batch_first=True, enforce_sorted=False) | ||
_, (h_n, _) = self.lstm(x) | ||
h_n = h_n.squeeze(0) | ||
out1 = self.fc1(h_n) | ||
out2 = self.fc2(h_n) | ||
out3 = self.fc3(h_n) | ||
return out1, out2, out3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
from torch import nn | ||
|
||
class LanguagePredictor(nn.Module): | ||
def __init__(self, num_chars, embedding_dim=64, lstm_hidden_dim=128, num_languages=37): | ||
super(LanguagePredictor, self).__init__() | ||
self.embedding = nn.Embedding(num_chars, embedding_dim) | ||
self.lstm = nn.LSTM(embedding_dim, lstm_hidden_dim, batch_first=True) | ||
self.fc1 = nn.Linear(lstm_hidden_dim, num_languages) | ||
self.fc2 = nn.Linear(lstm_hidden_dim, num_languages) | ||
self.fc3 = nn.Linear(lstm_hidden_dim, num_languages) | ||
|
||
def forward(self, x, lengths): | ||
x = self.embedding(x) | ||
x = nn.utils.rnn.pack_padded_sequence(x, lengths, batch_first=True, enforce_sorted=False) | ||
_, (h_n, _) = self.lstm(x) | ||
h_n = h_n.squeeze(0) | ||
out1 = self.fc1(h_n) | ||
out2 = self.fc2(h_n) | ||
out3 = self.fc3(h_n) | ||
return out1, out2, out3 |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
|
||
""" | ||
Tests for in_rolls_fn.py | ||
""" | ||
|
||
import unittest | ||
import pandas as pd | ||
from instate.instate import lookup_lang | ||
|
||
class TestInRollsLn(unittest.TestCase): | ||
def setUp(self): | ||
names = [{"name": "sood"}, {"name": "chintalapati"}] | ||
self.pred_lang = ["hindi", "telugu"] | ||
self.df = pd.DataFrame(names) | ||
|
||
def tearDown(self): | ||
pass | ||
|
||
def test_in_rolls_fn(self): | ||
odf = lookup_lang(self.df, "name") | ||
print(odf) | ||
self.assertIn("name", odf.columns) | ||
self.assertIn("predicted_lang", odf.columns) | ||
# check predicted_lang matches with pred_lang | ||
self.assertListEqual(odf["predicted_lang"].tolist(), self.pred_lang) |
Oops, something went wrong.