├── Cog.Presentation ├── Help │ ├── Cog.chm │ └── GettingStartedWithCog.pdf ├── Images │ ├── Cog.ico │ ├── help.png │ ├── pin.png │ ├── up-icon.png │ ├── world.png │ ├── SIL-logo.png │ ├── add-icon.png │ ├── down-icon.png │ ├── edit-icon.png │ ├── menu-icon.png │ ├── openhand.cur │ ├── save-icon.png │ ├── closedhand.cur │ ├── cursor_arrow.png │ ├── delete-icon.png │ ├── import-icon.png │ ├── polygon-icon.png │ └── cog logo hi res.png ├── Views │ ├── FindDialog.xaml.cs │ ├── WordPairView.xaml.cs │ ├── EditAffixDialog.xaml.cs │ ├── SyllabifierView.xaml.cs │ ├── EditRegionDialog.xaml.cs │ ├── EditMeaningDialog.xaml.cs │ ├── EditVarietyDialog.xaml.cs │ ├── TaskAreaIntegerView.xaml.cs │ ├── SelectVarietiesDialog.xaml.cs │ ├── GeographicalRegionView.xaml.cs │ ├── EditUnnaturalClassDialog.xaml.cs │ ├── NewSegmentMappingDialog.xaml.cs │ ├── BlairCognateIdentifierView.xaml.cs │ ├── SimilarSegmentMappingsView.xaml.cs │ ├── PoorMansAffixIdentifierView.xaml.cs │ ├── AddUnnaturalClassSegmentDialog.xaml.cs │ ├── SoundClassesView.xaml.cs │ ├── ThresholdCognateIdentifierView.xaml.cs │ ├── SegmentMappingsView.xaml.cs │ ├── DolgopolskyCognateIdentifierView.xaml.cs │ ├── SegmentMappingsTableSegmentPairView.xaml.cs │ ├── VarietyView.xaml.cs │ ├── EditNaturalClassDialog.xaml.cs │ ├── AboutDialog.xaml.cs │ ├── RunStemmerDialog.xaml.cs │ ├── ExportNetworkGraphDialog.xaml.cs │ ├── ImportTextWordListsDialog.xaml.cs │ ├── NetworkGraphView.xaml.cs │ ├── ExportSimilarityMatrixDialog.xaml.cs │ ├── ExportHierarchicalGraphDialog.xaml.cs │ ├── ExportSegmentFrequenciesDialog.xaml.cs │ ├── ExportGlobalCorrespondencesChartDialog.xaml.cs │ ├── SettingsView.xaml.cs │ ├── MeaningsView.xaml.cs │ ├── ComponentOptionsView.xaml.cs │ ├── TaskAreaCommandGroupView.xaml.cs │ ├── CognateIdentifierOptionsView.xaml.cs │ ├── GlobalCorrespondencesView.xaml.cs │ ├── VarietyPairView.xaml.cs │ ├── AlineView.xaml.cs │ ├── HierarchicalGraphView.xaml.cs │ ├── TaskAreaIntegerView.xaml │ ├── MainWindow.xaml.cs │ └── ProgressDialog.xaml.cs ├── Controls │ ├── Block.xaml.cs │ ├── NetworkGraphLayout.cs │ ├── ContentSizeChangedEventArgs.cs │ ├── MergedHeaderCell.cs │ ├── Block.xaml │ ├── PercentageControl.xaml.cs │ ├── PercentageSlider.xaml.cs │ ├── ScrollingMergedHeaderCellDecorator.cs │ ├── PercentageSlider.xaml │ ├── PercentageControl.xaml │ └── TreeListViewItem.cs ├── Services │ ├── SettingsService.cs │ ├── BusyService.cs │ └── IWindowViewModelMappings.cs ├── Converters │ ├── DebugConverter.cs │ ├── ProgressDialogTitleConverter.cs │ ├── LessThanConverter.cs │ ├── CognateSetNameConverter.cs │ ├── ContentToMarginConverter.cs │ ├── GreaterThanConverter.cs │ ├── StringFormatConverter.cs │ ├── ColorBrightnessConverter.cs │ ├── DoubleToLog10Converter.cs │ ├── SwitchCase.cs │ ├── EqualityConverter.cs │ ├── InvertedBooleanToVisibilityConverter.cs │ ├── EnumMatchToVisibilityConverter.cs │ ├── IndexToColorConverter.cs │ ├── PercentageToStrokeThicknessConverter.cs │ ├── PercentageToWidthConverter.cs │ ├── PercentageToSpectrumColorConverter.cs │ ├── EnumMatchToBooleanConverter.cs │ ├── LevelToIndentConverter.cs │ ├── BackgroundToForegroundConverter.cs │ ├── EnumToFriendlyNameConverter.cs │ ├── FirstGroupRowConverter.cs │ ├── PercentageToGradientColorConverter.cs │ ├── IsTextTrimmedConverter.cs │ ├── MultipleWordAlignmentHighlightSegmentConverter.cs │ ├── WordsToInlinesConverter.cs │ └── ContentToPathConverter.cs ├── Properties │ ├── Settings.settings │ └── AssemblyInfo.cs ├── App.xaml.cs └── Behaviors │ ├── MergedHeader.cs │ └── TextBlockBehaviors.cs ├── Installer └── Bootstrapper │ ├── Cog.ico │ └── logo.png ├── Cog.Domain ├── IProcessor.cs ├── Components │ ├── RegularSoundCorrespondenceThresholdTable.bin │ ├── ProgressEventArgs.cs │ ├── VarietyPairGenerator.cs │ ├── reg-corr-threshold │ │ └── compress.ps1 │ ├── VarietySegmenter.cs │ ├── SonorityClass.cs │ ├── AffixStripper.cs │ ├── AlineSettings.cs │ ├── ThresholdCognateIdentifier.cs │ ├── PrecisionRecallCalculator.cs │ ├── UnionSegmentMappings.cs │ ├── MultipleWordAlignerResult.cs │ ├── PairwiseWordAlignerResult.cs │ ├── ThresholdSegmentMappings.cs │ └── WordPairAlignerSettings.cs ├── ICognateIdentifier.cs ├── Config │ ├── IConfigMigration.cs │ ├── IComponentConfig.cs │ ├── ConfigException.cs │ ├── Migrations │ │ ├── ConfigMigrationExtensions.cs │ │ └── ConfigMigration1_2.cs │ └── Components │ │ ├── ThresholdCognateIdentifierConfig.cs │ │ ├── UnionSegmentMappingsConfig.cs │ │ ├── SimpleSyllabifierConfig.cs │ │ ├── PoorMansAffixIdentifierConfig.cs │ │ ├── TypeSegmentMappingsConfig.cs │ │ ├── ThresholdSegmentMappingsConfig.cs │ │ ├── SimpleWordPairGeneratorConfig.cs │ │ ├── DolgopolskyCognateIdentifierConfig.cs │ │ └── EMSoundChangeInducerConfig.cs ├── Platform.cs ├── ISegmentMappings.cs ├── IWordAlignerResult.cs ├── app.config ├── SoundClass.cs ├── IWordAligner.cs ├── packages.config ├── SymbolCollection.cs ├── GeographicRegion.cs ├── Meaning.cs ├── SoundCorrespondenceCollection.cs ├── NaturalClass.cs ├── Properties │ └── AssemblyInfo.cs ├── Symbol.cs ├── SoundCorrespondence.cs ├── GeographicCoordinate.cs ├── VarietyCollection.cs ├── MeaningCollection.cs ├── Affix.cs ├── CognacyDecision.cs ├── WordPairCollection.cs ├── SegmentPool.cs └── VarietyPairCollection.cs ├── debian ├── changelog ├── control └── copyright ├── Cog.Application ├── Import │ ├── IImporter.cs │ ├── IWordListsImporter.cs │ ├── IGeographicRegionsImporter.cs │ ├── ISegmentMappingsImporter.cs │ ├── ImportException.cs │ └── TextSegmentMappingsImporter.cs ├── Services │ ├── ISettingsService.cs │ ├── IBusyService.cs │ ├── IProjectMigration.cs │ ├── IAnalysisService.cs │ ├── IImportService.cs │ ├── IExportService.cs │ ├── IProjectService.cs │ ├── ProjectMigrations │ │ ├── ProjectMigrationExtensions.cs │ │ ├── ProjectMigration5.cs │ │ └── ProjectMigration3.cs │ ├── IImageExportService.cs │ ├── IGraphService.cs │ └── FileType.cs ├── Export │ ├── ICognateSetsExporter.cs │ ├── IWordListsExporter.cs │ ├── IVarietyPairExporter.cs │ ├── ISimilarityMatrixExporter.cs │ └── ISegmentFrequenciesExporter.cs ├── ViewModels │ ├── SoundType.cs │ ├── SimilarityMetric.cs │ ├── GlobalCorrespondencesGraphVertex.cs │ ├── SyllablePosition.cs │ ├── InputViewModel.cs │ ├── NetworkGraphVertex.cs │ ├── TaskAreaBooleanViewModel.cs │ ├── TaskAreaIntegerViewModel.cs │ ├── ExportSimilarityMatrixViewModel.cs │ ├── ExportSegmentFrequenciesViewModel.cs │ ├── HookFindMessage.cs │ ├── AnalyzeViewModel.cs │ ├── CompareViewModel.cs │ ├── SelectableVarietyViewModel.cs │ ├── DomainModelChangedMessage.cs │ ├── TaskAreaCommandViewModel.cs │ ├── MultipleWordAlignmentVarietyViewModel.cs │ ├── ComparisonPerformedMessage.cs │ ├── PerformingComparisonMessage.cs │ ├── TaskAreaViewModelBase.cs │ ├── InputSettingsViewModel.cs │ ├── CompareSettingsViewModel.cs │ ├── FeatureValueViewModel.cs │ ├── HierarchicalGraphEdge.cs │ ├── TaskAreaItemsViewModel.cs │ ├── VarietyViewModel.cs │ ├── MeaningViewModel.cs │ ├── WorkspaceViewModelBase.cs │ ├── ExportGlobalCorrespondencesChartViewModel.cs │ ├── GlobalSegmentVertex.cs │ ├── GlobalVowelVertex.cs │ ├── GlobalConsonantVertex.cs │ ├── SegmentMappingsTableSegmentViewModel.cs │ ├── RunStemmerViewModel.cs │ ├── RelevantValueViewModel.cs │ ├── SegmentPropertyVertex.cs │ ├── ExportNetworkGraphViewModel.cs │ ├── SegmentCategoryViewModel.cs │ ├── SwitchViewMessage.cs │ ├── NetworkGraphEdge.cs │ ├── ImportTextWordListsViewModel.cs │ ├── ContainerChildViewModelBase.cs │ ├── VowelBacknessVertex.cs │ ├── ExportHierarchicalGraphViewModel.cs │ ├── VowelHeightVertex.cs │ ├── HierarchicalGraphVertex.cs │ ├── ComponentSettingsViewModelBase.cs │ ├── SegmentViewModel.cs │ ├── ConsonantMannerVertex.cs │ ├── TaskAreaCommandGroupViewModel.cs │ ├── SimilarityMatrixVarietyViewModel.cs │ ├── GeographicalVarietyViewModel.cs │ ├── ConsonantPlaceVertex.cs │ ├── WordSegmentViewModel.cs │ ├── SegmentsVarietyViewModel.cs │ ├── SoundChangeViewModel.cs │ ├── FindViewModel.cs │ └── ThresholdCognateIdentifierViewModel.cs ├── ComponentIdentifiers.cs ├── app.config ├── SegmentCategoryComparer.cs ├── Collections │ ├── ReadOnlyBindableList.cs │ └── BindableList.cs ├── Properties │ └── AssemblyInfo.cs └── packages.config ├── Cog.CommandLine ├── ReturnCode.cs ├── MeaningFactory.cs ├── ComponentIdentifiers.cs ├── App.config ├── Program.cs ├── PairsVerb.cs └── Properties │ └── AssemblyInfo.cs ├── .editorconfig ├── Cog.Domain.Tests ├── app.config ├── Properties │ └── AssemblyInfo.cs └── packages.config ├── Cog.TestUtils ├── app.config ├── TestHelpers.cs ├── packages.config └── Properties │ └── AssemblyInfo.cs ├── Cog.Application.Tests ├── app.config ├── Properties │ └── AssemblyInfo.cs └── packages.config ├── Cog.CommandLine.Tests ├── app.config ├── SyllabifyTests.cs ├── PairsTests.cs ├── packages.config └── CognatesTests.cs ├── .gitignore ├── GlobalAssemblyInfo.cs └── LICENSE /Cog.Presentation/Help/Cog.chm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sillsdev/cog/HEAD/Cog.Presentation/Help/Cog.chm -------------------------------------------------------------------------------- /Installer/Bootstrapper/Cog.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sillsdev/cog/HEAD/Installer/Bootstrapper/Cog.ico -------------------------------------------------------------------------------- /Cog.Presentation/Images/Cog.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sillsdev/cog/HEAD/Cog.Presentation/Images/Cog.ico -------------------------------------------------------------------------------- /Cog.Presentation/Images/help.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sillsdev/cog/HEAD/Cog.Presentation/Images/help.png -------------------------------------------------------------------------------- /Cog.Presentation/Images/pin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sillsdev/cog/HEAD/Cog.Presentation/Images/pin.png -------------------------------------------------------------------------------- /Installer/Bootstrapper/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sillsdev/cog/HEAD/Installer/Bootstrapper/logo.png -------------------------------------------------------------------------------- /Cog.Presentation/Images/up-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sillsdev/cog/HEAD/Cog.Presentation/Images/up-icon.png -------------------------------------------------------------------------------- /Cog.Presentation/Images/world.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sillsdev/cog/HEAD/Cog.Presentation/Images/world.png -------------------------------------------------------------------------------- /Cog.Presentation/Images/SIL-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sillsdev/cog/HEAD/Cog.Presentation/Images/SIL-logo.png -------------------------------------------------------------------------------- /Cog.Presentation/Images/add-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sillsdev/cog/HEAD/Cog.Presentation/Images/add-icon.png -------------------------------------------------------------------------------- /Cog.Presentation/Images/down-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sillsdev/cog/HEAD/Cog.Presentation/Images/down-icon.png -------------------------------------------------------------------------------- /Cog.Presentation/Images/edit-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sillsdev/cog/HEAD/Cog.Presentation/Images/edit-icon.png -------------------------------------------------------------------------------- /Cog.Presentation/Images/menu-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sillsdev/cog/HEAD/Cog.Presentation/Images/menu-icon.png -------------------------------------------------------------------------------- /Cog.Presentation/Images/openhand.cur: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sillsdev/cog/HEAD/Cog.Presentation/Images/openhand.cur -------------------------------------------------------------------------------- /Cog.Presentation/Images/save-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sillsdev/cog/HEAD/Cog.Presentation/Images/save-icon.png -------------------------------------------------------------------------------- /Cog.Presentation/Images/closedhand.cur: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sillsdev/cog/HEAD/Cog.Presentation/Images/closedhand.cur -------------------------------------------------------------------------------- /Cog.Presentation/Images/cursor_arrow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sillsdev/cog/HEAD/Cog.Presentation/Images/cursor_arrow.png -------------------------------------------------------------------------------- /Cog.Presentation/Images/delete-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sillsdev/cog/HEAD/Cog.Presentation/Images/delete-icon.png -------------------------------------------------------------------------------- /Cog.Presentation/Images/import-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sillsdev/cog/HEAD/Cog.Presentation/Images/import-icon.png -------------------------------------------------------------------------------- /Cog.Presentation/Images/polygon-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sillsdev/cog/HEAD/Cog.Presentation/Images/polygon-icon.png -------------------------------------------------------------------------------- /Cog.Presentation/Images/cog logo hi res.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sillsdev/cog/HEAD/Cog.Presentation/Images/cog logo hi res.png -------------------------------------------------------------------------------- /Cog.Presentation/Help/GettingStartedWithCog.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sillsdev/cog/HEAD/Cog.Presentation/Help/GettingStartedWithCog.pdf -------------------------------------------------------------------------------- /Cog.Domain/IProcessor.cs: -------------------------------------------------------------------------------- 1 | namespace SIL.Cog.Domain 2 | { 3 | public interface IProcessor 4 | { 5 | void Process(T data); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /debian/changelog: -------------------------------------------------------------------------------- 1 | cog-cmdline (1.1.0-0) unstable; urgency=low 2 | 3 | * Initial release 4 | 5 | -- Robin Munn Wed, 16 Sep 2015 14:20:36 +0700 6 | -------------------------------------------------------------------------------- /Cog.Application/Import/IImporter.cs: -------------------------------------------------------------------------------- 1 | namespace SIL.Cog.Application.Import 2 | { 3 | public interface IImporter 4 | { 5 | object CreateImportSettingsViewModel(); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /Cog.Domain/Components/RegularSoundCorrespondenceThresholdTable.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sillsdev/cog/HEAD/Cog.Domain/Components/RegularSoundCorrespondenceThresholdTable.bin -------------------------------------------------------------------------------- /Cog.Application/Services/ISettingsService.cs: -------------------------------------------------------------------------------- 1 | namespace SIL.Cog.Application.Services 2 | { 3 | public interface ISettingsService 4 | { 5 | string LastProject { get; set; } 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /Cog.CommandLine/ReturnCode.cs: -------------------------------------------------------------------------------- 1 | namespace SIL.Cog.CommandLine 2 | { 3 | public enum ReturnCode 4 | { 5 | Okay = 0, 6 | InputError = 1, 7 | NotImplemented = 2, 8 | UnknownVerb = 3 9 | } 10 | } -------------------------------------------------------------------------------- /Cog.Domain/ICognateIdentifier.cs: -------------------------------------------------------------------------------- 1 | namespace SIL.Cog.Domain 2 | { 3 | public interface ICognateIdentifier 4 | { 5 | void UpdatePredictedCognacy(WordPair wordPair, IWordAlignerResult alignerResult); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /Cog.Domain/Config/IConfigMigration.cs: -------------------------------------------------------------------------------- 1 | using System.Xml.Linq; 2 | 3 | namespace SIL.Cog.Domain.Config 4 | { 5 | internal interface IConfigMigration 6 | { 7 | XNamespace FromNamespace { get; } 8 | void Migrate(XDocument doc); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Cog.Application/Export/ICognateSetsExporter.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | using SIL.Cog.Domain; 3 | 4 | namespace SIL.Cog.Application.Export 5 | { 6 | public interface ICognateSetsExporter 7 | { 8 | void Export(Stream stream, CogProject project); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Cog.Application/Export/IWordListsExporter.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | using SIL.Cog.Domain; 3 | 4 | namespace SIL.Cog.Application.Export 5 | { 6 | public interface IWordListsExporter 7 | { 8 | void Export(Stream stream, CogProject project); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Cog.Application/Services/IBusyService.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace SIL.Cog.Application.Services 4 | { 5 | public interface IBusyService 6 | { 7 | void ShowBusyIndicatorUntilFinishDrawing(); 8 | void ShowBusyIndicator(Action action); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*.cs] 4 | indent_style = tab 5 | indent_size = 4 6 | 7 | [*.xaml] 8 | indent_style = space 9 | indent_size = 4 10 | 11 | [*.xsd] 12 | indent_style = tab 13 | indent_size = 4 14 | 15 | [*.wxs] 16 | indent_style = tab 17 | indent_size = 2 -------------------------------------------------------------------------------- /Cog.Application/ViewModels/SoundType.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel; 2 | 3 | namespace SIL.Cog.Application.ViewModels 4 | { 5 | public enum SoundType 6 | { 7 | [Description("Consonant")] 8 | Consonant, 9 | [Description("Vowel")] 10 | Vowel 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Cog.Application/Services/IProjectMigration.cs: -------------------------------------------------------------------------------- 1 | using SIL.Cog.Domain; 2 | 3 | namespace SIL.Cog.Application.Services 4 | { 5 | internal interface IProjectMigration 6 | { 7 | int Version { get; } 8 | void Migrate(SegmentPool segmentPool, CogProject project); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Cog.Application/ViewModels/SimilarityMetric.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel; 2 | 3 | namespace SIL.Cog.Application.ViewModels 4 | { 5 | public enum SimilarityMetric 6 | { 7 | [Description("Lexical")] 8 | Lexical, 9 | [Description("Phonetic")] 10 | Phonetic 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Cog.Application/Export/IVarietyPairExporter.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | using SIL.Cog.Domain; 3 | 4 | namespace SIL.Cog.Application.Export 5 | { 6 | public interface IVarietyPairExporter 7 | { 8 | void Export(Stream stream, IWordAligner aligner, VarietyPair varietyPair); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Cog.Application/ViewModels/GlobalCorrespondencesGraphVertex.cs: -------------------------------------------------------------------------------- 1 | namespace SIL.Cog.Application.ViewModels 2 | { 3 | public abstract class GlobalCorrespondencesGraphVertex 4 | { 5 | public abstract string StrRep { get; } 6 | 7 | public abstract bool IsProperty { get; } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /Cog.Application/Import/IWordListsImporter.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | using SIL.Cog.Domain; 3 | 4 | namespace SIL.Cog.Application.Import 5 | { 6 | public interface IWordListsImporter : IImporter 7 | { 8 | void Import(object importSettingsViewModel, Stream stream, CogProject project); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Cog.Presentation/Views/FindDialog.xaml.cs: -------------------------------------------------------------------------------- 1 | namespace SIL.Cog.Presentation.Views 2 | { 3 | /// 4 | /// Interaction logic for FindDialog.xaml 5 | /// 6 | public partial class FindDialog 7 | { 8 | public FindDialog() 9 | { 10 | InitializeComponent(); 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Cog.Presentation/Views/WordPairView.xaml.cs: -------------------------------------------------------------------------------- 1 | namespace SIL.Cog.Presentation.Views 2 | { 3 | /// 4 | /// Interaction logic for WordPairView.xaml 5 | /// 6 | public partial class WordPairView 7 | { 8 | public WordPairView() 9 | { 10 | InitializeComponent(); 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Cog.Application/Import/IGeographicRegionsImporter.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | using SIL.Cog.Domain; 3 | 4 | namespace SIL.Cog.Application.Import 5 | { 6 | public interface IGeographicRegionsImporter : IImporter 7 | { 8 | void Import(object importSettingsViewModel, Stream stream, CogProject project); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Cog.Application/ViewModels/SyllablePosition.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel; 2 | 3 | namespace SIL.Cog.Application.ViewModels 4 | { 5 | public enum SyllablePosition 6 | { 7 | [Description("Onset")] 8 | Onset, 9 | [Description("Nucleus")] 10 | Nucleus, 11 | [Description("Coda")] 12 | Coda 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Cog.Domain/Platform.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace SIL.Cog.Domain 4 | { 5 | public static class Platform 6 | { 7 | static Platform() 8 | { 9 | IsMono = Type.GetType("Mono.Runtime") != null; 10 | } 11 | 12 | public static bool IsMono { get; } 13 | public static bool IsDotNet => !IsMono; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Cog.Presentation/Views/EditAffixDialog.xaml.cs: -------------------------------------------------------------------------------- 1 | namespace SIL.Cog.Presentation.Views 2 | { 3 | /// 4 | /// Interaction logic for EditAffixDialog.xaml 5 | /// 6 | public partial class EditAffixDialog 7 | { 8 | public EditAffixDialog() 9 | { 10 | InitializeComponent(); 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Cog.Presentation/Views/SyllabifierView.xaml.cs: -------------------------------------------------------------------------------- 1 | namespace SIL.Cog.Presentation.Views 2 | { 3 | /// 4 | /// Interaction logic for SyllabifierView.xaml 5 | /// 6 | public partial class SyllabifierView 7 | { 8 | public SyllabifierView() 9 | { 10 | InitializeComponent(); 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Cog.Domain/Config/IComponentConfig.cs: -------------------------------------------------------------------------------- 1 | using System.Xml.Linq; 2 | using SIL.Machine.Annotations; 3 | 4 | namespace SIL.Cog.Domain.Config 5 | { 6 | public interface IComponentConfig 7 | { 8 | T Load(SegmentPool segmentPool, CogProject project, XElement elem); 9 | void Save(T component, XElement elem); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Cog.Presentation/Views/EditRegionDialog.xaml.cs: -------------------------------------------------------------------------------- 1 | namespace SIL.Cog.Presentation.Views 2 | { 3 | /// 4 | /// Interaction logic for EditRegionDialog.xaml 5 | /// 6 | public partial class EditRegionDialog 7 | { 8 | public EditRegionDialog() 9 | { 10 | InitializeComponent(); 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Cog.Presentation/Controls/Block.xaml.cs: -------------------------------------------------------------------------------- 1 | namespace SIL.Cog.Presentation.Controls 2 | { 3 | /// 4 | /// Interaction logic for Block.xaml 5 | /// 6 | public partial class Block 7 | { 8 | public Block() 9 | { 10 | InitializeComponent(); 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Cog.Presentation/Views/EditMeaningDialog.xaml.cs: -------------------------------------------------------------------------------- 1 | namespace SIL.Cog.Presentation.Views 2 | { 3 | /// 4 | /// Interaction logic for EditMeaningDialog.xaml 5 | /// 6 | public partial class EditMeaningDialog 7 | { 8 | public EditMeaningDialog() 9 | { 10 | InitializeComponent(); 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Cog.Presentation/Views/EditVarietyDialog.xaml.cs: -------------------------------------------------------------------------------- 1 | namespace SIL.Cog.Presentation.Views 2 | { 3 | /// 4 | /// Interaction logic for EditVarietyDialog.xaml 5 | /// 6 | public partial class EditVarietyDialog 7 | { 8 | public EditVarietyDialog() 9 | { 10 | InitializeComponent(); 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Cog.Presentation/Controls/NetworkGraphLayout.cs: -------------------------------------------------------------------------------- 1 | using QuickGraph; 2 | using SIL.Cog.Application.ViewModels; 3 | 4 | namespace SIL.Cog.Presentation.Controls 5 | { 6 | public class NetworkGraphLayout : WeightedGraphLayout> 7 | { 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /Cog.Presentation/Views/TaskAreaIntegerView.xaml.cs: -------------------------------------------------------------------------------- 1 | namespace SIL.Cog.Presentation.Views 2 | { 3 | /// 4 | /// Interaction logic for TaskAreaIntegerView.xaml 5 | /// 6 | public partial class TaskAreaIntegerView 7 | { 8 | public TaskAreaIntegerView() 9 | { 10 | InitializeComponent(); 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Cog.Application/Export/ISimilarityMatrixExporter.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | using SIL.Cog.Application.ViewModels; 3 | using SIL.Cog.Domain; 4 | 5 | namespace SIL.Cog.Application.Export 6 | { 7 | public interface ISimilarityMatrixExporter 8 | { 9 | void Export(Stream stream, CogProject project, SimilarityMetric similarityMetric); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Cog.CommandLine/MeaningFactory.cs: -------------------------------------------------------------------------------- 1 | using SIL.Cog.Domain; 2 | 3 | namespace SIL.Cog.CommandLine 4 | { 5 | public class MeaningFactory 6 | { 7 | private static int _counter; 8 | 9 | public static Meaning Create() 10 | { 11 | _counter++; 12 | return new Meaning($"Meaning {_counter}", $"Category {_counter}"); 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Cog.Presentation/Views/SelectVarietiesDialog.xaml.cs: -------------------------------------------------------------------------------- 1 | namespace SIL.Cog.Presentation.Views 2 | { 3 | /// 4 | /// Interaction logic for SelectVarietiesDialog.xaml 5 | /// 6 | public partial class SelectVarietiesDialog 7 | { 8 | public SelectVarietiesDialog() 9 | { 10 | InitializeComponent(); 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Cog.Application/Export/ISegmentFrequenciesExporter.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | using SIL.Cog.Application.ViewModels; 3 | using SIL.Cog.Domain; 4 | 5 | namespace SIL.Cog.Application.Export 6 | { 7 | public interface ISegmentFrequenciesExporter 8 | { 9 | void Export(Stream stream, CogProject project, SyllablePosition syllablePosition); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Cog.Application/Import/ISegmentMappingsImporter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | 5 | namespace SIL.Cog.Application.Import 6 | { 7 | public interface ISegmentMappingsImporter : IImporter 8 | { 9 | IEnumerable> Import(object importSettingsViewModel, Stream stream); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Cog.Domain/ISegmentMappings.cs: -------------------------------------------------------------------------------- 1 | using SIL.Machine.Annotations; 2 | using SIL.Machine.NgramModeling; 3 | 4 | namespace SIL.Cog.Domain 5 | { 6 | public interface ISegmentMappings 7 | { 8 | bool IsMapped(ShapeNode leftNode1, Ngram target1, ShapeNode rightNode1, ShapeNode leftNode2, Ngram target2, ShapeNode rightNode2); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Cog.Presentation/Views/GeographicalRegionView.xaml.cs: -------------------------------------------------------------------------------- 1 | namespace SIL.Cog.Presentation.Views 2 | { 3 | /// 4 | /// Interaction logic for GeographicalRegionView.xaml 5 | /// 6 | public partial class GeographicalRegionView 7 | { 8 | public GeographicalRegionView() 9 | { 10 | InitializeComponent(); 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Cog.Presentation/Views/EditUnnaturalClassDialog.xaml.cs: -------------------------------------------------------------------------------- 1 | namespace SIL.Cog.Presentation.Views 2 | { 3 | /// 4 | /// Interaction logic for EditUnnaturalClassDialog.xaml 5 | /// 6 | public partial class EditUnnaturalClassDialog 7 | { 8 | public EditUnnaturalClassDialog() 9 | { 10 | InitializeComponent(); 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Cog.Presentation/Views/NewSegmentMappingDialog.xaml.cs: -------------------------------------------------------------------------------- 1 | namespace SIL.Cog.Presentation.Views 2 | { 3 | /// 4 | /// Interaction logic for NewSegmentMappingDialog.xaml 5 | /// 6 | public partial class NewSegmentMappingDialog 7 | { 8 | public NewSegmentMappingDialog() 9 | { 10 | InitializeComponent(); 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Cog.Presentation/Views/BlairCognateIdentifierView.xaml.cs: -------------------------------------------------------------------------------- 1 | namespace SIL.Cog.Presentation.Views 2 | { 3 | /// 4 | /// Interaction logic for BlairCognateIdentifierView.xaml 5 | /// 6 | public partial class BlairCognateIdentifierView 7 | { 8 | public BlairCognateIdentifierView() 9 | { 10 | InitializeComponent(); 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Cog.Presentation/Views/SimilarSegmentMappingsView.xaml.cs: -------------------------------------------------------------------------------- 1 | namespace SIL.Cog.Presentation.Views 2 | { 3 | /// 4 | /// Interaction logic for SimilarSegmentMappingsView.xaml 5 | /// 6 | public partial class SimilarSegmentMappingsView 7 | { 8 | public SimilarSegmentMappingsView() 9 | { 10 | InitializeComponent(); 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Cog.Presentation/Views/PoorMansAffixIdentifierView.xaml.cs: -------------------------------------------------------------------------------- 1 | namespace SIL.Cog.Presentation.Views 2 | { 3 | /// 4 | /// Interaction logic for PoorMansAffixIdentifierView.xaml 5 | /// 6 | public partial class PoorMansAffixIdentifierView 7 | { 8 | public PoorMansAffixIdentifierView() 9 | { 10 | InitializeComponent(); 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Cog.Presentation/Views/AddUnnaturalClassSegmentDialog.xaml.cs: -------------------------------------------------------------------------------- 1 | namespace SIL.Cog.Presentation.Views 2 | { 3 | /// 4 | /// Interaction logic for AddUnnaturalClassSegmentDialog.xaml 5 | /// 6 | public partial class AddUnnaturalClassSegmentDialog 7 | { 8 | public AddUnnaturalClassSegmentDialog() 9 | { 10 | InitializeComponent(); 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Cog.Presentation/Views/SoundClassesView.xaml.cs: -------------------------------------------------------------------------------- 1 | namespace SIL.Cog.Presentation.Views 2 | { 3 | /// 4 | /// Interaction logic for SoundClassesView.xaml 5 | /// 6 | public partial class SoundClassesView 7 | { 8 | public SoundClassesView() 9 | { 10 | InitializeComponent(); 11 | SoundClassesGrid.ClipboardExporters.Clear(); 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Cog.Presentation/Views/ThresholdCognateIdentifierView.xaml.cs: -------------------------------------------------------------------------------- 1 | namespace SIL.Cog.Presentation.Views 2 | { 3 | /// 4 | /// Interaction logic for ThresholdCognateIdentifierView.xaml 5 | /// 6 | public partial class ThresholdCognateIdentifierView 7 | { 8 | public ThresholdCognateIdentifierView() 9 | { 10 | InitializeComponent(); 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Cog.Domain/Config/ConfigException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace SIL.Cog.Domain.Config 4 | { 5 | public class ConfigException : Exception 6 | { 7 | public ConfigException(string message) 8 | : base(message) 9 | { 10 | } 11 | 12 | public ConfigException(string message, Exception innerException) 13 | : base(message, innerException) 14 | { 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Cog.Presentation/Views/SegmentMappingsView.xaml.cs: -------------------------------------------------------------------------------- 1 | namespace SIL.Cog.Presentation.Views 2 | { 3 | /// 4 | /// Interaction logic for SegmentMappingsView.xaml 5 | /// 6 | public partial class SegmentMappingsView 7 | { 8 | public SegmentMappingsView() 9 | { 10 | InitializeComponent(); 11 | MappingsGrid.ClipboardExporters.Clear(); 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Cog.Presentation/Views/DolgopolskyCognateIdentifierView.xaml.cs: -------------------------------------------------------------------------------- 1 | namespace SIL.Cog.Presentation.Views 2 | { 3 | /// 4 | /// Interaction logic for DolgopolskyCognateIdentifierView.xaml 5 | /// 6 | public partial class DolgopolskyCognateIdentifierView 7 | { 8 | public DolgopolskyCognateIdentifierView() 9 | { 10 | InitializeComponent(); 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Cog.Application/Import/ImportException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace SIL.Cog.Application.Import 4 | { 5 | public class ImportException : Exception 6 | { 7 | public ImportException(string message) 8 | : base(message) 9 | { 10 | } 11 | 12 | public ImportException(string message, Exception innerException) 13 | : base(message, innerException) 14 | { 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Cog.Presentation/Views/SegmentMappingsTableSegmentPairView.xaml.cs: -------------------------------------------------------------------------------- 1 | namespace SIL.Cog.Presentation.Views 2 | { 3 | /// 4 | /// Interaction logic for SegmentMappingsTableSegmentPairView.xaml 5 | /// 6 | public partial class SegmentMappingsTableSegmentPairView 7 | { 8 | public SegmentMappingsTableSegmentPairView() 9 | { 10 | InitializeComponent(); 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Cog.Presentation/Services/SettingsService.cs: -------------------------------------------------------------------------------- 1 | using SIL.Cog.Application.Services; 2 | using SIL.Cog.Presentation.Properties; 3 | 4 | namespace SIL.Cog.Presentation.Services 5 | { 6 | public class SettingsService : ISettingsService 7 | { 8 | public string LastProject 9 | { 10 | get { return Settings.Default.LastProject; } 11 | set { Settings.Default.LastProject = value; } 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Cog.Presentation/Views/VarietyView.xaml.cs: -------------------------------------------------------------------------------- 1 | namespace SIL.Cog.Presentation.Views 2 | { 3 | /// 4 | /// Interaction logic for VarietyView.xaml 5 | /// 6 | public partial class VarietyView 7 | { 8 | public VarietyView() 9 | { 10 | InitializeComponent(); 11 | AffixesGrid.ClipboardExporters.Clear(); 12 | SegmentsDataGrid.ClipboardExporters.Clear(); 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Cog.Presentation/Views/EditNaturalClassDialog.xaml.cs: -------------------------------------------------------------------------------- 1 | namespace SIL.Cog.Presentation.Views 2 | { 3 | /// 4 | /// Interaction logic for EditNaturalClassDialog.xaml 5 | /// 6 | public partial class EditNaturalClassDialog 7 | { 8 | public EditNaturalClassDialog() 9 | { 10 | InitializeComponent(); 11 | SelectedFeaturesDataGrid.ClipboardExporters.Clear(); 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Cog.Domain/Components/ProgressEventArgs.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace SIL.Cog.Domain.Components 4 | { 5 | public class ProgressEventArgs : EventArgs 6 | { 7 | private readonly int _percentCompleted; 8 | 9 | public ProgressEventArgs(int percentCompleted) 10 | { 11 | _percentCompleted = percentCompleted; 12 | } 13 | 14 | public int PercentCompleted 15 | { 16 | get { return _percentCompleted; } 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Cog.Application/ComponentIdentifiers.cs: -------------------------------------------------------------------------------- 1 | namespace SIL.Cog.Application 2 | { 3 | public static class ComponentIdentifiers 4 | { 5 | public const string PrimaryCognateIdentifier = "primary"; 6 | public const string PrimaryWordAligner = "primary"; 7 | public const string WordPairGenerator = "wordPairGenerator"; 8 | public const string Syllabifier = "syllabifier"; 9 | public const string AffixIdentifier = "affixIdentifier"; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Cog.CommandLine/ComponentIdentifiers.cs: -------------------------------------------------------------------------------- 1 | namespace SIL.Cog.CommandLine 2 | { 3 | public static class ComponentIdentifiers 4 | { 5 | public const string PrimaryCognateIdentifier = "primary"; 6 | public const string PrimaryWordAligner = "primary"; 7 | public const string WordPairGenerator = "wordPairGenerator"; 8 | public const string Syllabifier = "syllabifier"; 9 | public const string AffixIdentifier = "affixIdentifier"; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Cog.Presentation/Views/AboutDialog.xaml.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | 3 | namespace SIL.Cog.Presentation.Views 4 | { 5 | /// 6 | /// Interaction logic for AboutDialog.xaml 7 | /// 8 | public partial class AboutDialog 9 | { 10 | public AboutDialog() 11 | { 12 | InitializeComponent(); 13 | } 14 | 15 | private void okButton_Click(object sender, RoutedEventArgs e) 16 | { 17 | Close(); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Cog.Application/ViewModels/InputViewModel.cs: -------------------------------------------------------------------------------- 1 | namespace SIL.Cog.Application.ViewModels 2 | { 3 | public class InputViewModel : ContainerViewModelBase 4 | { 5 | public InputViewModel(WordListsViewModel wordLists, VarietiesViewModel varieties, MeaningsViewModel meanings, SegmentsViewModel segments, 6 | InputSettingsViewModel inputSettings) 7 | : base("Input", wordLists, varieties, meanings, segments, inputSettings) 8 | { 9 | } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Cog.Application/ViewModels/NetworkGraphVertex.cs: -------------------------------------------------------------------------------- 1 | using SIL.Cog.Domain; 2 | 3 | namespace SIL.Cog.Application.ViewModels 4 | { 5 | public class NetworkGraphVertex : WrapperViewModel 6 | { 7 | private readonly Variety _variety; 8 | 9 | public NetworkGraphVertex(Variety variety) 10 | : base(variety) 11 | { 12 | _variety = variety; 13 | } 14 | 15 | public string Name 16 | { 17 | get { return _variety.Name; } 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Cog.Application/ViewModels/TaskAreaBooleanViewModel.cs: -------------------------------------------------------------------------------- 1 | namespace SIL.Cog.Application.ViewModels 2 | { 3 | public class TaskAreaBooleanViewModel : TaskAreaViewModelBase 4 | { 5 | private bool _value; 6 | 7 | public TaskAreaBooleanViewModel(string displayName) 8 | : base(displayName) 9 | { 10 | } 11 | 12 | public bool Value 13 | { 14 | get { return _value; } 15 | set { Set(() => Value, ref _value, value); } 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Cog.Application/ViewModels/TaskAreaIntegerViewModel.cs: -------------------------------------------------------------------------------- 1 | namespace SIL.Cog.Application.ViewModels 2 | { 3 | public class TaskAreaIntegerViewModel : TaskAreaViewModelBase 4 | { 5 | private int _value; 6 | 7 | public TaskAreaIntegerViewModel(string displayName) 8 | : base(displayName) 9 | { 10 | } 11 | 12 | public int Value 13 | { 14 | get { return _value; } 15 | set { Set(() => Value, ref _value, value); } 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Cog.Application/ViewModels/ExportSimilarityMatrixViewModel.cs: -------------------------------------------------------------------------------- 1 | using GalaSoft.MvvmLight; 2 | 3 | namespace SIL.Cog.Application.ViewModels 4 | { 5 | public class ExportSimilarityMatrixViewModel : ViewModelBase 6 | { 7 | private SimilarityMetric _similarityMetric; 8 | 9 | public SimilarityMetric SimilarityMetric 10 | { 11 | get { return _similarityMetric; } 12 | set { Set(() => SimilarityMetric, ref _similarityMetric, value); } 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Cog.Domain/IWordAlignerResult.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using SIL.Machine.Annotations; 3 | using SIL.Machine.SequenceAlignment; 4 | using SIL.ObjectModel; 5 | 6 | namespace SIL.Cog.Domain 7 | { 8 | public interface IWordAlignerResult 9 | { 10 | IWordAligner WordAligner { get; } 11 | 12 | ReadOnlyList Words { get; } 13 | 14 | IEnumerable> GetAlignments(); 15 | 16 | int BestRawScore { get; } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Cog.Application/ViewModels/ExportSegmentFrequenciesViewModel.cs: -------------------------------------------------------------------------------- 1 | using GalaSoft.MvvmLight; 2 | 3 | namespace SIL.Cog.Application.ViewModels 4 | { 5 | public class ExportSegmentFrequenciesViewModel : ViewModelBase 6 | { 7 | private SyllablePosition _syllablePosition; 8 | 9 | public SyllablePosition SyllablePosition 10 | { 11 | get { return _syllablePosition; } 12 | set { Set(() => SyllablePosition, ref _syllablePosition, value); } 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Cog.Domain/app.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /Cog.Application/app.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /Cog.Domain.Tests/app.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /Cog.Presentation/Controls/ContentSizeChangedEventArgs.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Windows; 3 | 4 | namespace SIL.Cog.Presentation.Controls 5 | { 6 | public class ContentSizeChangedEventArgs : EventArgs 7 | { 8 | private readonly Size _contentSize; 9 | 10 | public ContentSizeChangedEventArgs(Size contentSize) 11 | { 12 | _contentSize = contentSize; 13 | } 14 | 15 | public Size ContentSize 16 | { 17 | get { return _contentSize; } 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Cog.Presentation/Views/RunStemmerDialog.xaml.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | 3 | namespace SIL.Cog.Presentation.Views 4 | { 5 | /// 6 | /// Interaction logic for RunStemmerDialog.xaml 7 | /// 8 | public partial class RunStemmerDialog 9 | { 10 | public RunStemmerDialog() 11 | { 12 | InitializeComponent(); 13 | } 14 | 15 | private void okButton_Click(object sender, RoutedEventArgs e) 16 | { 17 | DialogResult = true; 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Cog.TestUtils/app.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /Cog.Application.Tests/app.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /Cog.CommandLine.Tests/app.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /Cog.Domain/Components/VarietyPairGenerator.cs: -------------------------------------------------------------------------------- 1 | namespace SIL.Cog.Domain.Components 2 | { 3 | public class VarietyPairGenerator : IProcessor 4 | { 5 | public void Process(CogProject data) 6 | { 7 | data.VarietyPairs.Clear(); 8 | for (int i = 0; i < data.Varieties.Count; i++) 9 | { 10 | for (int j = i + 1; j < data.Varieties.Count; j++) 11 | data.VarietyPairs.Add(new VarietyPair(data.Varieties[i], data.Varieties[j])); 12 | } 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Cog.Application/ViewModels/HookFindMessage.cs: -------------------------------------------------------------------------------- 1 | using System.Windows.Input; 2 | using GalaSoft.MvvmLight.Messaging; 3 | 4 | namespace SIL.Cog.Application.ViewModels 5 | { 6 | public class HookFindMessage : MessageBase 7 | { 8 | private readonly ICommand _findCommand; 9 | 10 | public HookFindMessage(ICommand findCommand) 11 | { 12 | _findCommand = findCommand; 13 | } 14 | 15 | public ICommand FindCommand 16 | { 17 | get { return _findCommand; } 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Cog.Presentation/Controls/MergedHeaderCell.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | using System.Windows.Controls; 3 | using SIL.Cog.Presentation.Behaviors; 4 | 5 | namespace SIL.Cog.Presentation.Controls 6 | { 7 | public class MergedHeaderCell : ContentControl 8 | { 9 | static MergedHeaderCell() 10 | { 11 | FocusableProperty.OverrideMetadata(typeof(MergedHeaderCell), new FrameworkPropertyMetadata(false)); 12 | } 13 | 14 | public MergedHeader MergedHeader { get; set; } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Cog.Application/ViewModels/AnalyzeViewModel.cs: -------------------------------------------------------------------------------- 1 | namespace SIL.Cog.Application.ViewModels 2 | { 3 | public class AnalyzeViewModel : ContainerViewModelBase 4 | { 5 | public AnalyzeViewModel(HierarchicalGraphViewModel hierarchicalGraph, NetworkGraphViewModel networkGraph, GeographicalViewModel geographical, 6 | GlobalCorrespondencesViewModel globalCorrespondences) 7 | : base("Analyze", hierarchicalGraph, networkGraph, geographical, globalCorrespondences) 8 | { 9 | } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Cog.Presentation/Services/BusyService.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using SIL.Cog.Application.Services; 3 | using SIL.Cog.Presentation.Views; 4 | 5 | namespace SIL.Cog.Presentation.Services 6 | { 7 | public class BusyService : IBusyService 8 | { 9 | public void ShowBusyIndicatorUntilFinishDrawing() 10 | { 11 | BusyCursor.DisplayUntilIdle(); 12 | } 13 | 14 | public void ShowBusyIndicator(Action action) 15 | { 16 | using (BusyCursor.Display()) 17 | action(); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Cog.Application/ViewModels/CompareViewModel.cs: -------------------------------------------------------------------------------- 1 | namespace SIL.Cog.Application.ViewModels 2 | { 3 | public class CompareViewModel : ContainerViewModelBase 4 | { 5 | public CompareViewModel(SimilarityMatrixViewModel similarityMatrix, VarietyPairsViewModel varietyPairs, MultipleWordAlignmentViewModel multipleWordAlignment, 6 | CompareSettingsViewModel compareSettings) 7 | : base("Compare", similarityMatrix, varietyPairs, multipleWordAlignment, compareSettings) 8 | { 9 | } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Cog.Domain/SoundClass.cs: -------------------------------------------------------------------------------- 1 | using SIL.Machine.Annotations; 2 | using SIL.Machine.NgramModeling; 3 | 4 | namespace SIL.Cog.Domain 5 | { 6 | public abstract class SoundClass 7 | { 8 | private readonly string _name; 9 | 10 | protected SoundClass(string name) 11 | { 12 | _name = name; 13 | } 14 | 15 | public string Name 16 | { 17 | get { return _name; } 18 | } 19 | 20 | public abstract bool Matches(ShapeNode leftNode, Ngram target, ShapeNode rightNode); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | #ignore thumbnails created by windows 3 | Thumbs.db 4 | #Ignore files build by Visual Studio 5 | *.obj 6 | *.exe 7 | *.pdb 8 | *.user 9 | *.aps 10 | *.pch 11 | *.vspscc 12 | *_i.c 13 | *_p.c 14 | *.ncb 15 | *.suo 16 | *.tlb 17 | *.tlh 18 | *.bak 19 | *.cache 20 | *.ilk 21 | *.log 22 | [Bb]in 23 | [Dd]ebug*/ 24 | *.lib 25 | *.sbr 26 | obj/ 27 | [Rr]elease*/ 28 | _ReSharper*/ 29 | [Tt]est[Rr]esult* 30 | 31 | *.Resharper 32 | *.DotSettings 33 | *- Copy* 34 | packages/* 35 | output/ 36 | .vs 37 | -------------------------------------------------------------------------------- /Cog.Application/ViewModels/SelectableVarietyViewModel.cs: -------------------------------------------------------------------------------- 1 | using SIL.Cog.Domain; 2 | 3 | namespace SIL.Cog.Application.ViewModels 4 | { 5 | public class SelectableVarietyViewModel : VarietyViewModel 6 | { 7 | private bool _isSelected; 8 | 9 | public SelectableVarietyViewModel(Variety variety) 10 | : base(variety) 11 | { 12 | } 13 | 14 | public bool IsSelected 15 | { 16 | get { return _isSelected; } 17 | set { Set(() => IsSelected, ref _isSelected, value); } 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Cog.Application/ViewModels/DomainModelChangedMessage.cs: -------------------------------------------------------------------------------- 1 | using GalaSoft.MvvmLight.Messaging; 2 | 3 | namespace SIL.Cog.Application.ViewModels 4 | { 5 | public class DomainModelChangedMessage : MessageBase 6 | { 7 | private readonly bool _affectsComparison; 8 | 9 | public DomainModelChangedMessage(bool affectsComparison) 10 | { 11 | _affectsComparison = affectsComparison; 12 | } 13 | 14 | public bool AffectsComparison 15 | { 16 | get { return _affectsComparison; } 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Cog.Application/ViewModels/TaskAreaCommandViewModel.cs: -------------------------------------------------------------------------------- 1 | using System.Windows.Input; 2 | 3 | namespace SIL.Cog.Application.ViewModels 4 | { 5 | public class TaskAreaCommandViewModel : TaskAreaViewModelBase 6 | { 7 | private readonly ICommand _command; 8 | 9 | public TaskAreaCommandViewModel(string displayName, ICommand command) 10 | : base(displayName) 11 | { 12 | _command = command; 13 | } 14 | 15 | public ICommand Command 16 | { 17 | get { return _command; } 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Cog.Application/Services/IAnalysisService.cs: -------------------------------------------------------------------------------- 1 | using SIL.Cog.Application.ViewModels; 2 | using SIL.Cog.Domain; 3 | 4 | namespace SIL.Cog.Application.Services 5 | { 6 | public interface IAnalysisService 7 | { 8 | void SegmentAll(); 9 | void Segment(Variety variety); 10 | 11 | void StemAll(object ownerViewModel, StemmingMethod method); 12 | void Stem(StemmingMethod method, Variety variety); 13 | 14 | void CompareAll(object ownerViewModel); 15 | void Compare(VarietyPair varietyPair); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Cog.Domain/Components/reg-corr-threshold/compress.ps1: -------------------------------------------------------------------------------- 1 | param([Parameter(Mandatory=$true)][string]$i, [Parameter(Mandatory=$true)][string]$o) 2 | $inputStream = New-Object System.IO.FileStream($i, [System.IO.FileMode]::Open) 3 | $outputStream = New-Object System.IO.FileStream($o, [System.IO.FileMode]::Create) 4 | $deflateStream = New-Object System.IO.Compression.DeflateStream($outputStream, [System.IO.Compression.CompressionMode]::Compress) 5 | $inputStream.CopyTo($deflateStream) 6 | $deflateStream.Close() 7 | $inputStream.Close() -------------------------------------------------------------------------------- /Cog.Presentation/Services/IWindowViewModelMappings.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace SIL.Cog.Presentation.Services 4 | { 5 | public interface IWindowViewModelMappings 6 | { 7 | /// 8 | /// Gets the window type based on registered ViewModel type. 9 | /// 10 | /// The type of the ViewModel. 11 | /// The window type based on registered ViewModel type. 12 | Type GetWindowTypeFromViewModelType(Type viewModelType); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Cog.Presentation/Views/ExportNetworkGraphDialog.xaml.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | 3 | namespace SIL.Cog.Presentation.Views 4 | { 5 | /// 6 | /// Interaction logic for ExportNetworkGraphDialog.xaml 7 | /// 8 | public partial class ExportNetworkGraphDialog 9 | { 10 | public ExportNetworkGraphDialog() 11 | { 12 | InitializeComponent(); 13 | } 14 | 15 | private void exportButton_Click(object sender, RoutedEventArgs e) 16 | { 17 | DialogResult = true; 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Cog.Presentation/Views/ImportTextWordListsDialog.xaml.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | 3 | namespace SIL.Cog.Presentation.Views 4 | { 5 | /// 6 | /// Interaction logic for ImportTextWordListsDialog.xaml 7 | /// 8 | public partial class ImportTextWordListsDialog 9 | { 10 | public ImportTextWordListsDialog() 11 | { 12 | InitializeComponent(); 13 | } 14 | 15 | private void importButton_Click(object sender, RoutedEventArgs e) 16 | { 17 | DialogResult = true; 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Cog.TestUtils/TestHelpers.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | using System.Reflection; 3 | using SIL.Cog.Domain; 4 | using SIL.Cog.Domain.Config; 5 | 6 | namespace SIL.Cog.TestUtils 7 | { 8 | public static class TestHelpers 9 | { 10 | public static CogProject GetTestProject(SegmentPool segmentPool) 11 | { 12 | using (Stream stream = Assembly.GetAssembly(typeof(TestHelpers)).GetManifestResourceStream("SIL.Cog.TestUtils.TestProject.cogx")) 13 | return ConfigManager.Load(segmentPool, stream); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Cog.Presentation/Views/NetworkGraphView.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace SIL.Cog.Presentation.Views 4 | { 5 | /// 6 | /// Interaction logic for NetworkGraphView.xaml 7 | /// 8 | public partial class NetworkGraphView 9 | { 10 | public NetworkGraphView() 11 | { 12 | InitializeComponent(); 13 | BusyCursor.DisplayUntilIdle(); 14 | } 15 | 16 | private void GraphLayout_OnLayoutFinished(object sender, EventArgs e) 17 | { 18 | ZoomControl.ZoomToFill(); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Cog.Application/ViewModels/MultipleWordAlignmentVarietyViewModel.cs: -------------------------------------------------------------------------------- 1 | using SIL.Cog.Domain; 2 | 3 | namespace SIL.Cog.Application.ViewModels 4 | { 5 | public class MultipleWordAlignmentVarietyViewModel : VarietyViewModel 6 | { 7 | private readonly int _wordIndex; 8 | 9 | public MultipleWordAlignmentVarietyViewModel(Variety variety, int wordIndex) 10 | : base(variety) 11 | { 12 | _wordIndex = wordIndex; 13 | } 14 | 15 | public int WordIndex 16 | { 17 | get { return _wordIndex; } 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Cog.Presentation/Views/ExportSimilarityMatrixDialog.xaml.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | 3 | namespace SIL.Cog.Presentation.Views 4 | { 5 | /// 6 | /// Interaction logic for ExportSimilarityMatrixDialog.xaml 7 | /// 8 | public partial class ExportSimilarityMatrixDialog 9 | { 10 | public ExportSimilarityMatrixDialog() 11 | { 12 | InitializeComponent(); 13 | } 14 | 15 | private void exportButton_Click(object sender, RoutedEventArgs e) 16 | { 17 | DialogResult = true; 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Cog.Application/ViewModels/ComparisonPerformedMessage.cs: -------------------------------------------------------------------------------- 1 | using GalaSoft.MvvmLight.Messaging; 2 | using SIL.Cog.Domain; 3 | 4 | namespace SIL.Cog.Application.ViewModels 5 | { 6 | public class ComparisonPerformedMessage : MessageBase 7 | { 8 | private readonly VarietyPair _varietyPair; 9 | 10 | public ComparisonPerformedMessage(VarietyPair varietyPair = null) 11 | { 12 | _varietyPair = varietyPair; 13 | } 14 | 15 | public VarietyPair VarietyPair 16 | { 17 | get { return _varietyPair; } 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Cog.Application/ViewModels/PerformingComparisonMessage.cs: -------------------------------------------------------------------------------- 1 | using GalaSoft.MvvmLight.Messaging; 2 | using SIL.Cog.Domain; 3 | 4 | namespace SIL.Cog.Application.ViewModels 5 | { 6 | public class PerformingComparisonMessage : MessageBase 7 | { 8 | private readonly VarietyPair _varietyPair; 9 | 10 | public PerformingComparisonMessage(VarietyPair varietyPair = null) 11 | { 12 | _varietyPair = varietyPair; 13 | } 14 | 15 | public VarietyPair VarietyPair 16 | { 17 | get { return _varietyPair; } 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Cog.Domain/Config/Migrations/ConfigMigrationExtensions.cs: -------------------------------------------------------------------------------- 1 | using System.Xml.Linq; 2 | 3 | namespace SIL.Cog.Domain.Config.Migrations 4 | { 5 | internal static class ConfigMigrationExtensions 6 | { 7 | public static void SetDefaultNamespace(this XElement elem, XNamespace ns) 8 | { 9 | elem.Name = ns + elem.Name.LocalName; 10 | if (elem.Attribute("xmlns") != null) 11 | elem.SetAttributeValue("xmlns", ns); 12 | foreach (XElement child in elem.Elements()) 13 | child.SetDefaultNamespace(ns); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Cog.Presentation/Views/ExportHierarchicalGraphDialog.xaml.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | 3 | namespace SIL.Cog.Presentation.Views 4 | { 5 | /// 6 | /// Interaction logic for ExportHierarchicalGraphDialog.xaml 7 | /// 8 | public partial class ExportHierarchicalGraphDialog 9 | { 10 | public ExportHierarchicalGraphDialog() 11 | { 12 | InitializeComponent(); 13 | } 14 | 15 | private void exportButton_Click(object sender, RoutedEventArgs e) 16 | { 17 | DialogResult = true; 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Cog.Application/Services/IImportService.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace SIL.Cog.Application.Services 5 | { 6 | public interface IImportService 7 | { 8 | bool ImportWordListsFromFile(object ownerViewModel); 9 | bool CanImportWordListsFromClipboard(); 10 | bool ImportWordListsFromClipboard(object ownerViewModel); 11 | bool ImportSegmentMappings(object ownerViewModel, out IEnumerable> mappings); 12 | bool ImportGeographicRegions(object ownerViewModel); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Cog.Application/ViewModels/TaskAreaViewModelBase.cs: -------------------------------------------------------------------------------- 1 | using GalaSoft.MvvmLight; 2 | 3 | namespace SIL.Cog.Application.ViewModels 4 | { 5 | public abstract class TaskAreaViewModelBase : ViewModelBase 6 | { 7 | private readonly string _displayName; 8 | 9 | protected TaskAreaViewModelBase() 10 | { 11 | } 12 | 13 | protected TaskAreaViewModelBase(string displayName) 14 | { 15 | _displayName = displayName; 16 | } 17 | 18 | public string DisplayName 19 | { 20 | get { return _displayName; } 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Cog.Domain/Components/VarietySegmenter.cs: -------------------------------------------------------------------------------- 1 | namespace SIL.Cog.Domain.Components 2 | { 3 | public class VarietySegmenter : IProcessor 4 | { 5 | private readonly Segmenter _segmenter; 6 | 7 | public VarietySegmenter(Segmenter segmenter) 8 | { 9 | _segmenter = segmenter; 10 | } 11 | 12 | public void Process(Variety data) 13 | { 14 | foreach (Word word in data.Words) 15 | _segmenter.Segment(word); 16 | 17 | foreach (Affix affix in data.Affixes) 18 | _segmenter.Segment(affix); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Cog.Domain/IWordAligner.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using SIL.Machine.FeatureModel; 3 | 4 | namespace SIL.Cog.Domain 5 | { 6 | public interface IWordAligner 7 | { 8 | IEnumerable ContextualSoundClasses { get; } 9 | bool ExpansionCompressionEnabled { get; } 10 | 11 | IWordAlignerResult Compute(Word word1, Word word2); 12 | IWordAlignerResult Compute(WordPair wordPair); 13 | IWordAlignerResult Compute(IEnumerable words); 14 | 15 | int Delta(FeatureStruct fs1, FeatureStruct fs2); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Cog.Presentation/Views/ExportSegmentFrequenciesDialog.xaml.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | 3 | namespace SIL.Cog.Presentation.Views 4 | { 5 | /// 6 | /// Interaction logic for ExportSegmentFrequenciesDialog.xaml 7 | /// 8 | public partial class ExportSegmentFrequenciesDialog 9 | { 10 | public ExportSegmentFrequenciesDialog() 11 | { 12 | InitializeComponent(); 13 | } 14 | 15 | private void exportButton_Click(object sender, RoutedEventArgs e) 16 | { 17 | DialogResult = true; 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Cog.Domain/Components/SonorityClass.cs: -------------------------------------------------------------------------------- 1 | namespace SIL.Cog.Domain.Components 2 | { 3 | public class SonorityClass 4 | { 5 | private readonly int _sonority; 6 | private readonly SoundClass _soundClass; 7 | 8 | public SonorityClass(int sonority, SoundClass soundClass) 9 | { 10 | _sonority = sonority; 11 | _soundClass = soundClass; 12 | } 13 | 14 | public int Sonority 15 | { 16 | get { return _sonority; } 17 | } 18 | 19 | public SoundClass SoundClass 20 | { 21 | get { return _soundClass; } 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Cog.Application/ViewModels/InputSettingsViewModel.cs: -------------------------------------------------------------------------------- 1 | using SIL.Cog.Application.Services; 2 | 3 | namespace SIL.Cog.Application.ViewModels 4 | { 5 | public class InputSettingsViewModel : SettingsWorkspaceViewModelBase 6 | { 7 | public InputSettingsViewModel(IProjectService projectService, IBusyService busyService, SyllabifierViewModel syllabifierViewModel, 8 | PoorMansAffixIdentifierViewModel affixIdentifierViewModel) 9 | : base("Input", projectService, busyService, syllabifierViewModel, affixIdentifierViewModel) 10 | { 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Cog.Application/ViewModels/CompareSettingsViewModel.cs: -------------------------------------------------------------------------------- 1 | using SIL.Cog.Application.Services; 2 | 3 | namespace SIL.Cog.Application.ViewModels 4 | { 5 | public class CompareSettingsViewModel : SettingsWorkspaceViewModelBase 6 | { 7 | public CompareSettingsViewModel(IProjectService projectService, IBusyService busyService, AlineViewModel alineViewModel, 8 | CognateIdentifierOptionsViewModel cognateIdentifierOptionsViewModel) 9 | : base("Comparison", projectService, busyService, alineViewModel, cognateIdentifierOptionsViewModel) 10 | { 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Cog.Presentation/Views/ExportGlobalCorrespondencesChartDialog.xaml.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | 3 | namespace SIL.Cog.Presentation.Views 4 | { 5 | /// 6 | /// Interaction logic for ExportGlobalCorrespondencesChartDialog.xaml 7 | /// 8 | public partial class ExportGlobalCorrespondencesChartDialog 9 | { 10 | public ExportGlobalCorrespondencesChartDialog() 11 | { 12 | InitializeComponent(); 13 | } 14 | 15 | private void exportButton_Click(object sender, RoutedEventArgs e) 16 | { 17 | DialogResult = true; 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /GlobalAssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | 3 | // General Information about an assembly is controlled through the following 4 | // set of attributes. Change these attribute values to modify the information 5 | // associated with an assembly. 6 | [assembly: AssemblyCompany("SIL")] 7 | [assembly: AssemblyProduct("Cog")] 8 | [assembly: AssemblyCopyright("Copyright © 2023 SIL International")] 9 | [assembly: AssemblyTrademark("")] 10 | [assembly: AssemblyCulture("")] 11 | 12 | 13 | [assembly: AssemblyFileVersion("1.3.8.DEV_BUILD")] 14 | [assembly: AssemblyVersion("1.3.8.0")] 15 | -------------------------------------------------------------------------------- /Cog.Application/Services/IExportService.cs: -------------------------------------------------------------------------------- 1 | using SIL.Cog.Application.ViewModels; 2 | using SIL.Cog.Domain; 3 | 4 | namespace SIL.Cog.Application.Services 5 | { 6 | public interface IExportService 7 | { 8 | bool ExportSimilarityMatrix(object ownerViewModel, SimilarityMetric similarityMetric); 9 | bool ExportWordLists(object ownerViewModel); 10 | bool ExportCognateSets(object ownerViewModel); 11 | bool ExportVarietyPair(object ownerViewModel, VarietyPair varietyPair); 12 | bool ExportSegmentFrequencies(object ownerViewModel, SyllablePosition syllablePosition); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Cog.Application/ViewModels/FeatureValueViewModel.cs: -------------------------------------------------------------------------------- 1 | using GalaSoft.MvvmLight; 2 | using SIL.Machine.FeatureModel; 3 | 4 | namespace SIL.Cog.Application.ViewModels 5 | { 6 | public class FeatureValueViewModel : ViewModelBase 7 | { 8 | private readonly FeatureSymbol _symbol; 9 | 10 | public FeatureValueViewModel(FeatureSymbol symbol) 11 | { 12 | _symbol = symbol; 13 | } 14 | 15 | public string Name 16 | { 17 | get { return _symbol.Description; } 18 | } 19 | 20 | internal FeatureSymbol DomainSymbol 21 | { 22 | get { return _symbol; } 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Cog.Application/ViewModels/HierarchicalGraphEdge.cs: -------------------------------------------------------------------------------- 1 | using GraphSharp; 2 | using QuickGraph; 3 | 4 | namespace SIL.Cog.Application.ViewModels 5 | { 6 | public class HierarchicalGraphEdge : Edge, ILengthEdge 7 | { 8 | private readonly double _length; 9 | 10 | public HierarchicalGraphEdge(HierarchicalGraphVertex source, HierarchicalGraphVertex target, double length) 11 | : base(source, target) 12 | { 13 | _length = length; 14 | } 15 | 16 | public double Length 17 | { 18 | get { return _length; } 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Cog.Application/ViewModels/TaskAreaItemsViewModel.cs: -------------------------------------------------------------------------------- 1 | using SIL.ObjectModel; 2 | 3 | namespace SIL.Cog.Application.ViewModels 4 | { 5 | public class TaskAreaItemsViewModel : TaskAreaViewModelBase 6 | { 7 | private readonly ReadOnlyList _items; 8 | 9 | public TaskAreaItemsViewModel(string displayName, params TaskAreaViewModelBase[] items) 10 | : base(displayName) 11 | { 12 | _items = new ReadOnlyList(items); 13 | } 14 | 15 | public ReadOnlyList Items 16 | { 17 | get { return _items; } 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Cog.CommandLine/App.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /Cog.Application/Services/IProjectService.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using SIL.Cog.Domain; 3 | 4 | namespace SIL.Cog.Application.Services 5 | { 6 | public interface IProjectService 7 | { 8 | event EventHandler ProjectOpened; 9 | 10 | bool Init(); 11 | bool New(object ownerViewModel); 12 | bool Open(object ownerViewModel); 13 | bool Close(object ownerViewModel); 14 | bool Save(object ownerViewModel); 15 | bool SaveAs(object ownerViewModel); 16 | 17 | bool IsChanged { get; } 18 | CogProject Project { get; } 19 | string ProjectName { get; } 20 | bool AreAllVarietiesCompared { get; } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Cog.Application/ViewModels/VarietyViewModel.cs: -------------------------------------------------------------------------------- 1 | using SIL.Cog.Domain; 2 | 3 | namespace SIL.Cog.Application.ViewModels 4 | { 5 | public class VarietyViewModel : WrapperViewModel 6 | { 7 | private readonly Variety _variety; 8 | 9 | public VarietyViewModel(Variety variety) 10 | : base(variety) 11 | { 12 | _variety = variety; 13 | } 14 | 15 | public string Name 16 | { 17 | get { return _variety.Name; } 18 | } 19 | 20 | internal Variety DomainVariety 21 | { 22 | get { return _variety; } 23 | } 24 | 25 | public override string ToString() 26 | { 27 | return Name; 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Cog.CommandLine.Tests/SyllabifyTests.cs: -------------------------------------------------------------------------------- 1 | using NUnit.Framework; 2 | 3 | namespace SIL.Cog.CommandLine.Tests 4 | { 5 | [TestFixture] 6 | public class SyllabifyTests : TestBase 7 | { 8 | [Test, Sequential] 9 | public void CheckSyllabification( 10 | [Values("chair", "apple", "edit", "ed.it", "un.ed.it.a.ble", "un.|ed.it|.a.ble")] string input, 11 | [Values("|chair|", "|ap.ple|", "|e.dit|", "|ed.it|", "|un.ed.it.a.ble|", "un.|ed.it|.a.ble")] string expectedOutput) 12 | { 13 | var syllabifier = new SyllabifyVerb(); 14 | CheckVerbOutput(input, expectedOutput, syllabifier); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Cog.Presentation/Converters/DebugConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics; 3 | using System.Globalization; 4 | using System.Windows.Data; 5 | 6 | namespace SIL.Cog.Presentation.Converters 7 | { 8 | public class DebugConverter : IValueConverter 9 | { 10 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 11 | { 12 | Debug.WriteLine(value); 13 | return value; 14 | } 15 | 16 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 17 | { 18 | Debug.WriteLine(value); 19 | return value; 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Cog.Presentation/Views/SettingsView.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Windows; 3 | 4 | namespace SIL.Cog.Presentation.Views 5 | { 6 | /// 7 | /// Interaction logic for SettingsView.xaml 8 | /// 9 | public partial class SettingsView 10 | { 11 | public SettingsView() 12 | { 13 | InitializeComponent(); 14 | BusyCursor.DisplayUntilIdle(); 15 | } 16 | 17 | 18 | private void OnIsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e) 19 | { 20 | if (IsVisible) 21 | Dispatcher.BeginInvoke(new Action(() => ComponentSettingsControl.Focus())); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Cog.Application/ViewModels/MeaningViewModel.cs: -------------------------------------------------------------------------------- 1 | using SIL.Cog.Domain; 2 | 3 | namespace SIL.Cog.Application.ViewModels 4 | { 5 | public class MeaningViewModel : WrapperViewModel 6 | { 7 | private readonly Meaning _meaning; 8 | 9 | public MeaningViewModel(Meaning meaning) 10 | : base(meaning) 11 | { 12 | _meaning = meaning; 13 | } 14 | 15 | public string Gloss 16 | { 17 | get { return _meaning.Gloss; } 18 | } 19 | 20 | public string Category 21 | { 22 | get { return _meaning.Category; } 23 | } 24 | 25 | internal Meaning DomainMeaning 26 | { 27 | get { return _meaning; } 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Cog.Application/ViewModels/WorkspaceViewModelBase.cs: -------------------------------------------------------------------------------- 1 | using SIL.Cog.Application.Collections; 2 | using SIL.ObjectModel; 3 | 4 | namespace SIL.Cog.Application.ViewModels 5 | { 6 | public abstract class WorkspaceViewModelBase : ContainerChildViewModelBase 7 | { 8 | private readonly BindableList _taskAreas; 9 | 10 | protected WorkspaceViewModelBase(string displayName) 11 | : base(displayName) 12 | { 13 | _taskAreas = new BindableList(); 14 | } 15 | 16 | public ObservableList TaskAreas 17 | { 18 | get { return _taskAreas; } 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Cog.CommandLine.Tests/PairsTests.cs: -------------------------------------------------------------------------------- 1 | using NUnit.Framework; 2 | 3 | namespace SIL.Cog.CommandLine.Tests 4 | { 5 | [TestFixture] 6 | public class PairsTests : TestBase 7 | { 8 | [Test, Sequential] 9 | public void MakePairsProducesAllCombinations( 10 | [Values("one", "one\r\ntwo", "one\ntwo\n", "1\r\n2\r\n3\r\n", "1\n2\n3\n4")] 11 | string input, 12 | [Values("", "one two\n", "one two\n", "1 2\n1 3\n2 3\n", "1 2\n1 3\n1 4\n2 3\n2 4\n3 4\n")] 13 | string expectedOutput) 14 | { 15 | var pairs = new PairsVerb(); 16 | CheckVerbOutput(input, expectedOutput, pairs, stripNewlines:false); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Cog.Domain/Components/AffixStripper.cs: -------------------------------------------------------------------------------- 1 | using System.Linq; 2 | 3 | namespace SIL.Cog.Domain.Components 4 | { 5 | public class AffixStripper : IProcessor 6 | { 7 | private readonly Segmenter _segmenter; 8 | 9 | public AffixStripper(Segmenter segmenter) 10 | { 11 | _segmenter = segmenter; 12 | } 13 | 14 | public void Process(Variety data) 15 | { 16 | foreach (Word word in data.Words.Where(w => w.Shape.Count > 0 && (w.Prefix != null || w.Suffix != null))) 17 | { 18 | word.StemIndex = 0; 19 | word.StemLength = word.StrRep.Length; 20 | _segmenter.Segment(word); 21 | } 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Cog.Domain/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /Cog.Presentation/Views/MeaningsView.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Windows; 3 | 4 | namespace SIL.Cog.Presentation.Views 5 | { 6 | /// 7 | /// Interaction logic for MeaningsView.xaml 8 | /// 9 | public partial class MeaningsView 10 | { 11 | public MeaningsView() 12 | { 13 | InitializeComponent(); 14 | MeaningsGrid.ClipboardExporters.Clear(); 15 | BusyCursor.DisplayUntilIdle(); 16 | } 17 | 18 | private void OnIsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e) 19 | { 20 | if (IsVisible) 21 | Dispatcher.BeginInvoke(new Action(() => MeaningsGrid.Focus())); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Cog.TestUtils/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /Cog.Presentation/Controls/Block.xaml: -------------------------------------------------------------------------------- 1 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /Cog.CommandLine/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using CommandLine; 3 | 4 | namespace SIL.Cog.CommandLine 5 | { 6 | class Program 7 | { 8 | private static readonly Type[] ValidVerbs = { 9 | typeof(SyllabifyVerb), 10 | typeof(PairsVerb), 11 | typeof(AlignmentVerb), 12 | typeof(CognatesVerb), 13 | typeof(ClusterVerb), 14 | typeof(SimilarityVerb) 15 | }; 16 | static int Main(string[] args) 17 | { 18 | ParserResult parserResult = Parser.Default.ParseArguments(args, ValidVerbs); 19 | ReturnCode retcode = parserResult.MapResult((VerbBase opts) => opts.RunAsPipe(), errs => ReturnCode.InputError); 20 | return (int)retcode; 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Cog.Domain/SymbolCollection.cs: -------------------------------------------------------------------------------- 1 | using SIL.Machine.FeatureModel; 2 | using SIL.ObjectModel; 3 | 4 | namespace SIL.Cog.Domain 5 | { 6 | public class SymbolCollection : KeyedBulkObservableList 7 | { 8 | public void Add(string strRep) 9 | { 10 | Add(new Symbol(strRep)); 11 | } 12 | 13 | public void Add(string strRep, FeatureStruct fs) 14 | { 15 | Add(new Symbol(strRep, fs)); 16 | } 17 | 18 | public void Add(string strRep, FeatureStruct fs, bool overwrite) 19 | { 20 | Add(new Symbol(strRep, fs, overwrite)); 21 | } 22 | 23 | protected override string GetKeyForItem(Symbol item) 24 | { 25 | return item.StrRep; 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Cog.Presentation/Converters/ProgressDialogTitleConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | using System.Windows.Data; 4 | 5 | namespace SIL.Cog.Presentation.Converters 6 | { 7 | public class ProgressDialogTitleConverter : IMultiValueConverter 8 | { 9 | public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) 10 | { 11 | if (values[0] != null) 12 | return values[0]; 13 | 14 | return string.Format("{0}% completed", values[1]); 15 | } 16 | 17 | public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) 18 | { 19 | throw new NotImplementedException(); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Cog.Presentation/Converters/LessThanConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | using System.Windows.Data; 4 | 5 | namespace SIL.Cog.Presentation.Converters 6 | { 7 | public class LessThanConverter : IValueConverter 8 | { 9 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 10 | { 11 | var number = value as IComparable; 12 | if (number == null) 13 | return Binding.DoNothing; 14 | 15 | return number.CompareTo(parameter) < 0; 16 | } 17 | 18 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 19 | { 20 | throw new NotImplementedException(); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Cog.Application/ViewModels/ExportGlobalCorrespondencesChartViewModel.cs: -------------------------------------------------------------------------------- 1 | using GalaSoft.MvvmLight; 2 | 3 | namespace SIL.Cog.Application.ViewModels 4 | { 5 | public class ExportGlobalCorrespondencesChartViewModel : ViewModelBase 6 | { 7 | private SyllablePosition _syllablePosition; 8 | private int _frequencyThreshold; 9 | 10 | public SyllablePosition SyllablePosition 11 | { 12 | get { return _syllablePosition; } 13 | set { Set(() => SyllablePosition, ref _syllablePosition, value); } 14 | } 15 | 16 | public int FrequencyThreshold 17 | { 18 | get { return _frequencyThreshold; } 19 | set { Set(() => FrequencyThreshold, ref _frequencyThreshold, value); } 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Cog.Presentation/Converters/CognateSetNameConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | using System.Windows.Data; 4 | 5 | namespace SIL.Cog.Presentation.Converters 6 | { 7 | public class CognateSetNameConverter : IValueConverter 8 | { 9 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 10 | { 11 | var index = (int) value; 12 | if (index == int.MaxValue) 13 | return "Non-cognates"; 14 | return string.Format("Cognate set {0}", index); 15 | } 16 | 17 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 18 | { 19 | throw new NotImplementedException(); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Cog.Presentation/Converters/ContentToMarginConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Windows; 3 | using System.Windows.Controls; 4 | using System.Windows.Data; 5 | 6 | namespace SIL.Cog.Presentation.Converters 7 | { 8 | public class ContentToMarginConverter : IValueConverter 9 | { 10 | public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) 11 | { 12 | return new Thickness(0, 0, -((ContentPresenter)value).ActualHeight, 0); 13 | } 14 | 15 | public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) 16 | { 17 | throw new NotImplementedException(); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Cog.Presentation/Converters/GreaterThanConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | using System.Windows.Data; 4 | 5 | namespace SIL.Cog.Presentation.Converters 6 | { 7 | public class GreaterThanConverter : IValueConverter 8 | { 9 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 10 | { 11 | var number = value as IComparable; 12 | if (number == null) 13 | return Binding.DoNothing; 14 | 15 | return number.CompareTo(parameter) > 0; 16 | } 17 | 18 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 19 | { 20 | throw new NotImplementedException(); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Cog.Presentation/Converters/StringFormatConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | using System.Windows.Data; 4 | 5 | namespace SIL.Cog.Presentation.Converters 6 | { 7 | public class StringFormatConverter : IMultiValueConverter 8 | { 9 | public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) 10 | { 11 | var format = parameter as string; 12 | if (format == null) 13 | return null; 14 | 15 | return string.Format(format, values); 16 | } 17 | 18 | public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) 19 | { 20 | throw new NotImplementedException(); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Cog.Domain/Components/AlineSettings.cs: -------------------------------------------------------------------------------- 1 | namespace SIL.Cog.Domain.Components 2 | { 3 | public sealed class AlineSettings : WordPairAlignerSettings 4 | { 5 | private bool _soundChangeScoringEnabled = true; 6 | private bool _syllablePositionCostEnabled = true; 7 | 8 | public bool SoundChangeScoringEnabled 9 | { 10 | get { return _soundChangeScoringEnabled; } 11 | set 12 | { 13 | CheckReadOnly(); 14 | _soundChangeScoringEnabled = value; 15 | } 16 | } 17 | 18 | public bool SyllablePositionCostEnabled 19 | { 20 | get { return _syllablePositionCostEnabled; } 21 | set 22 | { 23 | CheckReadOnly(); 24 | _syllablePositionCostEnabled = value; 25 | } 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Cog.Application/SegmentCategoryComparer.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace SIL.Cog.Application 4 | { 5 | public class SegmentCategoryComparer : IComparer 6 | { 7 | private readonly static Dictionary CategorySortOrderLookup = new Dictionary 8 | { 9 | {"Close", 0}, 10 | {"Mid", 1}, 11 | {"Open", 2}, 12 | {"Labial", 0}, 13 | {"Coronal", 1}, 14 | {"Dorsal", 2}, 15 | {"Guttural", 3}, 16 | {string.Empty, 99} 17 | }; 18 | 19 | public int Compare(string x, string y) 20 | { 21 | int xnum = CategorySortOrderLookup[x]; 22 | int ynum = CategorySortOrderLookup[y]; 23 | return Comparer.Default.Compare(xnum, ynum); 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Cog.CommandLine.Tests/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /Cog.Domain/Components/ThresholdCognateIdentifier.cs: -------------------------------------------------------------------------------- 1 | using System.Linq; 2 | 3 | namespace SIL.Cog.Domain.Components 4 | { 5 | public class ThresholdCognateIdentifier : ICognateIdentifier 6 | { 7 | private readonly double _threshold; 8 | 9 | public ThresholdCognateIdentifier(double threshold) 10 | { 11 | _threshold = threshold; 12 | } 13 | 14 | public double Threshold 15 | { 16 | get { return _threshold; } 17 | } 18 | 19 | public void UpdatePredictedCognacy(WordPair wordPair, IWordAlignerResult alignerResult) 20 | { 21 | wordPair.PredictedCognacyScore = alignerResult.GetAlignments().First().NormalizedScore; 22 | wordPair.PredictedCognacy = wordPair.PredictedCognacyScore >= _threshold; 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Cog.Application/ViewModels/GlobalSegmentVertex.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Linq; 3 | 4 | namespace SIL.Cog.Application.ViewModels 5 | { 6 | public abstract class GlobalSegmentVertex : GlobalCorrespondencesGraphVertex 7 | { 8 | private readonly HashSet _strReps; 9 | 10 | protected GlobalSegmentVertex() 11 | { 12 | _strReps = new HashSet(); 13 | } 14 | 15 | public override string StrRep 16 | { 17 | get { return string.Join(",", _strReps.OrderBy(s => s)); } 18 | } 19 | 20 | public override bool IsProperty 21 | { 22 | get { return false; } 23 | } 24 | 25 | internal ISet StrReps 26 | { 27 | get { return _strReps; } 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Cog.Application/ViewModels/GlobalVowelVertex.cs: -------------------------------------------------------------------------------- 1 | namespace SIL.Cog.Application.ViewModels 2 | { 3 | public class GlobalVowelVertex : GlobalSegmentVertex 4 | { 5 | private readonly VowelHeight _height; 6 | private readonly VowelBackness _backness; 7 | private readonly bool _round; 8 | 9 | public GlobalVowelVertex(VowelHeight height, VowelBackness backness, bool round) 10 | { 11 | _height = height; 12 | _backness = backness; 13 | _round = round; 14 | } 15 | 16 | public VowelHeight Height 17 | { 18 | get { return _height; } 19 | } 20 | 21 | public VowelBackness Backness 22 | { 23 | get { return _backness; } 24 | } 25 | 26 | public bool Round 27 | { 28 | get { return _round; } 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Cog.Presentation/Controls/PercentageControl.xaml.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | 3 | namespace SIL.Cog.Presentation.Controls 4 | { 5 | /// 6 | /// Interaction logic for PercentageControl.xaml 7 | /// 8 | public partial class PercentageControl 9 | { 10 | public PercentageControl() 11 | { 12 | InitializeComponent(); 13 | } 14 | 15 | public static readonly DependencyProperty MaxPercentageProperty = DependencyProperty.Register("MaxPercentage", typeof(double), typeof(PercentageControl), 16 | new FrameworkPropertyMetadata(1.0)); 17 | 18 | public double MaxPercentage 19 | { 20 | get { return (double) GetValue(MaxPercentageProperty); } 21 | set { SetValue(MaxPercentageProperty, value); } 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Cog.Presentation/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | True 13 | 14 | 15 | -------------------------------------------------------------------------------- /Cog.Application/Collections/ReadOnlyBindableList.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Specialized; 2 | using SIL.ObjectModel; 3 | 4 | namespace SIL.Cog.Application.Collections 5 | { 6 | public class ReadOnlyBindableList : ReadOnlyObservableList 7 | { 8 | public override event NotifyCollectionChangedEventHandler CollectionChanged; 9 | 10 | public ReadOnlyBindableList(IObservableList list) 11 | : base(list) 12 | { 13 | } 14 | 15 | protected override void OnCollectionChanged(NotifyCollectionChangedEventArgs e) 16 | { 17 | NotifyCollectionChangedEventHandler collectionChanged = CollectionChanged; 18 | if (collectionChanged != null) 19 | BindableCollectionUtils.InvokeCollectionChanged(collectionChanged, this, e); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Cog.Application/ViewModels/GlobalConsonantVertex.cs: -------------------------------------------------------------------------------- 1 | namespace SIL.Cog.Application.ViewModels 2 | { 3 | public class GlobalConsonantVertex : GlobalSegmentVertex 4 | { 5 | private readonly ConsonantPlace _place; 6 | private readonly ConsonantManner _manner; 7 | private readonly bool _voiced; 8 | 9 | public GlobalConsonantVertex(ConsonantPlace place, ConsonantManner manner, bool voiced) 10 | { 11 | _place = place; 12 | _manner = manner; 13 | _voiced = voiced; 14 | } 15 | 16 | public ConsonantPlace Place 17 | { 18 | get { return _place; } 19 | } 20 | 21 | public ConsonantManner Manner 22 | { 23 | get { return _manner; } 24 | } 25 | 26 | public bool Voiced 27 | { 28 | get { return _voiced; } 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Cog.Application/ViewModels/SegmentMappingsTableSegmentViewModel.cs: -------------------------------------------------------------------------------- 1 | using SIL.Cog.Application.Collections; 2 | using SIL.Cog.Domain; 3 | using SIL.ObjectModel; 4 | 5 | namespace SIL.Cog.Application.ViewModels 6 | { 7 | public class SegmentMappingsTableSegmentViewModel : SegmentViewModel 8 | { 9 | private readonly BindableList _segmentPairs; 10 | 11 | public SegmentMappingsTableSegmentViewModel(Segment segment, SoundType type) 12 | : base(segment, type) 13 | { 14 | _segmentPairs = new BindableList(); 15 | } 16 | 17 | public ObservableList SegmentPairs 18 | { 19 | get { return _segmentPairs; } 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Cog.Presentation/Controls/PercentageSlider.xaml.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | 3 | namespace SIL.Cog.Presentation.Controls 4 | { 5 | /// 6 | /// Interaction logic for PercentageSlider.xaml 7 | /// 8 | public partial class PercentageSlider 9 | { 10 | public PercentageSlider() 11 | { 12 | InitializeComponent(); 13 | } 14 | 15 | public static readonly DependencyProperty ValueProperty = DependencyProperty.Register("Value", typeof(double), typeof(PercentageSlider), 16 | new FrameworkPropertyMetadata(0.0, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault)); 17 | 18 | public double Value 19 | { 20 | get { return (double) GetValue(ValueProperty); } 21 | set { SetValue(ValueProperty, value); } 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Cog.Application/ViewModels/RunStemmerViewModel.cs: -------------------------------------------------------------------------------- 1 | using GalaSoft.MvvmLight; 2 | 3 | namespace SIL.Cog.Application.ViewModels 4 | { 5 | public enum StemmingMethod 6 | { 7 | Automatic, 8 | Hybrid, 9 | Manual 10 | } 11 | 12 | public class RunStemmerViewModel : ViewModelBase 13 | { 14 | private StemmingMethod _method; 15 | private readonly bool _isHybridAvailable; 16 | 17 | public RunStemmerViewModel(bool isHybridAvailable) 18 | { 19 | _isHybridAvailable = isHybridAvailable; 20 | } 21 | 22 | public bool IsHybridAvailable 23 | { 24 | get { return _isHybridAvailable; } 25 | } 26 | 27 | public StemmingMethod Method 28 | { 29 | get { return _method; } 30 | set { Set(() => Method, ref _method, value); } 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /Cog.Presentation/Converters/ColorBrightnessConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | using System.Windows.Data; 4 | using System.Windows.Media; 5 | 6 | namespace SIL.Cog.Presentation.Converters 7 | { 8 | public class ColorBrightnessConverter : IValueConverter 9 | { 10 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 11 | { 12 | var color = (Color) value; 13 | var pcnt = (double) parameter; 14 | HslColor hsl = HslColor.FromColor(color); 15 | hsl.L += hsl.L * pcnt; 16 | return hsl.ToColor(); 17 | } 18 | 19 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 20 | { 21 | throw new NotImplementedException(); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Cog.Presentation/Views/ComponentOptionsView.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Windows; 6 | using System.Windows.Controls; 7 | using System.Windows.Data; 8 | using System.Windows.Documents; 9 | using System.Windows.Input; 10 | using System.Windows.Media; 11 | using System.Windows.Media.Imaging; 12 | using System.Windows.Navigation; 13 | using System.Windows.Shapes; 14 | 15 | namespace SIL.Cog.Presentation.Views 16 | { 17 | /// 18 | /// Interaction logic for ComponentOptionsView.xaml 19 | /// 20 | public partial class ComponentOptionsView : UserControl 21 | { 22 | public ComponentOptionsView() 23 | { 24 | InitializeComponent(); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Cog.Presentation/Views/TaskAreaCommandGroupView.xaml.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | using System.Windows.Documents; 3 | using SIL.Cog.Application.ViewModels; 4 | 5 | namespace SIL.Cog.Presentation.Views 6 | { 7 | /// 8 | /// Interaction logic for TaskAreaCommandGroupView.xaml 9 | /// 10 | public partial class TaskAreaCommandGroupView 11 | { 12 | public TaskAreaCommandGroupView() 13 | { 14 | InitializeComponent(); 15 | } 16 | 17 | private void Hyperlink_Click(object sender, RoutedEventArgs e) 18 | { 19 | var hyperlink = (Hyperlink) sender; 20 | var command = (TaskAreaCommandViewModel) hyperlink.DataContext; 21 | 22 | var vm = (TaskAreaCommandGroupViewModel) DataContext; 23 | vm.SelectedCommand = command; 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Cog.Domain/Config/Components/ThresholdCognateIdentifierConfig.cs: -------------------------------------------------------------------------------- 1 | using System.Xml.Linq; 2 | using SIL.Cog.Domain.Components; 3 | 4 | namespace SIL.Cog.Domain.Config.Components 5 | { 6 | public class ThresholdCognateIdentifierConfig : IComponentConfig 7 | { 8 | public ICognateIdentifier Load(SegmentPool segmentPool, CogProject project, XElement elem) 9 | { 10 | var threshold = (double) elem.Element(ConfigManager.Cog + "Threshold"); 11 | return new ThresholdCognateIdentifier(threshold); 12 | } 13 | 14 | public void Save(ICognateIdentifier component, XElement elem) 15 | { 16 | var identifier = (ThresholdCognateIdentifier) component; 17 | elem.Add(new XElement(ConfigManager.Cog + "Threshold", identifier.Threshold)); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Cog.Application/ViewModels/RelevantValueViewModel.cs: -------------------------------------------------------------------------------- 1 | using SIL.Machine.FeatureModel; 2 | 3 | namespace SIL.Cog.Application.ViewModels 4 | { 5 | public class RelevantValueViewModel : ChangeTrackingViewModelBase 6 | { 7 | private readonly FeatureSymbol _symbol; 8 | private int _metric; 9 | 10 | public RelevantValueViewModel(FeatureSymbol symbol, int metric) 11 | { 12 | _symbol = symbol; 13 | _metric = metric; 14 | } 15 | 16 | public string Description 17 | { 18 | get { return _symbol.Description; } 19 | } 20 | 21 | public int Metric 22 | { 23 | get { return _metric; } 24 | set { SetChanged(() => Metric, ref _metric, value); } 25 | } 26 | 27 | internal FeatureSymbol DomainSymbol 28 | { 29 | get { return _symbol; } 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Cog.Application/ViewModels/SegmentPropertyVertex.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.ComponentModel; 3 | using System.Reflection; 4 | 5 | namespace SIL.Cog.Application.ViewModels 6 | { 7 | public abstract class SegmentPropertyVertex : GlobalCorrespondencesGraphVertex 8 | { 9 | public override bool IsProperty 10 | { 11 | get { return true; } 12 | } 13 | 14 | protected static string GetEnumDescription(Enum value) 15 | { 16 | FieldInfo fi = value.GetType().GetField(value.ToString()); 17 | 18 | var attributes = (DescriptionAttribute[]) fi.GetCustomAttributes(typeof(DescriptionAttribute), false); 19 | 20 | if (attributes.Length > 0) 21 | return attributes[0].Description; 22 | return value.ToString(); 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Cog.Domain/Components/PrecisionRecallCalculator.cs: -------------------------------------------------------------------------------- 1 | namespace SIL.Cog.Domain.Components 2 | { 3 | public class PrecisionRecallCalculator : IProcessor 4 | { 5 | public void Process(VarietyPair varietyPair) 6 | { 7 | int tp = 0; 8 | int fp = 0; 9 | int fn = 0; 10 | foreach (WordPair wp in varietyPair.WordPairs) 11 | { 12 | if (wp.ActualCognacy != null) 13 | { 14 | if (wp.PredictedCognacy) 15 | { 16 | if ((bool) wp.ActualCognacy) 17 | tp++; 18 | else 19 | fp++; 20 | } 21 | else if ((bool) wp.ActualCognacy) 22 | { 23 | fn++; 24 | } 25 | } 26 | } 27 | 28 | varietyPair.Precision = (double) tp / (tp + fp); 29 | varietyPair.Recall = (double) tp / (tp + fn); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Cog.Application/Services/ProjectMigrations/ProjectMigrationExtensions.cs: -------------------------------------------------------------------------------- 1 | using SIL.Cog.Domain; 2 | using SIL.Machine.FeatureModel; 3 | 4 | namespace SIL.Cog.Application.Services.ProjectMigrations 5 | { 6 | internal static class ProjectMigrationExtensions 7 | { 8 | public static void AddSymbolBasedOn(this SymbolCollection symbols, string strRep, string basedOnStrRep, params FeatureSymbol[] values) 9 | { 10 | Symbol basedOnSymbol; 11 | if (!symbols.Contains(strRep) 12 | && symbols.TryGet(basedOnStrRep, out basedOnSymbol)) 13 | { 14 | FeatureStruct fs = basedOnSymbol.FeatureStruct.Clone(); 15 | foreach (FeatureSymbol value in values) 16 | fs.AddValue(value.Feature, value); 17 | fs.Freeze(); 18 | symbols.Add(strRep, fs); 19 | } 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /debian/control: -------------------------------------------------------------------------------- 1 | Package: cog-cmdline 2 | Version: DEBIAN_VERSION_NUMBER 3 | Section: contrib/cli-mono 4 | Priority: optional 5 | Architecture: all 6 | Depends: mono-runtime, libmono-system-core4.0-cil, libmono-system-xml-linq4.0-cil 7 | Description: Command-line part of Cog, a computational linguistics tool 8 | Cog helps you compare languages using lexicostatistics and comparative 9 | linguistics techniques. It can be used to automate much of the process 10 | of comparing word lists from different language varieties. 11 | . 12 | This package contains the command-line part of Cog, which allows users to 13 | automate a small subset of Cog's functionality with command-line scripts. 14 | Maintainer: Robin Munn 15 | Homepage: http://www.sil.org/resources/software_fonts/cog 16 | -------------------------------------------------------------------------------- /Cog.Presentation/Converters/DoubleToLog10Converter.cs: -------------------------------------------------------------------------------- 1 | using System.Globalization; 2 | using System.Windows.Data; 3 | using System; 4 | 5 | namespace SIL.Cog.Presentation.Converters 6 | { 7 | public class DoubleToLog10Converter : IValueConverter 8 | { 9 | #region IValueConverter Members 10 | 11 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 12 | { 13 | var val = (double) value; 14 | return Math.Log10(val); 15 | } 16 | 17 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 18 | { 19 | var val = (double) value; 20 | return Math.Pow(10, val); 21 | } 22 | 23 | #endregion 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Cog.Application/ViewModels/ExportNetworkGraphViewModel.cs: -------------------------------------------------------------------------------- 1 | using GalaSoft.MvvmLight; 2 | 3 | namespace SIL.Cog.Application.ViewModels 4 | { 5 | public class ExportNetworkGraphViewModel : ViewModelBase 6 | { 7 | private SimilarityMetric _similarityMetric; 8 | private double _similarityScoreFilter; 9 | 10 | public ExportNetworkGraphViewModel() 11 | { 12 | _similarityScoreFilter = 0.7; 13 | } 14 | 15 | public SimilarityMetric SimilarityMetric 16 | { 17 | get { return _similarityMetric; } 18 | set { Set(() => SimilarityMetric, ref _similarityMetric, value); } 19 | } 20 | 21 | public double SimilarityScoreFilter 22 | { 23 | get { return _similarityScoreFilter; } 24 | set { Set(() => SimilarityScoreFilter, ref _similarityScoreFilter, value); } 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Cog.Presentation/Views/CognateIdentifierOptionsView.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Windows; 6 | using System.Windows.Controls; 7 | using System.Windows.Data; 8 | using System.Windows.Documents; 9 | using System.Windows.Input; 10 | using System.Windows.Media; 11 | using System.Windows.Media.Imaging; 12 | using System.Windows.Navigation; 13 | using System.Windows.Shapes; 14 | 15 | namespace SIL.Cog.Presentation.Views 16 | { 17 | /// 18 | /// Interaction logic for CognateIdentifierOptionsView.xaml 19 | /// 20 | public partial class CognateIdentifierOptionsView : UserControl 21 | { 22 | public CognateIdentifierOptionsView() 23 | { 24 | InitializeComponent(); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Cog.Presentation/Converters/SwitchCase.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | using System.Windows.Markup; 3 | 4 | namespace SIL.Cog.Presentation.Converters 5 | { 6 | [ContentProperty("Then")] 7 | public class SwitchCase : DependencyObject 8 | { 9 | private static readonly DependencyProperty WhenProperty = DependencyProperty.Register("When", typeof(object), typeof(SwitchCase)); 10 | private static readonly DependencyProperty ThenProperty = DependencyProperty.Register("Then", typeof(object), typeof(SwitchCase)); 11 | 12 | public object When 13 | { 14 | get { return GetValue(WhenProperty); } 15 | set { SetValue(WhenProperty, value); } 16 | } 17 | 18 | public object Then 19 | { 20 | get { return GetValue(ThenProperty); } 21 | set { SetValue(ThenProperty, value); } 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Cog.Application/ViewModels/SegmentCategoryViewModel.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Linq; 3 | using GalaSoft.MvvmLight; 4 | using SIL.ObjectModel; 5 | 6 | namespace SIL.Cog.Application.ViewModels 7 | { 8 | public class SegmentCategoryViewModel : ViewModelBase 9 | { 10 | private readonly string _name; 11 | private readonly ReadOnlyList _segments; 12 | 13 | public SegmentCategoryViewModel(string name, IEnumerable segments) 14 | { 15 | _name = name; 16 | _segments = new ReadOnlyList(segments.ToArray()); 17 | } 18 | 19 | public string Name 20 | { 21 | get { return _name; } 22 | } 23 | 24 | public ReadOnlyList Segments 25 | { 26 | get { return _segments; } 27 | } 28 | 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Cog.Application/ViewModels/SwitchViewMessage.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using GalaSoft.MvvmLight.Messaging; 4 | using SIL.Extensions; 5 | using SIL.ObjectModel; 6 | 7 | namespace SIL.Cog.Application.ViewModels 8 | { 9 | public class SwitchViewMessage : MessageBase 10 | { 11 | private readonly Type _viewModelType; 12 | private readonly ReadOnlyList _domainModels; 13 | 14 | public SwitchViewMessage(Type viewModelType, params object[] models) 15 | { 16 | _viewModelType = viewModelType; 17 | _domainModels = models.ToReadOnlyList(); 18 | } 19 | 20 | public Type ViewModelType 21 | { 22 | get { return _viewModelType; } 23 | } 24 | 25 | public IReadOnlyList DomainModels 26 | { 27 | get { return _domainModels; } 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Cog.TestUtils/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.InteropServices; 3 | 4 | // General Information about an assembly is controlled through the following 5 | // set of attributes. Change these attribute values to modify the information 6 | // associated with an assembly. 7 | [assembly: AssemblyTitle("SIL.Cog.TestUtils")] 8 | [assembly: AssemblyDescription("")] 9 | 10 | // Setting ComVisible to false makes the types in this assembly not visible 11 | // to COM components. If you need to access a type in this assembly from 12 | // COM, set the ComVisible attribute to true on that type. 13 | [assembly: ComVisible(false)] 14 | 15 | // The following GUID is for the ID of the typelib if this project is exposed to COM 16 | [assembly: Guid("dd8bf2d3-9fd9-4ee5-b54b-5bee133e0ce2")] 17 | -------------------------------------------------------------------------------- /Cog.Application/ViewModels/NetworkGraphEdge.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using GraphSharp; 3 | using QuickGraph; 4 | using SIL.Cog.Domain; 5 | 6 | namespace SIL.Cog.Application.ViewModels 7 | { 8 | public class NetworkGraphEdge : Edge, IWeightedEdge 9 | { 10 | private readonly double _weight; 11 | 12 | public NetworkGraphEdge(NetworkGraphVertex source, NetworkGraphVertex target, VarietyPair varietyPair, SimilarityMetric similarityMetric) 13 | : base(source, target) 14 | { 15 | double weight = similarityMetric == SimilarityMetric.Lexical ? varietyPair.LexicalSimilarityScore : varietyPair.PhoneticSimilarityScore; 16 | _weight = Math.Min(weight, 0.99); 17 | } 18 | 19 | public double Weight 20 | { 21 | get { return _weight; } 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Cog.Domain.Tests/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.InteropServices; 3 | 4 | // General Information about an assembly is controlled through the following 5 | // set of attributes. Change these attribute values to modify the information 6 | // associated with an assembly. 7 | [assembly: AssemblyTitle("SIL.Cog.Domain.Tests")] 8 | [assembly: AssemblyDescription("")] 9 | 10 | // Setting ComVisible to false makes the types in this assembly not visible 11 | // to COM components. If you need to access a type in this assembly from 12 | // COM, set the ComVisible attribute to true on that type. 13 | [assembly: ComVisible(false)] 14 | 15 | // The following GUID is for the ID of the typelib if this project is exposed to COM 16 | [assembly: Guid("c8976482-72d5-4454-9b5e-92c2d1e80f44")] 17 | 18 | -------------------------------------------------------------------------------- /Cog.Application.Tests/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.InteropServices; 3 | 4 | // General Information about an assembly is controlled through the following 5 | // set of attributes. Change these attribute values to modify the information 6 | // associated with an assembly. 7 | [assembly: AssemblyTitle("SIL.Cog.Application.Tests")] 8 | [assembly: AssemblyDescription("")] 9 | 10 | // Setting ComVisible to false makes the types in this assembly not visible 11 | // to COM components. If you need to access a type in this assembly from 12 | // COM, set the ComVisible attribute to true on that type. 13 | [assembly: ComVisible(false)] 14 | 15 | // The following GUID is for the ID of the typelib if this project is exposed to COM 16 | [assembly: Guid("546af3b2-85a8-4f82-88d9-ec9631d5ffc6")] 17 | -------------------------------------------------------------------------------- /Cog.CommandLine/PairsVerb.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using CommandLine; 5 | 6 | namespace SIL.Cog.CommandLine 7 | { 8 | [Verb("pairs", HelpText = "Turn a list of words into unique word pairs")] 9 | public class PairsVerb : VerbBase 10 | { 11 | protected override ReturnCode DoWork(TextReader inputReader, TextWriter outputWriter, TextWriter errorWriter) 12 | { 13 | ReturnCode retcode = ReturnCode.Okay; 14 | var words = new List(); 15 | foreach (string line in ReadLines(inputReader)) 16 | { 17 | words.Add(line); 18 | } 19 | 20 | foreach (Tuple wordPair in AllPossiblePairs(words)) 21 | { 22 | outputWriter.WriteLine("{0} {1}", wordPair.Item1, wordPair.Item2); 23 | } 24 | 25 | return retcode; 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Cog.Application/ViewModels/ImportTextWordListsViewModel.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel; 2 | using GalaSoft.MvvmLight; 3 | 4 | namespace SIL.Cog.Application.ViewModels 5 | { 6 | public enum TextWordListsFormat 7 | { 8 | [Description("Varieties as rows")] 9 | VarietyRows, 10 | [Description("Glosses as rows")] 11 | GlossRows 12 | } 13 | 14 | public class ImportTextWordListsViewModel : ViewModelBase 15 | { 16 | private bool _categoriesIncluded; 17 | private TextWordListsFormat _format; 18 | 19 | public bool CategoriesIncluded 20 | { 21 | get { return _categoriesIncluded; } 22 | set { Set(() => CategoriesIncluded, ref _categoriesIncluded, value); } 23 | } 24 | 25 | public TextWordListsFormat Format 26 | { 27 | get { return _format; } 28 | set { Set(() => Format, ref _format, value); } 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Cog.Application/Services/ProjectMigrations/ProjectMigration5.cs: -------------------------------------------------------------------------------- 1 | using SIL.Cog.Domain; 2 | using SIL.Machine.FeatureModel; 3 | 4 | namespace SIL.Cog.Application.Services.ProjectMigrations 5 | { 6 | public class ProjectMigration5 : IProjectMigration 7 | { 8 | public int Version => 5; 9 | 10 | public void Migrate(SegmentPool segmentPool, CogProject project) 11 | { 12 | Symbol symbol; 13 | if (project.Segmenter.Consonants.TryGet("ħ", out symbol)) 14 | { 15 | FeatureStruct fs = symbol.FeatureStruct.Clone(); 16 | fs.PriorityUnion(FeatureStruct.New(project.FeatureSystem) 17 | .Symbol("pharyngeal") 18 | .Symbol("fricative").Value); 19 | fs.Freeze(); 20 | project.Segmenter.Consonants.Remove(symbol.StrRep); 21 | project.Segmenter.Consonants.Add(symbol.StrRep, fs, symbol.Overwrite); 22 | } 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Cog.Presentation/Converters/EqualityConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | using System.Windows.Data; 4 | 5 | namespace SIL.Cog.Presentation.Converters 6 | { 7 | public class EqualityConverter : IMultiValueConverter 8 | { 9 | public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) 10 | { 11 | if (values == null || values.Length == 0) return false; 12 | 13 | for (int i = 1; i < values.Length; i++) 14 | { 15 | if (values[0] == null && values[i] != null) return false; 16 | if (values[i] == null || !values[i].Equals(values[0])) return false; 17 | } 18 | 19 | return true; 20 | } 21 | 22 | public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) 23 | { 24 | throw new NotImplementedException(); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Cog.Application/ViewModels/ContainerChildViewModelBase.cs: -------------------------------------------------------------------------------- 1 | using GalaSoft.MvvmLight; 2 | 3 | namespace SIL.Cog.Application.ViewModels 4 | { 5 | public abstract class ContainerChildViewModelBase : ViewModelBase 6 | { 7 | private string _displayName; 8 | private bool _isSelected; 9 | 10 | protected ContainerChildViewModelBase(string displayName) 11 | { 12 | _displayName = displayName; 13 | } 14 | 15 | public string DisplayName 16 | { 17 | get { return _displayName; } 18 | set { Set(() => DisplayName, ref _displayName, value); } 19 | } 20 | 21 | public bool IsSelected 22 | { 23 | get { return _isSelected; } 24 | set 25 | { 26 | if (Set(() => IsSelected, ref _isSelected, value)) 27 | OnIsSelectedChanged(); 28 | } 29 | } 30 | 31 | protected virtual void OnIsSelectedChanged() 32 | { 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /Cog.Application/ViewModels/VowelBacknessVertex.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel; 2 | 3 | namespace SIL.Cog.Application.ViewModels 4 | { 5 | public enum VowelBackness 6 | { 7 | [Description("Front")] 8 | Front, 9 | [Description("Near-front")] 10 | NearFront, 11 | [Description("Central")] 12 | Central, 13 | [Description("Near-back")] 14 | NearBack, 15 | [Description("Back")] 16 | Back 17 | } 18 | 19 | public class VowelBacknessVertex : SegmentPropertyVertex 20 | { 21 | private readonly VowelBackness _backness; 22 | 23 | public VowelBacknessVertex(VowelBackness backness) 24 | { 25 | _backness = backness; 26 | } 27 | 28 | public VowelBackness Backness 29 | { 30 | get { return _backness; } 31 | } 32 | 33 | public override string StrRep 34 | { 35 | get { return GetEnumDescription(_backness); } 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Cog.Application/Services/IImageExportService.cs: -------------------------------------------------------------------------------- 1 | using SIL.Cog.Application.ViewModels; 2 | 3 | namespace SIL.Cog.Application.Services 4 | { 5 | public interface IImageExportService 6 | { 7 | bool ExportCurrentHierarchicalGraph(object ownerViewModel, HierarchicalGraphType type); 8 | bool ExportHierarchicalGraph(object ownerViewModel, HierarchicalGraphType graphType, ClusteringMethod clusteringMethod, SimilarityMetric similarityMetric); 9 | bool ExportCurrentNetworkGraph(object ownerViewModel); 10 | bool ExportNetworkGraph(object ownerViewModel, SimilarityMetric similarityMetric, double scoreFilter); 11 | bool ExportCurrentMap(object ownerViewModel); 12 | bool ExportGlobalCorrespondencesChart(object ownerViewModel, SyllablePosition syllablePosition, int frequencyFilter); 13 | bool ExportCurrentGlobalCorrespondencesChart(object ownerViewModel); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Cog.Domain/GeographicRegion.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using SIL.ObjectModel; 3 | 4 | namespace SIL.Cog.Domain 5 | { 6 | public class GeographicRegion : ObservableObject 7 | { 8 | private string _desc; 9 | private readonly ObservableList _coordinates; 10 | 11 | public GeographicRegion() 12 | { 13 | _coordinates = new ObservableList(); 14 | } 15 | 16 | public GeographicRegion(IEnumerable coordinates) 17 | { 18 | _coordinates = new ObservableList(coordinates); 19 | } 20 | 21 | public ObservableList Coordinates 22 | { 23 | get { return _coordinates; } 24 | } 25 | 26 | public string Description 27 | { 28 | get { return _desc; } 29 | set { Set(() => Description, ref _desc, value); } 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Cog.Presentation/Converters/InvertedBooleanToVisibilityConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | using System.Windows; 4 | using System.Windows.Data; 5 | 6 | namespace SIL.Cog.Presentation.Converters 7 | { 8 | public class InvertedBooleanToVisibilityConverter : IValueConverter 9 | { 10 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 11 | { 12 | if (!(value is bool)) 13 | return Binding.DoNothing; 14 | 15 | var f = (bool) value; 16 | return f ? Visibility.Collapsed : Visibility.Visible; 17 | } 18 | 19 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 20 | { 21 | if (!(value is Visibility)) 22 | return Binding.DoNothing; 23 | 24 | var v = (Visibility) value; 25 | return v == Visibility.Collapsed; 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Cog.Domain/Meaning.cs: -------------------------------------------------------------------------------- 1 | using SIL.ObjectModel; 2 | 3 | namespace SIL.Cog.Domain 4 | { 5 | public class Meaning : ObservableObject 6 | { 7 | private string _gloss; 8 | private string _category; 9 | 10 | public Meaning(string gloss, string category) 11 | { 12 | Gloss = gloss; 13 | Category = category; 14 | } 15 | 16 | public string Gloss 17 | { 18 | get { return _gloss; } 19 | set 20 | { 21 | if (Collection != null) 22 | Collection.ChangeMeaningGloss(this, value); 23 | Set(() => Gloss, ref _gloss, value); 24 | } 25 | } 26 | 27 | public string Category 28 | { 29 | get { return _category; } 30 | set { Set(() => Category, ref _category, value); } 31 | } 32 | 33 | internal MeaningCollection Collection { get; set; } 34 | 35 | public override string ToString() 36 | { 37 | return Gloss; 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /Cog.Domain/SoundCorrespondenceCollection.cs: -------------------------------------------------------------------------------- 1 | using SIL.ObjectModel; 2 | 3 | namespace SIL.Cog.Domain 4 | { 5 | public class SoundCorrespondenceCollection : KeyedBulkObservableList, SoundCorrespondence> 6 | { 7 | protected override UnorderedTuple GetKeyForItem(SoundCorrespondence item) 8 | { 9 | return UnorderedTuple.Create(item.Segment1, item.Segment2); 10 | } 11 | 12 | public bool TryGet(Segment seg1, Segment seg2, out SoundCorrespondence value) 13 | { 14 | return TryGet(UnorderedTuple.Create(seg1, seg2), out value); 15 | } 16 | 17 | public bool Contains(Segment seg1, Segment seg2) 18 | { 19 | return Contains(UnorderedTuple.Create(seg1, seg2)); 20 | } 21 | 22 | public bool Remove(Segment seg1, Segment seg2) 23 | { 24 | return Remove(UnorderedTuple.Create(seg1, seg2)); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Cog.Presentation/Views/GlobalCorrespondencesView.xaml.cs: -------------------------------------------------------------------------------- 1 | using System.Windows.Input; 2 | using GraphSharp.Controls; 3 | using SIL.Cog.Application.ViewModels; 4 | 5 | namespace SIL.Cog.Presentation.Views 6 | { 7 | /// 8 | /// Interaction logic for GlobalCorrespondencesView.xaml 9 | /// 10 | public partial class GlobalCorrespondencesView 11 | { 12 | public GlobalCorrespondencesView() 13 | { 14 | InitializeComponent(); 15 | BusyCursor.DisplayUntilIdle(); 16 | } 17 | 18 | private void Edge_OnPreviewMouseDown(object sender, MouseButtonEventArgs e) 19 | { 20 | var vm = (GlobalCorrespondencesViewModel) DataContext; 21 | var edgeControl = (EdgeControl) sender; 22 | var corr = (GlobalCorrespondencesGraphEdge) edgeControl.DataContext; 23 | vm.SelectedCorrespondence = vm.SelectedCorrespondence == corr ? null : corr; 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Cog.Presentation/Views/VarietyPairView.xaml.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Specialized; 2 | using System.ComponentModel; 3 | 4 | namespace SIL.Cog.Presentation.Views 5 | { 6 | /// 7 | /// Interaction logic for VarietyPairView.xaml 8 | /// 9 | public partial class VarietyPairView 10 | { 11 | public VarietyPairView() 12 | { 13 | InitializeComponent(); 14 | CorrespondenceDataGrid.ClipboardExporters.Clear(); 15 | ((INotifyCollectionChanged) CorrespondenceDataGrid.Items.SortDescriptions).CollectionChanged += OnSortChanged; 16 | } 17 | 18 | private void OnSortChanged(object sender, NotifyCollectionChangedEventArgs e) 19 | { 20 | var sortDescs = (SortDescriptionCollection) sender; 21 | if (e.Action == NotifyCollectionChangedAction.Reset && sortDescs.Count == 0) 22 | sortDescs.Add(new SortDescription("Lhs", ListSortDirection.Ascending)); 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Cog.Presentation/Converters/EnumMatchToVisibilityConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | using System.Windows; 4 | using System.Windows.Data; 5 | 6 | namespace SIL.Cog.Presentation.Converters 7 | { 8 | public class EnumMatchToVisibilityConverter : IValueConverter 9 | { 10 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 11 | { 12 | if (value == null || parameter == null) 13 | return Binding.DoNothing; 14 | 15 | string checkValue = value.ToString(); 16 | string targetValue = parameter.ToString(); 17 | return checkValue.Equals(targetValue, StringComparison.InvariantCultureIgnoreCase) ? Visibility.Visible : Visibility.Collapsed; 18 | } 19 | 20 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 21 | { 22 | throw new NotImplementedException(); 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Cog.Application/ViewModels/ExportHierarchicalGraphViewModel.cs: -------------------------------------------------------------------------------- 1 | using GalaSoft.MvvmLight; 2 | 3 | namespace SIL.Cog.Application.ViewModels 4 | { 5 | public class ExportHierarchicalGraphViewModel : ViewModelBase 6 | { 7 | private HierarchicalGraphType _graphType; 8 | private ClusteringMethod _clusteringMethod; 9 | private SimilarityMetric _similarityMetric; 10 | 11 | public HierarchicalGraphType GraphType 12 | { 13 | get { return _graphType; } 14 | set { Set(() => GraphType, ref _graphType, value); } 15 | } 16 | 17 | public ClusteringMethod ClusteringMethod 18 | { 19 | get { return _clusteringMethod; } 20 | set { Set(() => ClusteringMethod, ref _clusteringMethod, value); } 21 | } 22 | 23 | public SimilarityMetric SimilarityMetric 24 | { 25 | get { return _similarityMetric; } 26 | set { Set(() => SimilarityMetric, ref _similarityMetric, value); } 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Cog.Domain/NaturalClass.cs: -------------------------------------------------------------------------------- 1 | using SIL.Machine.Annotations; 2 | using SIL.Machine.FeatureModel; 3 | using SIL.Machine.NgramModeling; 4 | 5 | namespace SIL.Cog.Domain 6 | { 7 | public class NaturalClass : SoundClass 8 | { 9 | private readonly FeatureStruct _fs; 10 | 11 | public NaturalClass(string name, FeatureStruct fs) 12 | : base(name) 13 | { 14 | _fs = fs; 15 | _fs.Freeze(); 16 | } 17 | 18 | public FeatureSymbol Type 19 | { 20 | get { return (FeatureSymbol) _fs.GetValue(CogFeatureSystem.Type); } 21 | } 22 | 23 | public FeatureStruct FeatureStruct 24 | { 25 | get { return _fs; } 26 | } 27 | 28 | public override bool Matches(ShapeNode leftNode, Ngram target, ShapeNode rightNode) 29 | { 30 | foreach (Segment seg in target) 31 | { 32 | if (_fs.IsUnifiable(seg.FeatureStruct)) 33 | return true; 34 | } 35 | return false; 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Cog.Domain/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("SIL.Cog.Domain")] 9 | [assembly: AssemblyDescription("")] 10 | 11 | // Setting ComVisible to false makes the types in this assembly not visible 12 | // to COM components. If you need to access a type in this assembly from 13 | // COM, set the ComVisible attribute to true on that type. 14 | [assembly: ComVisible(false)] 15 | 16 | // The following GUID is for the ID of the typelib if this project is exposed to COM 17 | [assembly: Guid("e20a24a7-582d-4b61-bebe-4a8b9c2dad3e")] 18 | 19 | [assembly: InternalsVisibleTo("SIL.Cog.Domain.Tests")] -------------------------------------------------------------------------------- /Cog.Presentation/Converters/IndexToColorConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | using System.Windows.Data; 4 | using System.Windows.Media; 5 | 6 | namespace SIL.Cog.Presentation.Converters 7 | { 8 | public class IndexToColorConverter : IValueConverter 9 | { 10 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 11 | { 12 | var index = (int) value; 13 | if (index == -1) 14 | return Colors.Transparent; 15 | 16 | var seed = (Color) parameter; 17 | HslColor hsl = HslColor.FromColor(seed); 18 | for (int i = 0; i < index; i++) 19 | { 20 | hsl.H += 0.618033988749895; 21 | hsl.H %= 1; 22 | } 23 | 24 | return hsl.ToColor(); 25 | } 26 | 27 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 28 | { 29 | throw new NotImplementedException(); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Cog.Presentation/Converters/PercentageToStrokeThicknessConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | using System.Windows.Data; 4 | 5 | namespace SIL.Cog.Presentation.Converters 6 | { 7 | public class PercentageToStrokeThicknessConverter : IMultiValueConverter 8 | { 9 | public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) 10 | { 11 | if (!(values[0] is double) || !(values[1] is int) || !(values[2] is int)) 12 | return Binding.DoNothing; 13 | 14 | var pcnt = (double) values[0]; 15 | 16 | var maxThickness = (int) values[1]; 17 | var minThickness = (int) values[2]; 18 | 19 | return minThickness + ((maxThickness - minThickness) * pcnt); 20 | } 21 | 22 | public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) 23 | { 24 | throw new NotImplementedException(); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Cog.Presentation/Converters/PercentageToWidthConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | using System.Windows.Data; 4 | 5 | namespace SIL.Cog.Presentation.Converters 6 | { 7 | public class PercentageToWidthConverter : IMultiValueConverter 8 | { 9 | public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) 10 | { 11 | if (values[0] is double && values[1] is double) 12 | { 13 | var currentValue = (double) values[0]; 14 | var maxValue = Math.Max(0.2, (double) values[1]); 15 | var maxWidth = int.Parse((string) parameter, CultureInfo.InvariantCulture); 16 | 17 | return maxWidth * (currentValue / maxValue); 18 | } 19 | return null; 20 | } 21 | 22 | public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) 23 | { 24 | throw new NotImplementedException(); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Cog.Application/Collections/BindableList.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Collections.Specialized; 3 | using SIL.ObjectModel; 4 | 5 | namespace SIL.Cog.Application.Collections 6 | { 7 | public class BindableList : BulkObservableList 8 | { 9 | public override event NotifyCollectionChangedEventHandler CollectionChanged; 10 | 11 | public BindableList() 12 | { 13 | } 14 | 15 | public BindableList(IEnumerable items) 16 | : base(items) 17 | { 18 | } 19 | 20 | protected override void OnCollectionChanged(NotifyCollectionChangedEventArgs e) 21 | { 22 | if (Updating) 23 | return; 24 | 25 | NotifyCollectionChangedEventHandler collectionChanged = CollectionChanged; 26 | if (collectionChanged != null) 27 | { 28 | using (BlockReentrancy()) 29 | BindableCollectionUtils.InvokeCollectionChanged(collectionChanged, this, e); 30 | } 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /Cog.CommandLine.Tests/CognatesTests.cs: -------------------------------------------------------------------------------- 1 | using NUnit.Framework; 2 | 3 | namespace SIL.Cog.CommandLine.Tests 4 | { 5 | [TestFixture] 6 | public class CognatesTests : TestBase 7 | { 8 | [Test, Sequential] 9 | public void CheckCognates( 10 | [Values( 11 | "a a", 12 | "a b", 13 | "chair apple", 14 | "apple chair", 15 | "chair cheer", 16 | "apple apple", 17 | "edit editable", 18 | "ˈɛdɪt ˈɛdɪtəbl̩")] 19 | string input, 20 | [Values( 21 | "a a True 1", 22 | "a b False 0", 23 | "chair apple False 0.2", 24 | "apple chair False 0.2", 25 | "chair cheer True 0.75", 26 | "apple apple True 1", 27 | "edit editable False 0.571428571428571", 28 | "ˈɛdɪt ˈɛdɪtəbl̩ False 0.666666666666667")] 29 | string expectedOutput) 30 | { 31 | var aligner = new CognatesVerb(); 32 | CheckVerbOutput(input, expectedOutput, aligner, true); 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /Cog.Application/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("SIL.Cog.Application")] 9 | [assembly: AssemblyDescription("")] 10 | 11 | // Setting ComVisible to false makes the types in this assembly not visible 12 | // to COM components. If you need to access a type in this assembly from 13 | // COM, set the ComVisible attribute to true on that type. 14 | [assembly: ComVisible(false)] 15 | 16 | // The following GUID is for the ID of the typelib if this project is exposed to COM 17 | [assembly: Guid("d2d55066-11df-4665-8652-bc35671ce309")] 18 | 19 | [assembly: InternalsVisibleTo("SIL.Cog.Application.Tests")] -------------------------------------------------------------------------------- /Cog.Application/ViewModels/VowelHeightVertex.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel; 2 | 3 | namespace SIL.Cog.Application.ViewModels 4 | { 5 | public enum VowelHeight 6 | { 7 | [Description("Close")] 8 | Close, 9 | [Description("Near-close")] 10 | NearClose, 11 | [Description("Close-mid")] 12 | CloseMid, 13 | [Description("Mid")] 14 | Mid, 15 | [Description("Open-mid")] 16 | OpenMid, 17 | [Description("Near-open")] 18 | NearOpen, 19 | [Description("Open")] 20 | Open 21 | } 22 | 23 | public class VowelHeightVertex : SegmentPropertyVertex 24 | { 25 | private readonly VowelHeight _height; 26 | 27 | public VowelHeightVertex(VowelHeight height) 28 | { 29 | _height = height; 30 | } 31 | 32 | public VowelHeight Height 33 | { 34 | get { return _height; } 35 | } 36 | 37 | public override string StrRep 38 | { 39 | get { return GetEnumDescription(_height); } 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /Cog.Domain/Config/Components/UnionSegmentMappingsConfig.cs: -------------------------------------------------------------------------------- 1 | using System.Linq; 2 | using System.Xml.Linq; 3 | using SIL.Cog.Domain.Components; 4 | 5 | namespace SIL.Cog.Domain.Config.Components 6 | { 7 | public class UnionSegmentMappingsConfig : IComponentConfig 8 | { 9 | public ISegmentMappings Load(SegmentPool segmentPool, CogProject project, XElement elem) 10 | { 11 | return new UnionSegmentMappings(elem.Elements(ConfigManager.Cog + "SegmentMappings").Select(e => ConfigManager.LoadComponent(segmentPool, project, e))); 12 | } 13 | 14 | public void Save(ISegmentMappings component, XElement elem) 15 | { 16 | var unionSegmentMappings = (UnionSegmentMappings) component; 17 | foreach (ISegmentMappings segmentMappings in unionSegmentMappings.SegmentMappingsComponents) 18 | elem.Add(ConfigManager.SaveComponent("SegmentMappings", segmentMappings)); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Cog.Domain/Symbol.cs: -------------------------------------------------------------------------------- 1 | using SIL.Machine.FeatureModel; 2 | 3 | namespace SIL.Cog.Domain 4 | { 5 | public class Symbol 6 | { 7 | private readonly string _strRep; 8 | private readonly FeatureStruct _fs; 9 | private readonly bool _overwrite; 10 | 11 | public Symbol(string strRep) 12 | : this(strRep, FeatureStruct.New().Value) 13 | { 14 | 15 | } 16 | 17 | public Symbol(string strRep, FeatureStruct fs) 18 | : this(strRep, fs, false) 19 | { 20 | 21 | } 22 | 23 | public Symbol(string strRep, FeatureStruct fs, bool overwrite) 24 | { 25 | _strRep = strRep.ToLowerInvariant(); 26 | _fs = fs; 27 | _overwrite = overwrite; 28 | } 29 | 30 | public string StrRep 31 | { 32 | get { return _strRep; } 33 | } 34 | 35 | public FeatureStruct FeatureStruct 36 | { 37 | get { return _fs; } 38 | } 39 | 40 | public bool Overwrite 41 | { 42 | get { return _overwrite; } 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /Cog.Application/Services/IGraphService.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using QuickGraph; 3 | using SIL.Cog.Application.ViewModels; 4 | using SIL.Cog.Domain; 5 | 6 | namespace SIL.Cog.Application.Services 7 | { 8 | public interface IGraphService 9 | { 10 | IBidirectionalGraph GenerateHierarchicalGraph(HierarchicalGraphType graphType, 11 | ClusteringMethod clusteringMethod, SimilarityMetric similarityMetric); 12 | 13 | IBidirectionalGraph GenerateNetworkGraph(SimilarityMetric similarityMetric); 14 | 15 | IBidirectionalGraph GenerateGlobalCorrespondencesGraph(SyllablePosition syllablePosition); 16 | IBidirectionalGraph GenerateGlobalCorrespondencesGraph(SyllablePosition syllablePosition, IEnumerable varieties); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Cog.Application/ViewModels/HierarchicalGraphVertex.cs: -------------------------------------------------------------------------------- 1 | using SIL.Cog.Domain; 2 | 3 | namespace SIL.Cog.Application.ViewModels 4 | { 5 | public class HierarchicalGraphVertex : WrapperViewModel 6 | { 7 | private readonly Variety _variety; 8 | private readonly double _depth; 9 | 10 | public HierarchicalGraphVertex(double depth) 11 | { 12 | _depth = depth; 13 | } 14 | 15 | public HierarchicalGraphVertex(Variety variety, double depth) 16 | : base(variety) 17 | { 18 | _variety = variety; 19 | _depth = depth; 20 | } 21 | 22 | public string Name 23 | { 24 | get 25 | { 26 | if (_variety == null) 27 | return ""; 28 | return _variety.Name; 29 | } 30 | } 31 | 32 | public double Depth 33 | { 34 | get { return _depth; } 35 | } 36 | 37 | public bool IsCluster 38 | { 39 | get { return _variety == null; } 40 | } 41 | 42 | public override string ToString() 43 | { 44 | return Name; 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /Cog.Domain.Tests/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /Cog.Presentation/Converters/PercentageToSpectrumColorConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | using System.Windows.Data; 4 | using System.Windows.Media; 5 | 6 | namespace SIL.Cog.Presentation.Converters 7 | { 8 | public class PercentageToSpectrumColorConverter : IValueConverter 9 | { 10 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 11 | { 12 | if (!(value is double)) 13 | return null; 14 | 15 | var percentage = (double) value; 16 | 17 | if (percentage < 0) 18 | return new SolidColorBrush(Colors.White); 19 | 20 | double hue = (1.0 - (percentage / 100.0)) * (2.0 / 3.0); 21 | 22 | HslColor newColor = HslColor.FromHsl(hue, 1.0, 0.5); 23 | return new SolidColorBrush(newColor.ToColor()); 24 | } 25 | 26 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 27 | { 28 | throw new NotImplementedException(); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Cog.Domain/Config/Components/SimpleSyllabifierConfig.cs: -------------------------------------------------------------------------------- 1 | using System.Xml.Linq; 2 | using SIL.Cog.Domain.Components; 3 | 4 | namespace SIL.Cog.Domain.Config.Components 5 | { 6 | public class SimpleSyllabifierConfig : IComponentConfig> 7 | { 8 | public IProcessor Load(SegmentPool segmentPool, CogProject project, XElement elem) 9 | { 10 | var combineVowels = (bool?) elem.Element(ConfigManager.Cog + "CombineVowels") ?? true; 11 | var combineCons = (bool?) elem.Element(ConfigManager.Cog + "CombineConsonants") ?? true; 12 | return new SimpleSyllabifier(combineVowels, combineCons); 13 | } 14 | 15 | public void Save(IProcessor component, XElement elem) 16 | { 17 | var syllabifier = (SimpleSyllabifier) component; 18 | elem.Add(new XElement(ConfigManager.Cog + "CombineVowels", syllabifier.CombineVowels)); 19 | elem.Add(new XElement(ConfigManager.Cog + "CombineConsonants", syllabifier.CombineConsonants)); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Cog.Domain/SoundCorrespondence.cs: -------------------------------------------------------------------------------- 1 | using SIL.ObjectModel; 2 | 3 | namespace SIL.Cog.Domain 4 | { 5 | public class SoundCorrespondence : ObservableObject 6 | { 7 | private readonly Segment _segment1; 8 | private readonly Segment _segment2; 9 | private int _frequency; 10 | private readonly BulkObservableList _wordPairs; 11 | 12 | public SoundCorrespondence(Segment segment1, Segment segment2) 13 | { 14 | _segment1 = segment1; 15 | _segment2 = segment2; 16 | _wordPairs = new BulkObservableList(); 17 | } 18 | 19 | public Segment Segment1 20 | { 21 | get { return _segment1; } 22 | } 23 | 24 | public Segment Segment2 25 | { 26 | get { return _segment2; } 27 | } 28 | 29 | public int Frequency 30 | { 31 | get { return _frequency; } 32 | set { Set(() => Frequency, ref _frequency, value); } 33 | } 34 | 35 | public BulkObservableList WordPairs 36 | { 37 | get { return _wordPairs; } 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /Cog.Domain/Config/Components/PoorMansAffixIdentifierConfig.cs: -------------------------------------------------------------------------------- 1 | using System.Xml.Linq; 2 | using SIL.Cog.Domain.Components; 3 | 4 | namespace SIL.Cog.Domain.Config.Components 5 | { 6 | public class PoorMansAffixIdentifierConfig : IComponentConfig> 7 | { 8 | public IProcessor Load(SegmentPool segmentPool, CogProject project, XElement elem) 9 | { 10 | var stemThreshold = (double) elem.Element(ConfigManager.Cog + "AffixThreshold"); 11 | var maxAffixLen = (int) elem.Element(ConfigManager.Cog + "MaxAffixLength"); 12 | return new PoorMansAffixIdentifier(segmentPool, stemThreshold, maxAffixLen); 13 | } 14 | 15 | public void Save(IProcessor component, XElement elem) 16 | { 17 | var identifier = (PoorMansAffixIdentifier) component; 18 | elem.Add(new XElement(ConfigManager.Cog + "AffixThreshold", identifier.Threshold)); 19 | elem.Add(new XElement(ConfigManager.Cog + "MaxAffixLength", identifier.MaxAffixLength)); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Cog.Domain/Config/Migrations/ConfigMigration1_2.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Diagnostics; 3 | using System.Linq; 4 | using System.Xml.Linq; 5 | 6 | namespace SIL.Cog.Domain.Config.Migrations 7 | { 8 | internal class ConfigMigration1_2 : IConfigMigration 9 | { 10 | public XNamespace FromNamespace 11 | { 12 | get { return "http://www.sil.org/CogProject/1.0"; } 13 | } 14 | 15 | public void Migrate(XDocument doc) 16 | { 17 | XElement root = doc.Root; 18 | Debug.Assert(root != null); 19 | 20 | IEnumerable elems = root.Elements(FromNamespace + "VarietyPairProcessors").Elements(FromNamespace + "VarietyPairProcessor") 21 | .Where(e => (string) e.Attribute(ConfigManager.Xsi + "type") == "CognicityWordPairGenerator"); 22 | foreach (XElement elem in elems) 23 | elem.SetAttributeValue(ConfigManager.Xsi + "type", "CognacyWordPairGenerator"); 24 | 25 | root.SetDefaultNamespace("http://www.sil.org/CogProject/1.2"); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Cog.Presentation/Views/AlineView.xaml.cs: -------------------------------------------------------------------------------- 1 | using System.Linq; 2 | using System.Windows; 3 | using System.Windows.Controls; 4 | using SIL.Cog.Presentation.Controls; 5 | 6 | namespace SIL.Cog.Presentation.Views 7 | { 8 | /// 9 | /// Interaction logic for AlineView.xaml 10 | /// 11 | public partial class AlineView 12 | { 13 | public AlineView() 14 | { 15 | InitializeComponent(); 16 | } 17 | 18 | private void TreeListView_Loaded(object sender, RoutedEventArgs e) 19 | { 20 | var treeListView = (TreeListView) sender; 21 | double w = treeListView.ActualWidth; 22 | ScrollViewer sv = treeListView.FindVisualDescendants().First(); 23 | if (sv.ComputedVerticalScrollBarVisibility == Visibility.Visible) 24 | w -= SystemParameters.VerticalScrollBarWidth; 25 | double total = 0; 26 | for (int i = 1; i < treeListView.Columns.Count; i++) 27 | total += treeListView.Columns[i].ActualWidth; 28 | treeListView.Columns[0].Width = w - total; 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Cog.Presentation/Views/HierarchicalGraphView.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Windows; 3 | 4 | namespace SIL.Cog.Presentation.Views 5 | { 6 | /// 7 | /// Interaction logic for HierarchicalGraphView.xaml 8 | /// 9 | public partial class HierarchicalGraphView 10 | { 11 | public HierarchicalGraphView() 12 | { 13 | InitializeComponent(); 14 | BusyCursor.DisplayUntilIdle(); 15 | } 16 | 17 | private void GraphLayout_OnLayoutFinished(object sender, EventArgs e) 18 | { 19 | ZoomControl.ZoomToFill(); 20 | } 21 | 22 | private void GraphLayout_OnIsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e) 23 | { 24 | if (GraphLayout.IsVisible) 25 | ZoomControl.ZoomToFill(); 26 | } 27 | 28 | private void DendrogramLayout_OnIsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e) 29 | { 30 | if (DendrogramLayout.IsVisible) 31 | ZoomControl.ZoomToFill(); 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /Cog.Application/ViewModels/ComponentSettingsViewModelBase.cs: -------------------------------------------------------------------------------- 1 | using System.Diagnostics; 2 | using System.Windows.Input; 3 | using GalaSoft.MvvmLight.Command; 4 | 5 | namespace SIL.Cog.Application.ViewModels 6 | { 7 | public abstract class ComponentSettingsViewModelBase : ChangeTrackingViewModelBase 8 | { 9 | private readonly string _displayName; 10 | private readonly string _wikiTopic; 11 | private readonly ICommand _helpCommand; 12 | 13 | protected ComponentSettingsViewModelBase(string displayName, string wikiTopic) 14 | { 15 | _displayName = displayName; 16 | _wikiTopic = wikiTopic; 17 | _helpCommand = new RelayCommand(() => Process.Start(string.Format("https://github.com/sillsdev/cog/wiki/{0}", _wikiTopic))); 18 | } 19 | 20 | public string DisplayName 21 | { 22 | get { return _displayName; } 23 | } 24 | 25 | public ICommand HelpCommand 26 | { 27 | get { return _helpCommand; } 28 | } 29 | 30 | public abstract void Setup(); 31 | 32 | public abstract object UpdateComponent(); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /Cog.Presentation/Converters/EnumMatchToBooleanConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | using System.Windows.Data; 4 | 5 | namespace SIL.Cog.Presentation.Converters 6 | { 7 | public class EnumMatchToBooleanConverter : IValueConverter 8 | { 9 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 10 | { 11 | if (value == null || parameter == null) 12 | return false; 13 | 14 | string checkValue = value.ToString(); 15 | string targetValue = parameter.ToString(); 16 | return checkValue.Equals(targetValue, StringComparison.InvariantCultureIgnoreCase); 17 | } 18 | 19 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 20 | { 21 | if (value == null || parameter == null) 22 | return null; 23 | 24 | var useValue = (bool)value; 25 | string targetValue = parameter.ToString(); 26 | if (useValue) 27 | return Enum.Parse(targetType, targetValue); 28 | 29 | return null; 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Cog.Presentation/Converters/LevelToIndentConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Windows.Data; 3 | using System.Globalization; 4 | 5 | namespace SIL.Cog.Presentation.Converters 6 | { 7 | /// 8 | /// Convert Level to left margin 9 | /// Pass a prarameter if you want a unit length other than 19.0. 10 | /// 11 | public class LevelToIndentConverter : IValueConverter 12 | { 13 | public object Convert(object o, Type type, object parameter, CultureInfo culture) 14 | { 15 | Double indentSize = 0; 16 | if (parameter != null) 17 | Double.TryParse(parameter.ToString(), out indentSize); 18 | 19 | return ((int)o) * indentSize; 20 | //else 21 | // return new Thickness((int)o * c_IndentSize, 0, 0, 0); 22 | } 23 | 24 | public object ConvertBack(object o, Type type, object parameter, CultureInfo culture) 25 | { 26 | throw new NotSupportedException(); 27 | } 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /Cog.Presentation/App.xaml.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | using GalaSoft.MvvmLight.Threading; 3 | using SIL.Cog.Presentation.Properties; 4 | using SIL.Cog.Presentation.Views; 5 | 6 | namespace SIL.Cog.Presentation 7 | { 8 | /// 9 | /// Interaction logic for App.xaml 10 | /// 11 | public partial class App 12 | { 13 | static App() 14 | { 15 | DispatcherHelper.Initialize(); 16 | } 17 | 18 | protected override void OnStartup(StartupEventArgs e) 19 | { 20 | if (Settings.Default.NeedsUpgrade) 21 | { 22 | Settings.Default.Upgrade(); 23 | Settings.Default.NeedsUpgrade = false; 24 | Settings.Default.Save(); 25 | } 26 | 27 | base.OnStartup(e); 28 | 29 | ShutdownMode = ShutdownMode.OnExplicitShutdown; 30 | var locator = (ViewModelLocator) Resources["Locator"]; 31 | if (locator.Main.Init()) 32 | { 33 | var mainWindow = new MainWindow(); 34 | ShutdownMode = ShutdownMode.OnLastWindowClose; 35 | mainWindow.Show(); 36 | } 37 | else 38 | { 39 | Shutdown(); 40 | } 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /Cog.Presentation/Views/TaskAreaIntegerView.xaml: -------------------------------------------------------------------------------- 1 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /Cog.Presentation/Converters/BackgroundToForegroundConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | using System.Windows.Data; 4 | using System.Windows.Media; 5 | 6 | namespace SIL.Cog.Presentation.Converters 7 | { 8 | public class BackgroundToForegroundConverter : IValueConverter 9 | { 10 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 11 | { 12 | var brush = value as SolidColorBrush; 13 | Color color; 14 | if (brush == null) 15 | { 16 | color = Colors.Black; 17 | } 18 | else 19 | { 20 | Color bgColor = brush.Color; 21 | // Counting the perceptive luminance - human eye favors green color... 22 | double a = 1 - ( 0.299 * bgColor.R + 0.587 * bgColor.G + 0.114 * bgColor.B) / 255; 23 | color = a < 0.5 ? Colors.Black : Colors.White; 24 | } 25 | return new SolidColorBrush(color); 26 | } 27 | 28 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 29 | { 30 | throw new NotImplementedException(); 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /Cog.Application/ViewModels/SegmentViewModel.cs: -------------------------------------------------------------------------------- 1 | using GalaSoft.MvvmLight; 2 | using SIL.Cog.Domain; 3 | 4 | namespace SIL.Cog.Application.ViewModels 5 | { 6 | public class SegmentViewModel : ViewModelBase 7 | { 8 | private readonly Segment _segment; 9 | private readonly SoundType _type; 10 | 11 | public SegmentViewModel(Segment segment) 12 | { 13 | _segment = segment; 14 | _type = _segment.Type == CogFeatureSystem.ConsonantType ? SoundType.Consonant : SoundType.Vowel; 15 | } 16 | 17 | public SegmentViewModel(Segment segment, SoundType type) 18 | { 19 | _segment = segment; 20 | _type = type; 21 | } 22 | 23 | public string StrRep 24 | { 25 | get { return _segment == null ? "-" : _segment.StrRep; } 26 | } 27 | 28 | public SoundType Type 29 | { 30 | get { return _type; } 31 | } 32 | 33 | public string FeatureStructure 34 | { 35 | get { return _segment == null ? string.Empty : _segment.FeatureStruct.GetString(); } 36 | } 37 | 38 | internal Segment DomainSegment 39 | { 40 | get { return _segment; } 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /Cog.Domain/Components/UnionSegmentMappings.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Linq; 3 | using SIL.Machine.Annotations; 4 | using SIL.Machine.NgramModeling; 5 | using SIL.ObjectModel; 6 | 7 | namespace SIL.Cog.Domain.Components 8 | { 9 | public class UnionSegmentMappings : ISegmentMappings 10 | { 11 | private readonly ReadOnlyList _segmentMappingsComponents; 12 | 13 | public UnionSegmentMappings(IEnumerable segmentMappingsComponents) 14 | { 15 | _segmentMappingsComponents = new ReadOnlyList(segmentMappingsComponents.ToList()); 16 | } 17 | 18 | public ReadOnlyList SegmentMappingsComponents 19 | { 20 | get { return _segmentMappingsComponents; } 21 | } 22 | 23 | public bool IsMapped(ShapeNode leftNode1, Ngram target1, ShapeNode rightNode1, ShapeNode leftNode2, Ngram target2, ShapeNode rightNode2) 24 | { 25 | return _segmentMappingsComponents.Any(sm => sm.IsMapped(leftNode1, target1, rightNode1, leftNode2, target2, rightNode2)); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Cog.Presentation/Controls/ScrollingMergedHeaderCellDecorator.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Windows; 3 | using System.Windows.Controls; 4 | using System.Windows.Media; 5 | 6 | namespace SIL.Cog.Presentation.Controls 7 | { 8 | public class ScrollingMergedHeaderCellDecorator : Decorator 9 | { 10 | public ScrollingMergedHeaderCellDecorator() 11 | { 12 | Focusable = false; 13 | } 14 | 15 | protected override Size ArrangeOverride( Size arrangeSize ) 16 | { 17 | // We need to take ScrollingCellsDecoratorClipOffset into consideration 18 | // in case an animated column reordering is in progress 19 | double widthOffset = Math.Max(0, arrangeSize.Width); 20 | 21 | // Try to get the RectangleGeometry from the Clip 22 | // to avoid recreating one per call 23 | var clip = Clip as RectangleGeometry; 24 | if (clip == null) 25 | { 26 | clip = new RectangleGeometry(); 27 | Clip = clip; 28 | } 29 | 30 | clip.Rect = new Rect(0, -0.5d, widthOffset, arrangeSize.Height + 1d); 31 | return base.ArrangeOverride(arrangeSize); 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /Cog.Domain/Config/Components/TypeSegmentMappingsConfig.cs: -------------------------------------------------------------------------------- 1 | using System.Xml.Linq; 2 | using SIL.Cog.Domain.Components; 3 | 4 | namespace SIL.Cog.Domain.Config.Components 5 | { 6 | public class TypeSegmentMappingsConfig : IComponentConfig 7 | { 8 | public ISegmentMappings Load(SegmentPool segmentPool, CogProject project, XElement elem) 9 | { 10 | var vowelMappings = ConfigManager.LoadComponent(segmentPool, project, elem.Element(ConfigManager.Cog + "VowelMappings")); 11 | var consonantMappings = ConfigManager.LoadComponent(segmentPool, project, elem.Element(ConfigManager.Cog + "ConsonantMappings")); 12 | return new TypeSegmentMappings(vowelMappings, consonantMappings); 13 | } 14 | 15 | public void Save(ISegmentMappings component, XElement elem) 16 | { 17 | var ssmappings = (TypeSegmentMappings) component; 18 | elem.Add(ConfigManager.SaveComponent("VowelMappings", ssmappings.VowelMappings)); 19 | elem.Add(ConfigManager.SaveComponent("ConsonantMappings", ssmappings.ConsonantMappings)); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Cog.Presentation/Converters/EnumToFriendlyNameConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.ComponentModel; 3 | using System.Globalization; 4 | using System.Reflection; 5 | using System.Windows.Data; 6 | 7 | namespace SIL.Cog.Presentation.Converters 8 | { 9 | public class EnumToFriendlyNameConverter : IValueConverter 10 | { 11 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 12 | { 13 | if (value != null) 14 | { 15 | FieldInfo fi = value.GetType().GetField(value.ToString()); 16 | 17 | if (fi != null) 18 | { 19 | var attributes = (DescriptionAttribute[]) fi.GetCustomAttributes(typeof(DescriptionAttribute), false); 20 | 21 | return ((attributes.Length > 0) && (!String.IsNullOrEmpty(attributes[0].Description))) 22 | ? attributes[0].Description : value.ToString(); 23 | } 24 | } 25 | 26 | return string.Empty; 27 | } 28 | 29 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 30 | { 31 | throw new NotImplementedException(); 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /Cog.Application/Services/FileType.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace SIL.Cog.Application.Services 5 | { 6 | public class FileType 7 | { 8 | public FileType(string description, params string[] fileExtensions) 9 | { 10 | if (string.IsNullOrEmpty(description)) 11 | throw new ArgumentException("The description must not be null or empty.", nameof(description)); 12 | if (fileExtensions.Length == 0) 13 | throw new ArgumentException("A file extension must be specified.", nameof(fileExtensions)); 14 | 15 | Description = description; 16 | foreach (string ext in fileExtensions) 17 | { 18 | if (string.IsNullOrEmpty(ext)) 19 | throw new ArgumentException("A file extension cannot be empty.", nameof(fileExtensions)); 20 | if (ext[0] != '.') 21 | throw new ArgumentException("A file extension must start with the '.' character.", nameof(fileExtensions)); 22 | } 23 | FileExtensions = fileExtensions; 24 | } 25 | 26 | public string Description { get; } 27 | public IEnumerable FileExtensions { get; } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Cog.Application/ViewModels/ConsonantMannerVertex.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel; 2 | 3 | namespace SIL.Cog.Application.ViewModels 4 | { 5 | public enum ConsonantManner 6 | { 7 | [Description("Nasal")] 8 | Nasal, 9 | [Description("Stop")] 10 | Stop, 11 | [Description("Affricate")] 12 | Affricate, 13 | [Description("Fricative")] 14 | Fricative, 15 | [Description("Approximant")] 16 | Approximant, 17 | [Description("Flap or tap")] 18 | FlapOrTap, 19 | [Description("Trill")] 20 | Trill, 21 | [Description("Lateral fricative")] 22 | LateralFricative, 23 | [Description("Lateral approximant")] 24 | LateralApproximant 25 | } 26 | 27 | public class ConsonantMannerVertex : SegmentPropertyVertex 28 | { 29 | private readonly ConsonantManner _manner; 30 | 31 | public ConsonantMannerVertex(ConsonantManner manner) 32 | { 33 | _manner = manner; 34 | } 35 | 36 | public ConsonantManner Manner 37 | { 38 | get { return _manner; } 39 | } 40 | 41 | public override string StrRep 42 | { 43 | get { return GetEnumDescription(_manner); } 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /Cog.Application/ViewModels/TaskAreaCommandGroupViewModel.cs: -------------------------------------------------------------------------------- 1 | using SIL.ObjectModel; 2 | 3 | namespace SIL.Cog.Application.ViewModels 4 | { 5 | public class TaskAreaCommandGroupViewModel : TaskAreaViewModelBase 6 | { 7 | private readonly ReadOnlyList _commands; 8 | private TaskAreaCommandViewModel _selectedCommand; 9 | 10 | public TaskAreaCommandGroupViewModel(params TaskAreaCommandViewModel[] commands) 11 | : this(null, commands) 12 | { 13 | 14 | } 15 | 16 | public TaskAreaCommandGroupViewModel(string displayName, params TaskAreaCommandViewModel[] commands) 17 | : base(displayName) 18 | { 19 | _commands = new ReadOnlyList(commands); 20 | if (_commands.Count > 0) 21 | _selectedCommand = _commands[0]; 22 | } 23 | 24 | public ReadOnlyList Commands 25 | { 26 | get { return _commands; } 27 | } 28 | 29 | public TaskAreaCommandViewModel SelectedCommand 30 | { 31 | get { return _selectedCommand; } 32 | set { Set(() => SelectedCommand, ref _selectedCommand, value); } 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /Cog.Domain/Config/Components/ThresholdSegmentMappingsConfig.cs: -------------------------------------------------------------------------------- 1 | using System.Diagnostics; 2 | using System.Xml.Linq; 3 | using SIL.Cog.Domain.Components; 4 | 5 | namespace SIL.Cog.Domain.Config.Components 6 | { 7 | public class ThresholdSegmentMappingsConfig : IComponentConfig 8 | { 9 | public ISegmentMappings Load(SegmentPool segmentPool, CogProject project, XElement elem) 10 | { 11 | var threshold = (int) elem.Element(ConfigManager.Cog + "Threshold"); 12 | XElement alignerElem = elem.Element(ConfigManager.Cog + "ApplicableWordAligner"); 13 | Debug.Assert(alignerElem != null); 14 | var alignerID = (string) alignerElem.Attribute("ref"); 15 | return new ThresholdSegmentMappings(project, threshold, alignerID); 16 | } 17 | 18 | public void Save(ISegmentMappings component, XElement elem) 19 | { 20 | var identifier = (ThresholdSegmentMappings) component; 21 | elem.Add(new XElement(ConfigManager.Cog + "Threshold", identifier.Threshold)); 22 | elem.Add(new XElement(ConfigManager.Cog + "ApplicableWordAligner", new XAttribute("ref", identifier.AlignerID))); 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Cog.Application/ViewModels/SimilarityMatrixVarietyViewModel.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using SIL.Cog.Domain; 3 | using SIL.ObjectModel; 4 | 5 | namespace SIL.Cog.Application.ViewModels 6 | { 7 | public class SimilarityMatrixVarietyViewModel : VarietyViewModel 8 | { 9 | private readonly ReadOnlyList _varietyPairs; 10 | 11 | public SimilarityMatrixVarietyViewModel(SimilarityMetric similarityMetric, IEnumerable varieties, Variety variety) 12 | : base(variety) 13 | { 14 | var varietyPairs = new List(); 15 | foreach (Variety v in varieties) 16 | { 17 | VarietyPair vp; 18 | varietyPairs.Add(variety.VarietyPairs.TryGet(v, out vp) ? new SimilarityMatrixVarietyPairViewModel(similarityMetric, variety, vp) : new SimilarityMatrixVarietyPairViewModel(variety, v)); 19 | } 20 | _varietyPairs = new ReadOnlyList(varietyPairs); 21 | } 22 | 23 | public ReadOnlyList VarietyPairs 24 | { 25 | get { return _varietyPairs; } 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Cog.Application/ViewModels/GeographicalVarietyViewModel.cs: -------------------------------------------------------------------------------- 1 | using SIL.Cog.Application.Collections; 2 | using SIL.Cog.Domain; 3 | using SIL.ObjectModel; 4 | 5 | namespace SIL.Cog.Application.ViewModels 6 | { 7 | public class GeographicalVarietyViewModel : VarietyViewModel 8 | { 9 | public delegate GeographicalVarietyViewModel Factory(Variety variety); 10 | 11 | private readonly MirroredBindableList _regions; 12 | private int _clusterIndex; 13 | 14 | public GeographicalVarietyViewModel(GeographicalRegionViewModel.Factory regionFactory, Variety variety) 15 | : base(variety) 16 | { 17 | _regions = new MirroredBindableList(variety.Regions, region => regionFactory(this, region), vm => vm.DomainRegion); 18 | _clusterIndex = -1; 19 | } 20 | 21 | public ReadOnlyObservableList Regions 22 | { 23 | get { return _regions; } 24 | } 25 | 26 | public int ClusterIndex 27 | { 28 | get { return _clusterIndex; } 29 | set { Set(() => ClusterIndex, ref _clusterIndex, value); } 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Cog.Presentation/Behaviors/MergedHeader.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Windows; 3 | 4 | namespace SIL.Cog.Presentation.Behaviors 5 | { 6 | public class MergedHeader : DependencyObject 7 | { 8 | public MergedHeader() 9 | { 10 | SetValue(ColumnNamesPropertyKey, new List()); 11 | } 12 | 13 | private static readonly DependencyPropertyKey ColumnNamesPropertyKey = DependencyProperty.RegisterReadOnly("ColumnNames", typeof(List), 14 | typeof(MergedHeader), new FrameworkPropertyMetadata(new List())); 15 | 16 | public static readonly DependencyProperty ColumnNamesProperty = ColumnNamesPropertyKey.DependencyProperty; 17 | 18 | public static readonly DependencyProperty TitleProperty = DependencyProperty.Register("Title", typeof(string), typeof(MergedHeader), new FrameworkPropertyMetadata(null)); 19 | 20 | public string Title 21 | { 22 | get { return (string) GetValue(TitleProperty); } 23 | set { SetValue(TitleProperty, value); } 24 | } 25 | 26 | public List ColumnNames 27 | { 28 | get { return (List) GetValue(ColumnNamesProperty); } 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Cog.Presentation/Converters/FirstGroupRowConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.ObjectModel; 3 | using System.Globalization; 4 | using System.Windows; 5 | using System.Windows.Data; 6 | 7 | namespace SIL.Cog.Presentation.Converters 8 | { 9 | public class FirstGroupRowConverter : IMultiValueConverter 10 | { 11 | public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) 12 | { 13 | if (values[0] == DependencyProperty.UnsetValue) 14 | return false; 15 | 16 | var groups = (ReadOnlyObservableCollection) values[0]; 17 | var itemIndex = (int) values[1]; 18 | var groupDescCount = (int) values[2]; 19 | if (groupDescCount > 0 && groups != null) 20 | { 21 | int index = 0; 22 | foreach (CollectionViewGroup group in groups) 23 | { 24 | if (index == itemIndex) 25 | return true; 26 | index += group.ItemCount; 27 | } 28 | } 29 | return false; 30 | } 31 | 32 | public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) 33 | { 34 | throw new NotImplementedException(); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /Cog.Presentation/Views/MainWindow.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.ComponentModel; 3 | using System.Windows; 4 | using SIL.Cog.Application.ViewModels; 5 | using SIL.Cog.Presentation.Properties; 6 | 7 | namespace SIL.Cog.Presentation.Views 8 | { 9 | /// 10 | /// Interaction logic for MainWindow.xaml 11 | /// 12 | public partial class MainWindow 13 | { 14 | public MainWindow() 15 | { 16 | InitializeComponent(); 17 | } 18 | 19 | private void Exit_Click(object sender, RoutedEventArgs e) 20 | { 21 | Close(); 22 | } 23 | 24 | protected override void OnClosing(CancelEventArgs e) 25 | { 26 | var vm = (MainWindowViewModel) DataContext; 27 | if (vm.CanExit()) 28 | { 29 | Settings.Default.WindowPlacement = WindowPlacement.GetPlacement(this); 30 | Settings.Default.Save(); 31 | } 32 | else 33 | { 34 | e.Cancel = true; 35 | } 36 | base.OnClosing(e); 37 | } 38 | 39 | protected override void OnSourceInitialized(EventArgs e) 40 | { 41 | base.OnSourceInitialized(e); 42 | WindowPlacement.SetPlacement(this, Settings.Default.WindowPlacement); 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /Cog.Application/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 SIL International 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Cog.Application/ViewModels/ConsonantPlaceVertex.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel; 2 | 3 | namespace SIL.Cog.Application.ViewModels 4 | { 5 | public enum ConsonantPlace 6 | { 7 | [Description("Bilabial")] 8 | Bilabial, 9 | [Description("Labiodental")] 10 | Labiodental, 11 | [Description("Dental")] 12 | Dental, 13 | [Description("Alveolar")] 14 | Alveolar, 15 | [Description("Postalveolar")] 16 | Postalveolar, 17 | [Description("Retroflex")] 18 | Retroflex, 19 | [Description("Palatal")] 20 | Palatal, 21 | [Description("Velar")] 22 | Velar, 23 | [Description("Uvular")] 24 | Uvular, 25 | [Description("Pharyngeal")] 26 | Pharyngeal, 27 | [Description("Glottal")] 28 | Glottal 29 | } 30 | 31 | public class ConsonantPlaceVertex : SegmentPropertyVertex 32 | { 33 | private readonly ConsonantPlace _place; 34 | 35 | public ConsonantPlaceVertex(ConsonantPlace place) 36 | { 37 | _place = place; 38 | } 39 | 40 | public ConsonantPlace Place 41 | { 42 | get { return _place; } 43 | } 44 | 45 | public override string StrRep 46 | { 47 | get { return GetEnumDescription(_place); } 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /Cog.Domain/Components/MultipleWordAlignerResult.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Linq; 3 | using SIL.Machine.Annotations; 4 | using SIL.Machine.SequenceAlignment; 5 | using SIL.ObjectModel; 6 | 7 | namespace SIL.Cog.Domain.Components 8 | { 9 | internal class MultipleWordAlignerResult : WordAlignerResultBase 10 | { 11 | private readonly MultipleAlignmentAlgorithm _algorithm; 12 | private readonly ReadOnlyList _words; 13 | 14 | public MultipleWordAlignerResult(IWordAligner wordAligner, IPairwiseAlignmentScorer scorer, IEnumerable words) 15 | : base(wordAligner) 16 | { 17 | _words = new ReadOnlyList(words.ToArray()); 18 | _algorithm = new MultipleAlignmentAlgorithm(scorer, _words, GetNodes); 19 | _algorithm.Compute(); 20 | } 21 | 22 | public override ReadOnlyList Words 23 | { 24 | get { return _words; } 25 | } 26 | 27 | public override IEnumerable> GetAlignments() 28 | { 29 | yield return _algorithm.GetAlignment(); 30 | } 31 | 32 | public override int BestRawScore 33 | { 34 | get { return 0; } 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /Cog.Presentation/Converters/PercentageToGradientColorConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | using System.Windows.Data; 4 | using System.Windows.Media; 5 | 6 | namespace SIL.Cog.Presentation.Converters 7 | { 8 | public class PercentageToGradientColorConverter : IMultiValueConverter 9 | { 10 | public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) 11 | { 12 | if (!(values[0] is double) || !(values[1] is Color) || !(values[2] is Color)) 13 | return Binding.DoNothing; 14 | 15 | var pcnt = (double) values[0]; 16 | 17 | var maxColor = (Color) values[1]; 18 | var minColor = (Color) values[2]; 19 | 20 | int rAvg = minColor.R + (int) ((maxColor.R - minColor.R) * pcnt); 21 | int gAvg = minColor.G + (int) ((maxColor.G - minColor.G) * pcnt); 22 | int bAvg = minColor.B + (int) ((maxColor.B - minColor.B) * pcnt); 23 | 24 | return new SolidColorBrush(Color.FromRgb((byte) rAvg, (byte) gAvg, (byte) bAvg)); 25 | } 26 | 27 | public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) 28 | { 29 | throw new NotImplementedException(); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Cog.Presentation/Converters/IsTextTrimmedConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | using System.Windows; 4 | using System.Windows.Controls; 5 | using System.Windows.Data; 6 | 7 | namespace SIL.Cog.Presentation.Converters 8 | { 9 | public class IsTextTrimmedConverter : IMultiValueConverter 10 | { 11 | public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) 12 | { 13 | var textBlock = (TextBlock) values[0]; 14 | var width = (double) values[1]; 15 | 16 | if (textBlock.TextTrimming == TextTrimming.None) 17 | return false; 18 | if (textBlock.TextWrapping != TextWrapping.NoWrap) 19 | return false; 20 | 21 | double maxWidth = textBlock.MaxWidth; 22 | textBlock.MaxWidth = double.PositiveInfinity; 23 | textBlock.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity)); 24 | double totalWidth = textBlock.DesiredSize.Width; 25 | textBlock.MaxWidth = maxWidth; 26 | return (totalWidth - width) > 0.001; 27 | } 28 | 29 | public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) 30 | { 31 | throw new NotImplementedException(); 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /Cog.Presentation/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.InteropServices; 3 | using System.Windows; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("Cog")] 9 | [assembly: AssemblyDescription("This is a lexicostatistics application for comparing different language varieties.")] 10 | 11 | // Setting ComVisible to false makes the types in this assembly not visible 12 | // to COM components. If you need to access a type in this assembly from 13 | // COM, set the ComVisible attribute to true on that type. 14 | [assembly: ComVisible(false)] 15 | 16 | 17 | [assembly: ThemeInfo( 18 | ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located 19 | //(used if a resource is not found in the page, 20 | // or application resource dictionaries) 21 | ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located 22 | //(used if a resource is not found in the page, 23 | // app, or any theme specific resource dictionaries) 24 | )] 25 | -------------------------------------------------------------------------------- /Cog.Domain/GeographicCoordinate.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace SIL.Cog.Domain 4 | { 5 | public class GeographicCoordinate : IEquatable 6 | { 7 | private readonly double _latitude; 8 | private readonly double _longitude; 9 | 10 | public GeographicCoordinate(double latitude, double longitude) 11 | { 12 | _latitude = latitude; 13 | _longitude = longitude; 14 | } 15 | 16 | public double Latitude 17 | { 18 | get { return _latitude; } 19 | } 20 | 21 | public double Longitude 22 | { 23 | get { return _longitude; } 24 | } 25 | 26 | public override bool Equals(object obj) 27 | { 28 | if (!(obj is GeographicCoordinate)) 29 | return false; 30 | return Equals((GeographicCoordinate) obj); 31 | } 32 | 33 | public bool Equals(GeographicCoordinate other) 34 | { 35 | return other != null && Math.Abs(_latitude - other._latitude) < double.Epsilon && Math.Abs(_longitude - other._longitude) < double.Epsilon; 36 | } 37 | 38 | public override int GetHashCode() 39 | { 40 | int code = 23; 41 | code += code * 31 + _latitude.GetHashCode(); 42 | code += code * 31 + _longitude.GetHashCode(); 43 | return code; 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /Cog.Domain/VarietyCollection.cs: -------------------------------------------------------------------------------- 1 | using SIL.ObjectModel; 2 | 3 | namespace SIL.Cog.Domain 4 | { 5 | internal class VarietyCollection : KeyedBulkObservableList 6 | { 7 | protected override void InsertItem(int index, Variety item) 8 | { 9 | base.InsertItem(index, item); 10 | item.Collection = this; 11 | } 12 | 13 | protected override string GetKeyForItem(Variety item) 14 | { 15 | return item.Name; 16 | } 17 | 18 | protected override void SetItem(int index, Variety item) 19 | { 20 | Variety oldItem = Items[index]; 21 | base.SetItem(index, item); 22 | item.Collection = this; 23 | oldItem.Collection = null; 24 | } 25 | 26 | protected override void RemoveItem(int index) 27 | { 28 | Variety oldItem = Items[index]; 29 | base.RemoveItem(index); 30 | oldItem.Collection = null; 31 | } 32 | 33 | protected override void ClearItems() 34 | { 35 | foreach (Variety item in Items) 36 | item.Collection = null; 37 | 38 | base.ClearItems(); 39 | } 40 | 41 | internal void ChangeVarietyName(Variety variety, string newName) 42 | { 43 | Dictionary.Remove(GetKeyForItem(variety)); 44 | Dictionary.Add(newName, variety); 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /Cog.Presentation/Converters/MultipleWordAlignmentHighlightSegmentConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | using System.Windows; 4 | using System.Windows.Data; 5 | using SIL.Cog.Application.ViewModels; 6 | 7 | namespace SIL.Cog.Presentation.Converters 8 | { 9 | public class MultipleWordAlignmentHighlightSegmentConverter : IMultiValueConverter 10 | { 11 | public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) 12 | { 13 | if (values[2] == DependencyProperty.UnsetValue || values[3] == DependencyProperty.UnsetValue) 14 | return false; 15 | 16 | var word = (MultipleWordAlignmentWordViewModel) values[0]; 17 | int wordColumn = ((int) values[1]) - 2; 18 | var currentColumn = (int) values[2]; 19 | var currentWord = (MultipleWordAlignmentWordViewModel) values[3]; 20 | 21 | return currentColumn != -1 && currentWord != null && currentWord != word && wordColumn == currentColumn && word.Columns[wordColumn] == currentWord.Columns[currentColumn]; 22 | } 23 | 24 | public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) 25 | { 26 | throw new NotImplementedException(); 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Cog.Domain/MeaningCollection.cs: -------------------------------------------------------------------------------- 1 | using SIL.ObjectModel; 2 | 3 | namespace SIL.Cog.Domain 4 | { 5 | internal class MeaningCollection : KeyedBulkObservableList 6 | { 7 | protected override void InsertItem(int index, Meaning item) 8 | { 9 | base.InsertItem(index, item); 10 | item.Collection = this; 11 | } 12 | 13 | protected override string GetKeyForItem(Meaning item) 14 | { 15 | return item.Gloss; 16 | } 17 | 18 | protected override void SetItem(int index, Meaning item) 19 | { 20 | Meaning oldItem = Items[index]; 21 | base.SetItem(index, item); 22 | item.Collection = this; 23 | oldItem.Collection = null; 24 | } 25 | 26 | protected override void RemoveItem(int index) 27 | { 28 | Meaning oldItem = Items[index]; 29 | base.RemoveItem(index); 30 | oldItem.Collection = null; 31 | } 32 | 33 | protected override void ClearItems() 34 | { 35 | foreach (Meaning item in Items) 36 | item.Collection = null; 37 | 38 | base.ClearItems(); 39 | } 40 | 41 | internal void ChangeMeaningGloss(Meaning meaning, string newGloss) 42 | { 43 | Dictionary.Remove(GetKeyForItem(meaning)); 44 | Dictionary.Add(newGloss, meaning); 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /Cog.Application/Import/TextSegmentMappingsImporter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | 5 | namespace SIL.Cog.Application.Import 6 | { 7 | public class TextSegmentMappingsImporter : ISegmentMappingsImporter 8 | { 9 | private readonly char _delimiter; 10 | 11 | public TextSegmentMappingsImporter(char delimiter) 12 | { 13 | _delimiter = delimiter; 14 | } 15 | 16 | public object CreateImportSettingsViewModel() 17 | { 18 | return null; 19 | } 20 | 21 | public IEnumerable> Import(object importSettingsViewModel, Stream stream) 22 | { 23 | var mappings = new List>(); 24 | var reader = new CsvReader(new StreamReader(stream), _delimiter); 25 | IList mapping; 26 | while (reader.ReadRow(out mapping)) 27 | { 28 | if (mapping.Count >= 2) 29 | { 30 | string str1 = mapping[0].Trim(); 31 | string str2 = mapping[1].Trim(); 32 | if (string.IsNullOrEmpty(str1) || string.IsNullOrEmpty(str2)) 33 | throw new ImportException("An empty segment is not allowed."); 34 | mappings.Add(Tuple.Create(str1, str2)); 35 | } 36 | } 37 | 38 | return mappings; 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /Cog.Presentation/Controls/PercentageSlider.xaml: -------------------------------------------------------------------------------- 1 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /Cog.Domain/Affix.cs: -------------------------------------------------------------------------------- 1 | using SIL.Machine.Annotations; 2 | using SIL.Machine.Morphology; 3 | using SIL.ObjectModel; 4 | 5 | namespace SIL.Cog.Domain 6 | { 7 | public class Affix : ObservableObject 8 | { 9 | private readonly string _strRep; 10 | private readonly AffixType _type; 11 | private Shape _shape; 12 | private readonly string _category; 13 | private double _score; 14 | 15 | public Affix(string strRep, AffixType type, string category) 16 | { 17 | _strRep = strRep; 18 | _type = type; 19 | _category = category; 20 | } 21 | 22 | public Shape Shape 23 | { 24 | get { return _shape; } 25 | internal set { Set(() => Shape, ref _shape, value); } 26 | } 27 | 28 | public AffixType Type 29 | { 30 | get { return _type; } 31 | } 32 | 33 | public string Category 34 | { 35 | get { return _category; } 36 | } 37 | 38 | public string StrRep 39 | { 40 | get { return _strRep; } 41 | } 42 | 43 | public double Score 44 | { 45 | get { return _score; } 46 | set { Set(() => Score, ref _score, value); } 47 | } 48 | 49 | public override string ToString() 50 | { 51 | string strRep = StrRep; 52 | return _type == AffixType.Prefix ? strRep + "-" : "-" + strRep; 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /Cog.Domain/Config/Components/SimpleWordPairGeneratorConfig.cs: -------------------------------------------------------------------------------- 1 | using System.Diagnostics; 2 | using System.Xml.Linq; 3 | using SIL.Cog.Domain.Components; 4 | 5 | namespace SIL.Cog.Domain.Config.Components 6 | { 7 | public class SimpleWordPairGeneratorConfig : IComponentConfig> 8 | { 9 | public IProcessor Load(SegmentPool segmentPool, CogProject project, XElement elem) 10 | { 11 | var initialAlignmentThreshold = (double) elem.Element(ConfigManager.Cog + "InitialAlignmentThreshold"); 12 | XElement alignerElem = elem.Element(ConfigManager.Cog + "ApplicableWordAligner"); 13 | Debug.Assert(alignerElem != null); 14 | var alignerID = (string) alignerElem.Attribute("ref"); 15 | return new SimpleWordPairGenerator(segmentPool, project, initialAlignmentThreshold, alignerID); 16 | } 17 | 18 | public void Save(IProcessor component, XElement elem) 19 | { 20 | var wordPairGenerator = (SimpleWordPairGenerator) component; 21 | elem.Add(new XElement(ConfigManager.Cog + "InitialAlignmentThreshold", wordPairGenerator.InitialAlignmentThreshold)); 22 | elem.Add(new XElement(ConfigManager.Cog + "ApplicableWordAligner", new XAttribute("ref", wordPairGenerator.AlignerID))); 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Cog.Domain/CognacyDecision.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace SIL.Cog.Domain 4 | { 5 | public class CognacyDecision : IEquatable 6 | { 7 | public CognacyDecision(Variety variety1, Variety variety2, Meaning meaning, bool cognacy) 8 | { 9 | Variety1 = variety1; 10 | Variety2 = variety2; 11 | Meaning = meaning; 12 | Cognacy = cognacy; 13 | } 14 | 15 | public Variety Variety1 { get; } 16 | 17 | public Variety Variety2 { get; } 18 | 19 | public Meaning Meaning { get; } 20 | 21 | public bool Cognacy { get; } 22 | 23 | public override bool Equals(object obj) 24 | { 25 | if (!(obj is CognacyDecision)) 26 | return false; 27 | return Equals((CognacyDecision) obj); 28 | } 29 | 30 | public bool Equals(CognacyDecision other) 31 | { 32 | return other != null && Variety1 == other.Variety1 && Variety2 == other.Variety2 && Meaning == other.Meaning && Cognacy == other.Cognacy; 33 | } 34 | 35 | public override int GetHashCode() 36 | { 37 | int code = 23; 38 | code += code * 31 + Variety1.GetHashCode(); 39 | code += code * 31 + Variety2.GetHashCode(); 40 | code += code * 31 + Meaning.GetHashCode(); 41 | code += code * 31 + Cognacy.GetHashCode(); 42 | return code; 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /Cog.Presentation/Controls/PercentageControl.xaml: -------------------------------------------------------------------------------- 1 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /Cog.Presentation/Behaviors/TextBlockBehaviors.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Windows; 3 | using System.Windows.Controls; 4 | using System.Windows.Documents; 5 | 6 | namespace SIL.Cog.Presentation.Behaviors 7 | { 8 | public static class TextBlockBehaviors 9 | { 10 | public static readonly DependencyProperty InlinesListProperty = DependencyProperty.RegisterAttached("InlinesList", typeof(IEnumerable), typeof(TextBlockBehaviors), 11 | new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.AffectsMeasure, OnPropertyChanged)); 12 | 13 | public static void SetInlinesList(UIElement element, IEnumerable inlines) 14 | { 15 | element.SetValue(InlinesListProperty, inlines); 16 | } 17 | 18 | public static IEnumerable GetInlinesList(UIElement element) 19 | { 20 | return (IEnumerable) element.GetValue(InlinesListProperty); 21 | } 22 | 23 | private static void OnPropertyChanged(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs e) 24 | { 25 | var textBlock = (TextBlock) dependencyObject; 26 | textBlock.Inlines.Clear(); 27 | var inlines = (IEnumerable) e.NewValue; 28 | if (inlines != null) 29 | textBlock.Inlines.AddRange(inlines); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Cog.Presentation/Views/ProgressDialog.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.ComponentModel; 3 | using System.Windows; 4 | using GalaSoft.MvvmLight.Threading; 5 | using SIL.Cog.Application.ViewModels; 6 | 7 | namespace SIL.Cog.Presentation.Views 8 | { 9 | /// 10 | /// Interaction logic for ProgressDialog.xaml 11 | /// 12 | public partial class ProgressDialog 13 | { 14 | public ProgressDialog() 15 | { 16 | InitializeComponent(); 17 | } 18 | 19 | private void Window_Loaded(object sender, RoutedEventArgs e) 20 | { 21 | var vm = (ProgressViewModel) DataContext; 22 | vm.PropertyChanged += vm_PropertyChanged; 23 | vm.Execute(); 24 | } 25 | 26 | private void vm_PropertyChanged(object sender, PropertyChangedEventArgs e) 27 | { 28 | switch (e.PropertyName) 29 | { 30 | case "Executing": 31 | if (!((ProgressViewModel) sender).Executing) 32 | { 33 | DispatcherHelper.CheckBeginInvokeOnUI(() => 34 | { 35 | var vm = (ProgressViewModel) DataContext; 36 | if (vm.Exception != null) 37 | throw new InvalidOperationException("An error occurred in the worker thread.", vm.Exception); 38 | DialogResult = !vm.Canceled; 39 | }); 40 | } 41 | break; 42 | } 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /Cog.Application/ViewModels/WordSegmentViewModel.cs: -------------------------------------------------------------------------------- 1 | using GalaSoft.MvvmLight; 2 | using SIL.Cog.Domain; 3 | using SIL.Machine.Annotations; 4 | 5 | namespace SIL.Cog.Application.ViewModels 6 | { 7 | public class WordSegmentViewModel : ViewModelBase 8 | { 9 | private readonly string _strRep; 10 | private bool _isSelected; 11 | private readonly ShapeNode _node; 12 | private readonly bool _isNotInOriginal; 13 | 14 | public WordSegmentViewModel(ShapeNode node) 15 | { 16 | _node = node; 17 | _strRep = node.OriginalStrRep(); 18 | } 19 | 20 | public WordSegmentViewModel(string strRep) 21 | { 22 | _strRep = strRep; 23 | _isNotInOriginal = true; 24 | } 25 | 26 | public string StrRep 27 | { 28 | get { return _strRep; } 29 | } 30 | 31 | public bool IsBoundary 32 | { 33 | get { return _strRep == "|"; } 34 | } 35 | 36 | public bool IsNotInOriginal 37 | { 38 | get { return _isNotInOriginal; } 39 | } 40 | 41 | public bool IsSelected 42 | { 43 | get { return _isSelected; } 44 | set { Set(() => IsSelected, ref _isSelected, value); } 45 | } 46 | 47 | internal ShapeNode DomainNode 48 | { 49 | get { return _node; } 50 | } 51 | 52 | public override string ToString() 53 | { 54 | return _strRep; 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /Cog.Presentation/Converters/WordsToInlinesConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Globalization; 5 | using System.Windows; 6 | using System.Windows.Data; 7 | using System.Windows.Documents; 8 | using SIL.Cog.Application.ViewModels; 9 | 10 | namespace SIL.Cog.Presentation.Converters 11 | { 12 | public class WordsToInlinesConverter : IValueConverter 13 | { 14 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 15 | { 16 | var words = (IEnumerable) value; 17 | 18 | var textDecoration = (TextDecorationCollection) parameter; 19 | 20 | var inlines = new List(); 21 | bool first = true; 22 | foreach (WordViewModel wordVM in words) 23 | { 24 | if (!first) 25 | inlines.Add(new Run(",")); 26 | var run = new Run(wordVM.StrRep); 27 | if (!string.IsNullOrEmpty(((IDataErrorInfo) wordVM)["StrRep"])) 28 | run.TextDecorations = textDecoration; 29 | 30 | inlines.Add(run); 31 | first = false; 32 | } 33 | return inlines; 34 | } 35 | 36 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 37 | { 38 | throw new NotImplementedException(); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /Cog.Application.Tests/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /Cog.Application/ViewModels/SegmentsVarietyViewModel.cs: -------------------------------------------------------------------------------- 1 | using System.Windows.Input; 2 | using GalaSoft.MvvmLight.Command; 3 | using GalaSoft.MvvmLight.Messaging; 4 | using SIL.Cog.Application.Collections; 5 | using SIL.Cog.Domain; 6 | using SIL.ObjectModel; 7 | 8 | namespace SIL.Cog.Application.ViewModels 9 | { 10 | public class SegmentsVarietyViewModel : VarietyViewModel 11 | { 12 | private readonly MirroredBindableList _segments; 13 | private readonly ICommand _switchToVarietyCommand; 14 | 15 | public SegmentsVarietyViewModel(SegmentsViewModel segmentsViewModel, Variety variety) 16 | : base(variety) 17 | { 18 | _segments = new MirroredBindableList(segmentsViewModel.DomainSegments, 19 | segment => new VarietySegmentViewModel(this, segment, segmentsViewModel.DomainSyllablePosition), viewModel => viewModel.DomainSegment); 20 | _switchToVarietyCommand = new RelayCommand(() => Messenger.Default.Send(new SwitchViewMessage(typeof(VarietiesViewModel), DomainVariety))); 21 | } 22 | 23 | public ReadOnlyObservableList Segments 24 | { 25 | get { return _segments; } 26 | } 27 | 28 | public ICommand SwitchToVarietyCommand 29 | { 30 | get { return _switchToVarietyCommand; } 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /Cog.Domain/Config/Components/DolgopolskyCognateIdentifierConfig.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Diagnostics; 3 | using System.Xml.Linq; 4 | using SIL.Cog.Domain.Components; 5 | 6 | namespace SIL.Cog.Domain.Config.Components 7 | { 8 | public class DolgopolskyCognateIdentifierConfig : IComponentConfig 9 | { 10 | public ICognateIdentifier Load(SegmentPool segmentPool, CogProject project, XElement elem) 11 | { 12 | XElement soundClassesElem = elem.Element(ConfigManager.Cog + "SoundClasses"); 13 | Debug.Assert(soundClassesElem != null); 14 | IEnumerable soundClasses = ConfigManager.LoadSoundClasses(project.Segmenter, project.FeatureSystem, soundClassesElem); 15 | var threshold = (int) elem.Element(ConfigManager.Cog + "InitialEquivalenceThreshold"); 16 | return new DolgopolskyCognateIdentifier(segmentPool, soundClasses, threshold); 17 | } 18 | 19 | public void Save(ICognateIdentifier component, XElement elem) 20 | { 21 | var dolgopolsky = (DolgopolskyCognateIdentifier) component; 22 | elem.Add(new XElement(ConfigManager.Cog + "SoundClasses", ConfigManager.SaveSoundClasses(dolgopolsky.SoundClasses))); 23 | elem.Add(new XElement(ConfigManager.Cog + "InitialEquivalenceThreshold", dolgopolsky.InitialEquivalenceThreshold)); 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Cog.Domain/WordPairCollection.cs: -------------------------------------------------------------------------------- 1 | using SIL.ObjectModel; 2 | 3 | namespace SIL.Cog.Domain 4 | { 5 | public class WordPairCollection : KeyedBulkObservableList 6 | { 7 | private readonly VarietyPair _varietyPair; 8 | 9 | internal WordPairCollection(VarietyPair varietyPair) 10 | { 11 | _varietyPair = varietyPair; 12 | } 13 | 14 | protected override Meaning GetKeyForItem(WordPair item) 15 | { 16 | return item.Meaning; 17 | } 18 | 19 | public WordPair Add(Word word1, Word word2) 20 | { 21 | var wordPair = new WordPair(word1, word2); 22 | Add(wordPair); 23 | return wordPair; 24 | } 25 | 26 | protected override void InsertItem(int index, WordPair item) 27 | { 28 | base.InsertItem(index, item); 29 | item.VarietyPair = _varietyPair; 30 | } 31 | 32 | protected override void RemoveItem(int index) 33 | { 34 | this[index].VarietyPair = null; 35 | base.RemoveItem(index); 36 | } 37 | 38 | protected override void ClearItems() 39 | { 40 | foreach (WordPair wp in this) 41 | wp.VarietyPair = null; 42 | base.ClearItems(); 43 | } 44 | 45 | protected override void SetItem(int index, WordPair item) 46 | { 47 | this[index].VarietyPair = null; 48 | base.SetItem(index, item); 49 | item.VarietyPair = _varietyPair; 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /Cog.Presentation/Controls/TreeListViewItem.cs: -------------------------------------------------------------------------------- 1 | using System.Windows.Controls; 2 | using System.Windows; 3 | 4 | namespace SIL.Cog.Presentation.Controls 5 | { 6 | public class TreeListViewItem : TreeViewItem 7 | { 8 | 9 | static TreeListViewItem() 10 | { 11 | DefaultStyleKeyProperty.OverrideMetadata(typeof(TreeListViewItem), new FrameworkPropertyMetadata(typeof(TreeListViewItem))); 12 | } 13 | 14 | /// 15 | /// Item's hierarchy in the tree 16 | /// 17 | public int Level 18 | { 19 | get 20 | { 21 | if (_level == -1) 22 | { 23 | var parent = ItemsControlFromItemContainer(this) as TreeListViewItem; 24 | _level = (parent != null) ? parent.Level + 1 : 0; 25 | } 26 | return _level; 27 | } 28 | } 29 | 30 | 31 | protected override DependencyObject GetContainerForItemOverride() 32 | { 33 | return new TreeListViewItem(); 34 | } 35 | 36 | protected override bool IsItemItsOwnContainerOverride(object item) 37 | { 38 | return item is TreeListViewItem; 39 | } 40 | 41 | private int _level = -1; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /Cog.CommandLine/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("SIL.Cog.CommandLine")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | 12 | // Setting ComVisible to false makes the types in this assembly not visible 13 | // to COM components. If you need to access a type in this assembly from 14 | // COM, set the ComVisible attribute to true on that type. 15 | [assembly: ComVisible(false)] 16 | 17 | // The following GUID is for the ID of the typelib if this project is exposed to COM 18 | [assembly: Guid("2b283f48-f741-499f-b22a-df0d15178e42")] 19 | 20 | // Version information for an assembly consists of the following four values: 21 | // 22 | // Major Version 23 | // Minor Version 24 | // Build Number 25 | // Revision 26 | // 27 | // You can specify all the values or you can default the Build and Revision Numbers 28 | // by using the '*' as shown below: 29 | // [assembly: AssemblyVersion("1.0.*")] 30 | 31 | [assembly: InternalsVisibleTo("SIL.Cog.CommandLine.Tests")] -------------------------------------------------------------------------------- /Cog.Application/Services/ProjectMigrations/ProjectMigration3.cs: -------------------------------------------------------------------------------- 1 | using SIL.Cog.Domain; 2 | using SIL.Machine.FeatureModel; 3 | 4 | namespace SIL.Cog.Application.Services.ProjectMigrations 5 | { 6 | /// 7 | /// This migration adds tone numbers and alveolo-palatal consonants. 8 | /// 9 | internal class ProjectMigration3 : IProjectMigration 10 | { 11 | public int Version 12 | { 13 | get { return 3; } 14 | } 15 | 16 | public void Migrate(SegmentPool segmentPool, CogProject project) 17 | { 18 | AddToneNumber(project, "¹"); 19 | AddToneNumber(project, "²"); 20 | AddToneNumber(project, "³"); 21 | AddToneNumber(project, "⁴"); 22 | AddToneNumber(project, "⁵"); 23 | 24 | FeatureSymbol alvPal; 25 | if (project.FeatureSystem.TryGetSymbol("alveolo-palatal", out alvPal)) 26 | { 27 | project.Segmenter.Consonants.AddSymbolBasedOn("ȶ", "t", alvPal); 28 | project.Segmenter.Consonants.AddSymbolBasedOn("ȡ", "d", alvPal); 29 | project.Segmenter.Consonants.AddSymbolBasedOn("ȵ", "n", alvPal); 30 | project.Segmenter.Consonants.AddSymbolBasedOn("ȴ", "l", alvPal); 31 | } 32 | } 33 | 34 | private static void AddToneNumber(CogProject project, string strRep) 35 | { 36 | if (!project.Segmenter.Modifiers.Contains(strRep)) 37 | project.Segmenter.Modifiers.Add(strRep); 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /Cog.Domain/Components/PairwiseWordAlignerResult.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using SIL.Machine.Annotations; 3 | using SIL.Machine.SequenceAlignment; 4 | using SIL.ObjectModel; 5 | 6 | namespace SIL.Cog.Domain.Components 7 | { 8 | internal class PairwiseWordAlignerResult : WordAlignerResultBase 9 | { 10 | private readonly PairwiseAlignmentAlgorithm _algorithm; 11 | private readonly ReadOnlyList _words; 12 | 13 | public PairwiseWordAlignerResult(IWordAligner wordAligner, IPairwiseAlignmentScorer scorer, WordPairAlignerSettings settings, Word word1, Word word2) 14 | : base(wordAligner) 15 | { 16 | _words = new ReadOnlyList(new [] {word1, word2}); 17 | _algorithm = new PairwiseAlignmentAlgorithm(scorer, word1, word2, GetNodes) 18 | { 19 | ExpansionCompressionEnabled = settings.ExpansionCompressionEnabled, 20 | Mode = settings.Mode 21 | }; 22 | _algorithm.Compute(); 23 | } 24 | 25 | public override ReadOnlyList Words 26 | { 27 | get { return _words; } 28 | } 29 | 30 | public override IEnumerable> GetAlignments() 31 | { 32 | return _algorithm.GetAlignments(); 33 | } 34 | 35 | public override int BestRawScore 36 | { 37 | get { return _algorithm.BestRawScore; } 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /Cog.Domain/Config/Components/EMSoundChangeInducerConfig.cs: -------------------------------------------------------------------------------- 1 | using System.Diagnostics; 2 | using System.Xml.Linq; 3 | using SIL.Cog.Domain.Components; 4 | 5 | namespace SIL.Cog.Domain.Config.Components 6 | { 7 | public class EMSoundChangeInducerConfig : IComponentConfig> 8 | { 9 | public IProcessor Load(SegmentPool segmentPool, CogProject project, XElement elem) 10 | { 11 | XElement alignerElem = elem.Element(ConfigManager.Cog + "ApplicableWordAligner"); 12 | Debug.Assert(alignerElem != null); 13 | var alignerID = (string) alignerElem.Attribute("ref"); 14 | XElement cognateIdentifierElem = elem.Element(ConfigManager.Cog + "ApplicableCognateIdentifier"); 15 | Debug.Assert(cognateIdentifierElem != null); 16 | var cognateIdentifierID = (string) cognateIdentifierElem.Attribute("ref"); 17 | return new EMSoundChangeInducer(segmentPool, project, alignerID, cognateIdentifierID); 18 | } 19 | 20 | public void Save(IProcessor component, XElement elem) 21 | { 22 | var inducer = (EMSoundChangeInducer) component; 23 | elem.Add(new XElement(ConfigManager.Cog + "ApplicableWordAligner", new XAttribute("ref", inducer.AlignerId))); 24 | elem.Add(new XElement(ConfigManager.Cog + "ApplicableCognateIdentifier", new XAttribute("ref", inducer.CognateIdentifierId))); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Cog.Domain/Components/ThresholdSegmentMappings.cs: -------------------------------------------------------------------------------- 1 | using SIL.Machine.Annotations; 2 | using SIL.Machine.NgramModeling; 3 | 4 | namespace SIL.Cog.Domain.Components 5 | { 6 | public class ThresholdSegmentMappings : ISegmentMappings 7 | { 8 | private readonly CogProject _project; 9 | private readonly string _alignerID; 10 | private readonly int _threshold; 11 | 12 | public ThresholdSegmentMappings(CogProject project, int threshold, string alignerID) 13 | { 14 | _project = project; 15 | _threshold = threshold; 16 | _alignerID = alignerID; 17 | } 18 | 19 | public int Threshold 20 | { 21 | get { return _threshold; } 22 | } 23 | 24 | public string AlignerID 25 | { 26 | get { return _alignerID; } 27 | } 28 | 29 | public bool IsMapped(ShapeNode leftNode1, Ngram target1, ShapeNode rightNode1, ShapeNode leftNode2, Ngram target2, ShapeNode rightNode2) 30 | { 31 | if (_threshold == 0 || target1.Length == 0 || target2.Length == 0) 32 | return false; 33 | 34 | IWordAligner aligner = _project.WordAligners[_alignerID]; 35 | 36 | foreach (Segment seg1 in target1) 37 | { 38 | foreach (Segment seg2 in target2) 39 | { 40 | if (aligner.Delta(seg1.FeatureStruct, seg2.FeatureStruct) <= _threshold) 41 | return true; 42 | } 43 | } 44 | 45 | return false; 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /Cog.Domain/SegmentPool.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Concurrent; 2 | using SIL.Machine.Annotations; 3 | using SIL.Machine.FeatureModel; 4 | 5 | namespace SIL.Cog.Domain 6 | { 7 | public class SegmentPool 8 | { 9 | private readonly ConcurrentDictionary _segments; 10 | 11 | public SegmentPool() 12 | { 13 | _segments = new ConcurrentDictionary(); 14 | _segments["#"] = Segment.Anchor; 15 | } 16 | 17 | public Segment Get(ShapeNode node) 18 | { 19 | if (node == null) 20 | return null; 21 | 22 | return _segments.GetOrAdd(node.StrRep(), s => 23 | { 24 | FeatureStruct fs = node.Annotation.FeatureStruct.Clone(); 25 | fs.RemoveValue(CogFeatureSystem.OriginalStrRep); 26 | fs.RemoveValue(CogFeatureSystem.SyllablePosition); 27 | fs.Freeze(); 28 | return new Segment(fs); 29 | }); 30 | } 31 | 32 | public Segment GetExisting(ShapeNode node) 33 | { 34 | return GetExisting(node.StrRep()); 35 | } 36 | 37 | public Segment GetExisting(string strRep) 38 | { 39 | return _segments[strRep]; 40 | } 41 | 42 | public bool TryGetExisting(string strRep, out Segment segment) 43 | { 44 | return _segments.TryGetValue(strRep, out segment); 45 | } 46 | 47 | public void Reset() 48 | { 49 | _segments.Clear(); 50 | _segments["#"] = Segment.Anchor; 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /Cog.Presentation/Converters/ContentToPathConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Windows; 3 | using System.Windows.Controls; 4 | using System.Windows.Data; 5 | using System.Windows.Media; 6 | 7 | namespace SIL.Cog.Presentation.Converters 8 | { 9 | public class ContentToPathConverter : IValueConverter 10 | { 11 | public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) 12 | { 13 | var ps = new PathSegmentCollection(4); 14 | var cp = (ContentPresenter)value; 15 | double h = cp.ActualHeight > 10 ? 1.4 * cp.ActualHeight : 10; 16 | double w = cp.ActualWidth > 10 ? 1.25 * cp.ActualWidth : 10; 17 | ps.Add(new LineSegment(new Point(1, 0.7 * h), true)); 18 | ps.Add(new BezierSegment(new Point(1, 0.9 * h), new Point(0.1 * h, h), new Point(0.3 * h, h), true)); 19 | ps.Add(new LineSegment(new Point(w, h), true)); 20 | ps.Add(new BezierSegment(new Point(w + 0.6 * h, h), new Point(w + h, 0), new Point(w + h * 1.3, 0), true)); 21 | 22 | var figure = new PathFigure(new Point(1,0), ps, false); 23 | var geometry = new PathGeometry(); 24 | geometry.Figures.Add(figure); 25 | return geometry; 26 | } 27 | 28 | public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) 29 | { 30 | throw new NotImplementedException(); 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /Cog.Application/ViewModels/SoundChangeViewModel.cs: -------------------------------------------------------------------------------- 1 | using GalaSoft.MvvmLight; 2 | using SIL.Cog.Domain; 3 | using SIL.Machine.NgramModeling; 4 | 5 | namespace SIL.Cog.Application.ViewModels 6 | { 7 | public class SoundChangeViewModel : ViewModelBase 8 | { 9 | private readonly SoundContext _domainLhs; 10 | private readonly Ngram _correspondence; 11 | private readonly SoundChangeLhsViewModel _lhs; 12 | private readonly double _prob; 13 | private readonly int _frequency; 14 | 15 | public SoundChangeViewModel(SoundContext lhs, Ngram correspondence, double probability, int frequency) 16 | { 17 | _domainLhs = lhs; 18 | _correspondence = correspondence; 19 | _lhs = new SoundChangeLhsViewModel(lhs); 20 | _prob = probability; 21 | _frequency = frequency; 22 | } 23 | 24 | public SoundChangeLhsViewModel Lhs 25 | { 26 | get { return _lhs; } 27 | } 28 | 29 | public string Correspondence 30 | { 31 | get { return _correspondence.ToString(); } 32 | } 33 | 34 | public double Probability 35 | { 36 | get { return _prob; } 37 | } 38 | 39 | public int Frequency 40 | { 41 | get { return _frequency; } 42 | } 43 | 44 | internal SoundContext DomainSoundChangeLhs 45 | { 46 | get { return _domainLhs; } 47 | } 48 | 49 | internal Ngram DomainCorrespondence 50 | { 51 | get { return _correspondence; } 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /debian/copyright: -------------------------------------------------------------------------------- 1 | Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ 2 | Upstream-Name: cog-cmdline 3 | Source: https://github.com/sillsdev/cog 4 | 5 | Files: * 6 | Copyright: 2013, 2015 SIL International 7 | License: Expat 8 | Copyright (c) 2013, 2015 SIL International 9 | . 10 | Permission is hereby granted, free of charge, to any person obtaining 11 | a copy of this software and associated documentation files (the 12 | "Software"), to deal in the Software without restriction, including 13 | without limitation the rights to use, copy, modify, merge, publish, 14 | distribute, sublicense, and/or sell copies of the Software, and to 15 | permit persons to whom the Software is furnished to do so, subject to 16 | the following conditions: 17 | . 18 | The above copyright notice and this permission notice shall be included 19 | in all copies or substantial portions of the Software. 20 | . 21 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 22 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 23 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 24 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 25 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 26 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 27 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 28 | -------------------------------------------------------------------------------- /Cog.Application/ViewModels/FindViewModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.ComponentModel; 3 | using System.Windows.Input; 4 | using GalaSoft.MvvmLight; 5 | using GalaSoft.MvvmLight.Command; 6 | using SIL.Cog.Application.Services; 7 | 8 | namespace SIL.Cog.Application.ViewModels 9 | { 10 | public enum FindField 11 | { 12 | [Description("Gloss")] 13 | Gloss, 14 | [Description("Form")] 15 | Form 16 | } 17 | 18 | public class FindViewModel : ViewModelBase 19 | { 20 | private string _string; 21 | private FindField _field; 22 | private readonly ICommand _findNextCommand; 23 | private readonly IDialogService _dialogService; 24 | 25 | public FindViewModel(IDialogService dialogService, Action find) 26 | { 27 | _dialogService = dialogService; 28 | _findNextCommand = new RelayCommand(find, () => !string.IsNullOrEmpty(_string)); 29 | } 30 | 31 | public string String 32 | { 33 | get { return _string; } 34 | set { Set(() => String, ref _string, value); } 35 | } 36 | 37 | public FindField Field 38 | { 39 | get { return _field; } 40 | set { Set(() => Field, ref _field, value); } 41 | } 42 | 43 | internal void ShowSearchEndedMessage() 44 | { 45 | _dialogService.ShowMessage(this, "Find reached the starting point of the search.", "Cog"); 46 | } 47 | 48 | public ICommand FindNextCommand 49 | { 50 | get { return _findNextCommand; } 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /Cog.Domain/VarietyPairCollection.cs: -------------------------------------------------------------------------------- 1 | using SIL.ObjectModel; 2 | 3 | namespace SIL.Cog.Domain 4 | { 5 | public class VarietyPairCollection : BulkObservableList 6 | { 7 | protected override void InsertItem(int index, VarietyPair item) 8 | { 9 | base.InsertItem(index, item); 10 | AddVarietyPairToVarieties(item); 11 | } 12 | 13 | protected override void ClearItems() 14 | { 15 | foreach (VarietyPair vp in this) 16 | { 17 | vp.Variety1.VarietyPairs.VarietyPairsCleared(); 18 | vp.Variety2.VarietyPairs.VarietyPairsCleared(); 19 | } 20 | 21 | base.ClearItems(); 22 | } 23 | 24 | protected override void RemoveItem(int index) 25 | { 26 | RemoveVarietyPairFromVarieties(index); 27 | base.RemoveItem(index); 28 | } 29 | 30 | protected override void SetItem(int index, VarietyPair item) 31 | { 32 | RemoveVarietyPairFromVarieties(index); 33 | base.SetItem(index, item); 34 | AddVarietyPairToVarieties(item); 35 | } 36 | 37 | private void AddVarietyPairToVarieties(VarietyPair vp) 38 | { 39 | vp.Variety1.VarietyPairs.VarietyPairAdded(vp); 40 | vp.Variety2.VarietyPairs.VarietyPairAdded(vp); 41 | } 42 | 43 | private void RemoveVarietyPairFromVarieties(int index) 44 | { 45 | VarietyPair vp = this[index]; 46 | vp.Variety1.VarietyPairs.VarietyPairRemoved(vp); 47 | vp.Variety2.VarietyPairs.VarietyPairRemoved(vp); 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /Cog.Application/ViewModels/ThresholdCognateIdentifierViewModel.cs: -------------------------------------------------------------------------------- 1 | using SIL.Cog.Application.Services; 2 | using SIL.Cog.Domain; 3 | using SIL.Cog.Domain.Components; 4 | 5 | namespace SIL.Cog.Application.ViewModels 6 | { 7 | public class ThresholdCognateIdentifierViewModel : ComponentSettingsViewModelBase 8 | { 9 | private readonly IProjectService _projectService; 10 | private double _threshold; 11 | 12 | public ThresholdCognateIdentifierViewModel(IProjectService projectService) 13 | : base("Phonetic", "Phonetic-Method-Settings") 14 | { 15 | _projectService = projectService; 16 | } 17 | 18 | public double Threshold 19 | { 20 | get { return _threshold; } 21 | set { SetChanged(() => Threshold, ref _threshold, value); } 22 | } 23 | 24 | public override void Setup() 25 | { 26 | ICognateIdentifier cognateIdentifier = _projectService.Project.CognateIdentifiers[ComponentIdentifiers.PrimaryCognateIdentifier]; 27 | var threshold = cognateIdentifier as ThresholdCognateIdentifier; 28 | Set(() => Threshold, ref _threshold, threshold == null ? 0.75 : threshold.Threshold); 29 | } 30 | 31 | public override object UpdateComponent() 32 | { 33 | var cognateIdentifier = new ThresholdCognateIdentifier(_threshold); 34 | _projectService.Project.CognateIdentifiers[ComponentIdentifiers.PrimaryCognateIdentifier] = cognateIdentifier; 35 | return cognateIdentifier; 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Cog.Domain/Components/WordPairAlignerSettings.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using SIL.Machine.SequenceAlignment; 5 | 6 | namespace SIL.Cog.Domain.Components 7 | { 8 | public class WordPairAlignerSettings 9 | { 10 | private AlignmentMode _mode; 11 | private bool _expansionCompressionEnabled; 12 | private SoundClass[] _contextualSoundClasses; 13 | 14 | internal bool ReadOnly { get; set; } 15 | 16 | public AlignmentMode Mode 17 | { 18 | get { return _mode; } 19 | set 20 | { 21 | CheckReadOnly(); 22 | _mode = value; 23 | } 24 | } 25 | 26 | public bool ExpansionCompressionEnabled 27 | { 28 | get { return _expansionCompressionEnabled; } 29 | set 30 | { 31 | CheckReadOnly(); 32 | _expansionCompressionEnabled = value; 33 | } 34 | } 35 | 36 | public IEnumerable ContextualSoundClasses 37 | { 38 | get 39 | { 40 | if (_contextualSoundClasses == null) 41 | return Enumerable.Empty(); 42 | return _contextualSoundClasses; 43 | } 44 | set 45 | { 46 | CheckReadOnly(); 47 | _contextualSoundClasses = value == null ? null : value.ToArray(); 48 | } 49 | } 50 | 51 | protected void CheckReadOnly() 52 | { 53 | if (ReadOnly) 54 | throw new InvalidOperationException("Settings cannot be changed after an Aligner object has been created."); 55 | } 56 | } 57 | } 58 | --------------------------------------------------------------------------------