Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
AligNarr/processAlignment.py
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
40 lines (30 sloc)
1.13 KB
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
import re | |
import sentenceSceneMap | |
scriptProcess = sentenceSceneMap.ScriptSentenceMapExtractor() | |
sentenceSceneMap = scriptProcess.extractSentenceMap() | |
alignmentFile = open('al_wiki_script.txt', 'r') | |
sceneSentenceMap = open('sceneSentenceMap.txt', 'r') | |
summaryScriptAlignment = dict() | |
def addScriptSentenceNum(summarySentenceNum, scriptSentenceNum): | |
if not (summarySentenceNum in summaryScriptAlignment): | |
summaryScriptAlignment[summarySentenceNum] = set() | |
summaryScriptAlignment[summarySentenceNum].add(sentenceSceneMap[scriptSentenceNum]) | |
def processAlignment(): | |
for line in alignmentFile: | |
aligned = re.search('\t([0-9]*)', line) | |
summarySentenceNum = re.search('([0-9]*)/p_', line) | |
scriptSentenceNum = re.search('-([0-9]*)/', line) | |
if aligned and aligned.group(1) != '0': | |
addScriptSentenceNum(int(summarySentenceNum.group(1)), scriptSentenceNum.group(1)) | |
""" | |
alignment = [] | |
count = 0 | |
for key in summaryScriptAlignment: | |
alignment.append([]) | |
for element in summaryScriptAlignment[key]: | |
alignment[count].append(element) | |
count += 1 | |
""" | |
#print(summaryScriptAlignment) | |
return summaryScriptAlignment | |
#print(alignment) |