Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<utility assemblyPath="LexEdDll.dll" class="SIL.FieldWorks.XWorks.LexEd.HomographResetter"/>
<utility assemblyPath="MorphologyEditorDll.dll" class="SIL.FieldWorks.XWorks.MorphologyEditor.ParserAnalysisRemover"/>
<utility assemblyPath="MorphologyEditorDll.dll" class="SIL.FieldWorks.XWorks.MorphologyEditor.ParserAnnotationRemover"/>
<utility assemblyPath="MorphologyEditorDll.dll" class="SIL.FieldWorks.XWorks.MorphologyEditor.UserAnalysisRemover"/>
<utility assemblyPath="FixFwDataDll.dll" class="SIL.FieldWorks.FixData.ErrorFixer"/>
<utility assemblyPath="FixFwDataDll.dll" class="SIL.FieldWorks.FixData.WriteAllObjectsUtility"/>
<utility assemblyPath="ITextDll.dll" class="SIL.FieldWorks.IText.DuplicateWordformFixer"/>
Expand Down
6 changes: 6 additions & 0 deletions DistFiles/Language Explorer/Configuration/strings-en.xml
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,12 @@
<string id="WhatDescription" txt="This utility removes all parser annotations from the system. Parser annotations used to be added by the parser when there was a problem parsing a word. "/>
<string id="RedoDescription" txt="You cannot use 'Undo' to cancel the effect of this utility."/>
</group>
<group id="RemoveUserAnalyses">
<string id="Label" txt="Remove User-approved analyses"/>
<string id="WhenDescription" txt="Run this utility when you want to remove all user-approved analyses. This is useful if the parser changes how it analyses wordforms."/>
<string id="WhatDescription" txt="This utility removes all user approved analyses from the system. It does not remove analyses that are approved/disapproved of by the parser, however. "/>
<string id="RedoDescription" txt="You cannot use 'Undo' to cancel the effect of this utility. Therefore, you should back up your project before running this."/>
</group>
<group id="NaturalClassChooser">
<string id="kstidChooseNaturalClass" txt="Choose Natural Class"/>
<string id="kstidNaturalClassListing" txt="The following natural classes have been specified in the grammar area."/>
Expand Down
9 changes: 9 additions & 0 deletions Src/LexText/Interlinear/InterlinMaster.cs
Original file line number Diff line number Diff line change
Expand Up @@ -883,6 +883,15 @@ protected override void OnValidating(System.ComponentModel.CancelEventArgs e)
SaveWorkInProgress();
}

public void OnRefreshInterlin(object argument)
{
// Reset data.
RootStText = null;
m_idcAnalyze.ResetAnalysisCache();
// Refresh the display.
Clerk.JumpToIndex(Clerk.CurrentIndex);
}

protected override void ShowRecord()
{
SaveWorkInProgress();
Expand Down
1 change: 1 addition & 0 deletions Src/LexText/Morphology/MorphologyEditorDll.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,7 @@
<SubType>UserControl</SubType>
</Compile>
<Compile Include="RuleFormulaVcBase.cs" />
<Compile Include="UserAnalysisRemover.cs" />
<Compile Include="WordformGoDlg.cs">
<SubType>Form</SubType>
</Compile>
Expand Down
133 changes: 133 additions & 0 deletions Src/LexText/Morphology/UserAnalysisRemover.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SIL.FieldWorks.Common.FwUtils;
using SIL.FieldWorks.FwCoreDlgs;
using SIL.LCModel.Infrastructure;
using SIL.LCModel;

namespace SIL.FieldWorks.XWorks.MorphologyEditor
{
/// <summary>
/// This class serves to remove all analyses that are only approved by the user.
/// Analyses that have a parser evaluation (approved or disapproved) remain afterwards.
/// </summary>
public class UserAnalysisRemover : IUtility
{
#region Data members

private UtilityDlg m_dlg;
const string kPath = "/group[@id='Linguistics']/group[@id='Morphology']/group[@id='RemoveUserAnalyses']/";

#endregion Data members

/// <summary>
/// Override method to return the Label property.
/// </summary>
/// <returns></returns>
public override string ToString()
{
return Label;
}

#region IUtility implementation

/// <summary>
/// Get the main label describing the utility.
/// </summary>
public string Label
{
get
{
Debug.Assert(m_dlg != null);
return StringTable.Table.GetStringWithXPath("Label", kPath);
}
}

/// <summary>
/// Set the UtilityDlg.
/// </summary>
/// <remarks>
/// This must be set, before calling any other property or method.
/// </remarks>
public UtilityDlg Dialog
{
set
{
Debug.Assert(value != null);
Debug.Assert(m_dlg == null);

m_dlg = value;
}
}

/// <summary>
/// Load 0 or more items in the list box.
/// </summary>
public void LoadUtilities()
{
Debug.Assert(m_dlg != null);
m_dlg.Utilities.Items.Add(this);

}

/// <summary>
/// Notify the utility that has been selected in the dlg.
/// </summary>
public void OnSelection()
{
Debug.Assert(m_dlg != null);
m_dlg.WhenDescription = StringTable.Table.GetStringWithXPath("WhenDescription", kPath);
m_dlg.WhatDescription = StringTable.Table.GetStringWithXPath("WhatDescription", kPath);
m_dlg.RedoDescription = StringTable.Table.GetStringWithXPath("RedoDescription", kPath);
}

/// <summary>
/// Have the utility do what it does.
/// </summary>
public void Process()
{
Debug.Assert(m_dlg != null);
var cache = m_dlg.PropTable.GetValue<LcmCache>("cache");
IWfiAnalysis[] analyses = cache.ServiceLocator.GetInstance<IWfiAnalysisRepository>().AllInstances().ToArray();
if (analyses.Length == 0)
return;

// Set up progress bar.
m_dlg.ProgressBar.Minimum = 0;
m_dlg.ProgressBar.Maximum = analyses.Length;
m_dlg.ProgressBar.Step = 1;

NonUndoableUnitOfWorkHelper.Do(cache.ActionHandlerAccessor, () =>
{
foreach (IWfiAnalysis analysis in analyses)
{
ICmAgentEvaluation[] humanEvals = analysis.EvaluationsRC.Where(evaluation => evaluation.Human).ToArray();
foreach (ICmAgentEvaluation humanEval in humanEvals)
analysis.EvaluationsRC.Remove(humanEval);

IWfiWordform wordform = analysis.Wordform;
if (analysis.EvaluationsRC.Count == 0)
wordform.AnalysesOC.Remove(analysis);

if (humanEvals.Length > 0)
{
wordform.Checksum = 0;
if (analysis.Cache != null)
analysis.MoveConcAnnotationsToWordform();
}

m_dlg.ProgressBar.PerformStep();
}
});

m_dlg.Mediator.SendMessage("RefreshInterlin", null);

}

#endregion IUtility implementation
}
}
Loading