Skip to content

Commit

Permalink
Issue 444 closed
Browse files Browse the repository at this point in the history
  • Loading branch information
drdhaval2785 committed Feb 3, 2016
1 parent 20eac67 commit f5f8f28
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 3 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ v1.1.2 - 7 November 2015 - Code separated into Data, Documentations, scripts, te

v1.2.0 - 12 january 2016 - Merged SanskritSubanta code into SanskritVerb. Now there is only one code 'panini.php' which gives subanta / tiGanta / sandhi etc depending on the input HTML file.

v1.3.0 - 22 January 2016 - Commentaries available for local viewing.

v1.4.0 - 3 February 2016 - Option to deactivate some sUtras of Paninian grammar, to understand its importance in the structure of Astadhyayi.

# For understanding the code

Read [this](https://github.com/drdhaval2785/SanskritVerb/Documentations/blob/master/understandcode.md)
46 changes: 46 additions & 0 deletions comparewithdb.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# This Python file uses the following encoding: utf-8
import sys, re
import codecs
import string
import datetime
from lxml import etree
"""
Dr. Dhaval Patel
26 Jan 2016
Usage:
python comparwithdb.py
"""
# Function to return timestamp
def timestamp():
return datetime.datetime.now()

def triming(lst):
output = []
for member in lst:
member = member.strip()
output.append(member)
return output

def compare(inputfile,outputfile):
fout = codecs.open(outputfile,'w','utf-8')
tree = etree.parse(inputfile)
entries = tree.xpath('/forms/f')
verbdetails = [(member.get('form'),member.getchildren()[-2].tag,member.getchildren()[-1].tag,member.find('root').get('name'),member.find('root').get('num')) for member in entries]
verbforms = [a for (a,b,c,d,e) in verbdetails]
amba = open('Data/verbforms_amba.txt').read()
ambaverbforms = amba.split(',')
ambaverbforms = triming(ambaverbforms)
gerard = open('Data/verbforms_gerard.txt').read()
gerardverbforms = gerard.split(',')
gerardverbforms = triming(gerardverbforms)
baseverbforms = ambaverbforms+gerardverbforms
baseverbforms = list(set(baseverbforms))
print 'Input file has', len(verbforms), 'entries'
print 'Base data has', len(baseverbforms), 'entries'
for (a,b,c,d,e) in verbdetails:
if not a in baseverbforms:
print a,b,c,d,e
fout.write(a+':'+b+':'+c+':'+d+':'+e+'\n')
fout.close()

compare('generatedforms.xml','suspectforms/latest.txt')
2 changes: 2 additions & 0 deletions panini.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@
$pr = $_GET['pratya'];
$inprat = $_GET['pratyahara'];
//$type = 'subanta';
$removed_sutras = explode(',',$_GET['removed_sutras']);
$removed_sutras = array_map('trim',$removed_sutras);
global $storedata;
if (!$verbset && $type==="tiGanta") { $verbset = scrape1($number,8,9,1)[0]; } // for overcoming issue in https://github.com/drdhaval2785/SanskritVerb/issues/97
/* Now trying to make program equally compatible with commandline.
Expand Down
9 changes: 7 additions & 2 deletions scripts/function.php
Original file line number Diff line number Diff line change
Expand Up @@ -3150,14 +3150,19 @@ function Am()
/* function storedata to store necessary information for display later on. */
function storedata($sutra_number,$style,$note)
{
global $text, $storedata, $frontend, $us;
global $text, $storedata, $frontend, $us, $removed_sutras;
$text = one(array("++"),array("+"),0); // To remove double consecutive + signs before storing.
if (!in_array($style,array("pa","hn","st","red"))) { $style="sa"; }
if (!isset($note)) { $note=0; }
if ($frontend!=="0")
if ($frontend!=="0" && !in_array($sutra_number,$removed_sutras))
{
$storedata[]=array($text,$sutra_number,$style,$note,$us);
}
elseif (in_array($sutra_number,$removed_sutras))
{
$prevdata = array_pop($storedata);
$text = $prevdata[0];
}
}
/* displaying from the storedata */
function display_from_storedata()
Expand Down
4 changes: 3 additions & 1 deletion subanta.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@
<div id="step6" class="innerStep"></div>
</div>
<!--... Submit button -->
<input type="submit">
Experimental mode:<br/>
sUtra to be ignored (comma separated): <input type="textarea" name="removed_sutras">
<input type="submit"><br/>
<!--... Sending the step id to subanta.php hidden. -->
<input type="hidden" name="step" id="step" value="0" />
<input type="hidden" name="type" id="subanta" value="subanta" />
Expand Down
2 changes: 2 additions & 0 deletions tiGanta.html
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@
<div id="step5" class="innerStep"></div>
<div id="step6" class="innerStep"></div>
</div>
Experimental mode:<br/>
sUtra to be ignored (comma separated): <input type="textarea" name="removed_sutras"><br/>
<!--... Submit button -->
<input type="submit">
<!--... Sending the step id to tiGanta.php hidden. -->
Expand Down

0 comments on commit f5f8f28

Please sign in to comment.